Saturday, 31 August 2013

Using Drop Down Selects With My PHP Code To Send To My E-mail

Using Drop Down Selects With My PHP Code To Send To My E-mail

I am trying to go off the PHP code I had for my contact page (with no drop
down selects, all text fields) which worked perfect. But when I try to
make it work with Drop Down Selects, it doesn't work, it just keeps giving
me errors.
Here is my HTML for one drop down select: (i tried both, with and without
the [] after the name)
<select data-placeholder="Select a category" name="category[]" id="selK6U"
style="display: none;" class="chzn-done">
<option></option><option value="Snack &amp; Quick Meals"
data-connection="snackSelect">Snack &amp; Quick Meals</option><option
value="Wraps" data-connection="wrapSelect">Wraps</option><option
value="Breads" data-connection="breadSelect">Breads</option><option
value="Chicken Entrees" data-connection="chickenSelect">Chicken
Entrees</option><option value="Lahawajawaab Mutton"
data-connection="laSelect">Lahawajawaab Mutton</option><option value="Rice
Dishes" data-connection="riceSelect">Rice Dishes</option><option
value="Vegetarian" data-connection="vegSelect">Vegetarian</option>
</select>
and here is my PHP code:
<?php
if(isset($_POST['email'])) {
$email_to = "email@myemail.com";
$email_subject = "subject";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form
you submitted: <br />";
echo $error."<br />";
echo "Please fix these errors.<br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['phone']) ||
!isset($_POST['address']) ||
!isset($_POST['city']) ||
!isset($_POST['zip']) ||
!isset($_POST['category']) ||
!isset($_POST['meal']) ||
!isset($_POST['spicy']) ||
!isset($_POST['delivery']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form
you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$phone = $_POST['phone']; // not required
$phone = $_POST['address']; // not required
$phone = $_POST['city']; // not required
$phone = $_POST['zip']; // not required
$category = $_POST['category']; // not required
$meal = $_POST['meal']; // not required
$spicy = $_POST['spicy']; // not required
$delivery = $_POST['delivery']; // not required
$message = $_POST['message']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be
valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The First Name you entered does not appear to be
valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "Zip: ".clean_string($zip)."\n";
$email_message .= "Meal Category: ".clean_string($category)."\n";
$email_message .= "Meal: ".clean_string($meal)."\n";
$email_message .= "How Spicy: ".clean_string($spicy)."\n";
$email_message .= "Delivery: ".clean_string($delivery)."\n";
$email_message .= "Other Details: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
echo 'Thank you, your message has been sent! <br /> We will review
your submission and contact you as soon as possible.';
}
?>
Any help would be GREATLY appreciated. Thank You!

can the order of code make this program faster?

can the order of code make this program faster?

Hi this is my first post, I am learning how to write code so technically I
am a newbie.
I am learning python I am still at the very basics, I was getting to Know
the if statement and I tried to mix it with another concepts(function
definition,input,variables) in order to get a wider vision of python, I
wrote some code without a specific idea of what I wanted to do I just
wanted to mix everything that I have learned so far so probably I over do
it and its not practical, it "works" when I run it.
The question that I have its not about how to do it more efficient or with
less code it is about the order of code in all programming in general.
Here I'll show 2 different order of code that gives the same result with
exactly the same code(but with different order).
on (1) I define a function on the first line.
on (2) I define the same function closer to when I use it on line 5.
which one is faster? is defining a function "closer" to when I need it
impractical for the complexity of larger programs(but does it make it
faster), or defining a function "far" from where I need it makes a larger
program slower when running(but also more practical).
(1)
def t(n1,n2):
v=n1-n2
return abs(v)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
(2)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
def t(n1,n2):
v=n1-n2
return abs(v)
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()

Structural-type casting does not work with String?

Structural-type casting does not work with String?

Given these definitions:
type HasMkString = { def mkString(sep:String):String }
val name = "John"
val names = List("Peter", "Gabriel")
And given these facts:
name.mkString("-") // => "J-o-h-n"
name.isInstanceOf[HasMkString] // => true
names.isInstanceOf[HasMkString] // => true
While this works:
names.asInstanceOf[HasMkString].mkString("-")
// => Peter-Gabriel
This does not work:
name.asInstanceOf[HasMkString].mkString(", ")
java.lang.NoSuchMethodException: java.lang.String.mkString(java.lang.String)
at java.lang.Class.getMethod(Class.java:1624)
at .reflMethod$Method1(<console>:10)
at .<init>(<console>:10)
at .<clinit>(<console>:10)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
Why is that? Is it because String is a Java class? Can I work around this
problem? Is this a bug/shortcoming in the Scala implementation?

Adding text to paragraph moves neighbor elements down

Adding text to paragraph moves neighbor elements down

When ever I add text that differs in size to one of my paragraph tags the
neighbor elements get pushed down and I can't figure out why.
Codepen: http://cdpn.io/bqJec

Android alertdialogue returning boolean

Android alertdialogue returning boolean

I am wring a simple script where there is a confirmation box of two
options. I need to cal it more than one time in an activity. So i made a
method to do that. Based on the returning boolean i want to write the
conditional statements.
private void showConfirmation() {
// UserFunctions userFunctions = null;
// TODO Auto-generated methodastub
AlertDialog.Builder alertDialogBuilder = new
AlertDialog.Builder(ProfileActivity.this);
// set title
alertDialogBuilder.setTitle("Mobile Gullak");
// set dialog message
alertDialogBuilder.setMessage("Please update the unfilled
fields.").setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
return false;
}
}).setNegativeButton("Later on", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
return true;
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
return false;
}
if(showConfirmation()){
// do something.
}

PHP - Generating several forms, but the forms only ever output the same thing for each form

PHP - Generating several forms, but the forms only ever output the same
thing for each form

Ok so I basically have generated a list of links that use forms to send a
variable to PHP that would allow me to load different things on the next
page from each link. However, each link seems to only request the same
data from the database each time
Here is the first page:

Friday, 30 August 2013

Cant append HTML structre in jQuery PHP WORDPRESS

Cant append HTML structre in jQuery PHP WORDPRESS

