PostId
int64 4
11.8M
| PostCreationDate
stringlengths 19
19
| OwnerUserId
int64 1
1.57M
| OwnerCreationDate
stringlengths 10
19
| ReputationAtPostCreation
int64 -55
461k
| OwnerUndeletedAnswerCountAtPostTime
int64 0
21.5k
| Title
stringlengths 3
250
| BodyMarkdown
stringlengths 5
30k
⌀ | Tag1
stringlengths 1
25
⌀ | Tag2
stringlengths 1
25
⌀ | Tag3
stringlengths 1
25
⌀ | Tag4
stringlengths 1
25
⌀ | Tag5
stringlengths 1
25
⌀ | PostClosedDate
stringlengths 19
19
⌀ | OpenStatus
stringclasses 5
values | unified_texts
stringlengths 32
30.1k
| OpenStatus_id
int64 0
4
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,471,905 | 07/13/2012 13:54:12 | 1,523,721 | 07/13/2012 13:45:19 | 1 | 0 | conversion of php code into java | I have some issue in the following code, I am trying to write the same code in java but it is not working fine,
Follow is the php code :
foreach($tmp as $k => $v) {
$result[] = array(
"attr" => array("id" => "node_".$k, "rel" => $v[$this->fields["type"]]),
"data" => $v[$this->fields["title"]],
"state" => ((int)$v[$this->fields["right"]] - (int)$v[$this-fields["left"]] > 1) ? "closed" : ""
);
}
return json_encode($result); // it is returning the value to some ajax function
Java Conversion that I am doing :
while(result.next())
{
v1.add(result.getInt("id"),result.getString("type"));
v2.add(result.getString("title"));
v3.add((result.getInt("right") - result.getInt("left")) > 1 ? "closed" : "") ;
}
final1.add(v);
final1.add(v1);
final1.add(v3);
in the above code v1,v2,v3,final1 are the vectors...and final1 vector is passed to ajax function by using Json.toJson(final1). but its is not working fine as it works with php code.
Could anyone suggest me any good solution for this conversion in java.
| java | php | java-ee | null | null | 07/27/2012 00:26:10 | not a real question | conversion of php code into java
===
I have some issue in the following code, I am trying to write the same code in java but it is not working fine,
Follow is the php code :
foreach($tmp as $k => $v) {
$result[] = array(
"attr" => array("id" => "node_".$k, "rel" => $v[$this->fields["type"]]),
"data" => $v[$this->fields["title"]],
"state" => ((int)$v[$this->fields["right"]] - (int)$v[$this-fields["left"]] > 1) ? "closed" : ""
);
}
return json_encode($result); // it is returning the value to some ajax function
Java Conversion that I am doing :
while(result.next())
{
v1.add(result.getInt("id"),result.getString("type"));
v2.add(result.getString("title"));
v3.add((result.getInt("right") - result.getInt("left")) > 1 ? "closed" : "") ;
}
final1.add(v);
final1.add(v1);
final1.add(v3);
in the above code v1,v2,v3,final1 are the vectors...and final1 vector is passed to ajax function by using Json.toJson(final1). but its is not working fine as it works with php code.
Could anyone suggest me any good solution for this conversion in java.
| 1 |
11,693,131 | 07/27/2012 17:56:32 | 1,529,333 | 07/16/2012 15:24:25 | 23 | 3 | Selecting the very last record of the returned table | I'm from an access background with a little mySQL, so i'm slightly lost when it comes to SQL.
Here is the query I am using:
Select tbl_AcerPFSSurveyIVR.NTlogin,tbl_AcerPFSSurveyIVR.Customer_Firstname,tbl_AcerPFSSurveyIVR.Customer_Lastname,tbl_AcerPFSSurveyIVR.CaseId,tbl_AcerPFSSurveyIVR.ContactNumber,CRM_TRN_ORDER.ORDER_PRICE,CRM_TRN_ORDER.ORDER_CREATEDDATE
This returns the proper record, but I want the very last... I know I should use something like this...
SELECT TOP 1 * FROM table_Name ORDER BY unique_column DESC
Where I get lost, and if I am correct in saying so, you can only do one Select... so how do I integrate the two? Thanks in advance for your help.
| sql | sql-server | null | null | null | null | open | Selecting the very last record of the returned table
===
I'm from an access background with a little mySQL, so i'm slightly lost when it comes to SQL.
Here is the query I am using:
Select tbl_AcerPFSSurveyIVR.NTlogin,tbl_AcerPFSSurveyIVR.Customer_Firstname,tbl_AcerPFSSurveyIVR.Customer_Lastname,tbl_AcerPFSSurveyIVR.CaseId,tbl_AcerPFSSurveyIVR.ContactNumber,CRM_TRN_ORDER.ORDER_PRICE,CRM_TRN_ORDER.ORDER_CREATEDDATE
This returns the proper record, but I want the very last... I know I should use something like this...
SELECT TOP 1 * FROM table_Name ORDER BY unique_column DESC
Where I get lost, and if I am correct in saying so, you can only do one Select... so how do I integrate the two? Thanks in advance for your help.
| 0 |
11,693,132 | 07/27/2012 17:56:33 | 1,059,070 | 11/22/2011 04:20:40 | 537 | 17 | Mongo find in hash | Suppose I have several documents like so
{
title: 'blah',
value: {
"A": {property: "foo"},
"B": {property: "bar"},
"C": {property: "foo"},
"D": {property: "foo"}
}
}
{
title: 'blah2',
value: {
"A": {property: "bar"},
"B": {property: "bar"},
"C": {property: "bar"},
"D": {property: "foo"}
}
}
What mongodb query will get me all of the documents / hash keys that have `{property: "foo"}`
(I know this can be done using js after the query, but can it be done within the query itself?) | mongodb | mongodb-query | null | null | null | null | open | Mongo find in hash
===
Suppose I have several documents like so
{
title: 'blah',
value: {
"A": {property: "foo"},
"B": {property: "bar"},
"C": {property: "foo"},
"D": {property: "foo"}
}
}
{
title: 'blah2',
value: {
"A": {property: "bar"},
"B": {property: "bar"},
"C": {property: "bar"},
"D": {property: "foo"}
}
}
What mongodb query will get me all of the documents / hash keys that have `{property: "foo"}`
(I know this can be done using js after the query, but can it be done within the query itself?) | 0 |
11,693,135 | 07/27/2012 17:56:51 | 680,578 | 03/28/2011 16:24:25 | 3,405 | 254 | multiple websites on nginx & sites-available | With the base install of nginx, your `sites-available` folder has just one file: `default`
how does the `sites-available` folder work and how would I use it to host multiple (separate) websites? | nginx | hosting | sites-available | null | null | null | open | multiple websites on nginx & sites-available
===
With the base install of nginx, your `sites-available` folder has just one file: `default`
how does the `sites-available` folder work and how would I use it to host multiple (separate) websites? | 0 |
11,693,137 | 07/27/2012 17:57:14 | 234,945 | 12/19/2009 01:33:52 | 120 | 1 | How do I control PDF paper size with ImageMagick? | I have 16 jpg files which are around 920x1200 pixels (the widths slightly differ but heights are all 1200). I'm trying to join them into a pdf with:
convert *.jpg foo.pdf
But the resulting paper size is 1.53x2 inches. If I pass the arguments `-page Letter`, the page size ends up being a bewildering 1.02x1.32 inches. What is going wrong here? All of the information I can find suggests that this should work. I just want a document that consists of 16 letter-size pages. | linux | pdf | imagemagick | convert | null | null | open | How do I control PDF paper size with ImageMagick?
===
I have 16 jpg files which are around 920x1200 pixels (the widths slightly differ but heights are all 1200). I'm trying to join them into a pdf with:
convert *.jpg foo.pdf
But the resulting paper size is 1.53x2 inches. If I pass the arguments `-page Letter`, the page size ends up being a bewildering 1.02x1.32 inches. What is going wrong here? All of the information I can find suggests that this should work. I just want a document that consists of 16 letter-size pages. | 0 |
11,693,140 | 07/27/2012 17:57:17 | 1,558,389 | 07/27/2012 17:42:52 | 1 | 0 | Finding items in one array based upon a second array | I have two arrays A & B
A=array([[ 5., 5., 5.],
[ 8., 9., 9.]])
B=array([[ 1., 1., 2.],
[ 3., 2., 1.]])
Anywhere there is a "1" in B I want to sum the same row and column locations in A
So for example for this one the answer would be 5+5+9=10
I would want this to continue for 2,3....n (all unique values in B)
So for the 2's... it would be 9+5=14 and for the 3's it would be 8
I found the unique values by using:
numpy.unique(B)
I realize this make take multiple steps but I can't really wrap my head around using the index matrix to sum those locations in another matrix.
Thanks! | python | numpy | null | null | null | null | open | Finding items in one array based upon a second array
===
I have two arrays A & B
A=array([[ 5., 5., 5.],
[ 8., 9., 9.]])
B=array([[ 1., 1., 2.],
[ 3., 2., 1.]])
Anywhere there is a "1" in B I want to sum the same row and column locations in A
So for example for this one the answer would be 5+5+9=10
I would want this to continue for 2,3....n (all unique values in B)
So for the 2's... it would be 9+5=14 and for the 3's it would be 8
I found the unique values by using:
numpy.unique(B)
I realize this make take multiple steps but I can't really wrap my head around using the index matrix to sum those locations in another matrix.
Thanks! | 0 |
11,693,142 | 07/27/2012 17:57:18 | 226,897 | 12/08/2009 05:32:39 | 22,726 | 1,000 | How to set a foreign key value in EF? | I have the following code:
BudgetLineItem actualLi = new BudgetLineItem();
actualLi.YearId = be.lu_FiscalYear.Where(t => t.Year == actualYear).Select(t => t.Id).First();
actualLi.TypeId = be.lu_Type.Where(t => t.Name == "Actual").Select(t => t.id).First();
actualLi.DeptId = be.lu_Department.Where(t => t.Name == DeptName).Select(t => t.ID).First();
actualLi.LineItemId = be.lu_LineItem.Where(t => t.Name == revenueType).Select(t => t.id).First();
actualLi.Amount = actualAmount;
be.AddToBudgetLineItems(actualLi);
be.SaveChanges();
Which creates an object with exactly what I want to insert in the database. But when I try to save this record I get the error:
> Entities in 'xxxx' participate in the 'xxxx' relationship. 0 related
> 'xxxx' were found. 1 '' is expected.
My `BudgetLineItem` table has a foreign key relationship with a table called `lu_Department` which is what the error references.
I found [this question][1] which seems to offer a solution, but it seems overly complex for what I am trying to do.
Is my best option the solution provided in the question I linked to? If so, why does EF make this so complicated?
[1]: http://stackoverflow.com/questions/1011519/entity-framework-entitykey-foreign-key-problem | c# | .net | entity-framework | null | null | null | open | How to set a foreign key value in EF?
===
I have the following code:
BudgetLineItem actualLi = new BudgetLineItem();
actualLi.YearId = be.lu_FiscalYear.Where(t => t.Year == actualYear).Select(t => t.Id).First();
actualLi.TypeId = be.lu_Type.Where(t => t.Name == "Actual").Select(t => t.id).First();
actualLi.DeptId = be.lu_Department.Where(t => t.Name == DeptName).Select(t => t.ID).First();
actualLi.LineItemId = be.lu_LineItem.Where(t => t.Name == revenueType).Select(t => t.id).First();
actualLi.Amount = actualAmount;
be.AddToBudgetLineItems(actualLi);
be.SaveChanges();
Which creates an object with exactly what I want to insert in the database. But when I try to save this record I get the error:
> Entities in 'xxxx' participate in the 'xxxx' relationship. 0 related
> 'xxxx' were found. 1 '' is expected.
My `BudgetLineItem` table has a foreign key relationship with a table called `lu_Department` which is what the error references.
I found [this question][1] which seems to offer a solution, but it seems overly complex for what I am trying to do.
Is my best option the solution provided in the question I linked to? If so, why does EF make this so complicated?
[1]: http://stackoverflow.com/questions/1011519/entity-framework-entitykey-foreign-key-problem | 0 |
11,693,145 | 07/27/2012 17:57:32 | 548,634 | 12/20/2010 12:55:45 | 1,321 | 91 | understanding Prototype in javascript | Coming from Java background, I'm trying to understand javascript.
Please let me know if these are right.
1. Like in java, there is a supreme Object, from which all other objects inherit.
2. The prototype property is like a pointer that points to the parent object (classes in java)
3. For "Object" object, the prototype is null.
4. prototype property's values are strings denoting the objects nomenclature and aren't pointers like in C. The pointer concept is implemented using the hidden attribute,[[PROTOTYPE]] that is not accessible in script.
I'm using node.js instead of browser to learn JS.
I tried,
var human = Object.create(null); // same as var human;
console.log(Object.getPrototypeOf(human)); //null
var man = Object.create(human);
console.log(Object.getPrototypeOf(man));
//{}
//expected 'human'
var person = Object.create(Object.prototype); // same as var person = {}
console.log(Object.getPrototypeOf(person));
//{}
//expected 'object' | javascript | mozilla | null | null | null | null | open | understanding Prototype in javascript
===
Coming from Java background, I'm trying to understand javascript.
Please let me know if these are right.
1. Like in java, there is a supreme Object, from which all other objects inherit.
2. The prototype property is like a pointer that points to the parent object (classes in java)
3. For "Object" object, the prototype is null.
4. prototype property's values are strings denoting the objects nomenclature and aren't pointers like in C. The pointer concept is implemented using the hidden attribute,[[PROTOTYPE]] that is not accessible in script.
I'm using node.js instead of browser to learn JS.
I tried,
var human = Object.create(null); // same as var human;
console.log(Object.getPrototypeOf(human)); //null
var man = Object.create(human);
console.log(Object.getPrototypeOf(man));
//{}
//expected 'human'
var person = Object.create(Object.prototype); // same as var person = {}
console.log(Object.getPrototypeOf(person));
//{}
//expected 'object' | 0 |
11,693,146 | 07/27/2012 17:57:34 | 1,558,394 | 07/27/2012 17:49:44 | 1 | 0 | Jqueryui draggable, how to get handle id from drag function | Have this simple code:
$( "#draggable" ).draggable({ handle: ".dragableHandler", drag: function(e, ui) {}
});
and have 4 images with the class .dragableHandler, and different id each.
How inside drag function find the current handle (one of images) id?
i can only find the dragable elment info.. | jquery | jquery-ui | null | null | null | null | open | Jqueryui draggable, how to get handle id from drag function
===
Have this simple code:
$( "#draggable" ).draggable({ handle: ".dragableHandler", drag: function(e, ui) {}
});
and have 4 images with the class .dragableHandler, and different id each.
How inside drag function find the current handle (one of images) id?
i can only find the dragable elment info.. | 0 |
11,693,147 | 07/27/2012 17:57:39 | 1,558,155 | 07/27/2012 15:53:58 | 1 | 0 | Regex to detect WITH option in a stored procedure | I have been working on some legacy code in our application that detects certain keywords in the text of an SQL stored procedure by using Regex and I have found a bug that I can't quite correct due to my limited knowledge of Regex.
Basically the regex that I currently have works in all but one case:
(?<=\n\s*)(?<!with.*[\s\S]*)as
It should return a match on this version of a stored procedure:
ALTER PROCEDURE [dbo].[p_obj_name_with_something]
@username [nvarchar](100) = null,
@id [int] = null,
@mode [int] = 0
AS
/*-------------------------------------------------------------------------
However it shouldn't for this version, but it currently does return a match:
ALTER PROCEDURE [dbo].[p_obj_name_with_something]
@username [nvarchar](100) = null,
@id [int] = null,
@mode [int] = 0
WITH EXECUTE AS CALLER
AS
/*-------------------------------------------------------------------------
I want a match when the keyword WITH **isn't** found before the AS keyword, but it will allow the word within the name or parameters of the stored procedure.
The way I think the detection would work is if the keyword WITH has whitespace (or a newline) either side of it, but I can't quite figure out the regex syntax.
Any suggestions? | regex | null | null | null | null | null | open | Regex to detect WITH option in a stored procedure
===
I have been working on some legacy code in our application that detects certain keywords in the text of an SQL stored procedure by using Regex and I have found a bug that I can't quite correct due to my limited knowledge of Regex.
Basically the regex that I currently have works in all but one case:
(?<=\n\s*)(?<!with.*[\s\S]*)as
It should return a match on this version of a stored procedure:
ALTER PROCEDURE [dbo].[p_obj_name_with_something]
@username [nvarchar](100) = null,
@id [int] = null,
@mode [int] = 0
AS
/*-------------------------------------------------------------------------
However it shouldn't for this version, but it currently does return a match:
ALTER PROCEDURE [dbo].[p_obj_name_with_something]
@username [nvarchar](100) = null,
@id [int] = null,
@mode [int] = 0
WITH EXECUTE AS CALLER
AS
/*-------------------------------------------------------------------------
I want a match when the keyword WITH **isn't** found before the AS keyword, but it will allow the word within the name or parameters of the stored procedure.
The way I think the detection would work is if the keyword WITH has whitespace (or a newline) either side of it, but I can't quite figure out the regex syntax.
Any suggestions? | 0 |
11,692,575 | 07/27/2012 17:18:44 | 1,510,255 | 07/08/2012 16:15:52 | 56 | 2 | onStop(), onPause, onCreate onResume, and GPS | I have an app working that is GPS based. It has many activities and all use the GPS. For example, one activity shows the distance to a location, another shows the speed and direction. I set up and call requestLocationUpdates() in onCreate() and call removeUpdates() in onPause().
This all works but the GPS blinks and has to re-acquire when switching activities. I did a test and if I put the removeUpdates() in onStop() instead of in onPause() there is no blinking. Apparently onStop() is called after the new activity starts which explains the lack of blinking.
I have read the posts on this subject and there seems to be a difference of opinion. However, it looks like I should use onStop() and am wondering if there is any reason I should not.
The second issue is that there is no onResume() code so there is no GPS after a back-arrow or after turning the screen off and on. I should fix this. Right now my onCreate() code creates the location manager and basically has all my code in it. It looks like following the life cycle flow chart that I should move the removeUpdates() to onStop and move the creation of the lm and ll to onStart(). Is this correct?
Here is my onCreate code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.set);
textView1 = (TextView)findViewById(R.id.textView1);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
Here is my onPause code:
@Override
protected void onPause() {
super.onPause();
if(lm != null) {
lm.removeUpdates(ll);
}
ll = null;
lm = null;
}
So I think I should just change the onPause() to onStop() and make onStart() this:
@Override
public void onStart() {
super.onStart();
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
And my onCreate code as this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.set);
textView1 = (TextView)findViewById(R.id.textView1);
}
This said, I am kind of new to all this and this is my first application so I would like to know what I am missing here.
| android | gps | null | null | null | null | open | onStop(), onPause, onCreate onResume, and GPS
===
I have an app working that is GPS based. It has many activities and all use the GPS. For example, one activity shows the distance to a location, another shows the speed and direction. I set up and call requestLocationUpdates() in onCreate() and call removeUpdates() in onPause().
This all works but the GPS blinks and has to re-acquire when switching activities. I did a test and if I put the removeUpdates() in onStop() instead of in onPause() there is no blinking. Apparently onStop() is called after the new activity starts which explains the lack of blinking.
I have read the posts on this subject and there seems to be a difference of opinion. However, it looks like I should use onStop() and am wondering if there is any reason I should not.
The second issue is that there is no onResume() code so there is no GPS after a back-arrow or after turning the screen off and on. I should fix this. Right now my onCreate() code creates the location manager and basically has all my code in it. It looks like following the life cycle flow chart that I should move the removeUpdates() to onStop and move the creation of the lm and ll to onStart(). Is this correct?
Here is my onCreate code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.set);
textView1 = (TextView)findViewById(R.id.textView1);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
Here is my onPause code:
@Override
protected void onPause() {
super.onPause();
if(lm != null) {
lm.removeUpdates(ll);
}
ll = null;
lm = null;
}
So I think I should just change the onPause() to onStop() and make onStart() this:
@Override
public void onStart() {
super.onStart();
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
And my onCreate code as this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.set);
textView1 = (TextView)findViewById(R.id.textView1);
}
This said, I am kind of new to all this and this is my first application so I would like to know what I am missing here.
| 0 |
11,692,576 | 07/27/2012 17:18:47 | 399,641 | 07/22/2010 21:15:02 | 61 | 1 | My UINavBar doesn't Respond to Touch, and Scrolls with tableview | I have a subclass of a UITableViewController, and I want to add a UINavBar to it. It is a very similar setup to the native contacts app, where you tap "add contact", and it presents a grouped tableview with a navbar at the top with a "cancel," and "done" option. The key is that I need it to present using a vertical transition (effectively with presentModalViewController:animated:yes), but I have tried using Interface Builder and adding it programmatically, and in both cases, the buttons do not respond, and the bar scrolls with the tableview, rather than staying at the top.
Thanks in advance,
HBhargava | objective-c | ios | uinavigationcontroller | uitableviewcontroller | null | null | open | My UINavBar doesn't Respond to Touch, and Scrolls with tableview
===
I have a subclass of a UITableViewController, and I want to add a UINavBar to it. It is a very similar setup to the native contacts app, where you tap "add contact", and it presents a grouped tableview with a navbar at the top with a "cancel," and "done" option. The key is that I need it to present using a vertical transition (effectively with presentModalViewController:animated:yes), but I have tried using Interface Builder and adding it programmatically, and in both cases, the buttons do not respond, and the bar scrolls with the tableview, rather than staying at the top.
Thanks in advance,
HBhargava | 0 |
11,693,150 | 07/27/2012 17:57:45 | 1,293,578 | 03/26/2012 17:03:18 | 47 | 0 | LVL crashes on Jelly Bean | On Android documentation is written I can ask here about LVL problems.
My Android LVL was working great on android <=4.0.4 .
Today I updated to Jelly Bean and it doesn't work anymore. Here is the logcat:
07-27 19:53:28.036: I/Spegni schermo intelligente PRO(2976): Lo schermo si è acceso
07-27 19:53:34.661: E/ActivityThread(3087): Activity it.android.smartscreenoffpro.LicenseCheck has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@41754650 that was originally bound here
07-27 19:53:34.661: E/ActivityThread(3087): android.app.ServiceConnectionLeaked: Activity it.android.smartscreenoffpro.LicenseCheck has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@41754650 that was originally bound here
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:965)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ContextImpl.bindService(ContextImpl.java:1191)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ContextImpl.bindService(ContextImpl.java:1183)
07-27 19:53:34.661: E/ActivityThread(3087): at android.content.ContextWrapper.bindService(ContextWrapper.java:394)
07-27 19:53:34.661: E/ActivityThread(3087): at com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150)
07-27 19:53:34.661: E/ActivityThread(3087): at it.android.smartscreenoffpro.LicenseCheck.doCheck(LicenseCheck.java:89)
07-27 19:53:34.661: E/ActivityThread(3087): at it.android.smartscreenoffpro.LicenseCheck.onCreate(LicenseCheck.java:106)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.Activity.performCreate(Activity.java:5008)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-27 19:53:34.661: E/ActivityThread(3087): at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 19:53:34.661: E/ActivityThread(3087): at android.os.Looper.loop(Looper.java:137)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-27 19:53:34.661: E/ActivityThread(3087): at java.lang.reflect.Method.invokeNative(Native Method)
07-27 19:53:34.661: E/ActivityThread(3087): at java.lang.reflect.Method.invoke(Method.java:511)
07-27 19:53:34.661: E/ActivityThread(3087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-27 19:53:34.661: E/ActivityThread(3087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-27 19:53:34.661: E/ActivityThread(3087): at dalvik.system.NativeStart.main(Native Method)
Must I update something?
| java | android | licensing | android-lvl | null | null | open | LVL crashes on Jelly Bean
===
On Android documentation is written I can ask here about LVL problems.
My Android LVL was working great on android <=4.0.4 .
Today I updated to Jelly Bean and it doesn't work anymore. Here is the logcat:
07-27 19:53:28.036: I/Spegni schermo intelligente PRO(2976): Lo schermo si è acceso
07-27 19:53:34.661: E/ActivityThread(3087): Activity it.android.smartscreenoffpro.LicenseCheck has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@41754650 that was originally bound here
07-27 19:53:34.661: E/ActivityThread(3087): android.app.ServiceConnectionLeaked: Activity it.android.smartscreenoffpro.LicenseCheck has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@41754650 that was originally bound here
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:965)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ContextImpl.bindService(ContextImpl.java:1191)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ContextImpl.bindService(ContextImpl.java:1183)
07-27 19:53:34.661: E/ActivityThread(3087): at android.content.ContextWrapper.bindService(ContextWrapper.java:394)
07-27 19:53:34.661: E/ActivityThread(3087): at com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150)
07-27 19:53:34.661: E/ActivityThread(3087): at it.android.smartscreenoffpro.LicenseCheck.doCheck(LicenseCheck.java:89)
07-27 19:53:34.661: E/ActivityThread(3087): at it.android.smartscreenoffpro.LicenseCheck.onCreate(LicenseCheck.java:106)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.Activity.performCreate(Activity.java:5008)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-27 19:53:34.661: E/ActivityThread(3087): at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 19:53:34.661: E/ActivityThread(3087): at android.os.Looper.loop(Looper.java:137)
07-27 19:53:34.661: E/ActivityThread(3087): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-27 19:53:34.661: E/ActivityThread(3087): at java.lang.reflect.Method.invokeNative(Native Method)
07-27 19:53:34.661: E/ActivityThread(3087): at java.lang.reflect.Method.invoke(Method.java:511)
07-27 19:53:34.661: E/ActivityThread(3087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-27 19:53:34.661: E/ActivityThread(3087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-27 19:53:34.661: E/ActivityThread(3087): at dalvik.system.NativeStart.main(Native Method)
Must I update something?
| 0 |
11,693,151 | 07/27/2012 17:57:46 | 595,208 | 01/29/2011 19:04:31 | 2,327 | 76 | Removed default scene from storyboard cant rotate!\ | So I created a universal app, when I go into my iPad storyboard and remove the only scene that was created then add something like a navigation controller, tableview controller or even a regular view controller, I can no longer rotate my application in simulator. I have made no code changes at this point. I verified that my shouldAutorotateToInterfaceOrientation method hasnt changed. Is there a setting that I am missing that I have to set in the scene to allow it to rotate? | objective-c | ios | storyboard | orientation | null | null | open | Removed default scene from storyboard cant rotate!\
===
So I created a universal app, when I go into my iPad storyboard and remove the only scene that was created then add something like a navigation controller, tableview controller or even a regular view controller, I can no longer rotate my application in simulator. I have made no code changes at this point. I verified that my shouldAutorotateToInterfaceOrientation method hasnt changed. Is there a setting that I am missing that I have to set in the scene to allow it to rotate? | 0 |
11,627,990 | 07/24/2012 09:32:25 | 683,741 | 03/30/2011 10:28:43 | 421 | 15 | 2 similar queries in large sql table performing differently | I have a huge table in my database that contains distances between cities. This enables my application to find nearby cities around the world when a starting city is selected. It contains 4 columns - ID, StartCityID, EndCityID and Distance and contains about 120 million rows. I've got indexes set up on the startcityID, endcityID, another one for both, and another one each for startcity + distance, and endcity + distance. (This is my first real dealings with indexes so not 100% sure if I'm doing it correctly).
Anyway - I do the following 2 queries:
Select distinct StartCityID
From Distances where EndCityID = 23485
and
Select distinct EndCityID
From Distances where StartCityID = 20045
They both return the same number of cityIDs, but the top one takes 35 seconds to do, and the bottom one returns results immediately. When I look at the indexes, they seem to be set up to serve startCity and endCity in the same way. Anyone know why they might be acting differently? I'm at a loss...
NB - this may offer more insight, but the one that takes 35 seconds - if I press execute again straight away with the same ID, it returns results immediately as well that time. Unfortunately that isn't good enough for my website but it may be useful information.
Thanks | sql | sql-server | null | null | null | null | open | 2 similar queries in large sql table performing differently
===
I have a huge table in my database that contains distances between cities. This enables my application to find nearby cities around the world when a starting city is selected. It contains 4 columns - ID, StartCityID, EndCityID and Distance and contains about 120 million rows. I've got indexes set up on the startcityID, endcityID, another one for both, and another one each for startcity + distance, and endcity + distance. (This is my first real dealings with indexes so not 100% sure if I'm doing it correctly).
Anyway - I do the following 2 queries:
Select distinct StartCityID
From Distances where EndCityID = 23485
and
Select distinct EndCityID
From Distances where StartCityID = 20045
They both return the same number of cityIDs, but the top one takes 35 seconds to do, and the bottom one returns results immediately. When I look at the indexes, they seem to be set up to serve startCity and endCity in the same way. Anyone know why they might be acting differently? I'm at a loss...
NB - this may offer more insight, but the one that takes 35 seconds - if I press execute again straight away with the same ID, it returns results immediately as well that time. Unfortunately that isn't good enough for my website but it may be useful information.
Thanks | 0 |
11,628,121 | 07/24/2012 09:39:52 | 1,548,210 | 07/24/2012 09:31:58 | 1 | 0 | ray intersect planes with dynamic geometry returns empty array | Hey I'm building a webgl wall for my portfolio site, I need ray intersection to know both when user hovers over the wall and when they click what plane they're clicking on so I can redirect them to correct project.
http://www.martinlindelof.com
What i do is adding all planes on xyz(0,0,0) then I'm using dynamic geometry to place out their vertices on a point grid that's affected by a repelling particle (using traer)
now when I'm doing ray intersect (using examples from threejs r49) I get an empty array back, nothing hit.
could this be because all planes origins are in 0,0,0. should I maybe on each frame not only moving vertices but the entire plane?
or is something else.
(face normals seems to be pointing in the right direction, I see the texture on the plane and it's not inverted as it should be if it was the face backside with double sided planes. guess it's not by default in three.js when creating plane) | three.js | intersect | plane | ray | null | null | open | ray intersect planes with dynamic geometry returns empty array
===
Hey I'm building a webgl wall for my portfolio site, I need ray intersection to know both when user hovers over the wall and when they click what plane they're clicking on so I can redirect them to correct project.
http://www.martinlindelof.com
What i do is adding all planes on xyz(0,0,0) then I'm using dynamic geometry to place out their vertices on a point grid that's affected by a repelling particle (using traer)
now when I'm doing ray intersect (using examples from threejs r49) I get an empty array back, nothing hit.
could this be because all planes origins are in 0,0,0. should I maybe on each frame not only moving vertices but the entire plane?
or is something else.
(face normals seems to be pointing in the right direction, I see the texture on the plane and it's not inverted as it should be if it was the face backside with double sided planes. guess it's not by default in three.js when creating plane) | 0 |
11,628,122 | 07/24/2012 09:39:54 | 1,542,363 | 07/21/2012 07:57:42 | 10 | 1 | Why I cannot @JsonIgnore the nested object's field? | The code is as below:
public class Main {
private String name;
private int age;
private boolean male;
private innerPerson ip ;
public Main(){
System.out.println("main");
ip = new innerPerson();
}
public class innerPerson {
@JsonIgnore
String innerName;
public String getInnerName(){
return innerName;
}
public innerPerson(){
System.out.println("innerPerson");
}
public String toString(){
return innerName;
}
}
public static void main(String args[]){
Main person = new Main();
person.name = "David";
person.age = 22;
person.male = true;
ObjectMapper om = new ObjectMapper();
try {
String json = om.writeValueAsString(person);
System.out.println(json);
Main k = om.readValue(json, Main.class);
System.out.println(k);
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getName() {
System.out.println("getName() called");
return name;
}
public String toString(){
return name + "," + age + "," + male + "," + ip;
}
public int getAge() {
return age;
}
public boolean isMale() {
return male;
}
public innerPerson getIp() {
return ip;
}
}
I move the innerPerson class to a non-inner class, but the result is same.
The annotation above give error. I cannot ignore the field in the class innerPerson. It is possible that I want to ignore that field, how could I achieve that? | java | json | jackson | null | null | null | open | Why I cannot @JsonIgnore the nested object's field?
===
The code is as below:
public class Main {
private String name;
private int age;
private boolean male;
private innerPerson ip ;
public Main(){
System.out.println("main");
ip = new innerPerson();
}
public class innerPerson {
@JsonIgnore
String innerName;
public String getInnerName(){
return innerName;
}
public innerPerson(){
System.out.println("innerPerson");
}
public String toString(){
return innerName;
}
}
public static void main(String args[]){
Main person = new Main();
person.name = "David";
person.age = 22;
person.male = true;
ObjectMapper om = new ObjectMapper();
try {
String json = om.writeValueAsString(person);
System.out.println(json);
Main k = om.readValue(json, Main.class);
System.out.println(k);
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getName() {
System.out.println("getName() called");
return name;
}
public String toString(){
return name + "," + age + "," + male + "," + ip;
}
public int getAge() {
return age;
}
public boolean isMale() {
return male;
}
public innerPerson getIp() {
return ip;
}
}
I move the innerPerson class to a non-inner class, but the result is same.
The annotation above give error. I cannot ignore the field in the class innerPerson. It is possible that I want to ignore that field, how could I achieve that? | 0 |
11,628,123 | 07/24/2012 09:39:57 | 1,474,334 | 06/22/2012 08:59:36 | 402 | 50 | Retrieve the names of files in a folder | I'm finding a way to retrieve the names of all files in a specific folder in my FTP.
Any ideas ? | php | file | null | null | null | null | open | Retrieve the names of files in a folder
===
I'm finding a way to retrieve the names of all files in a specific folder in my FTP.
Any ideas ? | 0 |
11,628,124 | 07/24/2012 09:39:58 | 1,260,939 | 03/10/2012 11:36:11 | 57 | 12 | hexadecimal conversion | I am trying to do an hexadecimal to integer conversion on a 32 bit machine. Here is the code I am testing with,
int main(int argc,char **argv)
{
char *hexstring = "0xffff1234";
long int n;
fprintf(stdout, "Conversion results of string: %s\n", hexstring);
n = strtol(hexstring, (char**)0, 0); /* same as base = 16 */
fprintf(stdout, "strtol = %ld\n", n);
n = sscanf(hexstring, "%x", &n);
fprintf(stdout, "sscanf = %ld\n", n);
n = atol(hexstring);
fprintf(stdout, "atol = %ld\n", n);
fgetc(stdin);
return 0;
}
This is what I get:
strtol = 2147483647 /* = 0x7fffffff -> overflow!! */
sscanf = 1 /* nevermind */
atol = 0 /* nevermind */
As you see, with strtol I get an overflow (I also checked with errno), although I would expect none to happen, since 0xffff1234 is a valid integer 32bit value.
I would either expect 4294906420 or else -60876
What am I missing?
| c | hex | type-conversion | integer-overflow | strtol | null | open | hexadecimal conversion
===
I am trying to do an hexadecimal to integer conversion on a 32 bit machine. Here is the code I am testing with,
int main(int argc,char **argv)
{
char *hexstring = "0xffff1234";
long int n;
fprintf(stdout, "Conversion results of string: %s\n", hexstring);
n = strtol(hexstring, (char**)0, 0); /* same as base = 16 */
fprintf(stdout, "strtol = %ld\n", n);
n = sscanf(hexstring, "%x", &n);
fprintf(stdout, "sscanf = %ld\n", n);
n = atol(hexstring);
fprintf(stdout, "atol = %ld\n", n);
fgetc(stdin);
return 0;
}
This is what I get:
strtol = 2147483647 /* = 0x7fffffff -> overflow!! */
sscanf = 1 /* nevermind */
atol = 0 /* nevermind */
As you see, with strtol I get an overflow (I also checked with errno), although I would expect none to happen, since 0xffff1234 is a valid integer 32bit value.
I would either expect 4294906420 or else -60876
What am I missing?
| 0 |
11,567,738 | 07/19/2012 19:14:14 | 756,200 | 06/01/2010 14:44:07 | 1,958 | 99 | Split Container SplitterDistance changes without user intervention | My Winforms app saves and restore its GUI state in the database. Everything's working ok, except for a Split Container's SplitterDistance.
The value is correctly loaded and set from DB, but when I exit the app **without** touching the splitter, I expect it to save the same value. But it saves the initial value minus 25 pixels. If I open and close the app many times, the splitter distance decreases by 25 pixels every time.
It's not a custom control, just a plain old .NET SplitContainer. The control is only accessed programatically to load its initial SplitterDistance and save it on exit, nothing else.
How can I troubleshoot this?
| .net | winforms | splitcontainer | null | null | null | open | Split Container SplitterDistance changes without user intervention
===
My Winforms app saves and restore its GUI state in the database. Everything's working ok, except for a Split Container's SplitterDistance.
The value is correctly loaded and set from DB, but when I exit the app **without** touching the splitter, I expect it to save the same value. But it saves the initial value minus 25 pixels. If I open and close the app many times, the splitter distance decreases by 25 pixels every time.
It's not a custom control, just a plain old .NET SplitContainer. The control is only accessed programatically to load its initial SplitterDistance and save it on exit, nothing else.
How can I troubleshoot this?
| 0 |
11,567,749 | 07/19/2012 19:14:54 | 1,232,306 | 02/25/2012 09:12:59 | 1 | 0 | inline javascript onclick event | This is my html code
<a href="#" onclick="return clickHandler()">Hit</a>
This is my javascript file
function clickHandler(evt) {
var thisLink = (evt)?evt.target:Window.event.srcElement;
alert(thisLink.innerHTML);
return false;
}
But when i click the Hit Link, it redirects.
| javascript | null | null | null | null | null | open | inline javascript onclick event
===
This is my html code
<a href="#" onclick="return clickHandler()">Hit</a>
This is my javascript file
function clickHandler(evt) {
var thisLink = (evt)?evt.target:Window.event.srcElement;
alert(thisLink.innerHTML);
return false;
}
But when i click the Hit Link, it redirects.
| 0 |
11,567,750 | 07/19/2012 19:15:01 | 33,253 | 11/01/2008 00:25:23 | 386 | 7 | How can I open a resx file in Visual Studio XML editor by default? | I want the 'View Code' view by default (xml editor), so that I can use features in R# File Structure window. | visual-studio-2010 | ide | resources | null | null | null | open | How can I open a resx file in Visual Studio XML editor by default?
===
I want the 'View Code' view by default (xml editor), so that I can use features in R# File Structure window. | 0 |
11,567,751 | 07/19/2012 19:15:04 | 1,344,193 | 04/19/2012 14:04:58 | 13 | 1 | Javascript Image roll over with onclick toggle | I currently have code to roll over an image link as below:
<a id="show" href="#"><img src="images/show-me.png" border=0 onmouseover="this.src='images/show-me_over.png';" onmouseout="this.src='images/show-me.png'"></a>
on clicking this it shows a div
jQuery(document).ready(function(){
jQuery("#show").toggle(
function(){
jQuery('#home-hidden-extra').animate({'height': '480px'} ,1000);},
function(){
jQuery('#home-hidden-extra').animate({'height': '0px'} ,1000);}
);
});
What i would like to do but i cant find/figure out is to use show_me.png and show_me-over.png when the div is hidden and then hide_me.png and hide_me-over.png when the div is shown.
How is the simplest way to achive this?
Thanks again! | javascript | jquery | null | null | null | null | open | Javascript Image roll over with onclick toggle
===
I currently have code to roll over an image link as below:
<a id="show" href="#"><img src="images/show-me.png" border=0 onmouseover="this.src='images/show-me_over.png';" onmouseout="this.src='images/show-me.png'"></a>
on clicking this it shows a div
jQuery(document).ready(function(){
jQuery("#show").toggle(
function(){
jQuery('#home-hidden-extra').animate({'height': '480px'} ,1000);},
function(){
jQuery('#home-hidden-extra').animate({'height': '0px'} ,1000);}
);
});
What i would like to do but i cant find/figure out is to use show_me.png and show_me-over.png when the div is hidden and then hide_me.png and hide_me-over.png when the div is shown.
How is the simplest way to achive this?
Thanks again! | 0 |
11,567,752 | 07/19/2012 19:15:15 | 1,255,372 | 03/07/2012 17:56:52 | 54 | 1 | Rails: Appending and Interpolating Code in Javascript | I have a lightbox in which I want to render a Rails partial, like so:
var data = "render :conversations => new";
$('#lightbox').append('#{escape_javascript(data)');
Unfortunately, this results in the text "render :conversations => new" appearing in the lightbox, rather than the actual rendering. I assume this is because I'm appending the partial rather than rendering it at runtime. I've followed the advice on [this thread](http://stackoverflow.com/questions/3416460/render-a-partial-from-jquery-and-haml), but to little success. It recommends I add a "!=" in front of the append line like so:
!= "$('#lightbox').append('#{escape_javascript(data)');"
This throws a syntax error because of the "!=". Perhaps I'm using this symbol incorrectly, but I can't find any information about it on Google. How might I get this to work? | javascript | ruby-on-rails | append | interpolation | null | null | open | Rails: Appending and Interpolating Code in Javascript
===
I have a lightbox in which I want to render a Rails partial, like so:
var data = "render :conversations => new";
$('#lightbox').append('#{escape_javascript(data)');
Unfortunately, this results in the text "render :conversations => new" appearing in the lightbox, rather than the actual rendering. I assume this is because I'm appending the partial rather than rendering it at runtime. I've followed the advice on [this thread](http://stackoverflow.com/questions/3416460/render-a-partial-from-jquery-and-haml), but to little success. It recommends I add a "!=" in front of the append line like so:
!= "$('#lightbox').append('#{escape_javascript(data)');"
This throws a syntax error because of the "!=". Perhaps I'm using this symbol incorrectly, but I can't find any information about it on Google. How might I get this to work? | 0 |
11,567,754 | 07/19/2012 19:15:32 | 620,197 | 02/16/2011 18:45:29 | 860 | 59 | Android Library Projects and Unit Testing | I am developing an Android library for interacting with a web service, and I am trying to develop some unit tests to check how well this works.
When I run the specified tests, I get the following error:
[2012-07-19 15:12:09 - MMWebAPI] Could not find MMWebAPI.apk!
[2012-07-19 15:12:10 - MMWebAPITest] Test run failed: Unable to find instrumentation target package: com.webapi.mmwebapi
Where the `MMWebAPI` is the library, and does not produce a `.apk`.
I am looking for definitive guide for unit testing Android projects, specifically, what can and can not be tested (in this case, network operations are the core of the library), a step by step tutorial would be a great help also. | android | unit-testing | junit | null | null | null | open | Android Library Projects and Unit Testing
===
I am developing an Android library for interacting with a web service, and I am trying to develop some unit tests to check how well this works.
When I run the specified tests, I get the following error:
[2012-07-19 15:12:09 - MMWebAPI] Could not find MMWebAPI.apk!
[2012-07-19 15:12:10 - MMWebAPITest] Test run failed: Unable to find instrumentation target package: com.webapi.mmwebapi
Where the `MMWebAPI` is the library, and does not produce a `.apk`.
I am looking for definitive guide for unit testing Android projects, specifically, what can and can not be tested (in this case, network operations are the core of the library), a step by step tutorial would be a great help also. | 0 |
11,567,759 | 07/19/2012 19:15:56 | 1,508,754 | 07/07/2012 13:10:33 | 10 | 0 | Strings equal but different second javascript | I can not understand why javascript says that two identical strings are different!
if (mess == 'textnothing'){ /* mess is reported by ajax, what I am writing in a form */
document.write('equal');
}else{
document.write(mess);
}
What comes out? 'textnothing' (without quotation marks) that is what I write in the form!
Why is this happening? Should appear 'equal' (without quotation marks)! | javascript | null | null | null | null | null | open | Strings equal but different second javascript
===
I can not understand why javascript says that two identical strings are different!
if (mess == 'textnothing'){ /* mess is reported by ajax, what I am writing in a form */
document.write('equal');
}else{
document.write(mess);
}
What comes out? 'textnothing' (without quotation marks) that is what I write in the form!
Why is this happening? Should appear 'equal' (without quotation marks)! | 0 |
11,567,607 | 07/19/2012 19:04:27 | 1,440,797 | 06/06/2012 20:56:09 | 76 | 6 | unexplained syntax error in for loop | I'm getting a syntax error on the 2nd to last line here, but don't know why. It seems identical to the line 2 lines before it, but for some reason I'm getting a syntax error. I've tried it both with and without a blank line between it and the line before it, with the same results.
## numlist = some list
array_size = 20
for row in xrange(array_size):
for col in xrange(array_size):
if(col<=(array_size-4)):
check(sum(numlist[row][col:col+4])
if(row<=(array_size-4)):
check(sum([numlist[row+i][col] for i in range(4)]))
| python | syntax | null | null | null | null | open | unexplained syntax error in for loop
===
I'm getting a syntax error on the 2nd to last line here, but don't know why. It seems identical to the line 2 lines before it, but for some reason I'm getting a syntax error. I've tried it both with and without a blank line between it and the line before it, with the same results.
## numlist = some list
array_size = 20
for row in xrange(array_size):
for col in xrange(array_size):
if(col<=(array_size-4)):
check(sum(numlist[row][col:col+4])
if(row<=(array_size-4)):
check(sum([numlist[row+i][col] for i in range(4)]))
| 0 |
11,350,057 | 07/05/2012 18:08:21 | 183,527 | 10/03/2009 08:15:10 | 676 | 10 | Server and client side for flash game | I am going to write flash application.
For communicate between server and client side I am going to use node.js (server) and
FlashSocket.IO (https://github.com/simb/FlashSocket.IO).
Or maybe exists best way (other best library) for communicate between server and client side for flash games.
Pleas help me with choise | flash | null | null | null | null | null | open | Server and client side for flash game
===
I am going to write flash application.
For communicate between server and client side I am going to use node.js (server) and
FlashSocket.IO (https://github.com/simb/FlashSocket.IO).
Or maybe exists best way (other best library) for communicate between server and client side for flash games.
Pleas help me with choise | 0 |
11,350,042 | 07/05/2012 18:07:32 | 800,592 | 06/16/2011 00:02:28 | 32 | 1 | Terminal mysql queries | I'm looking to use terminal to execute mysql queries. I currently connect to a sql db via the sql workbench but would like to do this via terminal. Is this possible?
I've installed mysql via homebrew | mysql | terminal | null | null | null | null | open | Terminal mysql queries
===
I'm looking to use terminal to execute mysql queries. I currently connect to a sql db via the sql workbench but would like to do this via terminal. Is this possible?
I've installed mysql via homebrew | 0 |
11,350,064 | 07/05/2012 18:08:58 | 1,423,806 | 05/29/2012 13:35:41 | 18 | 5 | Android - How to handle two finger touch | The documentation say this about that:
> A gesture starts with a motion event with ACTION_DOWN that provides
> the location of the first pointer down. As each additional pointer
> that goes down or up, the framework will generate a motion event with
> ACTION_POINTER_DOWN or ACTION_POINTER_UP accordingly.
So i have done the override of onTouchEvent function in my activity:
@Override
public boolean onTouchEvent(MotionEvent MEvent)
{
motionaction = MEvent.getAction();
if(motionaction == MotionEvent.ACTION_DOWN)
{
System.out.println("DEBUG MESSAGE POINTER1 " + MEvent.getActionIndex() );
}
if(motionaction == MotionEvent.ACTION_POINTER_DOWN)
{
System.out.println("DEBUG MESSAGE POINTER2 " + MEvent.getActionIndex() );
}
}
Unfortunately the second if is never entered. The activity contains 2 view with 2 **OnTouchListener**, i know that **onTouchEvent** is called only if the view of the activity don't consume the event so i tried to return false in the listener and in that way i can recognize only the first finger touch but this avoid the listener to receive the ACTION_UP event and don't allow me to recognize the second finger touch. I also tried to return true in the listener but after manually invoke the onTouchEvent function but this allow me to recognize only the first finger touch too.
What's wrong in my code ? | java | android | events | multitouch | handle | null | open | Android - How to handle two finger touch
===
The documentation say this about that:
> A gesture starts with a motion event with ACTION_DOWN that provides
> the location of the first pointer down. As each additional pointer
> that goes down or up, the framework will generate a motion event with
> ACTION_POINTER_DOWN or ACTION_POINTER_UP accordingly.
So i have done the override of onTouchEvent function in my activity:
@Override
public boolean onTouchEvent(MotionEvent MEvent)
{
motionaction = MEvent.getAction();
if(motionaction == MotionEvent.ACTION_DOWN)
{
System.out.println("DEBUG MESSAGE POINTER1 " + MEvent.getActionIndex() );
}
if(motionaction == MotionEvent.ACTION_POINTER_DOWN)
{
System.out.println("DEBUG MESSAGE POINTER2 " + MEvent.getActionIndex() );
}
}
Unfortunately the second if is never entered. The activity contains 2 view with 2 **OnTouchListener**, i know that **onTouchEvent** is called only if the view of the activity don't consume the event so i tried to return false in the listener and in that way i can recognize only the first finger touch but this avoid the listener to receive the ACTION_UP event and don't allow me to recognize the second finger touch. I also tried to return true in the listener but after manually invoke the onTouchEvent function but this allow me to recognize only the first finger touch too.
What's wrong in my code ? | 0 |
11,350,065 | 07/05/2012 18:08:59 | 801,820 | 06/16/2011 15:43:06 | 359 | 3 | Testing whether a value is in a set and assigning variable |
Given this dict and an input GET parameter that indicates a chosen fruit
fruit = {apple, banana, orange, pear}
Is there a compact way to do this in one line in python?
chosen = request_obj.get('fruit', '')
if chosen not in fruit:
chosen = ''
| python | null | null | null | null | null | open | Testing whether a value is in a set and assigning variable
===
Given this dict and an input GET parameter that indicates a chosen fruit
fruit = {apple, banana, orange, pear}
Is there a compact way to do this in one line in python?
chosen = request_obj.get('fruit', '')
if chosen not in fruit:
chosen = ''
| 0 |
11,350,066 | 07/05/2012 18:09:03 | 1,504,833 | 07/05/2012 18:02:59 | 1 | 0 | Outlook VBA script development | I have a script which alters the sensitivity of a message, it does work- but what happens
is that the text changes the body layout (font size etc...) And additionally, I would like to see the "footer" text (info) to have a 1 line space after the full body of the message. Any help will be appreciated
Public Sub ConfidentialMSG()
Application.ActiveInspector.CurrentItem.Sensitivity = olConfidential
Application.ActiveInspector.CurrentItem.Save
Set MsgSub = Outlook.Application.ActiveInspector.CurrentItem
Set objMail = Outlook.Application.ActiveInspector.CurrentItem
Subject = MsgSub.Subject
MsgSub.Subject = Subject + " - [CONFIDENTIAL]"
email = objMail.Body
info = " AUTO TEXT: This message has been marked as 'CONFIDENTIAL' please treat it as such"
objMail.Body = email + info
End Sub | vba | macros | outlook | null | null | null | open | Outlook VBA script development
===
I have a script which alters the sensitivity of a message, it does work- but what happens
is that the text changes the body layout (font size etc...) And additionally, I would like to see the "footer" text (info) to have a 1 line space after the full body of the message. Any help will be appreciated
Public Sub ConfidentialMSG()
Application.ActiveInspector.CurrentItem.Sensitivity = olConfidential
Application.ActiveInspector.CurrentItem.Save
Set MsgSub = Outlook.Application.ActiveInspector.CurrentItem
Set objMail = Outlook.Application.ActiveInspector.CurrentItem
Subject = MsgSub.Subject
MsgSub.Subject = Subject + " - [CONFIDENTIAL]"
email = objMail.Body
info = " AUTO TEXT: This message has been marked as 'CONFIDENTIAL' please treat it as such"
objMail.Body = email + info
End Sub | 0 |
11,350,070 | 07/05/2012 18:09:10 | 193,431 | 10/20/2009 22:41:48 | 160 | 2 | NSImage and retina display confusion | I want to add crosses on a NSImage, here's my code:
-(NSSize)convertPixelSizeToPointSize:(NSSize)px
{
CGFloat displayScale = [[NSScreen mainScreen] backingScaleFactor];
NSSize res;
res.width = px.width / displayScale;
res.height = px.height / displayScale;
return res;
}
-(void)awakeFromNib
{
CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];
NSLog(@"backingScaleFactor : %f",scale);
NSImage *img = [[[NSImage alloc]initWithContentsOfFile:@"/Users/support/Pictures/cat.JPG"] autorelease];
NSBitmapImageRep *imgRep = [NSBitmapImageRep imageRepWithData:[img TIFFRepresentation]];
NSSize imgPixelSize = NSMakeSize([imgRep pixelsWide],[imgRep pixelsHigh]);
NSSize imgPointSize = [self convertPixelSizeToPointSize:imgPixelSize];
[img setSize:imgPointSize];
NSLog(@"imgPixelSize.width: %f , imgPixelSize.height:%f",imgPixelSize.width,imgPixelSize.height);
NSLog(@"imgPointSize.width: %f , imgPointSize.height:%f",imgPointSize.width,imgPointSize.height);
[img lockFocus];
NSAffineTransform *trans = [[[NSAffineTransform alloc] init] autorelease];
[trans scaleBy:1.0 / scale];
[trans set];
NSBezierPath *path = [NSBezierPath bezierPath];
[[NSColor redColor] setStroke];
[path moveToPoint:NSMakePoint(0.0, 0.0)];
[path lineToPoint:NSMakePoint(imgPixelSize.width, imgPixelSize.height)];
[path moveToPoint:NSMakePoint(0.0, imgPixelSize.height)];
[path lineToPoint:NSMakePoint(imgPixelSize.width, 0.0)];
[path setLineWidth:1];
[path stroke];
[img unlockFocus];
[imageView setImage:img];
imgRep = [NSBitmapImageRep imageRepWithData:[img TIFFRepresentation]];
NSData *imageData = [imgRep representationUsingType:NSJPEGFileType properties:nil];
[imageData writeToFile:@"/Users/support/Pictures/11-5.JPG" atomically:NO];
}
on non-retina display the result is:
![enter image description here][1]
and console displayed:
2012-07-06 00:53:09.889 RetinaTest[8074:403] backingScaleFactor : 1.000000
2012-07-06 00:53:09.901 RetinaTest[8074:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 00:53:09.902 RetinaTest[8074:403] imgPointSize.width: 515.000000 , imgPointSize.height:600.000000
but on retina display (I didn't use the real retina display but hidpi mode):
![enter image description here][2]
console:
2012-07-06 00:56:05.071 RetinaTest[8113:403] backingScaleFactor : 2.000000
2012-07-06 00:56:05.083 RetinaTest[8113:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 00:56:05.084 RetinaTest[8113:403] imgPointSize.width: 257.500000 , imgPointSize.height:300.000000
However if I change [NSAffineTransform scaleBy] to 1.0 the result is right
NSAffineTransform *trans = [[[NSAffineTransform alloc] init] autorelease];
[trans scaleBy:1.0];
[trans set];
![enter image description here][3]
Console:
2012-07-06 01:01:03.420 RetinaTest[8126:403] backingScaleFactor : 2.000000
2012-07-06 01:01:03.431 RetinaTest[8126:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 01:01:03.432 RetinaTest[8126:403] imgPointSize.width: 257.500000 , imgPointSize.height:300.000000
Could anyone give an explanation please ? is hidpi mode different from retina display ?
[1]: http://i.stack.imgur.com/OpwGG.jpg
[2]: http://i.stack.imgur.com/s8FqK.jpg
[3]: http://i.stack.imgur.com/fGWLd.jpg | osx | cocoa | osx-lion | retinadisplay | nsimage | null | open | NSImage and retina display confusion
===
I want to add crosses on a NSImage, here's my code:
-(NSSize)convertPixelSizeToPointSize:(NSSize)px
{
CGFloat displayScale = [[NSScreen mainScreen] backingScaleFactor];
NSSize res;
res.width = px.width / displayScale;
res.height = px.height / displayScale;
return res;
}
-(void)awakeFromNib
{
CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];
NSLog(@"backingScaleFactor : %f",scale);
NSImage *img = [[[NSImage alloc]initWithContentsOfFile:@"/Users/support/Pictures/cat.JPG"] autorelease];
NSBitmapImageRep *imgRep = [NSBitmapImageRep imageRepWithData:[img TIFFRepresentation]];
NSSize imgPixelSize = NSMakeSize([imgRep pixelsWide],[imgRep pixelsHigh]);
NSSize imgPointSize = [self convertPixelSizeToPointSize:imgPixelSize];
[img setSize:imgPointSize];
NSLog(@"imgPixelSize.width: %f , imgPixelSize.height:%f",imgPixelSize.width,imgPixelSize.height);
NSLog(@"imgPointSize.width: %f , imgPointSize.height:%f",imgPointSize.width,imgPointSize.height);
[img lockFocus];
NSAffineTransform *trans = [[[NSAffineTransform alloc] init] autorelease];
[trans scaleBy:1.0 / scale];
[trans set];
NSBezierPath *path = [NSBezierPath bezierPath];
[[NSColor redColor] setStroke];
[path moveToPoint:NSMakePoint(0.0, 0.0)];
[path lineToPoint:NSMakePoint(imgPixelSize.width, imgPixelSize.height)];
[path moveToPoint:NSMakePoint(0.0, imgPixelSize.height)];
[path lineToPoint:NSMakePoint(imgPixelSize.width, 0.0)];
[path setLineWidth:1];
[path stroke];
[img unlockFocus];
[imageView setImage:img];
imgRep = [NSBitmapImageRep imageRepWithData:[img TIFFRepresentation]];
NSData *imageData = [imgRep representationUsingType:NSJPEGFileType properties:nil];
[imageData writeToFile:@"/Users/support/Pictures/11-5.JPG" atomically:NO];
}
on non-retina display the result is:
![enter image description here][1]
and console displayed:
2012-07-06 00:53:09.889 RetinaTest[8074:403] backingScaleFactor : 1.000000
2012-07-06 00:53:09.901 RetinaTest[8074:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 00:53:09.902 RetinaTest[8074:403] imgPointSize.width: 515.000000 , imgPointSize.height:600.000000
but on retina display (I didn't use the real retina display but hidpi mode):
![enter image description here][2]
console:
2012-07-06 00:56:05.071 RetinaTest[8113:403] backingScaleFactor : 2.000000
2012-07-06 00:56:05.083 RetinaTest[8113:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 00:56:05.084 RetinaTest[8113:403] imgPointSize.width: 257.500000 , imgPointSize.height:300.000000
However if I change [NSAffineTransform scaleBy] to 1.0 the result is right
NSAffineTransform *trans = [[[NSAffineTransform alloc] init] autorelease];
[trans scaleBy:1.0];
[trans set];
![enter image description here][3]
Console:
2012-07-06 01:01:03.420 RetinaTest[8126:403] backingScaleFactor : 2.000000
2012-07-06 01:01:03.431 RetinaTest[8126:403] imgPixelSize.width: 515.000000 , imgPixelSize.height:600.000000
2012-07-06 01:01:03.432 RetinaTest[8126:403] imgPointSize.width: 257.500000 , imgPointSize.height:300.000000
Could anyone give an explanation please ? is hidpi mode different from retina display ?
[1]: http://i.stack.imgur.com/OpwGG.jpg
[2]: http://i.stack.imgur.com/s8FqK.jpg
[3]: http://i.stack.imgur.com/fGWLd.jpg | 0 |
11,350,071 | 07/05/2012 18:09:10 | 355,660 | 06/01/2010 16:59:21 | 64 | 1 | index.php being added after www. removed with .htaccess | I know that it is simple to remove the index.php from a CodeIgniter URI with `RewriteRule ^(.*)$ index.php/$1 [L]`. My issue is occurring as a result of a couple of other rules in my .htaccess file.
My issue is when the user goes to www.mydomain.com/blog they are redirected to mydomain.com/index.php/blog, this does not occur when there is a trailing slash; www.mydomain.com/blog/ redirects correctly to mydomain.com/blog. I really do not want the index.php to be there. An additional side note is that ideally should the user enter index.php in the URL I would like them to be to a URL without.
My current .htaccess file is this:
RewriteEngine on
RewriteBase /
# Protect CI system folders
RewriteCond %{REQUEST_URI} ^/(application|system)/(.*)$
RewriteRule ^(.*)$ index.php/$1 [L]
# Prevent rewriting URIs that exist: (-d directory -f files)
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# Remove index.php
RewriteRule ^(.*)$ index.php/$1 [L]
# Remove www.
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
# Remove trailing slash
RewriteRule ^(.+)/$ http://mydomain.com/$1 [R=301,L]
I am relatively new to adjusting the .htaccess file; please let me know if there is anything in there that could be adjusted for optimisation, bad practice, etc, the majority of this has been created through wandering through Google!
Many thanks. | .htaccess | codeigniter | null | null | null | null | open | index.php being added after www. removed with .htaccess
===
I know that it is simple to remove the index.php from a CodeIgniter URI with `RewriteRule ^(.*)$ index.php/$1 [L]`. My issue is occurring as a result of a couple of other rules in my .htaccess file.
My issue is when the user goes to www.mydomain.com/blog they are redirected to mydomain.com/index.php/blog, this does not occur when there is a trailing slash; www.mydomain.com/blog/ redirects correctly to mydomain.com/blog. I really do not want the index.php to be there. An additional side note is that ideally should the user enter index.php in the URL I would like them to be to a URL without.
My current .htaccess file is this:
RewriteEngine on
RewriteBase /
# Protect CI system folders
RewriteCond %{REQUEST_URI} ^/(application|system)/(.*)$
RewriteRule ^(.*)$ index.php/$1 [L]
# Prevent rewriting URIs that exist: (-d directory -f files)
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# Remove index.php
RewriteRule ^(.*)$ index.php/$1 [L]
# Remove www.
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
# Remove trailing slash
RewriteRule ^(.+)/$ http://mydomain.com/$1 [R=301,L]
I am relatively new to adjusting the .htaccess file; please let me know if there is anything in there that could be adjusted for optimisation, bad practice, etc, the majority of this has been created through wandering through Google!
Many thanks. | 0 |
11,571,579 | 07/20/2012 01:17:58 | 202,382 | 11/04/2009 06:36:53 | 1,712 | 13 | Asp.net: how to add a using inside a script tag | Let's say I am in source mode of a web page.
<script runat="server">
//Code inside
</script>
How do I add **using** statements so I don't have to use the fully qualified names of classes.
Thanks for helping | asp.net | null | null | null | null | null | open | Asp.net: how to add a using inside a script tag
===
Let's say I am in source mode of a web page.
<script runat="server">
//Code inside
</script>
How do I add **using** statements so I don't have to use the fully qualified names of classes.
Thanks for helping | 0 |
11,571,681 | 07/20/2012 01:34:32 | 1,523,078 | 07/13/2012 08:54:32 | 33 | 2 | Objective C: Create a new View in touches end | I'm trying to do a program that everytime my touches end, another UIView will appear using a loop for as many as UIView I want. How can I set a loop of UIView in my touches end? or should I create it in viewDidLoad and call it in touches end?
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event//upon leaving
{
UITouch *touch = [touches anyObject];
for (int i=0; i < 100; i++) {
UIImageView *layerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[layerView setAlpha:.05];
[self.view addSubview:layerView];
}
}
Hope you can help me guys..
| objective-c | ios | iphone-sdk-4.0 | null | null | null | open | Objective C: Create a new View in touches end
===
I'm trying to do a program that everytime my touches end, another UIView will appear using a loop for as many as UIView I want. How can I set a loop of UIView in my touches end? or should I create it in viewDidLoad and call it in touches end?
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event//upon leaving
{
UITouch *touch = [touches anyObject];
for (int i=0; i < 100; i++) {
UIImageView *layerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[layerView setAlpha:.05];
[self.view addSubview:layerView];
}
}
Hope you can help me guys..
| 0 |
11,571,623 | 07/20/2012 01:25:07 | 1,206,110 | 02/13/2012 05:37:44 | 1 | 1 | How to add slightly similar content with regular expressions (regex)? | I'm using Dreamweaver on a file that has about 30 instances the following:
'portfolio_bg' =>'#555555',
'portfolio_font'=>'#ffffff',
But, for each instance the hex codes are different. I want to add the following two lines underneath the above:
'product_bg' =>'#555555',
'product_font'=>'#ffffff',
where the hex codes in my two product lines will match the hex codes of the portfolio lines above it.
How do I accomplish his using regular expressions in Dreamweaver's Find and Replace?
Thanks in advance. | regex | dreamweaver | find-and-replace | null | null | null | open | How to add slightly similar content with regular expressions (regex)?
===
I'm using Dreamweaver on a file that has about 30 instances the following:
'portfolio_bg' =>'#555555',
'portfolio_font'=>'#ffffff',
But, for each instance the hex codes are different. I want to add the following two lines underneath the above:
'product_bg' =>'#555555',
'product_font'=>'#ffffff',
where the hex codes in my two product lines will match the hex codes of the portfolio lines above it.
How do I accomplish his using regular expressions in Dreamweaver's Find and Replace?
Thanks in advance. | 0 |
11,571,687 | 07/20/2012 01:35:27 | 1,472,497 | 06/21/2012 14:55:36 | 1 | 1 | Flush not working when using injected entity manager and JTA transaction using user transaction | **Scenario:**
Create new entity, save the new entity and return the list of all the entities.
**Implementation:**
1. Create new entity.
2. Call entitymanager.persist(entity).
3. Get the list of entities in the DB.
4. Commit transaction.
5. Return list of entities.
**Problem:**
Even though entityManager.persist() is called, insert query is executed only during commit. As a result, new entity is not part of the select query for the entities.
**Options tried:**
1. Called entityManager.flush() after persist, sill didn't insert when flush was called.
2. SetFlushMode to Auto, still didn't insert when flush was called.
**Technical backgroud:**
We are using spring LocalContainerEntityManagerFactoryBean to inject entity manager and UserTransaction to begin and commit transaction.
**Entity manager:**
<bean id="emf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="xxxDataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>
**Transaction management:**
Context context = new InitialContext();
UserTransaction userTransaction = (UserTransaction) context.lookup("java:comp/UserTransaction");
// Begin JTA Transaction
userTransaction.begin();
**Persistence.xml**
<property name="openjpa.TransactionMode" value="managed" />
<property name="openjpa.ConnectionFactoryMode" value="managed" />
<property name="IgnoreChanges" value="true" />
<property name="FlushBeforeQueries" value="true" />
| spring | jpa | null | null | null | null | open | Flush not working when using injected entity manager and JTA transaction using user transaction
===
**Scenario:**
Create new entity, save the new entity and return the list of all the entities.
**Implementation:**
1. Create new entity.
2. Call entitymanager.persist(entity).
3. Get the list of entities in the DB.
4. Commit transaction.
5. Return list of entities.
**Problem:**
Even though entityManager.persist() is called, insert query is executed only during commit. As a result, new entity is not part of the select query for the entities.
**Options tried:**
1. Called entityManager.flush() after persist, sill didn't insert when flush was called.
2. SetFlushMode to Auto, still didn't insert when flush was called.
**Technical backgroud:**
We are using spring LocalContainerEntityManagerFactoryBean to inject entity manager and UserTransaction to begin and commit transaction.
**Entity manager:**
<bean id="emf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="xxxDataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>
**Transaction management:**
Context context = new InitialContext();
UserTransaction userTransaction = (UserTransaction) context.lookup("java:comp/UserTransaction");
// Begin JTA Transaction
userTransaction.begin();
**Persistence.xml**
<property name="openjpa.TransactionMode" value="managed" />
<property name="openjpa.ConnectionFactoryMode" value="managed" />
<property name="IgnoreChanges" value="true" />
<property name="FlushBeforeQueries" value="true" />
| 0 |
11,571,688 | 07/20/2012 01:35:29 | 1,539,481 | 07/20/2012 01:25:35 | 1 | 0 | How to use GIT on Lan? | Nice day,
Me and my colleagues decided to use Git. I already installed mingw32, GIT extenxion, SmartGit and Github. I also studied how to use it and what is it, but I dont know How to apply it. Can anyone help me where to start.... and How setup server and client side. We are planning it to be connected through LAN.
Thank you very much ahead ^_^
P.S.
Please teach me also how to use that pull, push and sync functions. | git | null | null | null | null | 07/20/2012 13:37:24 | not a real question | How to use GIT on Lan?
===
Nice day,
Me and my colleagues decided to use Git. I already installed mingw32, GIT extenxion, SmartGit and Github. I also studied how to use it and what is it, but I dont know How to apply it. Can anyone help me where to start.... and How setup server and client side. We are planning it to be connected through LAN.
Thank you very much ahead ^_^
P.S.
Please teach me also how to use that pull, push and sync functions. | 1 |
11,571,689 | 07/20/2012 01:35:32 | 1,108,811 | 12/20/2011 22:47:22 | 32 | 2 | R.id.pager? Where is this defined? | The example for viewpager, [here][1], contains the lines:
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.pager);
I don't understand how R.id.pager is defined. Am I supposed to create a viewpager in xml somewhere? But that wouldn't make sense because it's instantiating a viewpager in the previous line. If someone could clear this up for me I would be most grateful!!
Thank you!!
[1]: http://developer.android.com/reference/android/support/v4/view/ViewPager.html | android | android-layout | null | null | null | null | open | R.id.pager? Where is this defined?
===
The example for viewpager, [here][1], contains the lines:
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.pager);
I don't understand how R.id.pager is defined. Am I supposed to create a viewpager in xml somewhere? But that wouldn't make sense because it's instantiating a viewpager in the previous line. If someone could clear this up for me I would be most grateful!!
Thank you!!
[1]: http://developer.android.com/reference/android/support/v4/view/ViewPager.html | 0 |
11,571,690 | 07/20/2012 01:36:11 | 1,460,123 | 06/16/2012 03:45:38 | 25 | 0 | VPython Install Issues | I'm trying to import the visual module for 64-bit python. Unfortunately, I keep getting the following error:
>ImportError: numpy.core.multiarray failed to import
>
Traceback (most recent call last):
> File "C:\python\color_space.py", line 2, in <module>
> from visual import scene, color, sphere
> File "C:\Python27\lib\site-packages\visual\__init__.py", line 1, in <module>
> from .visual_all import *
> File "C:\Python27\lib\site-packages\visual\visual_all.py", line 1, in <module>
> from vis import version
> File "C:\Python27\lib\site-packages\vis\__init__.py", line 3, in <module>
> from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
>ImportError: numpy.core.multiarray failed to import
I've uninstalled my 64-bit version of python and tried the 32-bit version of python with a 32-bit visual module, to no success. Now I've reverted to 64-bit. Any ideas on how to fix this? | python | 64bit | x64 | vpython | null | null | open | VPython Install Issues
===
I'm trying to import the visual module for 64-bit python. Unfortunately, I keep getting the following error:
>ImportError: numpy.core.multiarray failed to import
>
Traceback (most recent call last):
> File "C:\python\color_space.py", line 2, in <module>
> from visual import scene, color, sphere
> File "C:\Python27\lib\site-packages\visual\__init__.py", line 1, in <module>
> from .visual_all import *
> File "C:\Python27\lib\site-packages\visual\visual_all.py", line 1, in <module>
> from vis import version
> File "C:\Python27\lib\site-packages\vis\__init__.py", line 3, in <module>
> from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
>ImportError: numpy.core.multiarray failed to import
I've uninstalled my 64-bit version of python and tried the 32-bit version of python with a 32-bit visual module, to no success. Now I've reverted to 64-bit. Any ideas on how to fix this? | 0 |
11,571,692 | 07/20/2012 01:36:28 | 1,024,927 | 11/02/2011 04:20:16 | 60 | 6 | DomElement.click() Event don't work in chrome,but others works | I wanna submit the form when pressing down the enter key.
C#
<asp:LinkButton ID="LinkButton1" runat="server" class="login-button" OnClick="btnLogin_Click" >Login</asp:LinkButton>
JS
$(document).on('keydown ', function(event) {
var key = {
submit: event.keycode || event.which
};
if (key.submit == 13) {
document.getElementById('LinkButton1').click();
}
});
Then,I get the error in chrome 18.
Object javascript:__doPostBack('LinkButton1','') has no method 'click' | c# | javascript | click | null | null | null | open | DomElement.click() Event don't work in chrome,but others works
===
I wanna submit the form when pressing down the enter key.
C#
<asp:LinkButton ID="LinkButton1" runat="server" class="login-button" OnClick="btnLogin_Click" >Login</asp:LinkButton>
JS
$(document).on('keydown ', function(event) {
var key = {
submit: event.keycode || event.which
};
if (key.submit == 13) {
document.getElementById('LinkButton1').click();
}
});
Then,I get the error in chrome 18.
Object javascript:__doPostBack('LinkButton1','') has no method 'click' | 0 |
11,571,693 | 07/20/2012 01:36:33 | 1,521,588 | 07/12/2012 17:44:10 | 1 | 1 | How to go back two viewControllers before, from ABPeoplepicker delegate method | I'm developing an app which uses ABPeopleViewController, and i want to when the user finalized choosing a contact, go backward two viewcontroller before.
Here's how i am arriving to ABPeoplePickerNavigationController:
Tap in a button of a main view controller --> load modal (dialog) view controller --> tap in a button of the modal view controller --> load ABContacts.
I'm implementing the delegate of ABContacts in the modal view, which in turn has a delegate in the main view controller.
I want to go back from ABPeoplePicker delegate method to the main view controller.
Hope this understands and someone can help me, i didn't find anything like this.
My MainViewController.h:
@protocol ModalViewDialogDelegate
- (void)didReceiveMail:(NSString *)mail;
@end
@interface SetUpViewController : UIViewController<UITextFieldDelegate, ModalViewDialogDelegate>{
}
//...
My MainViewController.m:
//...
- (void)didReceiveMail:(NSString *)mail{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
//...
My ModalView.h:
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
@protocol ModalViewDialogDelegate;
@interface DialogViewController : UIViewController<ABNewPersonViewControllerDelegate, ABPeoplePickerNavigationControllerDelegate>{
id<ModalViewDialogDelegate> delegate;
}
@property (nonatomic, assign) id<ModalViewDialogDelegate> delegate;
@property (nonatomic, retain) NSString * mailSelected;
//...
My modalView.m:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
//...here i get the email person property and then i want to go backwards to the main view controller, not the modal.
[self dismissViewControllerAnimated:YES completion:nil];
//don't know if it's ok like this, because in the implementation also dismiss presented viewcontroller.
[_delegate didReceiveMail:self.mailSelected];
return NO;
}
return YES;
}
| objective-c | ios | delegates | modalviewcontroller | null | null | open | How to go back two viewControllers before, from ABPeoplepicker delegate method
===
I'm developing an app which uses ABPeopleViewController, and i want to when the user finalized choosing a contact, go backward two viewcontroller before.
Here's how i am arriving to ABPeoplePickerNavigationController:
Tap in a button of a main view controller --> load modal (dialog) view controller --> tap in a button of the modal view controller --> load ABContacts.
I'm implementing the delegate of ABContacts in the modal view, which in turn has a delegate in the main view controller.
I want to go back from ABPeoplePicker delegate method to the main view controller.
Hope this understands and someone can help me, i didn't find anything like this.
My MainViewController.h:
@protocol ModalViewDialogDelegate
- (void)didReceiveMail:(NSString *)mail;
@end
@interface SetUpViewController : UIViewController<UITextFieldDelegate, ModalViewDialogDelegate>{
}
//...
My MainViewController.m:
//...
- (void)didReceiveMail:(NSString *)mail{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
//...
My ModalView.h:
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
@protocol ModalViewDialogDelegate;
@interface DialogViewController : UIViewController<ABNewPersonViewControllerDelegate, ABPeoplePickerNavigationControllerDelegate>{
id<ModalViewDialogDelegate> delegate;
}
@property (nonatomic, assign) id<ModalViewDialogDelegate> delegate;
@property (nonatomic, retain) NSString * mailSelected;
//...
My modalView.m:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
//...here i get the email person property and then i want to go backwards to the main view controller, not the modal.
[self dismissViewControllerAnimated:YES completion:nil];
//don't know if it's ok like this, because in the implementation also dismiss presented viewcontroller.
[_delegate didReceiveMail:self.mailSelected];
return NO;
}
return YES;
}
| 0 |
11,571,695 | 07/20/2012 01:36:45 | 1,538,970 | 07/19/2012 19:49:16 | 1 | 0 | Retrieve data from query filled drop down box | I have made a dropdown box that is filled by a query that looks for company names from company name database, these names also have and ID number that I don't want displayed but are looked up in the query. I need the ID number to link to sites of the company so somehow when I hit the submit button on the site page it finds the ID number by looking at the position value and relating that to the position on the query array I just don't know what to do. If it helps this is how I fill the dropbox:
mysql_select_db("DB", $con);
$query = "SELECT Company_Name, ID FROM company_table";
$result = mysql_query($query) or die(mysql_error());
$options ='';
$num = 0;
while ($row=mysql_fetch_array($result)) {
$num = $num+1;
$options.= "<OPTION VALUE=\"$num\">".$row["Company_Name"];
}
<SELECT NAME=thing>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>
Any Ideas?
| php | mysql | query | drop-down-menu | null | null | open | Retrieve data from query filled drop down box
===
I have made a dropdown box that is filled by a query that looks for company names from company name database, these names also have and ID number that I don't want displayed but are looked up in the query. I need the ID number to link to sites of the company so somehow when I hit the submit button on the site page it finds the ID number by looking at the position value and relating that to the position on the query array I just don't know what to do. If it helps this is how I fill the dropbox:
mysql_select_db("DB", $con);
$query = "SELECT Company_Name, ID FROM company_table";
$result = mysql_query($query) or die(mysql_error());
$options ='';
$num = 0;
while ($row=mysql_fetch_array($result)) {
$num = $num+1;
$options.= "<OPTION VALUE=\"$num\">".$row["Company_Name"];
}
<SELECT NAME=thing>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>
Any Ideas?
| 0 |
11,571,696 | 07/20/2012 01:36:55 | 575,047 | 01/13/2011 23:56:21 | 1,065 | 56 | Embedded videos crash/break font-face | We've just released a new website ([http://www.vulytrampolines.com/][1]), and we're having issues with font-face calls on Mac Safari/Chrome only. It will load as the proper font in the first half second or so (in the navigation at the top), but then when the video loads within the iframe, the font breaks. It goes much lighter/thinner than normal, and we can't figure out how to fix it.
The issue only appears to occur when a page has an iframe to a youtube/vimeo video. E.G. http://vulytrampolines.com/aboutus. If you watch the orange navigation, you'll notice the font will have a bit more weight, but will then go lighter once the youtube video loads in. Deleting the video iframe from the DOM or setting it to display none then fixes the problem, BUT making it visible again breaks the font again.
Anyone have any ideas?
[1]: http://www.vulytrampolines.com/ | osx | google-chrome | video | safari | font-face | null | open | Embedded videos crash/break font-face
===
We've just released a new website ([http://www.vulytrampolines.com/][1]), and we're having issues with font-face calls on Mac Safari/Chrome only. It will load as the proper font in the first half second or so (in the navigation at the top), but then when the video loads within the iframe, the font breaks. It goes much lighter/thinner than normal, and we can't figure out how to fix it.
The issue only appears to occur when a page has an iframe to a youtube/vimeo video. E.G. http://vulytrampolines.com/aboutus. If you watch the orange navigation, you'll notice the font will have a bit more weight, but will then go lighter once the youtube video loads in. Deleting the video iframe from the DOM or setting it to display none then fixes the problem, BUT making it visible again breaks the font again.
Anyone have any ideas?
[1]: http://www.vulytrampolines.com/ | 0 |
11,387,362 | 07/08/2012 22:51:44 | 478,190 | 10/16/2010 21:56:19 | 8 | 0 | Tabs in ttk.Notebook for python: Is there a way to set tabs below one another? | So far when using Notebook for ttk/Tkinter, I am unable to set tabs below one another, they keep piling up eastward. There a way to set them to stack somehow? | python | gui | tabs | tkinter | ttk | null | open | Tabs in ttk.Notebook for python: Is there a way to set tabs below one another?
===
So far when using Notebook for ttk/Tkinter, I am unable to set tabs below one another, they keep piling up eastward. There a way to set them to stack somehow? | 0 |
11,387,330 | 07/08/2012 22:46:37 | 1,096,795 | 12/13/2011 23:24:14 | 1 | 0 | Can this Excel task be accomplished in R? | I have been using the Excel solver to handle the following problem
solve for a b and c in the equation:
y = a*b*c*x/((1 - c*x)(1 - c*x + b*c*x))
subject to the constraints
0 < a < 100
0 < b < 100
0 < c < 100
f(x[1]) < 10
f(x[2]) > 20
f(x[3]) < 40
where I have about 10 (x,y) value pairs. I minimize the sum of abs(y - f(x)). And I can constrain both the coefficients and the range of values for the result of my function at each x.
I tried nls (without trying to impose the constraints) and while Excel provided estimates for almost any starting values I cared to provide, nls almost never returned an answer.
I switched to using optim, but I'm having trouble applying the constraints.
This is where I have gotten so far-
best = function(p,x,y){sum(abs(y - p[1]*p[2]*p[3]*x/((1 - p[3]*x)*(1 - p[3]*x + p[2]*p[3]*x))))}
p = c(1,1,1)
x = c(.1,.5,.9)
y = c(5,26,35)
optim(p,best,x=x,y=y)
I did this to add the first set of constraints-
optim(p,best,x=x,y=y,method="L-BFGS-B",lower=c(0,0,0),upper=c(100,100,100))
I get the error ""ERROR: ABNORMAL_TERMINATION_IN_LNSRCH"
and end up with a higher value of the error ($value). So it seems like I am doing something wrong. I couldn't figure out how to apply my other set of constraints at all.
Could someone provide me a basic idea how to solve this problem that a non-statistician can understand? I looked at a lot of posts and looked in a few R books. The R books stopped at the simplest use of optim. | r | null | null | null | null | null | open | Can this Excel task be accomplished in R?
===
I have been using the Excel solver to handle the following problem
solve for a b and c in the equation:
y = a*b*c*x/((1 - c*x)(1 - c*x + b*c*x))
subject to the constraints
0 < a < 100
0 < b < 100
0 < c < 100
f(x[1]) < 10
f(x[2]) > 20
f(x[3]) < 40
where I have about 10 (x,y) value pairs. I minimize the sum of abs(y - f(x)). And I can constrain both the coefficients and the range of values for the result of my function at each x.
I tried nls (without trying to impose the constraints) and while Excel provided estimates for almost any starting values I cared to provide, nls almost never returned an answer.
I switched to using optim, but I'm having trouble applying the constraints.
This is where I have gotten so far-
best = function(p,x,y){sum(abs(y - p[1]*p[2]*p[3]*x/((1 - p[3]*x)*(1 - p[3]*x + p[2]*p[3]*x))))}
p = c(1,1,1)
x = c(.1,.5,.9)
y = c(5,26,35)
optim(p,best,x=x,y=y)
I did this to add the first set of constraints-
optim(p,best,x=x,y=y,method="L-BFGS-B",lower=c(0,0,0),upper=c(100,100,100))
I get the error ""ERROR: ABNORMAL_TERMINATION_IN_LNSRCH"
and end up with a higher value of the error ($value). So it seems like I am doing something wrong. I couldn't figure out how to apply my other set of constraints at all.
Could someone provide me a basic idea how to solve this problem that a non-statistician can understand? I looked at a lot of posts and looked in a few R books. The R books stopped at the simplest use of optim. | 0 |
11,387,365 | 07/08/2012 22:52:32 | 956,035 | 09/21/2011 03:11:38 | 1 | 0 | Jquery - identical codes but only one of them works | Consider code A and code B. They look identical but one is written by me. The other, copy pasted from W3. Code A (the one written by me) doesn't work but Code B does. Why is this? I've done a string match and it says it doesn't match but putting them ontop of each other in notepad (the code being one line already) reveals that its not different at all. Is there anything i'm doing wrong?
Code A:
$(document).ready(function(){
$(".sub").click(function(){
$(".sub").slideToggle("slow");
});
});
Code B:
$(document).ready(function(){
$(".sub").click(function(){
$(".sub").slideToggle("slow");
});
}); | javascript | jquery | html | bugs | slide | null | open | Jquery - identical codes but only one of them works
===
Consider code A and code B. They look identical but one is written by me. The other, copy pasted from W3. Code A (the one written by me) doesn't work but Code B does. Why is this? I've done a string match and it says it doesn't match but putting them ontop of each other in notepad (the code being one line already) reveals that its not different at all. Is there anything i'm doing wrong?
Code A:
$(document).ready(function(){
$(".sub").click(function(){
$(".sub").slideToggle("slow");
});
});
Code B:
$(document).ready(function(){
$(".sub").click(function(){
$(".sub").slideToggle("slow");
});
}); | 0 |
11,387,370 | 07/08/2012 22:53:13 | 179,015 | 09/25/2009 11:36:40 | 2,592 | 80 | How can I safely convert `unsigned long int` to `int`? | I have an app which is creating unique __ids__ in the form of `unsigned long int`s. The app needs this precision.
However, I have to send these __ids__ in a protocol that only allows for `int`s. The receiving application does not need this precision. So my questions is: how can I convert an `unsigned long int` to an `int`, especially when the `unsigned long int` is larger than an `int`?
| c++ | null | null | null | null | null | open | How can I safely convert `unsigned long int` to `int`?
===
I have an app which is creating unique __ids__ in the form of `unsigned long int`s. The app needs this precision.
However, I have to send these __ids__ in a protocol that only allows for `int`s. The receiving application does not need this precision. So my questions is: how can I convert an `unsigned long int` to an `int`, especially when the `unsigned long int` is larger than an `int`?
| 0 |
11,387,377 | 07/08/2012 22:54:04 | 1,008,986 | 10/22/2011 21:38:52 | 3 | 0 | PHP Post to Simple Modal then Update the page | So what I'm attempting to do is this:
<ol>
<li>User clicks a radio html form button.</li>
<li>User clicks a submit button to confirm his choice.</li>
<li>SimpleModal pops up and displays the value of the button chosen.</li>
<li>User clicks 'Accept' in the SimpleModal and the parent page updates accordingly.</li>
</ol>
I'm not so worried about step 4, but I'm not sure how to transfer the post information into the SimpleModal.
For reference I'm using the SimpleModal Contact Form demo that Eric Martin has provided.
I'm new to Ajax as well as jQuery.
I saw this post: http://stackoverflow.com/questions/3258751/passing-a-value-from-php-to-the-simplemodal-contact-form
They had a similar problem, however they are not retrieving post information from their index page.
Is there a way to retrieve this post information and pass it to the contact.php that is called for the SimpleModal window?
Any help is greatly appreciated.
-Chad | php | jquery | post | update | simplemodal | null | open | PHP Post to Simple Modal then Update the page
===
So what I'm attempting to do is this:
<ol>
<li>User clicks a radio html form button.</li>
<li>User clicks a submit button to confirm his choice.</li>
<li>SimpleModal pops up and displays the value of the button chosen.</li>
<li>User clicks 'Accept' in the SimpleModal and the parent page updates accordingly.</li>
</ol>
I'm not so worried about step 4, but I'm not sure how to transfer the post information into the SimpleModal.
For reference I'm using the SimpleModal Contact Form demo that Eric Martin has provided.
I'm new to Ajax as well as jQuery.
I saw this post: http://stackoverflow.com/questions/3258751/passing-a-value-from-php-to-the-simplemodal-contact-form
They had a similar problem, however they are not retrieving post information from their index page.
Is there a way to retrieve this post information and pass it to the contact.php that is called for the SimpleModal window?
Any help is greatly appreciated.
-Chad | 0 |
11,387,386 | 07/08/2012 22:55:32 | 1,476,205 | 06/23/2012 00:59:34 | 17 | 0 | How does tumblr handle subdomains? | How does Tumblr handle account subdomains like *blogname*.tumblr.com? Is it an .htaccess redirect? If so, what code can I use to make something like that on my site? | .htaccess | tumblr | null | null | null | null | open | How does tumblr handle subdomains?
===
How does Tumblr handle account subdomains like *blogname*.tumblr.com? Is it an .htaccess redirect? If so, what code can I use to make something like that on my site? | 0 |
11,387,388 | 07/08/2012 22:55:58 | 1,370,089 | 05/02/2012 13:11:46 | 8 | 0 | Relate two tables where one of the column name is common | I have two tables, TableA and TableB. Both tables have a column of their own that can function as part of their primary key. There is one column, "commonColumn" that exists in both tables. There is a one-to-many relationship between TableA and TableB. The constraint is that value of "commonColumn" must be same on both sides of the one-to-many relationship.
What complicates matters a bit is that this one-to-many relationship is not an identifying relationship. There can be rows in tableB that are not related to tableA. TableB can have rows with values for "commonColumn" that do not exist in TableA.
Hope the above is clear, albeit a bit extract.
What is the best way to model this?
Thanks in advance! | database | one-to-many | null | null | null | null | open | Relate two tables where one of the column name is common
===
I have two tables, TableA and TableB. Both tables have a column of their own that can function as part of their primary key. There is one column, "commonColumn" that exists in both tables. There is a one-to-many relationship between TableA and TableB. The constraint is that value of "commonColumn" must be same on both sides of the one-to-many relationship.
What complicates matters a bit is that this one-to-many relationship is not an identifying relationship. There can be rows in tableB that are not related to tableA. TableB can have rows with values for "commonColumn" that do not exist in TableA.
Hope the above is clear, albeit a bit extract.
What is the best way to model this?
Thanks in advance! | 0 |
11,734,363 | 07/31/2012 06:29:08 | 1,423,316 | 05/29/2012 09:33:11 | 25 | 0 | WPF Creating New usercontrol with BackgroundWorker Fail | I've looked around google cause i need to mutithread as my program lags whenever it attempts to load a gif and load a usercontrol at the same time. Rather, the gif hangs and the the page suddenly shows my usercontrol without any transition. Ok How the program is supposed to behave,
Show gif-->Load Usercontrol-->Hide Gif-->run animation(a Simple slide in effect)
But because of the lag when rendering the ui elements of the usercontrol, the program behaves like this
Show Gif -->Gif Hangs(or freezes) -->show Usercontrol immediately
So I found this thing called BackgroundWorker . Sounds great . Well ... not entirely. i tried it out and applied it to my codes like so
BackgroundWorker worker = new BackgroundWorker();
CrowdWatch_Portrait.CrowdWatch crowder;
//The page is a frame fyi
thePage.LoadCompleted += new LoadCompletedEventHandler(thePage_LoadCompleted);
worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
crowder = new CrowdWatch_Portrait.CrowdWatch();
thePage.Content = crowder;
};
worker.RunWorkerAsync();
Sounds good. Ran it. Failed. It gave me this error
The calling thread must be STA, because many UI components require this.
So after researching online again , I couldn't find any scenario in which this class was used to load a usercontrol. So I turn to the community for help....help? | wpf | multithreading | backgroundworker | sta | null | null | open | WPF Creating New usercontrol with BackgroundWorker Fail
===
I've looked around google cause i need to mutithread as my program lags whenever it attempts to load a gif and load a usercontrol at the same time. Rather, the gif hangs and the the page suddenly shows my usercontrol without any transition. Ok How the program is supposed to behave,
Show gif-->Load Usercontrol-->Hide Gif-->run animation(a Simple slide in effect)
But because of the lag when rendering the ui elements of the usercontrol, the program behaves like this
Show Gif -->Gif Hangs(or freezes) -->show Usercontrol immediately
So I found this thing called BackgroundWorker . Sounds great . Well ... not entirely. i tried it out and applied it to my codes like so
BackgroundWorker worker = new BackgroundWorker();
CrowdWatch_Portrait.CrowdWatch crowder;
//The page is a frame fyi
thePage.LoadCompleted += new LoadCompletedEventHandler(thePage_LoadCompleted);
worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
crowder = new CrowdWatch_Portrait.CrowdWatch();
thePage.Content = crowder;
};
worker.RunWorkerAsync();
Sounds good. Ran it. Failed. It gave me this error
The calling thread must be STA, because many UI components require this.
So after researching online again , I couldn't find any scenario in which this class was used to load a usercontrol. So I turn to the community for help....help? | 0 |
11,734,364 | 07/31/2012 06:29:16 | 396,404 | 07/20/2010 02:56:37 | 477 | 20 | InfiniDB insert speed with insert statement | I have recently started using InfinDB, and so far it is working well. I use the cipimport tool for bulk loads and it inserts millions of rows in seconds. However, there are certain situations in which I need to insert several thousand rows and using the insert statement is just far more programmatically rational due to nature of how the data is generated. However, when I try to do this, the insert speed seems pretty slow. It is inserting around 30 rows per second (each row is pretty small.. around 5 columns per row, each of type varchar(10)). Did I configure and/or install something incorrectly, or is the expected speed using the insert statement? My computer has 16 gb ram with a SSD with 520 mb/s write speed, and using MyISAM or Innodb I can insert several thousand rows per second using the insert statement. | mysql | infinidb | null | null | null | null | open | InfiniDB insert speed with insert statement
===
I have recently started using InfinDB, and so far it is working well. I use the cipimport tool for bulk loads and it inserts millions of rows in seconds. However, there are certain situations in which I need to insert several thousand rows and using the insert statement is just far more programmatically rational due to nature of how the data is generated. However, when I try to do this, the insert speed seems pretty slow. It is inserting around 30 rows per second (each row is pretty small.. around 5 columns per row, each of type varchar(10)). Did I configure and/or install something incorrectly, or is the expected speed using the insert statement? My computer has 16 gb ram with a SSD with 520 mb/s write speed, and using MyISAM or Innodb I can insert several thousand rows per second using the insert statement. | 0 |
11,734,368 | 07/31/2012 06:29:29 | 1,066,604 | 11/26/2011 05:33:11 | 471 | 8 | PHP Fatal error: Undefined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123 | i upgraded the magento site from 1.4.1.1 to latest version.
But when i loading the site it displays white page .
And in fire bug it displays network server error.
So i checked the errors using ssh.
tail -f /var/log/apache2/error.log
it displays some errors :
root@MSHOME:/var/www/magento_upgrade# tail -f /var/log/apache2/error.log
[Tue Jul 31 09:51:23 2012] [error] [client 192.168.1.16] File does not exist: /v ar/www/favicon.ico
[Tue Jul 31 09:51:23 2012] [error] [client 192.168.1.16] File does not exist: /v ar/www/favicon.ico
[Tue Jul 31 10:19:32 2012] [notice] caught SIGTERM, shutting down
[Tue Jul 31 10:19:33 2012] [notice] Apache/2.2.17 (Ubuntu) DAV/2 SVN/1.6.12 PHP/ 5.3.5-1ubuntu7.10 with Suhosin-Patch configured -- resuming normal operations
[Tue Jul 31 11:30:53 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:33 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:35 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:49 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:32:10 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:32:47 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:34:26 2012] [error] [client 67.190.104.93] request failed: error reading the headers
how can i solve this?
If there is any solution for this?
| magento | windows-shell | null | null | null | null | open | PHP Fatal error: Undefined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
===
i upgraded the magento site from 1.4.1.1 to latest version.
But when i loading the site it displays white page .
And in fire bug it displays network server error.
So i checked the errors using ssh.
tail -f /var/log/apache2/error.log
it displays some errors :
root@MSHOME:/var/www/magento_upgrade# tail -f /var/log/apache2/error.log
[Tue Jul 31 09:51:23 2012] [error] [client 192.168.1.16] File does not exist: /v ar/www/favicon.ico
[Tue Jul 31 09:51:23 2012] [error] [client 192.168.1.16] File does not exist: /v ar/www/favicon.ico
[Tue Jul 31 10:19:32 2012] [notice] caught SIGTERM, shutting down
[Tue Jul 31 10:19:33 2012] [notice] Apache/2.2.17 (Ubuntu) DAV/2 SVN/1.6.12 PHP/ 5.3.5-1ubuntu7.10 with Suhosin-Patch configured -- resuming normal operations
[Tue Jul 31 11:30:53 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:33 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:35 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:31:49 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:32:10 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:32:47 2012] [error] [client 192.168.1.11] PHP Fatal error: Undef ined class constant 'XML_PATH_USE_CUSTOM_ADMIN_PATH' in /var/www/magento_upgrade /app/code/core/Mage/Core/Controller/Varien/Router/Admin.php on line 123
[Tue Jul 31 11:34:26 2012] [error] [client 67.190.104.93] request failed: error reading the headers
how can i solve this?
If there is any solution for this?
| 0 |
11,734,369 | 07/31/2012 06:29:43 | 1,564,866 | 07/31/2012 06:24:06 | 1 | 0 | a case with ajax and jsonp response | i am trying to parse a website with ajax and jsonp and get a response to my "alert", from some reason it drops me this error: SyntaxError: syntax error and in the alert its returning "object" instead of some string of the site.
can anyone explain this to me and show me how i solve this so that i can get the website as a string to my alert?
$.ajax({
url:"http://www.tokov.com",
dataType: 'jsonp',
success:function(data){
alert(data);
},
error: function (data){
alert(data);
},
});
thanks in advanced. | ajax | jsonp | null | null | null | null | open | a case with ajax and jsonp response
===
i am trying to parse a website with ajax and jsonp and get a response to my "alert", from some reason it drops me this error: SyntaxError: syntax error and in the alert its returning "object" instead of some string of the site.
can anyone explain this to me and show me how i solve this so that i can get the website as a string to my alert?
$.ajax({
url:"http://www.tokov.com",
dataType: 'jsonp',
success:function(data){
alert(data);
},
error: function (data){
alert(data);
},
});
thanks in advanced. | 0 |
11,734,371 | 07/31/2012 06:30:06 | 1,564,795 | 07/31/2012 05:48:15 | 1 | 0 | How to store entire source of xml file as a string in c++ | The xml can only be referred to in the code as an external link for eg. "www.etc.com". I want to be able to extract certain words from the page source of certain websites, but first i need to dump the source content into a string or CString. Thanks for any help | c++ | xml | string | visual-c++ | xml-parsing | null | open | How to store entire source of xml file as a string in c++
===
The xml can only be referred to in the code as an external link for eg. "www.etc.com". I want to be able to extract certain words from the page source of certain websites, but first i need to dump the source content into a string or CString. Thanks for any help | 0 |
11,734,360 | 07/31/2012 06:28:57 | 898,057 | 08/17/2011 06:18:48 | 129 | 12 | AsyncTask postExecute or onCancelled not getting called when android kills Background tasks- No more background processes | I m running a queue where i m downloading videos and for que to work properly in need to get the postExecute of AsyncTask called mandatorily..or there must b an event where i can get when my asynctask is getting killed by the processor which says "No more Background Tasks"..Low memory..OnCancelled not getting called too...Any help??? | android | android-asynctask | null | null | null | null | open | AsyncTask postExecute or onCancelled not getting called when android kills Background tasks- No more background processes
===
I m running a queue where i m downloading videos and for que to work properly in need to get the postExecute of AsyncTask called mandatorily..or there must b an event where i can get when my asynctask is getting killed by the processor which says "No more Background Tasks"..Low memory..OnCancelled not getting called too...Any help??? | 0 |
11,734,256 | 07/31/2012 06:20:46 | 619,441 | 02/16/2011 10:20:09 | 118 | 9 | Dynamic data in AutoCompleteTextView with Array Adapter | I am having AutoCompleteTextView and loading the data from the Array adapter.
I am providing the adapter data from the String array.
Here the values in the string array are obtained once the user enters the text in the AutoCompleteTextView.I will send the AutoCompleteTextView's text in the url and get the response , parses it and stores in the String array.
My code is
final AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.autoCompleteEditText1);
textView.setOnKeyListener(new View.OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if(event.getAction()==KeyEvent.ACTION_UP)
{
city_name = textView.getText().toString();
sendhttprequest(countrycode,city_name);
parse_response();
ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_dropdown_item_1line, list_of_cities);
textView.setAdapter(adapter2);
}
return false;
}
});
So once i select the country from the spinner,
* AutoCompleteTextView should show the list of cities matching the entered text.
I am not getting the required result.
Sometimes Its working.
Sometimes its not working.
Will anyone suggest me how to do this?
Am I going in correct way? Else what changes should be made?
I have attached the screen shot.
![sample screen shot.][1]
It will be very helpful if I get the Solution as quick as possible.
Thanks in advance for spending your time here.
[1]: http://i.stack.imgur.com/aqxXG.png | java | android | android-arrayadapter | autocompletetextview | null | null | open | Dynamic data in AutoCompleteTextView with Array Adapter
===
I am having AutoCompleteTextView and loading the data from the Array adapter.
I am providing the adapter data from the String array.
Here the values in the string array are obtained once the user enters the text in the AutoCompleteTextView.I will send the AutoCompleteTextView's text in the url and get the response , parses it and stores in the String array.
My code is
final AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.autoCompleteEditText1);
textView.setOnKeyListener(new View.OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if(event.getAction()==KeyEvent.ACTION_UP)
{
city_name = textView.getText().toString();
sendhttprequest(countrycode,city_name);
parse_response();
ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_dropdown_item_1line, list_of_cities);
textView.setAdapter(adapter2);
}
return false;
}
});
So once i select the country from the spinner,
* AutoCompleteTextView should show the list of cities matching the entered text.
I am not getting the required result.
Sometimes Its working.
Sometimes its not working.
Will anyone suggest me how to do this?
Am I going in correct way? Else what changes should be made?
I have attached the screen shot.
![sample screen shot.][1]
It will be very helpful if I get the Solution as quick as possible.
Thanks in advance for spending your time here.
[1]: http://i.stack.imgur.com/aqxXG.png | 0 |
11,734,257 | 07/31/2012 06:20:46 | 1,497,948 | 07/03/2012 06:55:20 | 6 | 0 | how to get html struts styleClass with javascript/jquery | I need to get the value of the styleClass element in javascript. Page is in jsp with struts/html tag elements. jsp code is
<input type="hidden" class="filename" name="filename" value="<%= filename %>" />
<html:file property="testfile" styleClass="testfile"/>
and onclick of button I invoke the javascript
function fields() {
var filename = jQuery('.filename');
alert(filename);
var testfile= jQuery('.testfile').val();
alert(testfile);
}
However in the firstcase(filename) I get [object object] returned and in second case I get "undefined". Can someone give some pointers on how to get the uploaded file name in jquery. Thanks
| java | javascript | jquery | jsp | struts2 | null | open | how to get html struts styleClass with javascript/jquery
===
I need to get the value of the styleClass element in javascript. Page is in jsp with struts/html tag elements. jsp code is
<input type="hidden" class="filename" name="filename" value="<%= filename %>" />
<html:file property="testfile" styleClass="testfile"/>
and onclick of button I invoke the javascript
function fields() {
var filename = jQuery('.filename');
alert(filename);
var testfile= jQuery('.testfile').val();
alert(testfile);
}
However in the firstcase(filename) I get [object object] returned and in second case I get "undefined". Can someone give some pointers on how to get the uploaded file name in jquery. Thanks
| 0 |
11,733,262 | 07/31/2012 04:47:06 | 161,801 | 08/24/2009 03:07:35 | 2,152 | 29 | Regular expression to match a Python integer literal | What is a regular expression that will match any valid Python integer literal in a string? It should support all the extra stuff like `o` and `l`, but not match a float, or a variable with a number in it. I am using Python's `re`, so any syntax supported by that is OK. | python | regex | null | null | null | null | open | Regular expression to match a Python integer literal
===
What is a regular expression that will match any valid Python integer literal in a string? It should support all the extra stuff like `o` and `l`, but not match a float, or a variable with a number in it. I am using Python's `re`, so any syntax supported by that is OK. | 0 |
11,734,380 | 07/31/2012 06:31:27 | 531,984 | 12/06/2010 08:29:33 | 511 | 20 | Check for null in foreach loop | Is there a nicer way of doing the following:
I need a check for null to happen on file.Headers before proceeding with the loop
if (file.Headers != null)
{
foreach (var h in file.Headers)
{
//set lots of properties & some other stuff
}
}
In short it looks a bit ugly to write the foreach inside the if due to the level of indentation happening in my code.
Is something that would evaluate to
foreach(var h in (file.Headers != null))
{
//do stuff
}
possible? | c# | loops | foreach | null | null | null | open | Check for null in foreach loop
===
Is there a nicer way of doing the following:
I need a check for null to happen on file.Headers before proceeding with the loop
if (file.Headers != null)
{
foreach (var h in file.Headers)
{
//set lots of properties & some other stuff
}
}
In short it looks a bit ugly to write the foreach inside the if due to the level of indentation happening in my code.
Is something that would evaluate to
foreach(var h in (file.Headers != null))
{
//do stuff
}
possible? | 0 |
11,734,381 | 07/31/2012 06:31:34 | 1,564,807 | 07/31/2012 05:54:50 | 1 | 0 | Ruby On Rails - Retreive data from text box a display its contents | I am new to Ruby on Rails. I have a simple application which connects to twitter. The application has a search text box on the home page and a submit button.Also there is a model and the controller for the same. I want to search some keywords dynamically on twitter and then display them on the home page of our application. I have created a text box and submit button in the "index.html.erb" page. I don't know how to take the keyword and pass into the controller. Then i want to display the result of the search. Can anyone site an example for the same ? Kindly suggest errors /changes in the code. like-this ruby on rails
**The contents of the index.html.erb**
<h1>Tweets about New Year Resolution</h1>
<tr><td>Enter keyword <input type = "text" name = "keyword"></td></tr>
<tr><td><input type = "submit" value = "SEARCH"></td></tr>
<%= form_tag(tweets/index, :method => "get") do %>
<%= label_tag(:q, "Enter keyword :") %>
<%= text_field_tag(:q) %>
<%= submit_tag("SEARCH") %>
<% end %>
<div id="container">
<ul>
<% @tweets.each do |tweet| %>
<li class="<%=cycle('odd', '')%>">
<%= link_to tweet.from_user, "http://twitter.com/#{tweet.from_user}", :class => "username", :target => "_blank" %>
<div class="tweet_text_area">
<div class="tweet_text">
<%=raw display_content_with_links(tweet.text) %>
</div>
<div class="tweet_created_at">
<%= time_ago_in_words tweet.twitter_created_at %> ago
</div>
</div>
</li>
<% end %>
</ul>
</div>
**The contents of the controller tweets.rb**
class TweetsController < ApplicationController
def index
#Get the tweets (records) from the model Ordered by 'twitter_created_at' descending
searchValue = params[:keyword]
if Tweet.count > 0
Tweet.delete_all
end
Tweet.get_latest_new_year_resolution_tweets("iphone")
@tweets = Tweet.order("twitter_created_at desc")
end
end
| ruby-on-rails | ruby-on-rails-3 | null | null | null | null | open | Ruby On Rails - Retreive data from text box a display its contents
===
I am new to Ruby on Rails. I have a simple application which connects to twitter. The application has a search text box on the home page and a submit button.Also there is a model and the controller for the same. I want to search some keywords dynamically on twitter and then display them on the home page of our application. I have created a text box and submit button in the "index.html.erb" page. I don't know how to take the keyword and pass into the controller. Then i want to display the result of the search. Can anyone site an example for the same ? Kindly suggest errors /changes in the code. like-this ruby on rails
**The contents of the index.html.erb**
<h1>Tweets about New Year Resolution</h1>
<tr><td>Enter keyword <input type = "text" name = "keyword"></td></tr>
<tr><td><input type = "submit" value = "SEARCH"></td></tr>
<%= form_tag(tweets/index, :method => "get") do %>
<%= label_tag(:q, "Enter keyword :") %>
<%= text_field_tag(:q) %>
<%= submit_tag("SEARCH") %>
<% end %>
<div id="container">
<ul>
<% @tweets.each do |tweet| %>
<li class="<%=cycle('odd', '')%>">
<%= link_to tweet.from_user, "http://twitter.com/#{tweet.from_user}", :class => "username", :target => "_blank" %>
<div class="tweet_text_area">
<div class="tweet_text">
<%=raw display_content_with_links(tweet.text) %>
</div>
<div class="tweet_created_at">
<%= time_ago_in_words tweet.twitter_created_at %> ago
</div>
</div>
</li>
<% end %>
</ul>
</div>
**The contents of the controller tweets.rb**
class TweetsController < ApplicationController
def index
#Get the tweets (records) from the model Ordered by 'twitter_created_at' descending
searchValue = params[:keyword]
if Tweet.count > 0
Tweet.delete_all
end
Tweet.get_latest_new_year_resolution_tweets("iphone")
@tweets = Tweet.order("twitter_created_at desc")
end
end
| 0 |
11,734,382 | 07/31/2012 06:31:36 | 262,852 | 01/31/2010 10:01:23 | 467 | 19 | use generics to check an @Entity for @Unique | Is it even possible to use generics with `genericPersist` and `isUniqueEntity`? The persist method seems fairly straightforward:
package net.bounceme.dur.usenet.driver;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Folder;
import javax.mail.Message;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import net.bounceme.dur.usenet.model.Article;
import net.bounceme.dur.usenet.model.Newsgroup;
import net.bounceme.dur.usenet.model.Usenet;
public class Main {
private static final Logger LOG = Logger.getLogger(Main.class.getName());
private Usenet u = Usenet.INSTANCE;
public static void main(String[] args) {
try {
Main main = new Main();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Main() throws Exception {
EntityManagerFactory emf;
EntityManager em;
emf = Persistence.createEntityManagerFactory("USENETPU");
List<Newsgroup> subscribed = getFolders();
em = emf.createEntityManager();
for (Newsgroup newsgroup : subscribed) {
persistNewsgroups(em, newsgroup);
List<Message> messages = u.getMessages(newsgroup.getNewsgroup());
LOG.fine(newsgroup + " " + messages.size() + " messages");
for (Message message : messages) {
LOG.fine("message " + message.getMessageNumber());
Article article = new Article(message);
persistArticle(em, article);
}
}
em.close();
}
private boolean isUniqueArticle(Article article, List<Article> articles) {
LOG.fine(articles.toString());
for (Article a : articles) {
if (a.getSubject().equalsIgnoreCase(article.getSubject())) {
return false;
}
}
LOG.fine("new\t\t" + article);
return true;
}
private void persistArticle(EntityManager em, Article article) {
LOG.fine(article.toString());
TypedQuery<Article> query = em.createQuery("SELECT a FROM Article a", Article.class);
List<Article> results = query.getResultList();
if (isUniqueArticle(article, results)) {
em.getTransaction().begin();
em.persist(article);
em.getTransaction().commit();
}
}
private <T> void genericPersist(EntityManager em, Class<T> entity, String queryString) {
TypedQuery<T> query = em.createQuery(queryString, entity);
List<T> results = query.getResultList();
if (isUniqueEntity(entity, results)) {
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();
}
}
private <T> boolean isUniqueEntity(Class<T> entity,List<T> results) {
return false;
}
private void persistNewsgroups(EntityManager em, Newsgroup newNewsgroup) {
LOG.fine(newNewsgroup.toString());
TypedQuery<Newsgroup> query = em.createQuery("SELECT n FROM Newsgroup n", Newsgroup.class);
List<Newsgroup> results = query.getResultList();
if (isUniqueNewsgroup(newNewsgroup, results)) {
em.getTransaction().begin();
em.persist(newNewsgroup);
em.getTransaction().commit();
}
}
private boolean isUniqueNewsgroup(Newsgroup newNewsgroup, Iterable<Newsgroup> results) {
LOG.fine(results.toString());
for (Newsgroup existingNewsgroup : results) {
if ((existingNewsgroup.getNewsgroup().equals(newNewsgroup.getNewsgroup()))) {
return false;
}
}
LOG.fine(newNewsgroup + "\tnew");
return true;
}
private List<Newsgroup> getFolders() {
List<Folder> folders = u.getFolders();
List<Newsgroup> newsgroups = new ArrayList<>();
for (Folder folder : folders) {
Newsgroup newsgroup = new Newsgroup(folder);
newsgroups.add(newsgroup);
}
LOG.fine(newsgroups.toString());
return newsgroups;
}
}
For the `isUniqueEntity` all I can think of is to determine the type of the object and then use a switch, but that doesn't seem much of a savings. How can this be done?
Assuming that the entity has a single `@Unique` field, determine that field and then query the database accordingly? | java | generics | jpa | jpql | generic-programming | null | open | use generics to check an @Entity for @Unique
===
Is it even possible to use generics with `genericPersist` and `isUniqueEntity`? The persist method seems fairly straightforward:
package net.bounceme.dur.usenet.driver;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Folder;
import javax.mail.Message;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import net.bounceme.dur.usenet.model.Article;
import net.bounceme.dur.usenet.model.Newsgroup;
import net.bounceme.dur.usenet.model.Usenet;
public class Main {
private static final Logger LOG = Logger.getLogger(Main.class.getName());
private Usenet u = Usenet.INSTANCE;
public static void main(String[] args) {
try {
Main main = new Main();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Main() throws Exception {
EntityManagerFactory emf;
EntityManager em;
emf = Persistence.createEntityManagerFactory("USENETPU");
List<Newsgroup> subscribed = getFolders();
em = emf.createEntityManager();
for (Newsgroup newsgroup : subscribed) {
persistNewsgroups(em, newsgroup);
List<Message> messages = u.getMessages(newsgroup.getNewsgroup());
LOG.fine(newsgroup + " " + messages.size() + " messages");
for (Message message : messages) {
LOG.fine("message " + message.getMessageNumber());
Article article = new Article(message);
persistArticle(em, article);
}
}
em.close();
}
private boolean isUniqueArticle(Article article, List<Article> articles) {
LOG.fine(articles.toString());
for (Article a : articles) {
if (a.getSubject().equalsIgnoreCase(article.getSubject())) {
return false;
}
}
LOG.fine("new\t\t" + article);
return true;
}
private void persistArticle(EntityManager em, Article article) {
LOG.fine(article.toString());
TypedQuery<Article> query = em.createQuery("SELECT a FROM Article a", Article.class);
List<Article> results = query.getResultList();
if (isUniqueArticle(article, results)) {
em.getTransaction().begin();
em.persist(article);
em.getTransaction().commit();
}
}
private <T> void genericPersist(EntityManager em, Class<T> entity, String queryString) {
TypedQuery<T> query = em.createQuery(queryString, entity);
List<T> results = query.getResultList();
if (isUniqueEntity(entity, results)) {
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();
}
}
private <T> boolean isUniqueEntity(Class<T> entity,List<T> results) {
return false;
}
private void persistNewsgroups(EntityManager em, Newsgroup newNewsgroup) {
LOG.fine(newNewsgroup.toString());
TypedQuery<Newsgroup> query = em.createQuery("SELECT n FROM Newsgroup n", Newsgroup.class);
List<Newsgroup> results = query.getResultList();
if (isUniqueNewsgroup(newNewsgroup, results)) {
em.getTransaction().begin();
em.persist(newNewsgroup);
em.getTransaction().commit();
}
}
private boolean isUniqueNewsgroup(Newsgroup newNewsgroup, Iterable<Newsgroup> results) {
LOG.fine(results.toString());
for (Newsgroup existingNewsgroup : results) {
if ((existingNewsgroup.getNewsgroup().equals(newNewsgroup.getNewsgroup()))) {
return false;
}
}
LOG.fine(newNewsgroup + "\tnew");
return true;
}
private List<Newsgroup> getFolders() {
List<Folder> folders = u.getFolders();
List<Newsgroup> newsgroups = new ArrayList<>();
for (Folder folder : folders) {
Newsgroup newsgroup = new Newsgroup(folder);
newsgroups.add(newsgroup);
}
LOG.fine(newsgroups.toString());
return newsgroups;
}
}
For the `isUniqueEntity` all I can think of is to determine the type of the object and then use a switch, but that doesn't seem much of a savings. How can this be done?
Assuming that the entity has a single `@Unique` field, determine that field and then query the database accordingly? | 0 |
11,734,383 | 07/31/2012 06:31:42 | 1,563,758 | 07/30/2012 18:08:28 | 1 | 0 | How to scan only a part of a application in Webinspect | Can anyone explain the way to scan only a certain part of a web application using Webinspect? | security | null | null | null | null | null | open | How to scan only a part of a application in Webinspect
===
Can anyone explain the way to scan only a certain part of a web application using Webinspect? | 0 |
11,410,273 | 07/10/2012 09:23:26 | 1,511,366 | 07/09/2012 08:10:18 | 1 | 0 | Stored Procedure not returning records properly in sql server 2012 | I have to create a stored procedure that will search through matching records in database and show them in Gridview. The user can search through a form selecting multiple options, some of the options are not mandatory. I have created a Stored Procedure but its not showing the results properly when I am executing it on SQL Server Management Studio. The sp is showing the result only when I am selecting any one parameter but its not showing any records if I select more than one parameter. I don't have much experience with SQL Server so please help me find out if I am doing anything wrong here. The sp I created is as bellow :
use DatabaseName
go
ALTER PROCEDURE dbo.ProcName
@abc varchar(50) = null,
@def varchar(50) = null,
@ghi Int = null,
@jkl varchar(50) = null,
@mno varchar(50) = null
As
Begin
SELECT abc,def,ghi,jkl,mno,rst from TableName
where(@abc IS NULL OR abc= @abc)
AND (@def IS NULL OR def = @def)
AND (@ghi IS NULL OR ghi = @ghi)
AND (@jkl IS NULL OR jkl = @jkl)
AND (@mno IS NULL OR mno = @mno)
End
Go
Many Thanks,
P | sql-server | null | null | null | null | null | open | Stored Procedure not returning records properly in sql server 2012
===
I have to create a stored procedure that will search through matching records in database and show them in Gridview. The user can search through a form selecting multiple options, some of the options are not mandatory. I have created a Stored Procedure but its not showing the results properly when I am executing it on SQL Server Management Studio. The sp is showing the result only when I am selecting any one parameter but its not showing any records if I select more than one parameter. I don't have much experience with SQL Server so please help me find out if I am doing anything wrong here. The sp I created is as bellow :
use DatabaseName
go
ALTER PROCEDURE dbo.ProcName
@abc varchar(50) = null,
@def varchar(50) = null,
@ghi Int = null,
@jkl varchar(50) = null,
@mno varchar(50) = null
As
Begin
SELECT abc,def,ghi,jkl,mno,rst from TableName
where(@abc IS NULL OR abc= @abc)
AND (@def IS NULL OR def = @def)
AND (@ghi IS NULL OR ghi = @ghi)
AND (@jkl IS NULL OR jkl = @jkl)
AND (@mno IS NULL OR mno = @mno)
End
Go
Many Thanks,
P | 0 |
11,408,971 | 07/10/2012 07:59:05 | 258,418 | 01/25/2010 12:43:05 | 320 | 18 | Use Panel as renderer | I would like to use a more complex renderer consisting of several components for a list (more precisely something like [this](http://stackoverflow.com/questions/10840498/java-swing-1-6-textinput-like-firefox-bar) (a textfieldinput with some buttons arranged in a panel). However when I try it with my list (I only set the renderer for the selected item), the panel holding my list simply loses focus (every time I select an item), but i see no change.
pseudocode/Jython:
getListCellRenderer(...):
renderer = DefaulListCellRenderer.getListCellRendererComponent(...)
if selected:
panel = JPanel
panel.add(renderer)
panel.add(JButton("Testbutton"))
return panel
return renderer
can I use something like a panel with buttons as a renderer? and if so where do I go wrong, do I have to force a revalidation of my panel? | java | swing | jlist | null | null | null | open | Use Panel as renderer
===
I would like to use a more complex renderer consisting of several components for a list (more precisely something like [this](http://stackoverflow.com/questions/10840498/java-swing-1-6-textinput-like-firefox-bar) (a textfieldinput with some buttons arranged in a panel). However when I try it with my list (I only set the renderer for the selected item), the panel holding my list simply loses focus (every time I select an item), but i see no change.
pseudocode/Jython:
getListCellRenderer(...):
renderer = DefaulListCellRenderer.getListCellRendererComponent(...)
if selected:
panel = JPanel
panel.add(renderer)
panel.add(JButton("Testbutton"))
return panel
return renderer
can I use something like a panel with buttons as a renderer? and if so where do I go wrong, do I have to force a revalidation of my panel? | 0 |
11,410,590 | 07/10/2012 09:43:23 | 1,511,197 | 07/09/2012 06:42:20 | 1 | 0 | Lightbox Slider | I have following code.
It displays 3 images in lightbox slider and slides images as well.
But I want to display only one image and on the click of that image,i want to display more than one images in the lightbox slider.
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
How can i do that??
| jquery | html | null | null | null | null | open | Lightbox Slider
===
I have following code.
It displays 3 images in lightbox slider and slides images as well.
But I want to display only one image and on the click of that image,i want to display more than one images in the lightbox slider.
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
How can i do that??
| 0 |
11,410,593 | 07/10/2012 09:43:27 | 1,496,691 | 07/02/2012 17:08:33 | 1 | 0 | using foreach loop for two lists in c# for geting lists values | List<String> listA = new List<string> { "A1", "A2" };
List<String> listB = new List<string> { "B1", "B2" };
for(int i = 0; i < listA.Count; i++)
{
text+= listA[i]+" and "+ listB[i];
}
I want to do that with foreach loop. how can i do this with foreach loop
help me.
thanks in advance. | c# | list | loops | foreach | null | null | open | using foreach loop for two lists in c# for geting lists values
===
List<String> listA = new List<string> { "A1", "A2" };
List<String> listB = new List<string> { "B1", "B2" };
for(int i = 0; i < listA.Count; i++)
{
text+= listA[i]+" and "+ listB[i];
}
I want to do that with foreach loop. how can i do this with foreach loop
help me.
thanks in advance. | 0 |
11,410,594 | 07/10/2012 09:43:33 | 1,160,682 | 01/20/2012 13:10:24 | 1 | 0 | Simple program for yii? | Can any one suggest me a simple program for yii framework with following features?
1.User registration
2.login
3.The particular user who has logined should be able to update their profile using the session
4.Session management | php | yii | yii-mvc | yii-events | null | 07/10/2012 12:20:12 | not a real question | Simple program for yii?
===
Can any one suggest me a simple program for yii framework with following features?
1.User registration
2.login
3.The particular user who has logined should be able to update their profile using the session
4.Session management | 1 |
11,410,595 | 07/10/2012 09:43:36 | 1,511,876 | 07/09/2012 11:49:31 | 3 | 0 | how to store the clickable items(many) from the listview and get this items to next activity Listview? | > Blockquote
i am new in android.s0 plz help me.thanks in advance.
enter code here
l1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String s2=(String) ((TextView) view).getText();
String[] S5=new String[]{s2};
//global variable myval as static
GlobalClass.myval=S5;
| android | null | null | null | null | 07/10/2012 16:47:13 | not a real question | how to store the clickable items(many) from the listview and get this items to next activity Listview?
===
> Blockquote
i am new in android.s0 plz help me.thanks in advance.
enter code here
l1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String s2=(String) ((TextView) view).getText();
String[] S5=new String[]{s2};
//global variable myval as static
GlobalClass.myval=S5;
| 1 |
11,410,596 | 07/10/2012 09:43:38 | 449,344 | 09/16/2010 10:08:29 | 725 | 20 | Iterate over Time in ruby | I am working on business analytics application, where I need to fetch some data on per hour basis of a particular month. for example I wanna get the data from jun 01 2012 to jun 30 2012 and I need to fetch the data of every hour between those days.
Like 12:00 13:00,13:00-14:00 ....etc.
How do I do it. Kindly let me know. Using 1.8.7 platform. | ruby-on-rails | ruby | ruby-on-rails-3 | ruby-on-rails-3.1 | null | null | open | Iterate over Time in ruby
===
I am working on business analytics application, where I need to fetch some data on per hour basis of a particular month. for example I wanna get the data from jun 01 2012 to jun 30 2012 and I need to fetch the data of every hour between those days.
Like 12:00 13:00,13:00-14:00 ....etc.
How do I do it. Kindly let me know. Using 1.8.7 platform. | 0 |
11,410,132 | 07/10/2012 09:13:38 | 1,466,886 | 06/19/2012 15:33:51 | 11 | 0 | Connecting to SQL Database from another computer | I'm new to SQL Server, and have been following this [tutorial](http://msdn.microsoft.com/en-us/library/ms345343(v=sql.105).aspx)
I carefully followed all the steps, but when I try to connect to the database from the other computer, I get the error "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)"
What steps do I need to take to fix this?
Thanks
(I'm using SQL Server 2008 R2 on both the machines) | sql-server | sql-server-2008 | null | null | null | null | open | Connecting to SQL Database from another computer
===
I'm new to SQL Server, and have been following this [tutorial](http://msdn.microsoft.com/en-us/library/ms345343(v=sql.105).aspx)
I carefully followed all the steps, but when I try to connect to the database from the other computer, I get the error "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)"
What steps do I need to take to fix this?
Thanks
(I'm using SQL Server 2008 R2 on both the machines) | 0 |
11,410,603 | 07/10/2012 09:44:13 | 467,875 | 10/06/2010 11:21:37 | 610 | 55 | Stop part of page being index by search engines? | How can I stop search engines indexing part of my page? Is there an HTML5 element for this?
Its just a line of text that I want to hide (a co-worker doesnt want their name on google for some reason). Im thinking that I could inject the text with javascript, but I have heard google does sometimes look inside javascript files.
I also thought of using images instead of text, but im concerned how this will look cross device and platform. Ive noted text rendering can differ on mac and pc and thats before ive had to think about mobile devices, retina displays, etc.
Thanks | search-engine | null | null | null | null | null | open | Stop part of page being index by search engines?
===
How can I stop search engines indexing part of my page? Is there an HTML5 element for this?
Its just a line of text that I want to hide (a co-worker doesnt want their name on google for some reason). Im thinking that I could inject the text with javascript, but I have heard google does sometimes look inside javascript files.
I also thought of using images instead of text, but im concerned how this will look cross device and platform. Ive noted text rendering can differ on mac and pc and thats before ive had to think about mobile devices, retina displays, etc.
Thanks | 0 |
11,410,604 | 07/10/2012 09:44:13 | 954,267 | 09/16/2011 12:39:44 | 445 | 2 | Objective c - Canceling operations in NSOperationQueue | I'm using `AFNetworking` `AFHTTPClient` just for the example, but this question is about `NSOperationQueue` in general.
The `AFHTTPClient` manage an `NSOperationQueue` for requests made by the client.
It also has a `cancelAllOperations` method that iterate over the `self.operationQueue.operations` and call `[operation cancel]` for each one.
**If I understand this right, it will cancel all the operations waiting in the queue - meaning the operation that didn't started yet, but what with the operations that are currently running? they won't be cancelled??**
| objective-c | ios | nsoperation | nsoperationqueue | afnetworking | null | open | Objective c - Canceling operations in NSOperationQueue
===
I'm using `AFNetworking` `AFHTTPClient` just for the example, but this question is about `NSOperationQueue` in general.
The `AFHTTPClient` manage an `NSOperationQueue` for requests made by the client.
It also has a `cancelAllOperations` method that iterate over the `self.operationQueue.operations` and call `[operation cancel]` for each one.
**If I understand this right, it will cancel all the operations waiting in the queue - meaning the operation that didn't started yet, but what with the operations that are currently running? they won't be cancelled??**
| 0 |
11,410,607 | 07/10/2012 09:44:29 | 1,514,223 | 07/10/2012 08:44:51 | 1 | 0 | Need Help on integrating Bugzilla with SalesForce | We could integrate SalesForce Case object with the online hosted Bugzilla (by using RESTful WebServices of Bugzilla).We wanted to integrate with the Bugzilla instance installed in offline.
As per our investigation, we suspect that WebServices of Bugzilla might not have been exposed or enabled during the installation of offline bugzilla. We arrived to this conclusion as we are getting a response status code **403 Forbidden** when we access one of its WebServices (Response Body: You don't have permission to access /Bugzilla/WebService/Bug.pm).
Please share your pointers to resolve this issue. | web-services | salesforce | bugzilla | null | null | null | open | Need Help on integrating Bugzilla with SalesForce
===
We could integrate SalesForce Case object with the online hosted Bugzilla (by using RESTful WebServices of Bugzilla).We wanted to integrate with the Bugzilla instance installed in offline.
As per our investigation, we suspect that WebServices of Bugzilla might not have been exposed or enabled during the installation of offline bugzilla. We arrived to this conclusion as we are getting a response status code **403 Forbidden** when we access one of its WebServices (Response Body: You don't have permission to access /Bugzilla/WebService/Bug.pm).
Please share your pointers to resolve this issue. | 0 |
11,373,076 | 07/07/2012 07:16:39 | 340,457 | 05/13/2010 16:03:06 | 4,031 | 599 | Jquery multiple accordion effect with hierarchical menu or a nested tree? | I've seen some hierarchical tree with multiple accordian effect with Jquery. How can I do this with Xajax? I've a tree with Xajax but how can I achieve the accordion effect on open and close of subtrees in my tree? Do I need to wrap the opened and closed subtree with an jquery animate? How do I know which subtree is open and close? | jquery | xajax | null | null | null | null | open | Jquery multiple accordion effect with hierarchical menu or a nested tree?
===
I've seen some hierarchical tree with multiple accordian effect with Jquery. How can I do this with Xajax? I've a tree with Xajax but how can I achieve the accordion effect on open and close of subtrees in my tree? Do I need to wrap the opened and closed subtree with an jquery animate? How do I know which subtree is open and close? | 0 |
11,373,081 | 07/07/2012 07:17:28 | 1,508,332 | 07/07/2012 06:07:00 | 1 | 0 | Generating repeating bitmaps with wxPython trouble | Well, while I don't consider myself an experienced programmer, especially when it comes to multimedia applications, I had to do this image viewer sort of a program that displays images fullscreen, and the images change when the users press <- or -> arrows.
The general idea was to make a listbox where all the images contained in a certain folder (imgs) are shown, and when someone does double click or hits RETURN a new, fullscreen frame is generated containing, at first, the image selected in the listbox but after the user hits the arrows the images change in conecutive order, just like in a regular image viewer.
At the beginning, when the first 15 - 20 images are generated, everything goes well, after that, although the program still works an intermediary, very unpleasant and highly unwanted, effect appears between image generations, where basically some images that got generated previously are displayed quickly on the screen and after this the right, consecutive image appears. On the first apparitions the effect is barelly noticeble, but after a while it takes longer and longer between generations.
Here's the code that runs when someone does double click on a listbox entry:
def lbclick(self, eve):
frm = wx.Frame(None, -1, '')
frm.ShowFullScreen(True)
self.sel = self.lstb.GetSelection() # getting the selection from the listbox
def pressk(eve):
keys = eve.GetKeyCode()
if keys == wx.WXK_LEFT or keys == wx.WXK_RIGHT:
imgs() # invocking the function made for displaying fullscreen images
eve.Skip()
frm.Bind(wx.EVT_CHAR_HOOK, pressk)
def imgs(): # building the function
imgsl = self.chk[self.sel]
itm = wx.Image(str('imgs/{0}'.format(imgsl)), wx.BITMAP_TYPE_JPEG).ConvertToBitmap() # obtaining the name of the image stored in the list self.chk
mar = itm.Size # Because not all images are landscaped I had to figure a method to rescale them after height dimension, which is common to all images
frsz = frm.GetSize()
marx = float(mar[0])
mary = float(mar[1])
val = frsz[1] / mary
vsize = int(mary * val)
hsize = int(marx * val)
panl = wx.Panel(frm, -1, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0)) # making a panel container
panl.SetBackgroundColour('#000000')
imag = wx.Image(str('imgs/{0}'.format(imgsl)), wx.BITMAP_TYPE_JPEG).Scale(hsize, vsize, quality = wx.IMAGE_QUALITY_NORMAL).ConvertToBitmap()
def destr(eve): # unprofessionaly trying to destroy the panel container when a new image is generated hopeing the unvanted effect, with previous generated images will disappear. But it doesn't.
keycd = eve.GetKeyCode()
if keycd == wx.WXK_LEFT or keycd == wx.WXK_RIGHT:
try:
panl.Destroy()
except:
pass
eve.Skip()
panl.Bind(wx.EVT_CHAR_HOOK, destr) # the end of my futile tries
if vsize > hsize: # if the image is portrait instead of landscaped I have to put a black image as a container, otherwise in the background the previous image will remain, even if I use Refresh() on the container (the black bitmap named fundal)
intermed = wx.Image('./res/null.jpg', wx.BITMAP_TYPE_JPEG).Scale(frsz[0], frsz[1]).ConvertToBitmap()
fundal = wx.StaticBitmap(frm, 101, intermed)
stimag = wx.StaticBitmap(fundal, -1, imag, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0))
fundal.Refresh()
stimag.SetToolTip(wx.ToolTip('Esc = iesire din ecran pe tot monitorul\nSageata <- -> = navigare rapida'))
def destr(eve): # the same lame attempt to destroy the container in the portarit images situation
keycd = eve.GetKeyCode()
if keycd == wx.WXK_LEFT or keycd == wx.WXK_RIGHT:
try:
fundal.Destroy()
except:
pass
eve.Skip()
frm.Bind(wx.EVT_CHAR_HOOK, destr)
else: # the case when the images are landscape
stimag = wx.StaticBitmap(panl, -1, imag)
stimag.Refresh()
stimag.SetToolTip(wx.ToolTip('Esc = iesire din ecran pe tot monitorul\nSageata <- -> = navigare rapida'))
imgs() # invocking the function imgs for the situation when someone does double click
frm.Center()
frm.Show(True)
Thanks for any advice in advance.
| wxpython | null | null | null | null | null | open | Generating repeating bitmaps with wxPython trouble
===
Well, while I don't consider myself an experienced programmer, especially when it comes to multimedia applications, I had to do this image viewer sort of a program that displays images fullscreen, and the images change when the users press <- or -> arrows.
The general idea was to make a listbox where all the images contained in a certain folder (imgs) are shown, and when someone does double click or hits RETURN a new, fullscreen frame is generated containing, at first, the image selected in the listbox but after the user hits the arrows the images change in conecutive order, just like in a regular image viewer.
At the beginning, when the first 15 - 20 images are generated, everything goes well, after that, although the program still works an intermediary, very unpleasant and highly unwanted, effect appears between image generations, where basically some images that got generated previously are displayed quickly on the screen and after this the right, consecutive image appears. On the first apparitions the effect is barelly noticeble, but after a while it takes longer and longer between generations.
Here's the code that runs when someone does double click on a listbox entry:
def lbclick(self, eve):
frm = wx.Frame(None, -1, '')
frm.ShowFullScreen(True)
self.sel = self.lstb.GetSelection() # getting the selection from the listbox
def pressk(eve):
keys = eve.GetKeyCode()
if keys == wx.WXK_LEFT or keys == wx.WXK_RIGHT:
imgs() # invocking the function made for displaying fullscreen images
eve.Skip()
frm.Bind(wx.EVT_CHAR_HOOK, pressk)
def imgs(): # building the function
imgsl = self.chk[self.sel]
itm = wx.Image(str('imgs/{0}'.format(imgsl)), wx.BITMAP_TYPE_JPEG).ConvertToBitmap() # obtaining the name of the image stored in the list self.chk
mar = itm.Size # Because not all images are landscaped I had to figure a method to rescale them after height dimension, which is common to all images
frsz = frm.GetSize()
marx = float(mar[0])
mary = float(mar[1])
val = frsz[1] / mary
vsize = int(mary * val)
hsize = int(marx * val)
panl = wx.Panel(frm, -1, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0)) # making a panel container
panl.SetBackgroundColour('#000000')
imag = wx.Image(str('imgs/{0}'.format(imgsl)), wx.BITMAP_TYPE_JPEG).Scale(hsize, vsize, quality = wx.IMAGE_QUALITY_NORMAL).ConvertToBitmap()
def destr(eve): # unprofessionaly trying to destroy the panel container when a new image is generated hopeing the unvanted effect, with previous generated images will disappear. But it doesn't.
keycd = eve.GetKeyCode()
if keycd == wx.WXK_LEFT or keycd == wx.WXK_RIGHT:
try:
panl.Destroy()
except:
pass
eve.Skip()
panl.Bind(wx.EVT_CHAR_HOOK, destr) # the end of my futile tries
if vsize > hsize: # if the image is portrait instead of landscaped I have to put a black image as a container, otherwise in the background the previous image will remain, even if I use Refresh() on the container (the black bitmap named fundal)
intermed = wx.Image('./res/null.jpg', wx.BITMAP_TYPE_JPEG).Scale(frsz[0], frsz[1]).ConvertToBitmap()
fundal = wx.StaticBitmap(frm, 101, intermed)
stimag = wx.StaticBitmap(fundal, -1, imag, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0))
fundal.Refresh()
stimag.SetToolTip(wx.ToolTip('Esc = iesire din ecran pe tot monitorul\nSageata <- -> = navigare rapida'))
def destr(eve): # the same lame attempt to destroy the container in the portarit images situation
keycd = eve.GetKeyCode()
if keycd == wx.WXK_LEFT or keycd == wx.WXK_RIGHT:
try:
fundal.Destroy()
except:
pass
eve.Skip()
frm.Bind(wx.EVT_CHAR_HOOK, destr)
else: # the case when the images are landscape
stimag = wx.StaticBitmap(panl, -1, imag)
stimag.Refresh()
stimag.SetToolTip(wx.ToolTip('Esc = iesire din ecran pe tot monitorul\nSageata <- -> = navigare rapida'))
imgs() # invocking the function imgs for the situation when someone does double click
frm.Center()
frm.Show(True)
Thanks for any advice in advance.
| 0 |
11,373,088 | 07/07/2012 07:18:51 | 1,490,245 | 06/29/2012 04:14:31 | 9 | 0 | rearrange the UIButton position in a UIView iphone? | i have a set of UIButtons in my class. according to the url fields from UIWebView i need to rearrange the position of my buttons.
my button array is
buttonArray = [[NSMutableArray alloc] initWithObjects:btn1,btn2,btn3,btn4,btn5,btn6, nil];
these buttons are arranged in order, if mu url field gives the value false means i need to remove the button btn1 and other buttons should the retain the display order.
i tried this code
if(false)
{
btn1.hidden=YES;
btn2.center=CGPointMake(btn1.frame.origin.x, btn1.frame.origin.y);
}
but the btn2 does not take the position of btn1.
how will i arrange my buttons such that other buttons should retain the display order even when some of the buttons are missing in display.
hope will get some help. | iphone | uibutton | position | null | null | null | open | rearrange the UIButton position in a UIView iphone?
===
i have a set of UIButtons in my class. according to the url fields from UIWebView i need to rearrange the position of my buttons.
my button array is
buttonArray = [[NSMutableArray alloc] initWithObjects:btn1,btn2,btn3,btn4,btn5,btn6, nil];
these buttons are arranged in order, if mu url field gives the value false means i need to remove the button btn1 and other buttons should the retain the display order.
i tried this code
if(false)
{
btn1.hidden=YES;
btn2.center=CGPointMake(btn1.frame.origin.x, btn1.frame.origin.y);
}
but the btn2 does not take the position of btn1.
how will i arrange my buttons such that other buttons should retain the display order even when some of the buttons are missing in display.
hope will get some help. | 0 |
11,373,089 | 07/07/2012 07:18:53 | 1,503,950 | 07/05/2012 12:17:17 | 1 | 0 | how to dispaly login form again after invalid login | how can i redirect back to the Login form in win form application after invalid login
write now i am trying this in program.cs
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new frmLogin());
frmLogin fm = new frmLogin();
fm.ShowDialog();
if (fm.DialogResult == DialogResult.OK && Global.Login)
Application.Run(new MDIParent1());
else if(fm.DialogResult==DialogResult.Cancel)
{
MessageBox.Show("Wrong Username Or Password");
Application.Run(new frmLogin());
//fm.ShowDialog();
}
| c# | winforms | null | null | null | null | open | how to dispaly login form again after invalid login
===
how can i redirect back to the Login form in win form application after invalid login
write now i am trying this in program.cs
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new frmLogin());
frmLogin fm = new frmLogin();
fm.ShowDialog();
if (fm.DialogResult == DialogResult.OK && Global.Login)
Application.Run(new MDIParent1());
else if(fm.DialogResult==DialogResult.Cancel)
{
MessageBox.Show("Wrong Username Or Password");
Application.Run(new frmLogin());
//fm.ShowDialog();
}
| 0 |
11,373,082 | 07/07/2012 07:17:40 | 1,508,378 | 07/07/2012 06:56:39 | 1 | 0 | Protecting PHP Mail / Contact Form | Ah the joys, 9 million pieces of advice, guidance and code and not one agrees with another. So I'm trying to get to the point at which I can be confident that the way I've chosen to protect my contact form is robust.
I spent some time reading around and checking out the source for PEAR Mail and PHP Mailer and this is what I've managed to surmise - bearing in mind I am a beginner in most things and definitely in PHP, regex etc. (and essentially at zero when it comes to RFC822, SMTP etc. etc.)
(*What I really want to understand (rather than simply solve) is how to best protect a web contact form from being used maliciously.*)
Based on my limited understanding, one approach might be this - so, is it good, bad, misleading, wrong or (and this would be a surprise) not half bad?
1. First use filter_var twice, once with FILTER_SANITIZE_EMAIL and then FILTER_VALIDATE_EMAIL on the from address only (since we supply the to address)
2. Optionally use the PHP Mailer regex as belt and braces, again on the from address only -> `return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\``\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\``\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);`
3. Optionally test user data such as subject, name etc. (anything that goes in the header) with the regex from phundamentals -> `function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}`
4. Then build the headers array and use string replacement or `preg_replace` to remove line endings
5. This could be as simple as the PHP Mailer string replace -> `("\r", "\n")` or the more 'complex' PEAR Mail preg_replace -> `=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i` - which appears to define extra descriptions of an EOL - for PHP v5+, could use `str_ireplace` instead of `preg_replace`
For reference here are the notes I made that led to my uninformed and speculative ideas above:
// Functions found from various sources
// www.nyphp.org/phundamentals/8_Preventing-Email-Header-Injection
// Pattern for filtering email addresses -- '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i'
// Pattern for filtering fields such as names -- '/^[a-z0-9()\/\'":\*+|,.; \- !?&#$@]{2,75}$/i'
function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}
// www.dreamincode.net/forums/topic/228389-preventing-php-mail-header-injections/
$reply_to = filter_var($reply_to, FILTER_VALIDATE_EMAIL); if(!$reply_to) {...}
function sanitize(&$array) { foreach($array as &$data) $data = str_replace(array("\r", "\n", "%0a", "%0d"), '', stripslashes($data)); } }
// PHP Mailer
// code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.phpmailer.php
// interesting to note that only FILTER_VALIDATE_EMAIL is used, FILTER_SANITIZE_EMAIL is not used
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else {
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
public function SecureHeader($str) { return trim(str_replace(array("\r", "\n"), '', $str)); }
// PEAR Mail
function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] = preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', null, $value);
}
}
Mike | pear | injection | protection | phpmail | spoofing | null | open | Protecting PHP Mail / Contact Form
===
Ah the joys, 9 million pieces of advice, guidance and code and not one agrees with another. So I'm trying to get to the point at which I can be confident that the way I've chosen to protect my contact form is robust.
I spent some time reading around and checking out the source for PEAR Mail and PHP Mailer and this is what I've managed to surmise - bearing in mind I am a beginner in most things and definitely in PHP, regex etc. (and essentially at zero when it comes to RFC822, SMTP etc. etc.)
(*What I really want to understand (rather than simply solve) is how to best protect a web contact form from being used maliciously.*)
Based on my limited understanding, one approach might be this - so, is it good, bad, misleading, wrong or (and this would be a surprise) not half bad?
1. First use filter_var twice, once with FILTER_SANITIZE_EMAIL and then FILTER_VALIDATE_EMAIL on the from address only (since we supply the to address)
2. Optionally use the PHP Mailer regex as belt and braces, again on the from address only -> `return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\``\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\``\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);`
3. Optionally test user data such as subject, name etc. (anything that goes in the header) with the regex from phundamentals -> `function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}`
4. Then build the headers array and use string replacement or `preg_replace` to remove line endings
5. This could be as simple as the PHP Mailer string replace -> `("\r", "\n")` or the more 'complex' PEAR Mail preg_replace -> `=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i` - which appears to define extra descriptions of an EOL - for PHP v5+, could use `str_ireplace` instead of `preg_replace`
For reference here are the notes I made that led to my uninformed and speculative ideas above:
// Functions found from various sources
// www.nyphp.org/phundamentals/8_Preventing-Email-Header-Injection
// Pattern for filtering email addresses -- '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i'
// Pattern for filtering fields such as names -- '/^[a-z0-9()\/\'":\*+|,.; \- !?&#$@]{2,75}$/i'
function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}
// www.dreamincode.net/forums/topic/228389-preventing-php-mail-header-injections/
$reply_to = filter_var($reply_to, FILTER_VALIDATE_EMAIL); if(!$reply_to) {...}
function sanitize(&$array) { foreach($array as &$data) $data = str_replace(array("\r", "\n", "%0a", "%0d"), '', stripslashes($data)); } }
// PHP Mailer
// code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.phpmailer.php
// interesting to note that only FILTER_VALIDATE_EMAIL is used, FILTER_SANITIZE_EMAIL is not used
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else {
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
public function SecureHeader($str) { return trim(str_replace(array("\r", "\n"), '', $str)); }
// PEAR Mail
function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] = preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', null, $value);
}
}
Mike | 0 |
11,373,083 | 07/07/2012 07:18:00 | 1,417,178 | 05/25/2012 10:35:39 | 1 | 0 | Dice Permutation without Repetition | Good day.. How can I reformat my existing code to list all possible permutations but without repetitions for example: I've input 3 dices and if there is already a combination of 1,1,2 .. 2,1,1 would not be accepted anymore and so on .. I cannot think anymore of any possible solutions because I'am not good in math .. Thanks in advance!
Below is my code:
string[] Permutate(int input)
{
string[] dice;
int numberOfDice = input;
const int diceFace = 6;
dice = new string[(int)Math.Pow(diceFace, numberOfDice)];
int indexNumber = (int)Math.Pow(diceFace, numberOfDice);
int range = (int)Math.Pow(diceFace, numberOfDice) / 6;
int diceNumber = 1;
int counter = 0;
for (int i = 1; i <= indexNumber; i++)
{
if (range != 0)
{
dice[i - 1] += diceNumber + " ";
counter++;
if (counter == range)
{
counter = 0;
diceNumber++;
}
if (i == indexNumber)
{
range /= 6;
i = 0;
}
if (diceNumber == 7)
{
diceNumber = 1;
}
}
Thread.Sleep(1);
}
return dice;
} | c# | null | null | null | null | null | open | Dice Permutation without Repetition
===
Good day.. How can I reformat my existing code to list all possible permutations but without repetitions for example: I've input 3 dices and if there is already a combination of 1,1,2 .. 2,1,1 would not be accepted anymore and so on .. I cannot think anymore of any possible solutions because I'am not good in math .. Thanks in advance!
Below is my code:
string[] Permutate(int input)
{
string[] dice;
int numberOfDice = input;
const int diceFace = 6;
dice = new string[(int)Math.Pow(diceFace, numberOfDice)];
int indexNumber = (int)Math.Pow(diceFace, numberOfDice);
int range = (int)Math.Pow(diceFace, numberOfDice) / 6;
int diceNumber = 1;
int counter = 0;
for (int i = 1; i <= indexNumber; i++)
{
if (range != 0)
{
dice[i - 1] += diceNumber + " ";
counter++;
if (counter == range)
{
counter = 0;
diceNumber++;
}
if (i == indexNumber)
{
range /= 6;
i = 0;
}
if (diceNumber == 7)
{
diceNumber = 1;
}
}
Thread.Sleep(1);
}
return dice;
} | 0 |
11,373,094 | 07/07/2012 07:19:44 | 997,625 | 10/16/2011 08:23:12 | 18 | 0 | Binding Data to aspxgridview editform controls | I have created a custom editform for my aspxgrdiview.I want to bind data from data base to edit form in edit mode.
<SettingsEditing Mode="PopupEditForm" PopupEditFormModal="True" PopupEditFormWidth="500px" />
<Templates>
<EditForm>
<div>
<table>
<tr>
<td style="width: 150px">
Name
</td>
<td style="width: 200px">
<dx:ASPxTextBox ID="txtName" runat="server" Width="170px">
</dx:ASPxTextBox>
</td>
</tr>
<tr>
<td>
Status
</td>
<td>
<dx:ASPxRadioButtonList ID="LstStatus" runat="server" ClientIDMode="AutoID" RepeatDirection="Horizontal">
<Items>
<dx:ListEditItem Text="Enabled" Value="E" />
<dx:ListEditItem Text="Disabled" Value="D" />
</Items>
</dx:ASPxRadioButtonList>
</td>
</tr>
</table>
<div style="text-align: right; padding: 2px 2px 2px 2px">
<dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
runat="server"></dx:ASPxGridViewTemplateReplacement>
<dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
runat="server"></dx:ASPxGridViewTemplateReplacement>
</div>
</div>
</EditForm>
</Templates>
In my grid StartRowEditing, I have given as below.but data is not showing in edit form.
int RolId = Convert.ToInt32(e.EditingKeyValue);
UserRoles URoles = UserRepository.GetRole(RolId );
if (URoles != null)
{
ASPxTextBox Txtname = (ASPxTextBox)grdRoles.FindEditFormTemplateControl("txtName");
ASPxRadioButtonList rlst = (ASPxRadioButtonList)grdRoles.FindEditFormTemplateControl("LstStatus");
txtName.Text = URoles.RoleName;
rlst.Value = URoles.RoleStatus;
}
Thanks in advance. | asp.net | devexpress | null | null | null | null | open | Binding Data to aspxgridview editform controls
===
I have created a custom editform for my aspxgrdiview.I want to bind data from data base to edit form in edit mode.
<SettingsEditing Mode="PopupEditForm" PopupEditFormModal="True" PopupEditFormWidth="500px" />
<Templates>
<EditForm>
<div>
<table>
<tr>
<td style="width: 150px">
Name
</td>
<td style="width: 200px">
<dx:ASPxTextBox ID="txtName" runat="server" Width="170px">
</dx:ASPxTextBox>
</td>
</tr>
<tr>
<td>
Status
</td>
<td>
<dx:ASPxRadioButtonList ID="LstStatus" runat="server" ClientIDMode="AutoID" RepeatDirection="Horizontal">
<Items>
<dx:ListEditItem Text="Enabled" Value="E" />
<dx:ListEditItem Text="Disabled" Value="D" />
</Items>
</dx:ASPxRadioButtonList>
</td>
</tr>
</table>
<div style="text-align: right; padding: 2px 2px 2px 2px">
<dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
runat="server"></dx:ASPxGridViewTemplateReplacement>
<dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
runat="server"></dx:ASPxGridViewTemplateReplacement>
</div>
</div>
</EditForm>
</Templates>
In my grid StartRowEditing, I have given as below.but data is not showing in edit form.
int RolId = Convert.ToInt32(e.EditingKeyValue);
UserRoles URoles = UserRepository.GetRole(RolId );
if (URoles != null)
{
ASPxTextBox Txtname = (ASPxTextBox)grdRoles.FindEditFormTemplateControl("txtName");
ASPxRadioButtonList rlst = (ASPxRadioButtonList)grdRoles.FindEditFormTemplateControl("LstStatus");
txtName.Text = URoles.RoleName;
rlst.Value = URoles.RoleStatus;
}
Thanks in advance. | 0 |
11,373,095 | 07/07/2012 07:19:53 | 996,366 | 10/15/2011 00:39:03 | 92 | 2 | How to split strings at specific intervals to arrays in javascript | how to split strings at specific interveals to arrays in javascript
for example: split this string into 4 characters (including space and characters)
this is an example should be split,numbers(123),space,characters also included
to
this ------> 1st array
is ------> 2nd array
an ------> 3rd array
exam ------> 4th array
ple ------> 5th array
shou ------> 6th array ............ etc till.....
..ed ------> last array | javascript-events | split | null | null | null | null | open | How to split strings at specific intervals to arrays in javascript
===
how to split strings at specific interveals to arrays in javascript
for example: split this string into 4 characters (including space and characters)
this is an example should be split,numbers(123),space,characters also included
to
this ------> 1st array
is ------> 2nd array
an ------> 3rd array
exam ------> 4th array
ple ------> 5th array
shou ------> 6th array ............ etc till.....
..ed ------> last array | 0 |
11,373,097 | 07/07/2012 07:20:06 | 245,493 | 01/07/2010 12:11:40 | 150 | 11 | faking xmlhttprequests with casperjs | I'm writing end-to-end tests with casperjs and would like to fake ajax server responses
I've came up with the idea of including a simple script that mocks the xmlhttprequest object and would always return my expected results, like the following
var ajax_requests = [
['GET', '/jobs', JSON.stringify(jobs)]
], stubs = stubs || {};
function setup_ajax(){
stubs.server = sinon.fakeServer.create();
_.each(ajax_requests, function(r){
//r[1] = "http://localhost:8000" + r[1]
r[2] = [200, { "Content-Type": "application/json" }, r[2]]
stubs.server.respondWith.apply(stubs.server, r)
})
stubs.server.autoRespond = true;
stubs.server.autoRespondAfter = 2;
}
Then I call `setup_ajax` in my casper test like
casper.then(function(){
this.evaluate(setup_ajax)
}
but seemingly future ajax requests still avoid my xmlhttprequest implementation.
I've tried running setup_ajax on the fly, using $.ready() and having it called from casper too, but neither of these worked
More interestingly, checking for objects' existence strangely fails.
function setup_ajax(){
return typeof(sinon)
}
casper.then(function(){
var x = this.evaluate(setup_ajax)
casper.log(x) // logs 'null'
}
But sinon is properly included, at least casper did not cause any errors when I've made some calls to it outside the setup_ajax function, but caused error when I deliberately had sinon excluded.
Do you have any ideas on mocking xmlhttprequests under casperjs? | javascript | testing | mocking | sinon | casperjs | null | open | faking xmlhttprequests with casperjs
===
I'm writing end-to-end tests with casperjs and would like to fake ajax server responses
I've came up with the idea of including a simple script that mocks the xmlhttprequest object and would always return my expected results, like the following
var ajax_requests = [
['GET', '/jobs', JSON.stringify(jobs)]
], stubs = stubs || {};
function setup_ajax(){
stubs.server = sinon.fakeServer.create();
_.each(ajax_requests, function(r){
//r[1] = "http://localhost:8000" + r[1]
r[2] = [200, { "Content-Type": "application/json" }, r[2]]
stubs.server.respondWith.apply(stubs.server, r)
})
stubs.server.autoRespond = true;
stubs.server.autoRespondAfter = 2;
}
Then I call `setup_ajax` in my casper test like
casper.then(function(){
this.evaluate(setup_ajax)
}
but seemingly future ajax requests still avoid my xmlhttprequest implementation.
I've tried running setup_ajax on the fly, using $.ready() and having it called from casper too, but neither of these worked
More interestingly, checking for objects' existence strangely fails.
function setup_ajax(){
return typeof(sinon)
}
casper.then(function(){
var x = this.evaluate(setup_ajax)
casper.log(x) // logs 'null'
}
But sinon is properly included, at least casper did not cause any errors when I've made some calls to it outside the setup_ajax function, but caused error when I deliberately had sinon excluded.
Do you have any ideas on mocking xmlhttprequests under casperjs? | 0 |
11,373,100 | 07/07/2012 07:20:29 | 753,341 | 05/14/2011 05:48:17 | 3,725 | 112 | How to ensure Singleton is not destroyed prematurely? | In my project, I'm working with about 4 singletons made the Scott Meyer's way. One of them:
LevelRenderer& LevelRenderer::Instance()
{
static LevelRenderer obj;
return obj;
}
Now two of those Singletons, `LevelRenderer` and `LevelSymbolTable` interact with each other. For example, in this method:
void LevelRenderer::Parse(std::vector<std::string>& lineSet)
{
LevelSymbolTable& table = LevelSymbolTable::Instance();
/** removed code which was irrelevant **/
// for each line in lineSet
BOOST_FOREACH(std::string line, lineSet)
{
// for each character in the line
BOOST_FOREACH(char sym, line)
{
/** code... **/
// otherwise
else
{
sf::Sprite spr;
// Used LevelSymbolTable's Instance here...
table.GenerateSpriteFromSymbol(spr, sym);
// ^ Inside LevelRenderer
/** irrelevant code... **/
}
}
}
}
Now, although the problem hasn't occurred yet. The thing I am afraid of is, what if the `LevelSymbolTable` instance is already destroyed _before_ I call `GenerateSpriteFromSymbol` ?
Since I used the Scott Meyer way, the Singleton's instance was allocated by the stack. Hence is is guaranteed to be destroyed using the _last created first destroyed_ rule. Now if `LevelSymbolTable`'s Instance is created _after_ `LevelRenderer`'s Instance, it will be destroyed _before_ `LevelRenderer`'s Instance, right? So then, if I call a method of `LevelSymbolTable` inside `LevelRenderer` (especially in `LevelRenderer`'s destructor), I will be treading on undefined behaviour land.
As I said before, this problem hasn't actually occurred while debugging, and is purely my assumption and guess-work. So, is my conclusion correct? Is `LevelSymbolTable` liable to be destroyed before `LevelRenderer`. If so, is there any way out of this mess? | c++ | memory-management | singleton | stack | destructor | null | open | How to ensure Singleton is not destroyed prematurely?
===
In my project, I'm working with about 4 singletons made the Scott Meyer's way. One of them:
LevelRenderer& LevelRenderer::Instance()
{
static LevelRenderer obj;
return obj;
}
Now two of those Singletons, `LevelRenderer` and `LevelSymbolTable` interact with each other. For example, in this method:
void LevelRenderer::Parse(std::vector<std::string>& lineSet)
{
LevelSymbolTable& table = LevelSymbolTable::Instance();
/** removed code which was irrelevant **/
// for each line in lineSet
BOOST_FOREACH(std::string line, lineSet)
{
// for each character in the line
BOOST_FOREACH(char sym, line)
{
/** code... **/
// otherwise
else
{
sf::Sprite spr;
// Used LevelSymbolTable's Instance here...
table.GenerateSpriteFromSymbol(spr, sym);
// ^ Inside LevelRenderer
/** irrelevant code... **/
}
}
}
}
Now, although the problem hasn't occurred yet. The thing I am afraid of is, what if the `LevelSymbolTable` instance is already destroyed _before_ I call `GenerateSpriteFromSymbol` ?
Since I used the Scott Meyer way, the Singleton's instance was allocated by the stack. Hence is is guaranteed to be destroyed using the _last created first destroyed_ rule. Now if `LevelSymbolTable`'s Instance is created _after_ `LevelRenderer`'s Instance, it will be destroyed _before_ `LevelRenderer`'s Instance, right? So then, if I call a method of `LevelSymbolTable` inside `LevelRenderer` (especially in `LevelRenderer`'s destructor), I will be treading on undefined behaviour land.
As I said before, this problem hasn't actually occurred while debugging, and is purely my assumption and guess-work. So, is my conclusion correct? Is `LevelSymbolTable` liable to be destroyed before `LevelRenderer`. If so, is there any way out of this mess? | 0 |
11,373,101 | 07/07/2012 07:20:29 | 1,395,994 | 05/15/2012 11:20:13 | 15 | 0 | how to set a Single key Mnemonic in button in java | I am working on a project and i want to set Mnemonic on buttons. But the problem is Mnemonic works on pairing key example (Alt+F) etc. But i want it to be on single key.
Pls help.. | java | swing | null | null | null | null | open | how to set a Single key Mnemonic in button in java
===
I am working on a project and i want to set Mnemonic on buttons. But the problem is Mnemonic works on pairing key example (Alt+F) etc. But i want it to be on single key.
Pls help.. | 0 |
11,401,433 | 07/09/2012 19:06:32 | 765,015 | 05/22/2011 17:16:34 | 155 | 0 | Python Close Shell with no popup | I am looking for way to exit the python shell without the Kill? popup
print ("Hello")
print ("Press any key to exit")
ex = raw_input ("")
exit
I am talking about the python shell for windows not the command prompt.
This is the popup I want to ignore and close the program after the user has hit any key.
![enter image description here][1]
[1]: http://i.stack.imgur.com/hGS1a.jpg | python | close | null | null | null | null | open | Python Close Shell with no popup
===
I am looking for way to exit the python shell without the Kill? popup
print ("Hello")
print ("Press any key to exit")
ex = raw_input ("")
exit
I am talking about the python shell for windows not the command prompt.
This is the popup I want to ignore and close the program after the user has hit any key.
![enter image description here][1]
[1]: http://i.stack.imgur.com/hGS1a.jpg | 0 |
11,401,434 | 07/09/2012 19:06:34 | 411,141 | 08/04/2010 18:33:19 | 1,060 | 32 | GIT Packfile claims to have more objects, inaccessable | hey guys I'm running into multiple errors about my packfile that seem pretty insidious,
this is a pretty scary deal since this is a live site and am not sure how to handle it,
maybe someone can talk me through it, here's whats going on.
It seems that I have a missing object, and also the count of my packfile is bad?
remote: Counting objects: 25733, done.
remote: Compressing objects: 100% (12458/12458), done.
remote: Total 19185 (delta 6914), reused 17995 (delta 6535)
Receiving objects: 100% (19185/19185), 1.69 GiB | 465 KiB/s, done.
Resolving deltas: 100% (6914/6914), completed with 1058 local objects.
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: unable to find e17196d88ae91dea07b4d61716b91dac581fb131
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
fatal: object e17196d88ae91dea07b4d61716b91dac581fb131 not found
| git | object | git-pull | null | null | null | open | GIT Packfile claims to have more objects, inaccessable
===
hey guys I'm running into multiple errors about my packfile that seem pretty insidious,
this is a pretty scary deal since this is a live site and am not sure how to handle it,
maybe someone can talk me through it, here's whats going on.
It seems that I have a missing object, and also the count of my packfile is bad?
remote: Counting objects: 25733, done.
remote: Compressing objects: 100% (12458/12458), done.
remote: Total 19185 (delta 6914), reused 17995 (delta 6535)
Receiving objects: 100% (19185/19185), 1.69 GiB | 465 KiB/s, done.
Resolving deltas: 100% (6914/6914), completed with 1058 local objects.
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: unable to find e17196d88ae91dea07b4d61716b91dac581fb131
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
fatal: object e17196d88ae91dea07b4d61716b91dac581fb131 not found
| 0 |
11,401,435 | 07/09/2012 19:06:34 | 1,322,429 | 04/09/2012 17:52:40 | 3 | 0 | DoubleClick Studio V2 AS3 | Hello Stack Overflow community,
I am using Google's DoubleClick Studio Version 2 AS3.
I am using Flash CS5.5.
I've read through DoubleClicks' material on how to build a banner ad using Rich Media, in other words, using video.
I have a parent swf and a child swf. The parent loads the child swf after the webpage is finished loading.
My child swf is organized as such:
Scene 1 with Layer 1.
Layer 1 has a MovieClip on the stage that contains all my banner elements (Video player, video player buttons, text, background, an image, and CTA button again these are using DoubleClick Studio components). This MovieClip has an instance name of "Spread_1". This MovieClip contains the Video player Advanced Component.
I understand the Video Player Advanced component. I understand what to place in the component inspector with one exception, when I'm in "Video end options" I have three radio button options plus a fourth option that calls a function. In the textfield I placed this function "lastframe()"
In an actions layer I placed the code to the function that's called by the Video Player Advanced Component. The code to the function is this:
**function lastFrame(){
gotoAndStop(2, "Spread_1")
}**
This function is located in the first frame of the MovieClip "Spread_1". My intent is when the video has stopped playing I want to go to frame 2.
When I test the banner I get this output:
**[0.01] Enabler: Simulating page load.
[2.08] Enabler: Page loaded.
[2.45] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_PLAY
[2.45] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_VIEW_TIMER
[7.54] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_MIDPOINT
[12.83] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_COMPLETE
[12.83] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_VIEW_TIMER
ArgumentError: Error #2108: Scene Spread_1 was not found.
at flash.display::MovieClip/gotoAndStop()
at H100_fla::Spread_1_1/lastFrame()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.google.ads.studio.utils::FunctionUtils$/invokeStringAsFunction()
at MethodInfo-37()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.google.ads.studio.video::EnhancedVideoController/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.google.ads.studio.video::VideoEventDispatcher/dispatch()
at com.google.ads.studio.video::VideoEventDispatcher/monitorPlayHead()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()**
I don't understand the error and I'm a relative novice at Using DoubleClick Studio Version2 AS3.
Thank you for any help, it's greatly appreciated. | actionscript-3 | flash | null | null | null | null | open | DoubleClick Studio V2 AS3
===
Hello Stack Overflow community,
I am using Google's DoubleClick Studio Version 2 AS3.
I am using Flash CS5.5.
I've read through DoubleClicks' material on how to build a banner ad using Rich Media, in other words, using video.
I have a parent swf and a child swf. The parent loads the child swf after the webpage is finished loading.
My child swf is organized as such:
Scene 1 with Layer 1.
Layer 1 has a MovieClip on the stage that contains all my banner elements (Video player, video player buttons, text, background, an image, and CTA button again these are using DoubleClick Studio components). This MovieClip has an instance name of "Spread_1". This MovieClip contains the Video player Advanced Component.
I understand the Video Player Advanced component. I understand what to place in the component inspector with one exception, when I'm in "Video end options" I have three radio button options plus a fourth option that calls a function. In the textfield I placed this function "lastframe()"
In an actions layer I placed the code to the function that's called by the Video Player Advanced Component. The code to the function is this:
**function lastFrame(){
gotoAndStop(2, "Spread_1")
}**
This function is located in the first frame of the MovieClip "Spread_1". My intent is when the video has stopped playing I want to go to frame 2.
When I test the banner I get this output:
**[0.01] Enabler: Simulating page load.
[2.08] Enabler: Page loaded.
[2.45] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_PLAY
[2.45] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_VIEW_TIMER
[7.54] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_MIDPOINT
[12.83] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_COMPLETE
[12.83] Enabler: Video event for: 'cakePlayer': EVENT_VIDEO_VIEW_TIMER
ArgumentError: Error #2108: Scene Spread_1 was not found.
at flash.display::MovieClip/gotoAndStop()
at H100_fla::Spread_1_1/lastFrame()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.google.ads.studio.utils::FunctionUtils$/invokeStringAsFunction()
at MethodInfo-37()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.google.ads.studio.video::EnhancedVideoController/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.google.ads.studio.video::VideoEventDispatcher/dispatch()
at com.google.ads.studio.video::VideoEventDispatcher/monitorPlayHead()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()**
I don't understand the error and I'm a relative novice at Using DoubleClick Studio Version2 AS3.
Thank you for any help, it's greatly appreciated. | 0 |
11,401,447 | 07/09/2012 19:07:09 | 1,399,176 | 05/16/2012 16:44:17 | 34 | 3 | Where should I convert my entities to DTO's? | My architecture looks like this:
Domain
Entities
Interfaces
DTO's
Infrastructure
ORM
Repositories
Services
Web Services
I'm wanting to use AutoMapper to convert it. I would like my service layer to only know about DTO's. So I'm guessing I would have my Interfaces and my Repositories return the converted DTO. As for the other direction, I would assume that my Repositories will take DTO's and convert to Entities? Am I on the correct path here or am I in left field? | c# | domain-driven-design | null | null | null | null | open | Where should I convert my entities to DTO's?
===
My architecture looks like this:
Domain
Entities
Interfaces
DTO's
Infrastructure
ORM
Repositories
Services
Web Services
I'm wanting to use AutoMapper to convert it. I would like my service layer to only know about DTO's. So I'm guessing I would have my Interfaces and my Repositories return the converted DTO. As for the other direction, I would assume that my Repositories will take DTO's and convert to Entities? Am I on the correct path here or am I in left field? | 0 |
11,660,387 | 07/25/2012 23:49:13 | 8,426 | 09/15/2008 15:59:29 | 673 | 21 | Query to find possible columns that should be foreign keys? | I am looking for a query to help with a cleanup of an old database that doesn't have many relationships where it should. I don't need it to be perfect, just to help guide me in beginning cleanup and starting to enforce data integrity.
I am assuming that all tables have the proper primary key and that a column in a related table has the same name.
Theoretically speaking I could have three tables, one which has a composite key (I wouldn't choose to design the db like this, but am limited in the cleanup of it and these types of composite/primary/foreign keys are common):
Case.CaseId (PK)
<br />Workstep.WorkstepId (PK)
<br />Workstep.CaseId (PK,FK)
<br />WorkQueue.CaseId
What I would like to be able to do is run a query and come up with results that give me something like table name, column name, and foreign key, e.g.:
TABLE NAME, COLUMN NAME, PRIMARY KEY
<br />WorkQueue, CaseId, Case.CaseId
See the SQL I am using below but it is returning any primary key, even ones that are both a primary key but also are part of a foreign key. Using my example again, instead of returning 1 row I get 2:
TABLE NAME, COLUMN NAME, PRIMARY KEY
<br />WorkQueue, CaseId, Workstep.CaseId
<br />WorkQueue, CaseId, Case.CaseId
SELECT
SubqueryAllPotentialForeignKeys.TABLE_NAME
,SubqueryAllPotentialForeignKeys.COLUMN_NAME
,(PrimaryKeys.TABLE_NAME + '.' + PrimaryKeys.COLUMN_NAME) as 'Possible Primary Key'
--all potential foreign keys (column name matches another column name but there is no reference from this column anywhere else)
FROM
(
SELECT
INFORMATION_SCHEMA.COLUMNS.TABLE_NAME
,INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
--only get columns that are in multiple tables
INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME IN
(
SELECT COLUMN_NAME FROM
(SELECT COLUMN_NAME, COUNT(COLUMN_NAME) AS ColNameCount FROM INFORMATION_SCHEMA.COLUMNS GROUP BY COLUMN_NAME) AS SubQueryColumns
WHERE ColNameCount > 1
)
--only get the table.column if not part of a foreign or primary key
EXCEPT
(
SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
)
) AS SubqueryAllPotentialForeignKeys
LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS PrimaryKeys ON
SubqueryAllPotentialForeignKeys.COLUMN_NAME = PrimaryKeys.COLUMN_NAME
--when finding possible keys for our columns that don't have references, limit to primary keys
WHERE
PrimaryKeys.CONSTRAINT_NAME LIKE '%PK_%'
ORDER BY TABLE_NAME, COLUMN_NAME
| sql-server | tsql | foreign-keys | relational-database | primary-key | null | open | Query to find possible columns that should be foreign keys?
===
I am looking for a query to help with a cleanup of an old database that doesn't have many relationships where it should. I don't need it to be perfect, just to help guide me in beginning cleanup and starting to enforce data integrity.
I am assuming that all tables have the proper primary key and that a column in a related table has the same name.
Theoretically speaking I could have three tables, one which has a composite key (I wouldn't choose to design the db like this, but am limited in the cleanup of it and these types of composite/primary/foreign keys are common):
Case.CaseId (PK)
<br />Workstep.WorkstepId (PK)
<br />Workstep.CaseId (PK,FK)
<br />WorkQueue.CaseId
What I would like to be able to do is run a query and come up with results that give me something like table name, column name, and foreign key, e.g.:
TABLE NAME, COLUMN NAME, PRIMARY KEY
<br />WorkQueue, CaseId, Case.CaseId
See the SQL I am using below but it is returning any primary key, even ones that are both a primary key but also are part of a foreign key. Using my example again, instead of returning 1 row I get 2:
TABLE NAME, COLUMN NAME, PRIMARY KEY
<br />WorkQueue, CaseId, Workstep.CaseId
<br />WorkQueue, CaseId, Case.CaseId
SELECT
SubqueryAllPotentialForeignKeys.TABLE_NAME
,SubqueryAllPotentialForeignKeys.COLUMN_NAME
,(PrimaryKeys.TABLE_NAME + '.' + PrimaryKeys.COLUMN_NAME) as 'Possible Primary Key'
--all potential foreign keys (column name matches another column name but there is no reference from this column anywhere else)
FROM
(
SELECT
INFORMATION_SCHEMA.COLUMNS.TABLE_NAME
,INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
--only get columns that are in multiple tables
INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME IN
(
SELECT COLUMN_NAME FROM
(SELECT COLUMN_NAME, COUNT(COLUMN_NAME) AS ColNameCount FROM INFORMATION_SCHEMA.COLUMNS GROUP BY COLUMN_NAME) AS SubQueryColumns
WHERE ColNameCount > 1
)
--only get the table.column if not part of a foreign or primary key
EXCEPT
(
SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
)
) AS SubqueryAllPotentialForeignKeys
LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS PrimaryKeys ON
SubqueryAllPotentialForeignKeys.COLUMN_NAME = PrimaryKeys.COLUMN_NAME
--when finding possible keys for our columns that don't have references, limit to primary keys
WHERE
PrimaryKeys.CONSTRAINT_NAME LIKE '%PK_%'
ORDER BY TABLE_NAME, COLUMN_NAME
| 0 |
11,660,262 | 07/25/2012 23:35:23 | 1,422,200 | 05/28/2012 17:35:00 | 2,332 | 156 | Applying Custom Metadata to Files | I've been trying to figure out a way to give files custom metadata. An example of this would be giving files tags, but that's not the only sort of custom metadata I want to apply. I've looked at a couple posts like these ones - http://stackoverflow.com/questions/10699494/adding-custom-metadata-to-jpeg-files, http://stackoverflow.com/questions/11266687/can-i-add-custom-metadata-to-files, http://stackoverflow.com/questions/9876956/set-custom-metadata-to-files-of-any-type - but they all deal with languages other then Objective-C, which is the language that I'm trying to use for the custom metadata. I've looked at Apple's documentation like the [File Metadata Attributes Reference][1] and the [NSMetadataItem Class Reference][2], but I haven't found anything related to custom metadata.
My question basically is, is it possible to apply custom metadata to files and if so, how would I go about doing it?
Thanks in advance!
[1]: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/MetadataAttributesRef/MetadataAttrRef.html
[2]: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMetadataItem_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMetadataItem | objective-c | file | metadata | customization | null | null | open | Applying Custom Metadata to Files
===
I've been trying to figure out a way to give files custom metadata. An example of this would be giving files tags, but that's not the only sort of custom metadata I want to apply. I've looked at a couple posts like these ones - http://stackoverflow.com/questions/10699494/adding-custom-metadata-to-jpeg-files, http://stackoverflow.com/questions/11266687/can-i-add-custom-metadata-to-files, http://stackoverflow.com/questions/9876956/set-custom-metadata-to-files-of-any-type - but they all deal with languages other then Objective-C, which is the language that I'm trying to use for the custom metadata. I've looked at Apple's documentation like the [File Metadata Attributes Reference][1] and the [NSMetadataItem Class Reference][2], but I haven't found anything related to custom metadata.
My question basically is, is it possible to apply custom metadata to files and if so, how would I go about doing it?
Thanks in advance!
[1]: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/MetadataAttributesRef/MetadataAttrRef.html
[2]: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMetadataItem_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMetadataItem | 0 |
11,660,391 | 07/25/2012 23:49:57 | 965,986 | 09/26/2011 23:19:59 | 6 | 0 | C# convert JSON result | I am getting this JSON back from Box.com:
{
"total_count": 2,
"entries": [
{
"type": "file",
"id": "2615240421",
"sequence_id": "0",
"name": "successful file upload.png",
"description": null,
"size": 19586,
"path": "/Hey Hey Whats Goin On/successful file upload.png",
"path_id": "/316877053/2615240421",
"created_at": "2012-07-11T11:54:21-07:00",
"modified_at": "2012-07-11T11:54:21-07:00",
"etag": null,
"created_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"modified_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"owned_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"shared_link": null,
"parent": {
"type": "folder",
"id": "316877053",
"sequence_id": "0",
"name": "Hey Hey Whats Goin On"
}
},
{
"type": "file",
"id": "2615240431",
"sequence_id": "0",
"name": "a whole lot of shit just happenedjson.png",
"description": null,
"size": 128063,
"path": "/Hey Hey Whats Goin On/a whole lot of shit just happenedjson.png",
"path_id": "/316877053/2615240431",
"created_at": "2012-07-11T11:54:21-07:00",
"modified_at": "2012-07-11T11:54:21-07:00",
"sha1": null,
"created_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"modified_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"owned_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"shared_link": null,
"parent": {
"type": "folder",
"id": "316877053",
"sequence_id": "0",
"name": "Hey Hey Whats Goin On"
}
}
]
}
I need to get the "Modified" information for each file. Not sure how to do this in .NET. I'm used to parsing XML. I've seen a few examples on Stack, but they are usually shallow objects. Not sure about deeper objects.
Help?
Thanks
| json | parsing | null | null | null | null | open | C# convert JSON result
===
I am getting this JSON back from Box.com:
{
"total_count": 2,
"entries": [
{
"type": "file",
"id": "2615240421",
"sequence_id": "0",
"name": "successful file upload.png",
"description": null,
"size": 19586,
"path": "/Hey Hey Whats Goin On/successful file upload.png",
"path_id": "/316877053/2615240421",
"created_at": "2012-07-11T11:54:21-07:00",
"modified_at": "2012-07-11T11:54:21-07:00",
"etag": null,
"created_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"modified_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"owned_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"shared_link": null,
"parent": {
"type": "folder",
"id": "316877053",
"sequence_id": "0",
"name": "Hey Hey Whats Goin On"
}
},
{
"type": "file",
"id": "2615240431",
"sequence_id": "0",
"name": "a whole lot of shit just happenedjson.png",
"description": null,
"size": 128063,
"path": "/Hey Hey Whats Goin On/a whole lot of shit just happenedjson.png",
"path_id": "/316877053/2615240431",
"created_at": "2012-07-11T11:54:21-07:00",
"modified_at": "2012-07-11T11:54:21-07:00",
"sha1": null,
"created_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"modified_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"owned_by": {
"type": "user",
"id": "181757341",
"name": "sean test",
"login": "[email protected]"
},
"shared_link": null,
"parent": {
"type": "folder",
"id": "316877053",
"sequence_id": "0",
"name": "Hey Hey Whats Goin On"
}
}
]
}
I need to get the "Modified" information for each file. Not sure how to do this in .NET. I'm used to parsing XML. I've seen a few examples on Stack, but they are usually shallow objects. Not sure about deeper objects.
Help?
Thanks
| 0 |
11,660,392 | 07/25/2012 23:50:05 | 1,229,164 | 02/23/2012 19:05:55 | 24 | 0 | Selection Sort Java HW | public static void main(String[] args) {
int[] a = {34,17,23,35,45,9,1};
int[] sorted = new int[a.length];
int index = 0;//to hold index of smallest element in array
int cc = 0;
for(int j = a.length-1;j <= 0;j--){//beause every time there
if(a[index]>a[j]){
index = j;//if 17 is less then 34, then 1 becomes the index, ig 9 is less then 17, then 5 becomes index
sorted [cc] = a[index];
}
cc++;//DO I NEED TO DO SOMETING IN BETWEEN THE FOR LOOPS?
}
for (int c = 0; c< a.length; c++) {
System.out.print(sorted[c] + "," );
}
}
Please just dont solve it for me, i would like to understand it(which is why i didnt look at the other threads containing the solution). Well, i understand the logic of the selection sort. In this case, if 34 is greater than 17, then make the int index to whatever the index of 17 is, then copmare everything with 17.
Then when something is smaller then 17 (9 in this case), then make the int index hold the value of the index of 9, and once is does that,
sorted [0]= a[index], and you keep doing that until the array is finished sorting(that is why i did the for loop subtacting like thatbecause the lowest value is irrelevant each time the for loop executes again).
Thanks for your help! | java | sorting | selection | null | null | 07/27/2012 12:02:59 | not constructive | Selection Sort Java HW
===
public static void main(String[] args) {
int[] a = {34,17,23,35,45,9,1};
int[] sorted = new int[a.length];
int index = 0;//to hold index of smallest element in array
int cc = 0;
for(int j = a.length-1;j <= 0;j--){//beause every time there
if(a[index]>a[j]){
index = j;//if 17 is less then 34, then 1 becomes the index, ig 9 is less then 17, then 5 becomes index
sorted [cc] = a[index];
}
cc++;//DO I NEED TO DO SOMETING IN BETWEEN THE FOR LOOPS?
}
for (int c = 0; c< a.length; c++) {
System.out.print(sorted[c] + "," );
}
}
Please just dont solve it for me, i would like to understand it(which is why i didnt look at the other threads containing the solution). Well, i understand the logic of the selection sort. In this case, if 34 is greater than 17, then make the int index to whatever the index of 17 is, then copmare everything with 17.
Then when something is smaller then 17 (9 in this case), then make the int index hold the value of the index of 9, and once is does that,
sorted [0]= a[index], and you keep doing that until the array is finished sorting(that is why i did the for loop subtacting like thatbecause the lowest value is irrelevant each time the for loop executes again).
Thanks for your help! | 4 |
11,660,393 | 07/25/2012 23:50:21 | 126,640 | 06/22/2009 02:10:24 | 165 | 8 | ProxyPassReverse and Load Balancing resulting in exposed Backend | I have 3 machines running httpd. Foo1 is primarily the load balancer and it is the host that should be displayed in urls etc. Foo2 is the backend primary server and Foo3 is the hot standby. The problem is that about half the time users who type in Foo1 into their address end up at Foo2/Foo1 instead. There are alot of users who have the Foo2 backend bookmarked and so I come to StackOverflow. Any help appreciated.
This is my virtual host config for Foo1 please let me know if I'm doing something wrong.
<VirtualHost *:80>
ServerName Foo1
<Proxy balancer://Foocluster>
#This is our primary Server
BalancerMember http://Foo2/Foo1
#This is our Hot Standby rsynced ever few hours.
BalancerMember http://Foo3/Foo1 status=+H
</Proxy>
ProxyPass / balancer://Foocluster/
ProxyPassReverse / balancer://Foocluster/
</VirtualHost>
Should I set RewriteEngine On ?
Server Info :
Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8l PHP/5.3.3 mod_fastcgi/2.4.2 mod_perl/2.0.4 Perl/v5.10.0 | apache | httpd | proxypass | null | null | null | open | ProxyPassReverse and Load Balancing resulting in exposed Backend
===
I have 3 machines running httpd. Foo1 is primarily the load balancer and it is the host that should be displayed in urls etc. Foo2 is the backend primary server and Foo3 is the hot standby. The problem is that about half the time users who type in Foo1 into their address end up at Foo2/Foo1 instead. There are alot of users who have the Foo2 backend bookmarked and so I come to StackOverflow. Any help appreciated.
This is my virtual host config for Foo1 please let me know if I'm doing something wrong.
<VirtualHost *:80>
ServerName Foo1
<Proxy balancer://Foocluster>
#This is our primary Server
BalancerMember http://Foo2/Foo1
#This is our Hot Standby rsynced ever few hours.
BalancerMember http://Foo3/Foo1 status=+H
</Proxy>
ProxyPass / balancer://Foocluster/
ProxyPassReverse / balancer://Foocluster/
</VirtualHost>
Should I set RewriteEngine On ?
Server Info :
Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8l PHP/5.3.3 mod_fastcgi/2.4.2 mod_perl/2.0.4 Perl/v5.10.0 | 0 |
11,660,394 | 07/25/2012 23:50:20 | 1,553,099 | 07/25/2012 23:38:49 | 1 | 0 | HOW TO USE IPHONE WITH USB CONNECT TO PC SSH | I know we can use itunnel to forward the device port on PC port. And than PC can ssh iphone. But my question is, can iphone use ssh connect to PC (ALSO WITH USB CONNECTION)? HOW TO DO THAT. | iphone | ios | ssh | usb | connect | 07/25/2012 23:53:41 | off topic | HOW TO USE IPHONE WITH USB CONNECT TO PC SSH
===
I know we can use itunnel to forward the device port on PC port. And than PC can ssh iphone. But my question is, can iphone use ssh connect to PC (ALSO WITH USB CONNECTION)? HOW TO DO THAT. | 2 |
11,594,354 | 07/21/2012 17:28:51 | 1,291,744 | 03/25/2012 20:01:01 | 173 | 0 | How to set up a countup timer only when the button press? | I am implementing a countup timer and I follow an example from StackoverFlow.
In my version, I will press the Begin button to start counting and the Stop button to stop.
But the problem is that the counting start immediately after i enter the activity.
Any idea how to make it the way i want?
public class StartActivity extends Activity
{
Button beginRecordingButton;
TextView timer;
long startTime;
long countup;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.startactivity);
beginRecordingButton = (Button) findViewById(R.id.BeginRecording);
timer = (TextView) findViewById(R.id.timer);
final Chronometer stopwatch = (Chronometer) findViewById(R.id.chrono);
startTime = SystemClock.elapsedRealtime();
stopwatch.setOnChronometerTickListener(listener);
beginRecordingButton.setOnClickListener(new OnClickListener()
{
int counter = 0;
public void onClick(View v)
{
if (counter % 2 == 0)
{
stopwatch.start();
beginRecordingButton.setText("Stop");
}
if (counter % 2 == 1)
{
stopwatch.stop();
beginRecordingButton.setText("Begin");
}
counter++; //counter is used for knowing it is stop or begin
}
});
}
private OnChronometerTickListener listener = new OnChronometerTickListener()
{
public void onChronometerTick(Chronometer chronometer)
{
String text;
countup = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
if(countup%60<10)
{
text = (countup/60) + ":0" + (countup%60);
}
else
{
text = (countup/60) + ":" + (countup%60);
}
timer.setText(text);
}
};
} | android | null | null | null | null | null | open | How to set up a countup timer only when the button press?
===
I am implementing a countup timer and I follow an example from StackoverFlow.
In my version, I will press the Begin button to start counting and the Stop button to stop.
But the problem is that the counting start immediately after i enter the activity.
Any idea how to make it the way i want?
public class StartActivity extends Activity
{
Button beginRecordingButton;
TextView timer;
long startTime;
long countup;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.startactivity);
beginRecordingButton = (Button) findViewById(R.id.BeginRecording);
timer = (TextView) findViewById(R.id.timer);
final Chronometer stopwatch = (Chronometer) findViewById(R.id.chrono);
startTime = SystemClock.elapsedRealtime();
stopwatch.setOnChronometerTickListener(listener);
beginRecordingButton.setOnClickListener(new OnClickListener()
{
int counter = 0;
public void onClick(View v)
{
if (counter % 2 == 0)
{
stopwatch.start();
beginRecordingButton.setText("Stop");
}
if (counter % 2 == 1)
{
stopwatch.stop();
beginRecordingButton.setText("Begin");
}
counter++; //counter is used for knowing it is stop or begin
}
});
}
private OnChronometerTickListener listener = new OnChronometerTickListener()
{
public void onChronometerTick(Chronometer chronometer)
{
String text;
countup = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
if(countup%60<10)
{
text = (countup/60) + ":0" + (countup%60);
}
else
{
text = (countup/60) + ":" + (countup%60);
}
timer.setText(text);
}
};
} | 0 |
11,594,355 | 07/21/2012 17:28:57 | 565,968 | 01/06/2011 19:34:37 | 4,339 | 90 | linq-to-sql SingleOrDefault return when null | I'm writing a linq-to-sql query and I'm loading an ID (a `bigint` in the database and a `long` in my code) from a table, something like this:
var SomeQuery = (from x in ...
select x.ID).SingleOrDefault();
When I get the result, I use `SingleOrDefault` in case the return is empty. Does that mean that if the result is empty the `SomeQuery` variable will be 0 or null?
Thanks. | c# | linq-to-sql | null | null | null | null | open | linq-to-sql SingleOrDefault return when null
===
I'm writing a linq-to-sql query and I'm loading an ID (a `bigint` in the database and a `long` in my code) from a table, something like this:
var SomeQuery = (from x in ...
select x.ID).SingleOrDefault();
When I get the result, I use `SingleOrDefault` in case the return is empty. Does that mean that if the result is empty the `SomeQuery` variable will be 0 or null?
Thanks. | 0 |
11,594,356 | 07/21/2012 17:29:07 | 1,542,996 | 07/21/2012 17:25:13 | 1 | 0 | Warning: mysqli::prepare() [mysqli.prepare]: | i have this problem
Warning: mysqli::prepare() [mysqli.prepare]: (42000/1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, keyword) VALUES (?,?,?,?)' at line 1 in D:\xampp\htdocs\Optimizer\login\submit.php on line 125
Help Please I have this problem while making link directory how to fix
if ($stmt = $mysqli->prepare("INSERT url (url, title, desc, keyword) VALUES (?,?,?,?)"))**==>>Line 125**
{
$stmt->bind_param("ssss", $input['url'], $input['title'],$input['desc'],$input['keyword']);
$stmt->execute();
$stmt->close();
how to fix it | php | null | null | null | null | null | open | Warning: mysqli::prepare() [mysqli.prepare]:
===
i have this problem
Warning: mysqli::prepare() [mysqli.prepare]: (42000/1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, keyword) VALUES (?,?,?,?)' at line 1 in D:\xampp\htdocs\Optimizer\login\submit.php on line 125
Help Please I have this problem while making link directory how to fix
if ($stmt = $mysqli->prepare("INSERT url (url, title, desc, keyword) VALUES (?,?,?,?)"))**==>>Line 125**
{
$stmt->bind_param("ssss", $input['url'], $input['title'],$input['desc'],$input['keyword']);
$stmt->execute();
$stmt->close();
how to fix it | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.