<script type="text/javascript">
jQuery(function($) {
$("td").filter(function (){
return $(this).text() == '<?php echo $eventDate ?>';
}).css({ 'background-color': 'Green' });
$("td").filter(function (){
return $(this).text() == '<?php echo $eventDate ?>';
}).append("
<div id="myCard" class="flip-container" >
<div class="flipper">
<div class="front">
<!-- front content -->
salam
</div>
<div class="back">
<!-- back content -->
salam
</div>
</div>
</div>");
});
</script>

Wednesday, 28 August 2013

MySQL C++ Connector strange compile warning

MySQL C++ Connector strange compile warning

I have an application that uses the MySQL C++ Connector, version 1.1.3.
Everything works fine, but the compiler has been throwing an odd warning
that I can't seem to make go away:
sqlstring.h(38): warning C4251: 'sql::SQLString::realStr' : class
'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be
used by clients
of class 'sql::SQLString'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
As I said, everything works fine, this warning is just bugging me. It
shows up in a lot of places in the Connector library. What is it and how
can I fix it?

Close dialog box automatically

Close dialog box automatically

I have a question about JOptionPane on how to automatically closes dialog
box that i can use to alert a user in an event and close automatically
after a delay without having to close the dialog?
public class ShutdownComputer
{
public static void main(String[]args)
{
int wholeTimeBeforeShutdown=0;
int hour=0;
int minute=0;
int second=0;
try
{
String a=JOptionPane.showInputDialog(null,"HOUR","HOUR BEFORE
SHUTDOWN",JOptionPane.QUESTION_MESSAGE);
String b=JOptionPane.showInputDialog(null,"MINUTE","MINUTE
BEFORE SHUTDOWN",JOptionPane.QUESTION_MESSAGE);
String c=JOptionPane.showInputDialog(null,"SECOND","SECOND
BEFORE SHUTDOWN",JOptionPane.QUESTION_MESSAGE);
if((a==null)||(a.equals("")))
{
a="0";
}
if((b==null)||(b.equals("")))
{
b="0";
}
if((c==null)||(c.equals("")))
{
c="0";
}
int e=Integer.parseInt(a);
int f=Integer.parseInt(b);
int g=Integer.parseInt(c);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+((e*60)*60);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+(f*60);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+(g);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown*1000;
Thread.sleep(wholeTimeBeforeShutdown);
JOptionPane.showMessageDialog(null, "You only have less than 2
minutes left");
Runtime.getRuntime().exec("shutdown -r -f -t 120");
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}

R building a subset based on value in previous row

R building a subset based on value in previous row

I have a problem figuering this out: suppose this is how my data looks like:
Num condition y
1 a 1
2 a 2
3 a 3
4 b 4
5 b 5
6 b 6
7 c 7
8 c 8
9 c 9
10 b 10
11 b 11
12 b 12
I now want to make calculation (e.g., mean) on b, depending on whether
value was in the row before b, in this example a or c? Thanks for any
help!!! Angelika

Serializing abstract class over WCF with subclasses in different assemblies

Serializing abstract class over WCF with subclasses in different assemblies

We are using C# and .NET 4 to build an WCF-enabled application. We have a
"parent" assembly that implements:
[DataContract]
public abstract class A
{
//...
}
Then, other "child" assemblies implement subclasses of A, like this:
[DataContract]
public class B : A
{
//...
}
In another assembly we have some methods that we are trying to encapsulate
as WCF services. Some of these methods have a return type of A.
Evidently, child assemblies need to include a reference to the parent
assembly in order for derived classes to inherit from class A. The problem
arises when WCF seems to demand that we add KnownType attributes to class
A to list all its potential subclasses; this would need that the parent
assembly where A resides had references to the child assemblies, which
would create circular dependencies.
Is there any other way around this? Does WCF really need to know the types
of all the potential concrete classes of an abstract class that is being
used as a return type? Thank you.

Tuesday, 27 August 2013

horizontal scroll appear at right by default

horizontal scroll appear at right by default

In mCustomScrollbar, I want to place the scroller at the right end by
default of horizontal position. so i tried this.
$('.content').mCustomScrollbar("scrollTo",'last', {horizontalScroll: true});
But this works for me, except the right position
$('.content').mCustomScrollbar({horizontalScroll: true});
What should i do to make the horizontal scroll appear at right by default

resource(5) of type (mysql result) Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 5 in

resource(5) of type (mysql result) Warning: mysql_result(): Unable to jump
to row 0 on MySQL result index 5 in

<?php
include('dbconn.php');
$dbconnect = new DB_Class('ctresults', 'root', '');
$sem=$_REQUEST['sem'];
$roll=$_REQUEST['txtroll'];
$roll=mysql_real_escape_string($roll);
if($sem>6)
{
$query="SELECT name FROM `studentrecord` WHERE rollno=$roll And
sem=$sem";
$RS=mysql_query($query);
//var_dump($RS);
if (!$RS) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_array($RS);
$name = mysql_result($RS, 0);
if(!$name)
{
header('Location:pagetwo.html');
exit;
}
I am getting mysql errors,because the result set is returning null value
what should i do? I want that when result set returns null value the page
must be redirected to 'pagetwo.html' please help!

Woocommerce - Get product category 2nd level category

Woocommerce - Get product category 2nd level category

I have 3 levels deep product categories like following :
A
|--B
|---C
I want to get B, but don't know how to do. I can get all product
categories, but don't know how to filter out.
Here the code I use to get product categories : ID, 'product_cat' );
foreach( $product_category as $cat ):
if( 0 == $cat->parent )
echo $cat->name;
endforeach;

dynamically create buttons with different event calls Javascript

dynamically create buttons with different event calls Javascript

I have a problem in the following function,I am trying to create buttons
dynamically based on details from the results variable,The button are
created and an event is attached but it seems each button has the exact
same event attached.I need for the address variable to be different for
each event attached to a button and for that button then to be added to
replace text in my macField variable.I know i am close but have been
looking at this for a good while and cannot seem to pinpoint where exactly
i am going wrong ,If some with a fresh eye and more experienced could help
me out here I'd be grateful.
function (results) {
var r;
var x, i;
var btn;
for (i = 0; i < results.length; i++) {
app.display("Paired to" + results[i].name +
results[i].address);
x = document.getElementById("message2");
r = results[i].address;
w = document.getElementById('macField').value;
btn = document.createElement('input');
btn.onclick = function () {
document.getElementById('macField').value = r;
};
btn.setAttribute('type', 'button');
btn.setAttribute('name', 'sal' + [i]);
btn.setAttribute('id', 'Button' + [i]);
btn.setAttribute('value', results[i].name);
appendChild(btn);
}
},
function (error) {
app.display(JSON.stringify(error));
}

Why is Javascript Regex matching every second time?

Why is Javascript Regex matching every second time?

I'm defining a regex object and then matching it in a loop. It only
matches sometimes, to be precise - every second time. So I created a
smallest working sample of this problem.
I tried this code in Opera and Firefox. The behavior is the same in both:
>>> domainRegex = /(?:\.|^)([a-z0-9\-]+\.[a-z0-9\-]+)$/g;
/(?:\.|^)([a-z0-9\-]+\.[a-z0-9\-]+)$/g
>>> domainRegex.exec('mail-we0-f174.google.com');
Array [".google.com", "google.com"]
>>> domainRegex.exec('mail-we0-f174.google.com');
null
>>> domainRegex.exec('mail-we0-f174.google.com');
Array [".google.com", "google.com"]
>>> domainRegex.exec('mail-we0-f174.google.com');
null
>>> domainRegex.exec('mail-we0-f174.google.com');
Array [".google.com", "google.com"]
>>> domainRegex.exec('mail-we0-f174.google.com');
null
Why is this happening? Is this behaviour documented? Is there a way
around, other than defining the regex inside loop body?

how to kill specific process using %cpu over given time in python on linux?

how to kill specific process using %cpu over given time in python on linux?

I have this script in python on linux which deploys vnc locally, does some
graphical job on this vnc screen, and kills vnc. Sometimes after the job
is done process named gnome-panel hangs and stays with 100% cpu usage.
Then I need to log in through putty and kill all those processes manually
(sometime lots of them actually). I would like to add few lines to my
python script when it finishes its job, which will not only kill vnc (it
does it already), but also kill gnome-panel if it consumes certain amount
of cpu over given time period. I cant simply kill all gnome-panels, as
some of them are working fine (im deploying 4 vnc screens at the same
time).
So I need this condition in python:
if process name is gnome-panel and consumes over 80% of cpu and runs over
1 minute, kill process id
thank you!

Monday, 26 August 2013

Dynamic PL/SQL date parameter with time value retained

Dynamic PL/SQL date parameter with time value retained

It might be a silly problem but I cant find a solution with "DATE" type
passed in a PL/SQL proc which is called dynamically. What I need is to
pass both date and time parts in the called proc:
create or replace
PROCEDURE DATE_TIME_TEST ( dte_Date_IN IN DATE
) IS
vch_SQL_Stmnt VARCHAR2(2000);
BEGIN
DBMS_OUTPUT.PUT_LINE('Date is :'||TO_CHAR(dte_Date_IN, 'DD-Mon-YYYY
HH24:MI:SS'));
END;
/
declare
v_sql varchar2(2000);
begin
v_sql := 'begin DATE_TIME_TEST( dte_Date_IN => '''||
sysdate || ''''|| '); end;';
execute immediate v_sql;
end;
/
The output here is - Date is :27-Aug-2013 00:00:00.
I want it to be - Date is :27-Aug-2013 13:01:09

Abusing Objective-C Shorthand Notation

Abusing Objective-C Shorthand Notation

Other than giving old school Objective-C programmers heart attacks, are
there any other performance implications to doing this:
NSMutableArray *derp = @[].mutableCopy
Versus this:
NSMutableArray *derp = [[NSMutableArray alloc] init];

Adding a paramter to a new eventhandler

Adding a paramter to a new eventhandler

Hello i am creating a dynamic gridview and there is a part that i create a
new eventhandler for edits. I also create a new method for doing the
actual edit, but i need to pass it a datatable name as one of the
parameters so i can rebind it. I can't figure out where to add that
paramter:
GridView gridData = new GridView();
gridData.ID = "test";
gridData.AutoGenerateEditButton = true;
gridData.RowEditing += new GridViewEditEventHandler(grid_RowEditing);
gridData.DataSource = tbl;
gridData.DataBind();
protected void grid_RowEditing(object sender, GridViewEditEventArgs e)
{
((GridView)sender).EditIndex = e.NewEditIndex;
// I don't know how to pass the datasource name to this method, or
if its even possible, because i won't ever know the actual
gridview name because its dynamically created
//((GridView)sender).DataSource = ;
((GridView)sender).DataBind();

Component One Licenses.licx throws an Exception

Component One Licenses.licx throws an Exception

Hy Guys,
After we decided to buy an C1 License for the Silverlight FlexGrid
Component we were wondering why the activation won't work.
The Dialog Shows up that the copy of C1.FlexGrid is activated, but however
after we published our Silverlight Addin we still get the Message that C1
is not activated.
After a long time of Research we found out that no licenses.licx file was
created.
So we created the file manually with the following entry:
C1.Silverlight.FlexGrid.C1FlexGrid, C1.Silverlight.FlexGrid.5
Afte Rebuilding the whole solution we get an Invalid-Cross threat Access
Exception right from the licenses.licx file.
Error 1 Exception occurred creating type
'C1.Silverlight.FlexGrid.C1FlexGrid, C1.Silverlight.FlexGrid.5,
Version=5.0.20131.311, Culture=neutral, PublicKeyToken=***************'
System.UnauthorizedAccessException: Invalid cross-thread access.
Any Suggestions?

trying to display mysql data in an html text field

trying to display mysql data in an html text field

I would like to be able to view and edit information contained within a
table from my web browser however I can't for the life in me get the
current values to pull though to an html text field.
Can anyone shed any light as im quite new to php?
Table name: request_details
Column Names: id, name, email_address
My PHP code is:
<?
$order = "SELECT * FROM request_details WHERE id='$id'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
HTML Code
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<?php echo "$row[id]"?>">
<tr>
<td>Name</td>
<td>
<input type="text" name="name" size="20" value="<?php echo
"$row[name]"?>">
</td>
</tr>
<tr>
<td>Email Address</td>
<td>
<input type="text" name="email_address" size="40" value="<?php
echo "$row[email_address]"?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>

NullReferenceException thrown even though checking for Nothing

NullReferenceException thrown even though checking for Nothing

I have some rather straightforward code for a Compare Function
Public Overridable Function Comparer(thisValue As Object, otherValue
As Object) As Integer
Try
If thisValue Is Nothing Then
If otherValue Is Nothing Then
Return 0
Else
Return -1
End If
Else
If otherValue Is Nothing Then
Return 1
Else
Return thisValue.ToString.CompareTo(otherValue.ToString)
End If
End If
Catch ex As Exception
Return 0
End Try
End Function
The reason for the try-catch block is: I get a NullReferenceException at
the actual comparision line if thisValue is Nothing. The debugger shows me
that thisValue is "Nothing" but lands in the ELSE branch anyway.
Can anyone tell me why?

Sunday, 25 August 2013

have changed a folder to www-data, but apache is still not able to create file on it

have changed a folder to www-data, but apache is still not able to create
file on it

I have several folder that I use for uploading file from PHP. I have
change the group permission of this folder to www-data ( a group that
apache2 also shares ). but somehow I am still not able to upload a file to
it. I think I miss some small thing, but I'm not really sure what it is.
Any idea?
Below is my folder configuration :
ubuntu@myip:~/tweb/Server/myserver/assets$ ls -l
total 112
drwxrwsr-x 2 ubuntu www-data 4096 Aug 23 10:02 attachment
drwxrwxr-x 2 ubuntu www-data 4096 Aug 23 10:02 photo
drwxrwsr-x 2 ubuntu www-data 16384 Aug 23 10:02 logo
Below is the screenshot of the apache instance.
ubuntu@myip:~/tweb/Server/myserver/assets$ ps aux | grep apache
www-data 2324 0.1 3.8 285548 23036 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2326 0.0 3.9 287104 23888 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2327 0.1 3.8 285560 23152 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2328 0.1 3.8 285544 23140 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2329 0.1 3.8 285828 23276 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2332 0.0 1.6 276284 10076 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2333 0.0 3.3 282852 20520 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2334 0.0 1.6 276284 10076 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2336 0.0 1.6 276276 9984 ? S 03:32 0:00
/usr/sbin/apache2 -k start
www-data 2714 0.0 1.4 275624 8504 ? S 03:40 0:00
/usr/sbin/apache2 -k start
ubuntu 2718 0.0 0.1 8128 660 pts/0 S+ 03:41 0:00 grep
--color=auto apache
root 22942 0.0 2.6 275592 15904 ? Ss Aug23 0:14
/usr/sbin/apache2 -k start
When I checked to which group www-data is belong to, it seems that the
user is belong to www-data group.
groups www-data
www-data : www-data

Convert multiline JSON to python dictionary

Convert multiline JSON to python dictionary

I currently have this data in a file which is multiple JSON rows (about
13k rows but the example below is shortened:
{"first_name":"John","last_name":"Smith","age":30}
{"first_name":"Tim","last_name":"Johnson","age":34}
I have the following code:
import json
import codecs
with open('brief.csv') as f:
for line in f:
tweet = codecs.open('brief.csv', encoding='utf8').read()
data = json.loads(tweet)
print data
print data.keys()
print data.values()
If I only have one row of data in my file, this works great. However, I
can't seem to figure out how to go row by row to change each row into a
dictionary. When I try to run this on multiple lines, I get the
ValueError(errmsg("Extra data", s end, len(s))) error due to the code only
wanting to deal with two curly braces, IE the first row. I ultimately want
to be able to select certain keys (like first_name and age) and then print
out only those values out of my file.
Any idea how to accomplish this?

Callback on loading basic Google Maps with marker to display coordinates

Callback on loading basic Google Maps with marker to display coordinates

I've got a simple map, on Google Maps, with a marker.
I would like to display the coordinates, that are dynamically set, in a
div above the map.
Is there any callback functionality that I can tap in to here?
function initialize() {
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
google.maps.event.addDomListener(window, 'load', initialize);

google maps tiling scheme index grid

google maps tiling scheme index grid

I have a need to cut tiles from a raster with bounds that result in no
partially filled tiles at a particular zoom level (no transparency or
black/white areas). First thought was to overlay an index grid so I could
see how to cut the raster. Is it possible to find shapefile or other
description of the tiling grid for google maps or other tiling schemes.
Also interested in other idea for achieving this goal. One is to simply
programmatically discard tiles with empty areas after the fact. Interested
in other suggestions as well.

Saturday, 24 August 2013

What happened to Voldemort's wand after the last book, and does Harry own it now?

What happened to Voldemort's wand after the last book, and does Harry own
it now?

Is there any reference about what happened to Voldemort's wand after he
started using the Elder Wand he stole from Hogwarts? Would it stop
responding to Voldemort after he started using the elder wand? This does
not seem a possibility, as he never really mastered the Elder Wand.
However, now that Harry has defeated him in a duel, does his original wand
change alliance as well as the Elder Wand? Does Harry own 4 wands at the
end of the Book (his own, Elder Wand, Draco's and Voldemort's) ?

List results of a competition by meet name

List results of a competition by meet name

I am attempting to list the results of a horse racing meet based on the
meet's name. I would like it to look like this:



RACE MEET (DATE)
RACE NAME 1. Horse (sire) owned by Farm 2. Horse (sire) owned by Farm 3.
Horse (sire) owned by Farm
RACE NAME 1. Horse (sire) owned by Farm 2. Horse (sire) owned by Farm



I have gotten it to sort of work, but it only lists the horse in 1st place
and goes onto the next race. I can't figure out how to list every placing
for that race.
Current Code:
<?php
$sql = "SELECT DISTINCT * FROM racing WHERE `meet` = '$meet' LIMIT 1";
$query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql );
while($row = mysql_fetch_array($query)){
$date= $row['date'];
echo "<h2><strong>$meet Results</strong> ($date)</h2>";
}
?>
</h2>
<?php
$sql = "SELECT *
FROM `racing`
WHERE `meet` = '$meet'
GROUP BY `race`
ORDER BY `place` "; $query = mysql_query($sql) or die( mysql_error() .
"<br />" . $sql );
while($row = mysql_fetch_array($query)){
$race= $row['race'];
$place= $row['place'];
$horse= $row['horse'];
$sire= $row['sire'];
$farm= $row['farm'];
echo "
<b>$race</b><br>
$place <a href='horse.php?horse={$row['horse']}'>$horse</a> (<a
href='sire.php?sire={$row['sire']}'>$sire</a>) owned by <a
href='owners.php?farm={$row['farm']}'>$farm</a><br>
"; }
?>

Authorization header and apache_request_headers function

Authorization header and apache_request_headers function

I've been on a journey to getting apache_request_headers() working on my
server. I have upgraded to the latest stable of PHP 5.4 and changed my PHP
handler to FastCGI as this allows you to run the apache_request_headers()
function. I'd rather not run PHP as an apache module due to permission
issues.
Everything works fine with my new set-up but the only issue is that
apache_request_headers() does not seem to pick up the "Authorization"
header which I require for my OAuth 2 server.
The header I am sending is:
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
However, if I send the following header (or anything other than
'Authorization'), it works:
X-Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Frustrating... Any ideas on how I can get this working?

The time limit for receiving a large amount of asynchronous messages

The time limit for receiving a large amount of asynchronous messages

I'm totally new in WF. So I want to ask about such situation: In one step
my workflow can receive messages (0 to N) from clients for 3 minutes. The
simplest method of implementation as I see it is manually written method
that is called from workflow.
But I want to know how it should be done in designer. I tried it this way.
But as I see it workflow only can synchronous receive messages one by one.
How can I improve it or am I even need to go in this direction?

Increase top and bottom margin FancyBox v2 because of fixed navigation

Increase top and bottom margin FancyBox v2 because of fixed navigation

I'm currently working on a website which in future will be responsive. The
site is primarily made up of images which in turn load into a FancyBox
when clicked. v2 of FancyBox is now responsive and so re-sizes the images
etc when screen size changes. As part of my design I have two fixed
banners which appear at the top and bottom of the page, see image below:

By default there is a margin around the FancyBox so that it's styled
nicely. However, with the fixed positioning that I've added to the banners
I need to increase the top and bottom margin. I've looked through the JS
source but I can't for the life of me find where I should be adding extra
margin. There are all sorts of margins on the transitions etc (which I
think is where I'm getting confused).
In theory I just need to add "x" amount of pixels to the margin, where x
is the height of the banners. As an aside I'm not sure how I would
replicate this in a responsive design, as the banners may be slightly
shallower on a mobile. Adding the margin would mean there's a slight gap
between the image and the banner, where currently the image goes behind
the banner. See the following image for what I'd like it to look like:

I'd appreciate any thoughts/examples of where this has been done before.
Thanks in advance, Adam.

User Management through Refinery

User Management through Refinery

Tried using refinery with an exiting devise rails app. It works well but
in the refinery backend console, I do not see a tab for users as shown
here http://demo.refinerycms.com/refinery
The guide says
Now if you want to be able to edit the User model from refinery, then you
should make sure the User table matches the Refinery::User table exactly.
In most cases with devise, it is as simple as adding the username column
to the users table and making that attribute accessible in the model. Next
you can set up the following initializer:
config/initializers/refinery_class_substitutions.rb
class Refinery::User < User; end class Refinery::Role < Role; end
Does that mean that if I have additional fields in my User table, I cannot
manage them through refinery users console?

Can't use System.Windows.Forms;

Can't use System.Windows.Forms;

I have referenced System.Windows.Forms, but Xamarin will not let me use
it. It only allows me to use Windows.Input and Markup.

Solving ODE with negative expansion power series

Solving ODE with negative expansion power series

I am solving a series of ODE, such that each DE is equal to some degree of
term that I'm expanding to. For instance, one DE is this:
$\xi^r\partial_r g_{rr}+2g_{tt}\partial_t\xi^t=\mathcal{O}(r)$
$g_{ii}$ are given, from metric, but that's not important. I need to
assume that the solution (since I'm looking for components of $\xi^\mu$,
which is a vector with components $\xi^t,\xi^r,\xi^\phi$) is given with
power series of the form:
$\xi^\mu=\sum\limits_{n}\xi^\mu_n(t,\phi)r^n$, and this is to be seen as
expansion around $1/r$ (expansion around $r=\infty$).
Now when I plug this in the ODE I get this
$\frac{2}{l^2}\sum_n\xi^r_nr^{n+1}+2\sum_n\xi^t_{n,t}
r^n+\frac{2}{l^2}\sum_n\xi^t_{n,t}r^{n+2}=\mathcal{O}(r)$, where
$\xi^\mu_{n,i}$
is the derivative with the respect to i-th component.
What troubles me is, how to expand this? Do I set n=0,-1,-2,... until my
$\mathcal{O}(r)$ terms cancel each other out? Or?
I'm kinda stuck :\

Delete the folder

Delete the folder

i am not able to delete one folder on the desktop....if i try to delete i
get the message as " Access is denied"..i tried running the command from
cmd prompt as an administrator: RD /S /Q
"C:\Users\username\Desktop\folder" - still the same error and i trying to
change the permissions on the folder but still i am not able to do the
changes i get access denied...any help will be much appreciated.

Friday, 23 August 2013

Is there a way to import Python3's multiprocessing module inside a Sublime Text 3 plugin?

Is there a way to import Python3's multiprocessing module inside a Sublime
Text 3 plugin?

I'm making a ST3 plugin on my OSX dev-environment, but according to the
unofficial docs:
Sublime Text ships with a trimmed down standard library. The Tkinter,
multiprocessing and sqlite3 modules are among the missing ones.
Even if it's not bundled with ST3, is there a way I can still import
multiprocessing (docs)? Is there a way I can import it as a "standalone"
module inside my plugin dir?

How to change Language for non-Unicode program in Windows 8 without changing global settings?

How to change Language for non-Unicode program in Windows 8 without
changing global settings?

I have an old non-Unicode program which doesn't display correctly on the
system with English(USA) settings for such programs. I want to use this
program but I don't want to change global settings for the whole system
because it's affecting my other programs this way.
Is there any way to apply this non-Unicode language setting for just one
program?
I'm using Windows 8 Pro.

PHP/MYSQL - "ORDER BY" Doesn't work

PHP/MYSQL - "ORDER BY" Doesn't work

I have a table with a bunch of users who have a certain amount of points.
I would like to arrange the users from highest points first to the lowest.
However ORDER BY PTS DESC doesn't work.
<tr>
<th id="users_th1"><img src="<?php echo
mysql_result($r_TEAMS, $i, 'LOGO'); ?>"/> <p><?php
echo mysql_result($r_TEAMS, $i, 'NAME');
?></p></th>
<th id="users_th2">Points Value</th>
</tr>
<?php
$q_users = 'Select * from POINTS LEFT JOIN USERS on
USERS.UID = POINTS.UID where TID =
'.mysql_result($r_TEAMS, $i, 'TID');
$r_users = mysql_query($q_users, $connection) or
die(mysql_error());
$n_users = mysql_num_rows($r_users);
for($k = 0; $k <$n_users; $k++){
?>
<tr>
<td class="person"><?php echo
mysql_result($r_users, $k, 'NAME'); ?></td>
<td><?php echo mysql_result($r_users, $k,
'POINTS.PTS'); ?></td>
</tr>
<?php
}
}

Import specific rows and columns form csv file into table using php

Import specific rows and columns form csv file into table using php

I'm very new to php but have been experimenting fairly successfully with
using 'fgetcsv' to bring in a CSV file and convert it into an html table.
However I also have a large CSV file with 70 columns and 700 rows, but I
only want to display columns 1 to 47 and rows 3 to 21 in one table, and
then same columns but rows 22 to 44 in another table.
I'd appreciate some help with this, below is the code I am currently using:
<?php
$row = 1;
if (($handle = fopen("CSV/test.csv", "r")) !== FALSE) {
echo '<table border="1">';
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
if ($row == 1) {
echo '<thead><tr>';
}else{
echo '<tr>';
}
for ($c=0; $c < $num; $c++) {
//echo $data[$c] . "<br />\n";
if(empty($data[$c])) {
$value = "&nbsp;";
}else{
$value = $data[$c];
}
if ($row == 1) {
echo '<th>'.$value.'</th>';
}else{
echo '<td>'.$value.'</td>';
}
}
if ($row == 1) {
echo '</tr></thead><tbody>';
}else{
echo '</tr>';
}
$row++;
}
echo '</tbody></table>';
fclose($handle);
}
?>

AngularJS make custom form field.error act like "required"

AngularJS make custom form field.error act like "required"

I am validating my forms both in the client and in my API when sent. If
validation fails in my backend I want to show identical messages as I do
when my client validation fails. To do this I use the following piece of
code when a field fails in the backend.
#Template
<span class="registration-error"
ng-show="accPasswordForm.password.$error.required">*</span>
<span class="registration-error"
ng-show="accPasswordForm.password.$error.authfail">Authentication
failed</span>
<input ng-model="changePasswordForm.password" name="password"
type="password" authfail required/>
#Controller ( I set this if the password field throws a validation error
in my API )
scope.myForm.password.$setValidity('authfail', false);
This works fine, but the problem is that I want this $setValidity to be
set to true when I start typing in the password field again. Same behavior
as the required error has. Ive tried in different ways to watch the field
input but I seem to always fail getting it to work.
Someone able to give me a hint/code snippet on how I can manage to get
this working?

Thursday, 22 August 2013

Alternative to NewRelic for PHP Apps

Alternative to NewRelic for PHP Apps

What are some alternatives to NewRelic for PHP application performance
metrics and tracing of requests?

Firefox - Any way to watch only the videos from weather.com no sponsor videos?

Firefox - Any way to watch only the videos from weather.com no sponsor
videos?

Is it possible using Firefox and any add-on to watch only the videos from
weather.com, no sponsor videos? By default Adblock Plus blocks every flash
video from weather.com

Pattern Match Timed-out

Pattern Match Timed-out

I use Perl Net::telnet for connecting to my router and change some
options, but i get this error:
pattern match timed-out
every thing is true (user , pass , pattern and etc), i am going crazy for
the source of this error. my code is:
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
$telnet->open('192.168.1.1');
$telnet->waitfor('/login[: ]$/i');
$telnet->print('admin');
$telnet->waitfor('/password[: ]$/i');
$telnet->print('admin');
$telnet->waitfor('/\$ $/i' );
$telnet->print('list');
$output = $telnet->waitfor('/\$ $/i');
print $output;
What should i do now? Is there any alternative way? Thank you

How do I align webview borders of js to fit any custom screen

How do I align webview borders of js to fit any custom screen

I am working on some js files, which have assets defined in js aswell, I
am planning to pull a webview on top of the js, so it can be displayed,
however seems like when I use webview the content displays full screen and
the game becomes scrollable, which is not what i intended.Any idea how I
can adjust the same in the code in the assets with js without resorting to
making the images local as mdpi/hdpi etc.?

How to organize css file in an asp.net mvc project?

How to organize css file in an asp.net mvc project?

Where is the best place to put view-specific css files in an Asp.Net Mvc
project? Should I create a structure that mirrors the organization of
views? The solution must ease maintenance and be compatible with bundling.

How can send request server and receive response by php

How can send request server and receive response by php

Request format:
http://site.com/VSServices/SendSms.ashx?login=CLIENT_LOGIN&pass=CLIENT_PASSWORD&from=Paulx&to=442081368002&&text=Hello
response is xml

Wednesday, 21 August 2013

Wordpress logo only working on front page nothing else

Wordpress logo only working on front page nothing else

I am working on a website and the logo works on the front page but on the
other pages the links seem to be broken and no images are showing.
http://utahtraveldirectory.com is the front page and for example
http://utahtraveldirectory.com/hotel-search/ the logo isn't working.
I checked all the permissions and I think they are fine, maybe I wasn't
checking the right folder? I won't leave the site up for long but I needed
some help! Thanks!
I am using the YooTheme - Lava

WP7 Multiselectlist not scrolling

WP7 Multiselectlist not scrolling

I am building a WP7 application that contains a Multiselectlist. I want to
put text above and below the multiselectlist control using TextBlock's.
The problem Im having is that this causes the Multiselectlist to not
scroll. I have tried wrapping all controls in a ScrollViewer as well as a
Grid but to no avail. Any suggestions on what I can do to maintain
scrolling?

Clarification of definition of category

Clarification of definition of category

Need the set of objects and the set of morphisms be disjoint? If not, can
the morphisms be a subset of the objects?

Bypass 3-legged Yahoo Fantasy OAuth

Bypass 3-legged Yahoo Fantasy OAuth

There are two companies right now (that I know of) importing Fantasy data
with just basic name/pw auth in their apps: FantasyBuzzer and FantasyPros.
Judging from the documentation I've found online, it would appear the only
way to get a users Fantasy data is via 3-legged Oauth which requires
sending the user to Yahoo to log in, grant access, THEN copy and paste a
code back to the app asking for access. How are these companies able to
get access to a users fantasy data without all that extra BS in front?
I'm trying to put something together that just gets a list of the users
fantasy team members, and it's not feasible for me to send the user to
yahoo within my app and then wait for them to grant access, and then copy
and paste a unique code back into the app... If anyone has any insight, it
would be greatly appreciated. Thanks!

Python: assertRaises( ) not catching ldap.SERVER_DOWN error when raised

Python: assertRaises( ) not catching ldap.SERVER_DOWN error when raised

Thanks for your help in advance.
I've got the following class method that I'm trying to test:
def _get_ldap_connection(self):
"""
Instantiate and return simpleldap.Connection object.
Raises:
ldap.SERVER_DOWN: When ldap_url is invalid or server is
not reachable.
"""
try:
ldap_connection = simpleldap.Connection(
self.ldap_url, encryption='ssl', require_cert=False,
debug=False, dn=self.ldap_login_dn,
password=self.ldap_login_password)
except ldap.SERVER_DOWN:
raise ldap.SERVER_DOWN(
"The LDAP server specified, {}, did not respond to the "
"connection attempt.".format(self.ldap_url))
And here's the unittest:
def test__get_ldap_connection(self):
"""
VERY IMPORTANT: This test refers to your actual config.json file.
If it is correctly populated, you can expect this test to fail.
"""
# Instantiate Class
test_extractor = SakaiLdapExtractor('config_files/config.json')
# Monkey with ldap server url to ensure error.
test_extractor.ldap_url = "invalid_ldap_url"
self.assertRaises(
ldap.SERVER_DOWN, test_extractor._get_ldap_connection())
So far, so good. But when I execute the unit tests (via nose)
test_extractor._get_ldap_connection() is called from the assertRaises
statement, but the exception is not caught and the test fails.
Here is the output:
vagrant@precise64:/vagrant/sakai-directory-integration$ nosetests
...E..
======================================================================
ERROR: VERY IMPORTANT: This test refers to your actual config.json file.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/vagrant/sakai-directory-integration/test_sakaiLdapExtractor.py",
line 77, in test__get_ldap_connection
ldap.SERVER_DOWN, test_extractor._get_ldap_connection())
File "/vagrant/sakai-directory-integration/sakai_ldap_integration.py",
line 197, in _get_ldap_connection
"connection attempt.".format(self.ldap_url))
SERVER_DOWN: The LDAP server specified, invalid_ldap_url, did not respond
to the connection attempt.
----------------------------------------------------------------------
Ran 6 tests in 0.159s
Help me!

XSL Reversing the order with a counter

XSL Reversing the order with a counter

I have a very unusual scenario. Never heard or done something like this
before. Here's my source XML.
<?xml version="1.0" encoding="UTF-8"?>
<ListItems>
<List>
<name>A<name/>
</List>
<List>
<name>B<name/>
</List>
<List>
<name>C<name/>
</List>
<List>
<name>D<name/>
</List>
</ListItems>
What I am looking to do is to reverse the order of the list with a reverse
counter added as an index. The resultant XML should look like this:
<UpdateListItems>
<List>
<name>D<name/>
<index>4<index/>
</List>
<List>
<name>C<name/>
<index>3<index/>
</List>
<List>
<name>B<name/>
<index>2<index/>
</List>
<List>
<name>A<name/>
<index>1<index/>
</List>
</UpdateListItems>
Notice the names in reverse order with an index added in reverse order.
Sounds a bit stupid but is it possible to do this in xml transformation?

CSS fix for Firefox - Ruining the whole page

CSS fix for Firefox - Ruining the whole page

this is my project working fine on Chrome/Opera/IE but layout messup in
Firefox here's the link http://www.evawoxfam.org/aitebaar/ Plz help

Tuesday, 20 August 2013

Jemdoc installation

Jemdoc installation

This is a somewhat obscure question, although if any of you are familiar
with the markup language jemdoc you'll be able to help me.
Python is installed, although the
jemdoc jemdoc.index
command is not working: 'jemdoc command not found'
jemdoc.py is in usr/local/bin/
Any suggestions?

When do equivariant quasi-isomorphisms of chain complexes induce a quasi isomorphism on the tensor product

When do equivariant quasi-isomorphisms of chain complexes induce a quasi
isomorphism on the tensor product

Suppose I have chain complexes $A,B,C,D$ where $A$ and $C$ have right
$R$-module structures and $B$ and $D$ have left $R$-module structures, and
that I have maps $f:A\to B$ and $g:C\to D$ which satisfy $g(r\cdot
x)=r\cdot g(x)$ and $f(x\cdot r)=f(x)\cdot r$. Suppose further that $f,g$
are quasi-isomorphisms.
Question: When can I conclude that $f\otimes_{R} g: A\otimes_{R} B\to
C\otimes_{R} D$ also induces a quasi-isomorphism?

Unexpected Echo at time

Unexpected Echo at time

So im making a simple batch game for my friends and when it get to this
part it is telling me that the Echo command was unexpected at this time
and closes i can't figure out what is wrong with it please help.
:WTS5
set /p chainboots=<"character\inventory\armor\chain\chainboots.txt"
set /p chaingloves=<"character\inventory\armor\chain\chaingloves.txt"
set /p chainhelm=<"character\inventory\armor\chain\chainhelm.txt"
set /p chainlegging=<"character\inventory\armor\chain\chainleggings.txt"
set /p chaintorso=<"character\inventory\armor\chain\chaintorso.txt"
set /p woodensword=<character\inventory\woodensword.txt
set /p Echainboots=<"character/equiped/armor/chain/chainboots.txt
set /p Echainlegging=<"character/equiped/armor/chain/chainleggings.txt
set /p Echaintorso=<"character/equiped/armor/chain/chaintorso.txt
set /p Echainhelm=<"character/equiped/armor/chain/chainhelm.txt
set /p Echaingloves=<"character/equiped/armor/chain/chaingloves.txt
set /p Ewoodensword=<"character/equiped/hands/woodensword.txt
set /p Ewoodensheild=<"character/equiped/hands/woodenshield.txt
cls
echo.
echo.
echo.
echo Current armor intems in inventory include:
echo %true% >"character/inventory/woodensheild.txt"
set /p woodensheild= <"character\inventory\woodensheild.txt"
if %chainboots%==%true% echo 575 Chain boots
if %chainleggins%==%true% echo 680 Chain leggings
if %chaintorso%==%true% echo 902 chain torso
if %chaingloved%==%true% echo 588 Chain gloves
If %chainhelm%==%true% echo 795 Chain helm
echo.
echo.
echo Current weapons and shelds in inventory include:
If %woodensheild%==%true% echo 841 wooden shield
IF %woodensword%==%true% echo 426 wooden sword
echo.
echo.
echo Current items in inventory include:
echo.
echo.
echo Type 1 to continue otherwise type item id to equip
echo.
set /p a="Enter Item ID:"
If %a%=575 (
echo %false% > %chainboots%
echo %true% > %Echainboots%
goto WTS5
) Else IF %a%==680 (
echo %false% > %chainleggings%
echo %true% > %Echainleggings%
goto WTS5
) Else if %a%==902 (
echo %false% > %chaintorso%
echo %true% > %Echaintorso%
goto WTS5
) Else if %a%==588 (
echo %false% > %changloves%
echo %true% > %Echaingloves%
goto WTS5
) Else if %a%==795 (
echo %false% > %chainhelm%
echo %true% > %Ehainhelm%
goto WTS5
) Else if %a%==841 (
echo %false% > %woodenshield%
echo %true% > %Ewoodenshield%
goto WTS5
) Else if %a%==426 (
echo %false% > %woodensword%
echo %true% > %Ewoodensword%
goto WTS5
) Else IF %a%==1 (
goto WTS6
) Else (
cls
echo invalid ID
pause
goto WTS5
)

How to properly handle rental inventory via database

How to properly handle rental inventory via database

I am building a rental inventory app that handles the tracking of rental
reservations. I think I might be over thinking it but I am getting stuck
on trying to figure out the model or schema of inventory scheduling part.
In the attached image, I have 4 copies of one movie. On the first only one
copy is scheduled to be out; on the 5th, 3 copies are out; on the 6th and
10th all copies are out. Now, I would like to design the database in a way
in which I can look up a date OR date-range to see how much inventory is
available that day(s). The challenge is that there might NOT be individual
sku's or tracking for each individual rental item. So I can't treat
Movie_1 as if it has movie_1_a,movie_1_b,movie_1_c,movie_1_d. Instead I
have to treat it like Movie_1 has 4 copies and on the 5th, 3 copies are
out but we don't know which ones.
Can anyone give any suggestions on how to write the schema. How would a
sample query look like to search for availability?

Avoid deadlock when the order of acquisition of locks is not guaranteed

Avoid deadlock when the order of acquisition of locks is not guaranteed

Suppose that I have the following class:
public class BagWithLock
{
private readonly lockObject = new object();
private object data;
public object Data
{
get { lock (lockObject) { return data; } }
set { lock (lockObject) { data = value; } }
}
public bool IsEquivalentTo(BagWithLock other)
{
lock (lockObject)
lock (other.lockObject)
return object.Equals(data, other.data);
}
}
The problem I am worried about here is that, because of the way that
IsEquivalentTo is implemented, I could be left with a deadlock condition,
if a thread invoked item1.IsEquivalentTo(item2) and acquired item1's lock,
and another invoked item2.IsEquivalentTo(item1) and acquired item2.
What should I do to ensure, as much as possible, that such deadlocks
cannot happen?

How to create a new Live ID and check exists id from Web?

How to create a new Live ID and check exists id from Web?

So, i want to create the tool to register a new Live ID & check exists Id
vailable [Winform- C# - HttpWebRequest] I used fiddler to catch GET/POST
request but i didn't see parameters post to server
(username=xxx&password=xxx&xxx). Register link: enter link description
here how can i do ?

Monday, 19 August 2013

Displaying a "Reveal" modal when validating an "Abide" form

Displaying a "Reveal" modal when validating an "Abide" form

I'm loving the Foundation framework! It's making my life much easier.
I'm running into a problem with creating custom callbacks when an Abide
form runs its validation. Here's the code that I found in the Docs:
$('#myForm')
.on('invalid', function () {
var invalid_fields = $(this).find('[data-invalid]');
console.log(invalid_fields);
});
.on('valid', function () {
console.log('valid!');
});
What I want to do is to display a success modal using Reveal when all
fields validate and an error modal when they don't.
I thought I could simply replace
console.log('valid!');
With...
$("#myModalSuccess").reveal();
But, that doesn't work. I'm sure I'm missing something. I'm guessing I'm
coming at the problem all wrong.
Thoughts?

watchPosition on iOS with Location Services OFF hangs

watchPosition on iOS with Location Services OFF hangs

I'm having a problem with geolocation.watchPosition. I've scoured the
boards, but I didn't find a post that has this specific issue.
Here is my PhoneGap version:
name="phonegap-version" value="2.9.0" />
Here is some of my code:
var waitTimerVal = 10*1000; // milliseconds
var options = { enableHighAccuracy:true, timeout:waitTimerVal,
maximumAge:60000};
watch_id = navigator.geolocation.watchPosition(onSuccess, onError, options);
// onError Callback receives a PositionError object
function onError(error) {
var perror;
switch(error.code)
{
case error.PERMISSION_DENIED:
perror="Req.Den."
error_cnt++;
//alert(perror);
break;
case error.POSITION_UNAVAILABLE:
perror="No.Pos."
error_cnt++;
//alert(perror);
break;
case error.TIMEOUT:
perror="Poor..."
error_cnt++;
//alert(perror);
break;
case error.UNKNOWN_ERROR:
perror="Error"
error_cnt++;
//alert(perror);
break;
}
}
// onSuccess Geolocation
function onSuccess(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
alt = position.coords.altitude;
accuracy = position.coords.accuracy;
}
This works perfectly on my Android (4.2.1), but on my iPhone. I am running
this on iOS 6.1.3.
On iOS, if the Location Services are enabled, this works fine. On iOS, if
the Location Services are disabled, it makes my app just hang.
Oddly, on Android, I get the POSITION_UNAVAILABLE enum each iteration when
I turn of Location Services on my phone (I thought it would have been
PERMISSION_DENIED, but it's not... maybe I just didn't wait long enough
iterations)
I check the number of error_cnt values, and if it exceeds a certain
number, I pop up a message. On the Android, I get that message. On iOS, I
don't. So I know the callbacks are not being invoked.
Does anyone have an idea of what may be causing this, and a suggested work
around?
Thanks in advance.

Magento Block construct - use _construct or __construct?

Magento Block construct - use _construct or __construct?

I am a little bit confused. I read Alan Storm's excellent article about
Magento Block Lifecycle Methods and as far as I understand one should be
using the protected _construct() method to initialize the block. In my
case I just want to set the right block template. So I assume I should be
using
protected function _construct()
{
parent::_construct();
$this->setTemplate('stenik/qaforum/forum.phtml');
}
However, when I look at the blocks of some of the core Magento modules,
they seem to use the php __construct method to do it. For example
Mage_Poll_Block_Poll, Mage_ProductAlert_Block_Price,
Mage_Rating_Block_Entity_Detailed, Mage_Review_Block_Form
Although both ways actually work, I'd like to know what is the right way
to do it.

How to use/handle a loader in an MVC app?

How to use/handle a loader in an MVC app?

in a ASP.NET MVC application that I am currently working there are
multiple places in a single page that the user can click. So there is a
main menu that's in _layout and for each inidividual page there can be
links associated with that page. I am trying to use a loader which will be
shown on every click, mainly where the response takes time but for now
it's for every click. For example in the home page, from the main menu the
user can click Students and the loader should come up and hide when the
page loads completely. On the students page there can be an ajax call that
gets data and binds it to the grid. So from the time the user clicks on a
menu link and the page loads the loader is active/shown. It's hidden once
the page loads completely. The grid can have editing functionality and
when the user clicks on any of the CRUD links the loader should show and
hide.
I am looking at suggestions on implementing this requirement. If I can
hookup any of the MVC events, that would be cool as I want less of
Javascript/jQuery stuff but if Javascript/jQuery is the way then that's
fine too.
Currently I don't have anything so anypointers are appreciated.

Sunday, 18 August 2013

mysql Load database slow after power outage

mysql Load database slow after power outage

I'm using mysql to storing database in 17/09/2013. After power outage
appear , mysql only load database 16/09/2013 and can't connect then for 2
hours + restart .Mysql load full database (17/09/2013) , i can't
understand.Anybody suggest me ?

Why this compareFunction is not working?

Why this compareFunction is not working?

I have an object with the next JSON structure:
{
"matter": [
{
"title": "Systems",
"date": "23/08/2010",
"score": 5
},
....
]
}
I want to sort this variable with the sort() function. I can do it using
the score field, but I can't sort it using the date field. This is what
I'm using:
$.getJSON('js/data.json', function(data) {
// data now contains one node with all the matters
$.each(data, function(key, val) {
// val now contains all the matters in their nodes
val.sort(function (a,b) {
return
parseInt(a.date.substring(6,10)+a.date.substring(3,5)+a.date.substring(0,2))
-
parseInt(b.date.substring(6,10)+b.date.substring(3,5)+b.date.substring(0,2));
});
// Here I get the same array not sorted!
}
}
Both parseInt() functions returns an integer with this format:
if date=="23/08/2010" => 20100823
I used alerts to check if I'm splitting correctly the date but that is
fine. Anyway, I can sort the array.
What I'm doing wrong?
I'm testing the code using this JSON file.

How to assign ships to a specific Firecloud warp-chunnel?

How to assign ships to a specific Firecloud warp-chunnel?

I'm playing the game VGA Planets and i have choosen the Cyborg as race.
Currently i have two different Fireclouds on the same Planet, my whole
army plus two freighters with heavily needed ressources for my starbase.
I want that my army jump with one Firecloud to a nearby planet and the
freighters should jump with the other Firecloud to my starbase. How can i
assign ships to their dedicated Firecloud?
Maybe the same friendly codes will work?
On the

Return 3 closest locations to a users location (geolocation) and list those locations for them

Return 3 closest locations to a users location (geolocation) and list
those locations for them

Background:
I am working on a website/app built with HTML/CSS/Javascript that will use
geolocation (Google Maps API) to find a users location (geolocation) and
return them, for example, the top 5 closest water parks to them at that
location they are currently at so they will be able to then navigate to
one of those locations. I am using Google Fusion Tables to return the
results to them.
Question:
I have been able to successfully...
Find the users location and put a marker there (using Map API/geolocation)
Return 3 out of 5 locations and put markers down for those 3 (I used
Fusion Tables & limited results to 3)
I want to be able to…
Return only the 3 closest locations to the user (i.e. calculate distance
from users location to nearest water park)
Put a "sidebar" or list of those 3 locations, detailing name, address, and
other fields in my Fusion Table
I made a Fiddle below this code with what I have so far. The code below is
my Fusion Table query, which I assume is what I will need to make the
changes to in order to get the 3 closest locations (question #1). Question
#2, listing those locations, might use all of the code I have in my
Fiddle.
var base_query = {
select: 'Location',
from: '1MsmdOvWLKNNrtKnmoEf2djCc3Rp_gYmueN4FGnc',
limit: 3
};
var ftLayer = new google.maps.FusionTablesLayer({
map: map,
query: $.extend({}, base_query)
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < base_query.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(base_query[i][1],
base_query[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function (marker,
i) {
return function () {
infowindow.setContent(base_query[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
};
var signChange = function () {
var options = {
query: $.extend({}, base_query)
};
};
http://jsfiddle.net/jamez14/bRLaH/1/
Any help would be appreciated. I have been doing research on this question
for some time, but for whatever reason I am not able to piece it all
together. Any help/resources would be greatly appreciated!

Go web frameworks or Dart

Go web frameworks or Dart

As you know there are lots of web framework on Google Go such as Revel or
Gorilla. Also Google provide Dart as a web development platform. Which
choice is better between them to develop a RESTful API?

How to update Activity's variable during AsyncTask?

How to update Activity's variable during AsyncTask?

I'm trying to update a variable from AsyncTask, but I'm not exactly sure
how. This is what I tried:
Outside the AsyncTask is the activity class that has a variable..:
int myVariable = 0;
class MyTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... args0) {
myVariable = 3;
return null;
}
}
When i print out the variable, it still says 0, and not 3. I'm using
AsynTask for something more complicated, but this is the dumbed down
version of what I'm trying to accomplish.

Saturday, 17 August 2013

compare input to an object arraylist

compare input to an object arraylist

I would like to compare the input from a JTextField to all the elements in
a string arraylist. If the input is equal to an element in the list I
would like the program to acknowledge by saying "This is in my
vocabulary.", and if it is not, I would like the program to say "This is
NOT in my vocabulary." In my code, I have tried getting this to work buy I
always get the message "This is NOT in my vocabulary." even if the input
matches an element in my list. How can I get this to work properly?
Here is my code, in it AI is where the list that is being compared is.
package Important;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
import javax.swing.JTextField;
import AI.*;
public class TextActions implements ActionListener{
private String hero;
private Vocabulary vocab1 = new Vocabulary();
public void actionPerformed(ActionEvent e) {
e.getSource();
hero = e.getActionCommand();
if (vocab1.Adjectives.equals(hero)){
System.out.println("This word is in my vocab");
}else{
System.out.println( hero + " is not in my vocab");
}
//CompareWords(hero);
}
public void CompareWords(String readme){
if (vocab1.Adjectives.contains(readme)){
//System.out.println("This word is in my vocab");
}
}
}

SEGMENTATION FAULT IN LINKED LIST IMPLEMENTATION IN C++

SEGMENTATION FAULT IN LINKED LIST IMPLEMENTATION IN C++

I am writing a function in C++ to add a "data" of type 'int' to the end of
a linked list.
void insert_back()
{
int no;
node *temp;
cout<<"\nEnter the number"<<"\n";
cin>>no;
temp = head;
if(temp != NULL)
{
while(temp != NULL)
temp = temp->next;
}
temp->next = (node*)malloc(sizeof(node));
temp = temp->next;
temp->data = no;
temp->next = NULL;
}
However, at the line, temp->next = (node*)malloc(sizeof(node)), I get an
access violation error(segmentation fault). I do not find anything
fundamentally wrong. Can you please enlighten me on the issue?

Running a windows batch command using chef blocks the chef provision

Running a windows batch command using chef blocks the chef provision

I'm using chef for windows and need to run a batch file that starts up the
selenium-server java service (java -jar seleniumserver.jar) as a daemon.
When I try to use a windows_batch resource, it causes chef to hang during
it's provisioning.
The problem is that the selenium server stays running in whatever command
line you start it in, but chef won't continue provisioning the machine
until the command is finished. The thing is, the command never finishes,
it's not supposed to.
Here's what I've tried so far:
Executing java -jar seleniumserver.jar & (with the windows_batch resource)
Using a template to create a batch file for the command, then using
windows_batch to execute file.bat Using windows_batch to execute the
batchfile with an & (file.bat &)
I'm open to any ideas, even if it's kind of hacky. Thanks in advance!

Search similar results

Search similar results

In my database, I will have college building rooms (such as B100, A200,
TLAB100) and I want it so that when people search for a specific room
(such as B101, B102) it will return the building name without the ending
number, so: B100.
My controller so far looks like this:
$results = $this->Building->find('all', array(
'conditions' => array(
'Building.building LIKE' => $this->data['Food']['q']
)
)
);
But I believe LIKE isn't the right command for it. Because it's not
working that way

Ubuntu 13.04 won't boot and boot repair doesn't work

Ubuntu 13.04 won't boot and boot repair doesn't work

As the title says I installed it again and again but it won't boot and it
turns out GRUB is conflicting or something like that with UEFI bios so I
downloaded the boot repair disk and used it to fix GRUB and it gets to a
point that it gives me a window telling me what to do if the remove GRUB
window shows the problem is the remove GRUB window doesnt show up so I
can't remove so can anybody help me? It's also worth mentioning that when
I go to download the boot repair disk it says it's 532MB but when I
download it I find it to be 508MB and I downloaded it several times and
it's the same case so is that normal and thanks in advance

How can I remove the error at "Context.USB_SERVICE" (Eclipse -> Android)

How can I remove the error at "Context.USB_SERVICE" (Eclipse -> Android)

Please keep in mind this is my first StackOverflow post, thus if there are
some details that are vague of stated in a stupid way, my apologies. Down
to business:
I am working on a project where a friend and I are using the FT232R IC to
connect an Android USB host device to a device that communicates via
serial port. I have a great code source where I am working from:
https://code.google.com/p/usb-serial-for-android/
The following source code is our own interpreted code derived from the
above to suite our own program:
package com.example.commtest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
import com.hoho.android.usbserial.driver.*;
import com.hoho.android.usbserial.util.*;
import com.example.commtest.ReadUSBdata;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedHashMap;
import java.util.Map;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbRequest;
import android.util.Log;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbAccessory;
import com.hoho.android.usbserial.util.HexDump;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView theOutput = (TextView) findViewById(R.id.edtVertoon);
theOutput.setText("1234553242342342341243214");
// Get UsbManager from Android.
UsbManager manager = (UsbManager)
getSystemService(Context.USB_SERVICE);
// Find the first available driver.
UsbSerialDriver driver = UsbSerialProber.acquire(manager);
(The above is just the 'Top' part of the code)
The error appears on the 4th line from the bottom, and it states: "Context
cannot be resolved to a variable". This is just a test program to gain
understanding on this subject.
Before everybody lose their minds, I have Google'd this, and there are a
few posts that helped, but none that actually solved my problem.
Any advice would help, and again, thank you for your time guys.

Node JS vs. Symfony 2 for SPA

Node JS vs. Symfony 2 for SPA

I have little experience with both Symfony 2 and Node JS and I have to
decide which tool will be better for single page application.
As far as I know SPA works on client (UI) - server (API) architecture, so
NodeJS seems to be a better option ( faster and handles event driven
programming ). But on the other site to fully support some CMS features
like admin side and other Symfony 2 seems to be more mature.
I want to ask experienced developer which technology should I choose for
SPA architecture when I wan to develop a robust website with many 'admin'
features. Also UI will be written in angularJS.
Thanx for constructive advices.

Friday, 16 August 2013

How to convert float[][] type array to "emxArray_real_T *x"

How to convert float[][] type array to "emxArray_real_T *x"

I have converted a function which takes a NxN matrix as input and gives a
NxN matrix output from matlab to C, using the MatlabCoder. It gave me the
function which has two parameters namely
void func(const emxArray_real_T *x, emxArray_real_T *y)
I get that x is the input to the function and i can get the output of the
function from y. The problem is i have a array in float[][] and i wish to
give this data as an input to the func, which only takes emxArray_real_T
*x as an input.
Any ideas on how to convert this float[][] data to emxArray_real_T *x
emxArray_real_T has this structure
struct emxArray_real_T
{
real_T *data;
int32_T *size;
int32_T allocatedSize;
int32_T numDimensions;
boolean_T canFreeData;
};

Thursday, 8 August 2013

How to manage access to static content?

How to manage access to static content?

I need the best way to manage and serve static content such as images,
videos, etc.
I need to allow only permitted users to load a particular image or video.
Let's say that I have a dedicated server to serve my PHP application
http://server1.com and a dedicated server to serve static content
http://server2.com/image.jpg how can I allow or deny a user from accessing
that image?

UIPickerView Changing UIButton Title Size

UIPickerView Changing UIButton Title Size

So I'm making Alarm Clock to test my skills but can't seem to figure this
out... What I've got a UIPickerView that gives a user a time that they can
select. Once the time is selected the titleLabel on a UIButton is supposed
to update with the time they selected and it does, but it shrinks the new
time so it's unreadable... Is there something that needs adjusted with the
formatting?
Before when my page loads Here's my code
- (NSDate *)dateFromString:(NSString *)string {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm"];
NSDate *date = [[NSDate alloc] init];
date = [formatter dateFromString:@"15:00"];
assert(date != nil); // Error converting string to date
return date;
}
After when a user has set a time
Any reason why it might be doing this?

Parser Error Message: Could not load type 'ibeto_hotels.Global'

Parser Error Message: Could not load type 'ibeto_hotels.Global'

Am having issue on my project with the following error:Line 1:
<%@ Application Codebehind="Global.asax.cs"
Inherits="ibeto_hotels.Global" Language="C#" %>.
Please, anyone to help with a solution.

How to kill a JQuery function while it's running

How to kill a JQuery function while it's running

I've written a script that checks to see if the user is active on a page,
if not a pop up is displayed after 15 minutes, at which point a timer is
displayed which counts down from 60 seconds, and then redirects the user
to a page that kills the users session on the website.
However, while I can reset the timer that displays the pop up window, I
can't seem to be able to cancel the second timer that counts down from 60.
Here is my code:
<script type="text/javascript">
idleTime = 0;
idleRedirect = 0;
// Count for the timer
var wsCount = 60;
// Start Countdown
function startCountdown() {
if((wsCount - 1) >= 0){
wsCount = wsCount - 1;
// Display countdown
$("#countdown").html('<span id="timecount">' + wsCount +
'</span>.');
timing = setTimeout(startCountdown, 1000);
}
else{
// Redirect to session kill
alert('Goodbye');
}
}
// Pop up when the timer hits 15 minutes
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 1) { // 15 minutes
$('#inactiveWarning').modal('show');
startCountdown();
}
}
$(document).ready(function () {
//Increment the idle time counter every minute.
var idleInterval = setInterval("timerIncrement()", 5000); // 1
minute
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
idleRedirect = 0;
startCountdown.die();
});
$(this).keypress(function (e) {
idleTime = 0;
idleRedirect = 0;
startCountdown.die();
});
$(this).scroll(function (e) {
idleTime = 0;
idleRedirect = 0;
startCountdown.die();
});
})
</script>

how to let users drop pins in map view, that others can see

how to let users drop pins in map view, that others can see

how do i code a map view in which users can drop multiple pins, make
annotations and add pictures?
my question has several parts to it really. i know how to code a map view
in Xcode and how to put a pre-set pin however i want to be able to code
something a bit more complex as it works in relation to an app i'm hoping
to create!
1: how do i let a user of the app drop multiple pins to specify a certain
location?
2: once the user has dropped a pin i want that he is able to add
annotations and pictures?
3: finally i need that all the information of where the pins have been
dropped, the annotations and the pictures can be seen by all other people
using the app!
i have loked extensively into this and although i have found how to code
basic maps into an app i have not been able to code the follow up parts!
thank you for reading my question and would really appreciate any
suggestions that can be given. if you think there is a useful youtube
video or a blog that you think could help me please put it at the bottom
and i will look through it!

xOpenDisplay fails inside my cgi with apache2 [on hold]

xOpenDisplay fails inside my cgi with apache2 [on hold]

I am trying to make graphics with xlib (X11) inside a cgi written in C.
Apache2 disables the DISPLAY environment variable, I solved this problem
with setenv. But I still cannot get the Display
*display=xOpenDisplay(getenv("DISPLAY")) [xOpenDisplay(NULL),
xOpenDisplay(":0"), etc.] and therefore I cannot use xLib. I have also
modified the permissions of www-data inside /etc/group in similar way to
an ordinary user

Restoring a Mac but maintaining the files

Restoring a Mac but maintaining the files

I've got an external hard drive which I've hooked up to time machine, I
have multiple Mac's but the one in question I am unable to remember the
administrator password, which is a pain when trying to create an extra
user account and install software, etc.
Is there a way of restoring the iMac (what's the best way to do this?) and
getting all my files back, including Microsoft Office (if I am correct
Time Machine will automatically back up software as well?) but is there a
way of setting up the mac once restored through TM keeping all the files
but not the user profile.
OR, what should I do in this situation? I don't really want to lug this
thing into London and back! What's the best way of keeping all my files
and existing software but be able to start up with a new user.

Can not sync my django database after installing django.contrib.comments app

Can not sync my django database after installing django.contrib.comments app

Error that I have:
CommandError: One or more models did not validate:
comments.comment: Accessor for field 'content_type' clashes with related
field 'ContentType.content_type_set_for_comment'. Add a related_name
argument to the definition for 'content_type'.
comments.comment: Reverse query name for field 'content_type' clashes with
related field 'ContentType.content_type_set_for_comment'. Add a
related_name argument to the definition for 'content_type'.
comments.comment: Accessor for field 'site' clashes with related field
'Site.comment_set'. Add a related_name argument to the definition for
'site'.
comments.comment: Accessor for field 'user' clashes with related field
'User.comment_comments'. Add a related_name argument to the definition for
'user'.
comments.comment: Reverse query name for field 'user' clashes with related
field 'User.comment_comments'. Add a related_name argument to the
definition for 'user'.
comments.commentflag: Accessor for field 'user' clashes with related field
'User.comment_flags'. Add a related_name argument to the definition for
'user'.
comments.commentflag: Reverse query name for field 'user' clashes with
related field 'User.comment_flags'. Add a related_name argument to the
definition for 'user'.
In the beginning I installed newer app called django_comments, and did
sync my database. But after I decided to use django-fluent-comments that
need django.contrib.comments. So insteed of django_comments I put
django.contrib.comments.
After I sync database my django project crashed with the error above.
So, please help to solve this problem or give me some recommendations.
Thanks for any advices!
PS: I tried to create new project with another virtualenvironment and
changed mysql to sqlite3, but still have this error.

Wednesday, 7 August 2013

How do I write a query to get monthly inventory data

How do I write a query to get monthly inventory data

I have following table in which i have the inventory of items on different
dates:
Item Date inventory ---- ---- --------- I1 6/25/2013 10 I2 6/25/2013 8 I3
7/01/2013 20 I1 7/02/2013 12 I2 7/03/2013 6 I3 8/02/2013 10
I need to create a view that gives me opening inventory level of each item
of each month. The output I want is as follows:
Item Month inventory ---- ----- --------- I1 7/2013 10 I2 7/2013 8 I3
7/2013 20 I1 8/2013 12 I2 8/2013 6 I3 8/2013 20
Pls help me how i can write a query to achieve this.

Adding data from text inputs to Entity in Xcode

Adding data from text inputs to Entity in Xcode

I am a new developer and am working on my first app in Xcode. In trying to
add data to an Entity named "Rounds." I am getting the error message:
* Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '+entityForName: nil is not a legal NSManagedObjectContext
parameter searching for entity name 'Rounds'
In debugging the app is crashing at the line:
Rounds *rounds= (Rounds*)[NSEntityDescription
insertNewObjectForEntityForName:@"Rounds" inManagedObjectContext:
self.managedObjectContext];
From my limited knowledge I feel like this is happening because
managedObjectContext is not instantiated. How do I fix this? Thanks in
advance.
-(void)AddRound
NSNumber *rating = [[NSNumber alloc] initWithDouble:[ratingValue.text
integerValue]];
NSNumber *slope = [[NSNumber alloc] initWithDouble:[slopeValue.text
integerValue]];
NSNumber *score= [[NSNumber alloc] initWithDouble:[scoreValue.text
integerValue]];
NSString *courseName = courseNameValue.text;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM-dd-yyyy"];
NSDate *date = [formatter dateFromString:dateValue.text];
Rounds *rounds= (Rounds*)[NSEntityDescription
insertNewObjectForEntityForName:@"Rounds" inManagedObjectContext:
self.managedObjectContext];
[rounds setRoundRating:rating];
[rounds setRoundSlope:slope];
[rounds setRoundScore:score];
[rounds setRoundDate:date];
[rounds setRoundCourseName:courseName];
NSError * error;
[self.managedObjectContext save:&error];

Error Display while sending message in Plone 4.1

Error Display while sending message in Plone 4.1

I am developing a website in Plone 4.1 and have added a Instant message
addon named "Product.IMS" to it but when I try to send message following
error display...
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Products.IMS.browser.views, line 236, in call
Module zope.formlib.form, line 795, in call
Module five.formlib.formbase, line 50, in update
Module zope.formlib.form, line 776, in update
Module zope.formlib.form, line 620, in success
Module Products.IMS.browser.views, line 242, in action_send
Module Products.IMS.browser.views, line 247, in _sendMessage
Module Products.IMS.adapter, line 121, in sendMessage
Module Products.IMS.adapter, line 95, in _getMessageFolder
Module zope.interface.declarations, line 935, in alsoProvides
Module zope.interface.declarations, line 867, in directlyProvides
AttributeError: 'NoneType' object has no attribute 'provides
Please anyone tell me in which location I find these error...!!!

Nullpointer at creating Intent

Nullpointer at creating Intent

I get a nullpointer at PendingIntent pi =
PendingIntent.getService(context, 0, new Intent( context,
MyNotification.class), PendingIntent.FLAG_UPDATE_CURRENT); But I have no
idea how to fix this.. I hope someone might be able to help me..
What it should do is set the alarm everyday at 9 so I can set a
notification in the MyNotification class which contains a
BroadcastReceiver.
Below is all my code:
Calling the AlarmManager class (From MainActivity):
Alarm setAlarm = new Alarm();
setAlarm.setRecurringAlarm();
The class where I want to set the AlarmManager (Alarm.class):
public class Alarm extends Activity {
public void setRecurringAlarm() {
Context context = getBaseContext();
Log.i("Alarm", "Setting Recurring Alarm");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 7);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
PendingIntent pi = PendingIntent.getService(context, 0, new Intent(
context, MyNotification.class),
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, pi);
}}
My Log:
08-07 22:43:38.079: E/AndroidRuntime(21476): FATAL EXCEPTION: main 08-07
22:43:38.079: E/AndroidRuntime(21476): java.lang.RuntimeException: Unable
to start activity
ComponentInfo{com.weatherclothes/com.weatherclothes.MainActivity}:
java.lang.NullPointerException 08-07 22:43:38.079:
E/AndroidRuntime(21476): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
08-07 22:43:38.079: E/AndroidRuntime(21476): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
08-07 22:43:38.079: E/AndroidRuntime(21476): at
android.app.ActivityThread.access$600(ActivityThread.java:151) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
android.os.Handler.dispatchMessage(Handler.java:99) 08-07 22:43:38.079:
E/AndroidRuntime(21476): at android.os.Looper.loop(Looper.java:155) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
android.app.ActivityThread.main(ActivityThread.java:5493) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
java.lang.reflect.Method.invokeNative(Native Method) 08-07 22:43:38.079:
E/AndroidRuntime(21476): at
java.lang.reflect.Method.invoke(Method.java:511) 08-07 22:43:38.079:
E/AndroidRuntime(21476): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
08-07 22:43:38.079: E/AndroidRuntime(21476): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
dalvik.system.NativeStart.main(Native Method) 08-07 22:43:38.079:
E/AndroidRuntime(21476): Caused by: java.lang.NullPointerException 08-07
22:43:38.079: E/AndroidRuntime(21476): at
android.content.ComponentName.(ComponentName.java:75) 08-07 22:43:38.079:
E/AndroidRuntime(21476): at android.content.Intent.(Intent.java:3655)
08-07 22:43:38.079: E/AndroidRuntime(21476): at
com.weatherclothes.Alarm.setRecurringAlarm(Alarm.java:23) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
com.weatherclothes.MainActivity.onCreate(MainActivity.java:58) 08-07
22:43:38.079: E/AndroidRuntime(21476): at
android.app.Activity.performCreate(Activity.java:5066) 08-07 22:43:38.079:
E/AndroidRuntime(21476): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
08-07 22:43:38.079: E/AndroidRuntime(21476): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
08-07 22:43:38.079: E/AndroidRuntime(21476): ... 11 more