question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
6,219,743
6,219,877
non-blocking producer and consumer using .NET 2.0
In our scenario, the consumer takes at least half-a-second to complete a cycle of process (against a row in a data table). Producer produces at least 8 items in a second (no worries, we don't mind about the duration of a consuming). the shared data is simply a data table. we should never ask producer to wait (as it is ...
There is a great example of a producer/consumer queue using Monitors at this page under the "Producer/Consumer Queue" section. In order to synchronize access to the underlying data table, you can have a single consumer. That page is probably the best resource for threading in.NET on the net.
non-blocking producer and consumer using .NET 2.0 In our scenario, the consumer takes at least half-a-second to complete a cycle of process (against a row in a data table). Producer produces at least 8 items in a second (no worries, we don't mind about the duration of a consuming). the shared data is simply a data tabl...
TITLE: non-blocking producer and consumer using .NET 2.0 QUESTION: In our scenario, the consumer takes at least half-a-second to complete a cycle of process (against a row in a data table). Producer produces at least 8 items in a second (no worries, we don't mind about the duration of a consuming). the shared data is ...
[ "multithreading", "c#-2.0" ]
3
1
860
3
0
2011-06-02T20:03:00.810000
2011-06-02T20:17:28.137000
6,219,750
6,219,780
Copy sql server database using Entity Framework?
I'm having a problem with copying or scripting my database at a web host (which I need for use in a test application), and I'm not getting much help from their support. They don't seem to know what's wrong, but I can't do it because of some "access rights" problem. So for the time being I'm trying to think of a tempora...
You can copy your EF model and change the connection string. That should work fine.
Copy sql server database using Entity Framework? I'm having a problem with copying or scripting my database at a web host (which I need for use in a test application), and I'm not getting much help from their support. They don't seem to know what's wrong, but I can't do it because of some "access rights" problem. So fo...
TITLE: Copy sql server database using Entity Framework? QUESTION: I'm having a problem with copying or scripting my database at a web host (which I need for use in a test application), and I'm not getting much help from their support. They don't seem to know what's wrong, but I can't do it because of some "access righ...
[ "sql-server", "database", "entity-framework-4", "copy" ]
0
1
1,073
2
0
2011-06-02T20:04:23.923000
2011-06-02T20:07:26.200000
6,219,754
6,219,828
A couple simple XSLT changes
I'm new to XSLT so I believe that what I'm looking for is very basic. I'm starting with some XML like this: 10 v1 A Value 12 v2 Another Value I want to do 3 things with this: Filter so that I only see v2 results Empty out the Replace "v2" with "v3" So the result should be: v3 Another Value The original XML is 9MB but t...
This template will produce the required result from your input XML: v3 xsl:copy-of is not suitable for the kind of transformation you want. (tested in this web utility).
A couple simple XSLT changes I'm new to XSLT so I believe that what I'm looking for is very basic. I'm starting with some XML like this: 10 v1 A Value 12 v2 Another Value I want to do 3 things with this: Filter so that I only see v2 results Empty out the Replace "v2" with "v3" So the result should be: v3 Another Value ...
TITLE: A couple simple XSLT changes QUESTION: I'm new to XSLT so I believe that what I'm looking for is very basic. I'm starting with some XML like this: 10 v1 A Value 12 v2 Another Value I want to do 3 things with this: Filter so that I only see v2 results Empty out the Replace "v2" with "v3" So the result should be:...
[ "xml", "xslt" ]
0
1
80
3
0
2011-06-02T20:04:38.903000
2011-06-02T20:12:53.787000
6,219,756
6,219,850
How to execute system() without any output
I have a basic php script that calls system("netstat -l") and the reads what services are online. I got it all working exept that system() sends the whole return to the client... So my question is how do i run system() whiteout having it sending the command output to the client? Im running this on ubuntu server.
You can do: $output = shell_exec('netstat -l'); $output will now contain the output of the command. shell_exec
How to execute system() without any output I have a basic php script that calls system("netstat -l") and the reads what services are online. I got it all working exept that system() sends the whole return to the client... So my question is how do i run system() whiteout having it sending the command output to the clien...
TITLE: How to execute system() without any output QUESTION: I have a basic php script that calls system("netstat -l") and the reads what services are online. I got it all working exept that system() sends the whole return to the client... So my question is how do i run system() whiteout having it sending the command o...
[ "php" ]
2
1
183
2
0
2011-06-02T20:04:40.947000
2011-06-02T20:15:23.527000
6,219,757
6,231,300
How to make an SQLite database as part of the build process - iPhone SDK
I have created a Core Data application in iPhone Simulator. Now when I am testing it on a device, my SQLite database is empty. I have some preloaded settings which I want to deploy when the application is installed. How can I achieve that? I have seen a few questions on Stack Overflow, but they don't exactly answer my ...
If you have an existing sqlite-store file you just add it to the app bundle just like you would any resource e.g. images, audio, etc. If it is read only, you just use the NSBundle commands to supple a path to it inside the readonly app bundle. If you want it writable, you copy the store file from inside the app bundle ...
How to make an SQLite database as part of the build process - iPhone SDK I have created a Core Data application in iPhone Simulator. Now when I am testing it on a device, my SQLite database is empty. I have some preloaded settings which I want to deploy when the application is installed. How can I achieve that? I have ...
TITLE: How to make an SQLite database as part of the build process - iPhone SDK QUESTION: I have created a Core Data application in iPhone Simulator. Now when I am testing it on a device, my SQLite database is empty. I have some preloaded settings which I want to deploy when the application is installed. How can I ach...
[ "sqlite", "ios4", "core-data" ]
0
1
70
1
0
2011-06-02T20:04:42.987000
2011-06-03T18:43:48.463000
6,219,759
6,220,158
How to set onClickListener on a button in a ListView (Adapter using Reflection...)?
I'm using some reflection to set up a ListView made up of custom views. One of the HashMaps that I'll be using with this Adapter has a button in it. I'm pretty sure I need to set the onClickListener on the button in the getView method, but I'm not sure how. Here's the code for my Adapter: private class ViewAdapter exte...
I'm guessing here but in order to have a button, I would assume that the View is actually a ViewGroup. If so, try casting it to ViewGroup and iterating through the children Views using getChildAt(i): ViewGroup vg = (ViewGroup) myObject; for (int i=0; i< vg.getChildCount(); i++) { View v = vg.getChildAt(i); if (v insta...
How to set onClickListener on a button in a ListView (Adapter using Reflection...)? I'm using some reflection to set up a ListView made up of custom views. One of the HashMaps that I'll be using with this Adapter has a button in it. I'm pretty sure I need to set the onClickListener on the button in the getView method, ...
TITLE: How to set onClickListener on a button in a ListView (Adapter using Reflection...)? QUESTION: I'm using some reflection to set up a ListView made up of custom views. One of the HashMaps that I'll be using with this Adapter has a button in it. I'm pretty sure I need to set the onClickListener on the button in th...
[ "android" ]
0
0
1,204
2
0
2011-06-02T20:04:47.077000
2011-06-02T20:41:51.577000
6,219,773
6,219,817
Is there any keyword in Java which is similar to the 'AS' keyword of C#
As we know C# provides an AS keyword which automatically performs a check whether the Object is of a type and if it is, it then casts it to the needed type else gives a null. public class User { } Object obj = someObj; User user = obj As User; Here in the above example, An Object obj can be of type User or some other t...
You can create a helper method public static T as(Object o, Class tClass) { return tClass.isInstance(o)? (T) o: null; } User user = as(obj, User.class);
Is there any keyword in Java which is similar to the 'AS' keyword of C# As we know C# provides an AS keyword which automatically performs a check whether the Object is of a type and if it is, it then casts it to the needed type else gives a null. public class User { } Object obj = someObj; User user = obj As User; Here...
TITLE: Is there any keyword in Java which is similar to the 'AS' keyword of C# QUESTION: As we know C# provides an AS keyword which automatically performs a check whether the Object is of a type and if it is, it then casts it to the needed type else gives a null. public class User { } Object obj = someObj; User user =...
[ "c#", "java", "keyword", "as-keyword" ]
26
29
16,114
3
0
2011-06-02T20:06:35.833000
2011-06-02T20:11:51.307000
6,219,774
6,219,880
Handling Symbols with PHP xml parser
I'm writing a xml to text file script with PHP's xml parser. I delimit attributes with @ signs and data with | symbols, what I've noticed is when I open the text file is that symbols are seen as their own data. i.e. For this theorem assume X < Y and Z & A = 0 should have output @yes@ |For this theorem assume X < Y and ...
I believe you are asking about special characters in a string? If so you need to use the ascii equivilent, i.e. For this theorem assume X < Y and Z & A = 0 Becomes For this theorem assume X < Y and Z & A = 0
Handling Symbols with PHP xml parser I'm writing a xml to text file script with PHP's xml parser. I delimit attributes with @ signs and data with | symbols, what I've noticed is when I open the text file is that symbols are seen as their own data. i.e. For this theorem assume X < Y and Z & A = 0 should have output @yes...
TITLE: Handling Symbols with PHP xml parser QUESTION: I'm writing a xml to text file script with PHP's xml parser. I delimit attributes with @ signs and data with | symbols, what I've noticed is when I open the text file is that symbols are seen as their own data. i.e. For this theorem assume X < Y and Z & A = 0 shoul...
[ "php", "xml", "xml-parsing" ]
0
0
199
1
0
2011-06-02T20:06:57.543000
2011-06-02T20:17:51.437000
6,219,789
6,219,998
the best way to deal with Sound in Flash
is it best to load sound files into the library, or to load them externally? What I want to do is make a sampler app. You'd have a selection of loops and drag and drop them onto a timeline. My main concern is performance and any delay of sound.
If a big initial download is not a problem for you, then put them in the library. It's easy and you won't have to do any loading or unloading stuff, apart from showing load progress for the app itself. If you have a LOT of sounds and don't want the users to only be able to use your application after all sounds are load...
the best way to deal with Sound in Flash is it best to load sound files into the library, or to load them externally? What I want to do is make a sampler app. You'd have a selection of loops and drag and drop them onto a timeline. My main concern is performance and any delay of sound.
TITLE: the best way to deal with Sound in Flash QUESTION: is it best to load sound files into the library, or to load them externally? What I want to do is make a sampler app. You'd have a selection of loops and drag and drop them onto a timeline. My main concern is performance and any delay of sound. ANSWER: If a bi...
[ "flash", "actionscript-3", "audio" ]
0
2
184
2
0
2011-06-02T20:08:43.763000
2011-06-02T20:28:22.757000
6,219,790
6,219,846
Need a RegEx tool that suggests expressions based on selected text
I've found several online tools that allow me to see the effect of a regular expression I have created on sample text, but I am looking for a tool that would make expression suggestions based on a portion of text selected. For Example: Let's say I have a string like this, obssoCookie=set-usermember1-404343994;Version=1...
Check out txt2re. Using your sample text, with the relevant portions selected, and C# selected for the code to be generated, this is the result. It takes some getting used to, but the basic steps are: Select the link for individual characters or whole words desired based on the colored boxes generated on the page. Sele...
Need a RegEx tool that suggests expressions based on selected text I've found several online tools that allow me to see the effect of a regular expression I have created on sample text, but I am looking for a tool that would make expression suggestions based on a portion of text selected. For Example: Let's say I have ...
TITLE: Need a RegEx tool that suggests expressions based on selected text QUESTION: I've found several online tools that allow me to see the effect of a regular expression I have created on sample text, but I am looking for a tool that would make expression suggestions based on a portion of text selected. For Example:...
[ "regex" ]
10
12
77,008
5
0
2011-06-02T20:08:44.300000
2011-06-02T20:15:18.403000
6,219,801
6,219,879
Refactoring a Dictionary, changing key type
I am refactoring a C# library that uses a Dictionary all over the system. I need to change the key type from int to string, and use a Dictionary instead, and I am making dozens of changes. How to do it better, how to define a type in one place and uses it everywhere, so that if I need to change it later, I can change i...
If swapping the type of key is important to you, consider a custom class wrapping the underlying key. e.g, public class Key { public Key(object adaptee) {... } } Remember to implement Equals() and GetHashCode() and just delegate to the underlying object. I'm not sure if this helps your particular scenario, but in gener...
Refactoring a Dictionary, changing key type I am refactoring a C# library that uses a Dictionary all over the system. I need to change the key type from int to string, and use a Dictionary instead, and I am making dozens of changes. How to do it better, how to define a type in one place and uses it everywhere, so that ...
TITLE: Refactoring a Dictionary, changing key type QUESTION: I am refactoring a C# library that uses a Dictionary all over the system. I need to change the key type from int to string, and use a Dictionary instead, and I am making dozens of changes. How to do it better, how to define a type in one place and uses it ev...
[ "c#", "refactoring" ]
3
4
421
2
0
2011-06-02T20:09:32.757000
2011-06-02T20:17:50.103000
6,219,813
6,298,360
How can I modify the instance name for an ec2 instance
I would like to modify the "name" attribute of an amazon instance. See attached screenshot. I need to do it programmatically, but can't find anywhere in the EC2 API how to set that. If it matters, I'm launching these via a spot request through their API. I would like to set the field that I tagged, "set this name" in t...
This might help... AmazonEC2 ec2; AWSCredentials credentials; String accKey = "your access key"; String secKey = "your secret key"; credentials = new BasicAWSCredentials(accKey, secKey); ec2 = new AmazonEC2Client(credentials); String instanceId = "Your Instance ID"; List tags = new ArrayList (); Tag t = new Tag(); t...
How can I modify the instance name for an ec2 instance I would like to modify the "name" attribute of an amazon instance. See attached screenshot. I need to do it programmatically, but can't find anywhere in the EC2 API how to set that. If it matters, I'm launching these via a spot request through their API. I would li...
TITLE: How can I modify the instance name for an ec2 instance QUESTION: I would like to modify the "name" attribute of an amazon instance. See attached screenshot. I need to do it programmatically, but can't find anywhere in the EC2 API how to set that. If it matters, I'm launching these via a spot request through the...
[ "amazon-ec2", "ec2-api-tools" ]
34
35
41,334
4
0
2011-06-02T20:11:35.373000
2011-06-09T19:45:48.537000
6,219,821
6,219,897
Objective-C method to nullify object
i have some trouble writing a method in Objective-C to make an object nil. Here is some example: @interface testA: NSObject { NSString *a; } @property (nonatomic, retain) NSString *a; +(testA*)initWithA:(NSString *)aString; -(void)displayA; -(void)nillify; @end @implementation testA @synthesize a; +(testA*)initWith...
You can't actually do something like this, because setting 'self' to nil only has any effect within the scope of that method (in your case, 'nilify'). You don't have any actual way to effect the values of pointers located on other parts of the stack or in random places in the heap, for example. Basically any code that ...
Objective-C method to nullify object i have some trouble writing a method in Objective-C to make an object nil. Here is some example: @interface testA: NSObject { NSString *a; } @property (nonatomic, retain) NSString *a; +(testA*)initWithA:(NSString *)aString; -(void)displayA; -(void)nillify; @end @implementation t...
TITLE: Objective-C method to nullify object QUESTION: i have some trouble writing a method in Objective-C to make an object nil. Here is some example: @interface testA: NSObject { NSString *a; } @property (nonatomic, retain) NSString *a; +(testA*)initWithA:(NSString *)aString; -(void)displayA; -(void)nillify; @end ...
[ "iphone", "objective-c" ]
1
5
380
3
0
2011-06-02T20:12:27.733000
2011-06-02T20:19:37.403000
6,219,829
6,219,855
Method to dynamically load java class files
What would be a good way to dynamically load java class files so that a program compiled into a jar can read all the class files in a directory and use them, and how can one write the files so that they have the necessary package name in relation to the jar?
I believe it's a ClassLoader you're after. I suggest you start by looking at the example below which loads class files that are not on the class path. // Create a File object on the root of the directory containing the class file File file = new File("c:\\myclasses\\"); try { // Convert File to a URL URL url = file.to...
Method to dynamically load java class files What would be a good way to dynamically load java class files so that a program compiled into a jar can read all the class files in a directory and use them, and how can one write the files so that they have the necessary package name in relation to the jar?
TITLE: Method to dynamically load java class files QUESTION: What would be a good way to dynamically load java class files so that a program compiled into a jar can read all the class files in a directory and use them, and how can one write the files so that they have the necessary package name in relation to the jar?...
[ "java", "class", "reflection", "dynamic", "load" ]
57
111
86,620
3
0
2011-06-02T20:13:15.813000
2011-06-02T20:15:36.913000
6,219,830
6,219,870
CPU-intensive thread wisdom
I want to run a batch say 20 CPU intensive comps (basically really long nested for loop) on a machine. Each of these 20 jobs doesn't share data with the other 19. If the machine has N cores, should I spin off N-1 of these jobs then? Or N? Or should I just launch all 20, and have Windows figure out how to schedule them?
Unfortunately, there is no simple answer. The only way to know for sure is to implement and then profile your application. Typically, for maximum throughput, if the jobs are pure CPU, you'd want one per core. Depending on the type of work, this would include one per hyperthread code or just one per "true physical core"...
CPU-intensive thread wisdom I want to run a batch say 20 CPU intensive comps (basically really long nested for loop) on a machine. Each of these 20 jobs doesn't share data with the other 19. If the machine has N cores, should I spin off N-1 of these jobs then? Or N? Or should I just launch all 20, and have Windows figu...
TITLE: CPU-intensive thread wisdom QUESTION: I want to run a batch say 20 CPU intensive comps (basically really long nested for loop) on a machine. Each of these 20 jobs doesn't share data with the other 19. If the machine has N cores, should I spin off N-1 of these jobs then? Or N? Or should I just launch all 20, and...
[ "windows", "multithreading", "cpu" ]
4
5
198
3
0
2011-06-02T20:13:22.897000
2011-06-02T20:16:41.180000
6,219,834
6,220,075
Can GNU make have targets that depend on the completion of targets from other makefiles?
I have several directories representing subparts of a project, each with its own Makefile. I want to create a master Makefile with targets for each of those subparts, each target satisfying the following: depend on a certain target from that subproject's Makefile. This is the tricky part. copy some resulting library/ex...
Have a look at recursive make. You could do something like, SRCDIR:= src TARGETS:= projA projB.PHONY: $(TARGETS) $(TARGETS): cd $(SRCDIR)/$@; $(MAKE) release
Can GNU make have targets that depend on the completion of targets from other makefiles? I have several directories representing subparts of a project, each with its own Makefile. I want to create a master Makefile with targets for each of those subparts, each target satisfying the following: depend on a certain target...
TITLE: Can GNU make have targets that depend on the completion of targets from other makefiles? QUESTION: I have several directories representing subparts of a project, each with its own Makefile. I want to create a master Makefile with targets for each of those subparts, each target satisfying the following: depend o...
[ "makefile", "gnu-make" ]
1
2
736
1
0
2011-06-02T20:14:03.347000
2011-06-02T20:33:18.107000
6,219,835
6,219,892
install apk from another android app without using sd card
I was able to download an apk file and stored it in my /data/data/com.android.myApp/anotherApp.apk. I was wondering if there is a way I can install this file from another app. I am currently using: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(filepath), "application/vnd.android.packag...
Normally, when you save files on your app sandbox, they are saved under the "files" folder. So you're full path should be: /data/data/com.android.myApp/files/anotherApp.apk If you are working on an emulator you can do an adb shell ls to confirm if the file is actually there: adb shell "ls /data/data/com.android.myApp/f...
install apk from another android app without using sd card I was able to download an apk file and stored it in my /data/data/com.android.myApp/anotherApp.apk. I was wondering if there is a way I can install this file from another app. I am currently using: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataA...
TITLE: install apk from another android app without using sd card QUESTION: I was able to download an apk file and stored it in my /data/data/com.android.myApp/anotherApp.apk. I was wondering if there is a way I can install this file from another app. I am currently using: Intent intent = new Intent(Intent.ACTION_VIEW...
[ "android", "installation", "apk", "package-managers" ]
3
1
2,528
3
0
2011-06-02T20:14:07.433000
2011-06-02T20:19:06.153000
6,219,837
6,219,977
How can I determine if a date is between two dates in PHP?
I need know if a $paymentDate (31/12/2010) is valid between $contractDateBegin (01/01/2001) and $contractDateEnd (01/01/2012) dd/mm/yyyy FORMAT!
As of PHP 5.3: $paymentDate = DateTime::createFromFormat('d/m/Y', '31/12/2010'); $contractDateBegin = DateTime::createFromFormat('d/m/Y', '01/01/2001'); $contractDateEnd = DateTime::createFromFormat('d/m/Y', '01/01/2012'); if ($paymentDate >= $contractDateBegin && $paymentDate <= $contractDateEnd) { echo "is between\n...
How can I determine if a date is between two dates in PHP? I need know if a $paymentDate (31/12/2010) is valid between $contractDateBegin (01/01/2001) and $contractDateEnd (01/01/2012) dd/mm/yyyy FORMAT!
TITLE: How can I determine if a date is between two dates in PHP? QUESTION: I need know if a $paymentDate (31/12/2010) is valid between $contractDateBegin (01/01/2001) and $contractDateEnd (01/01/2012) dd/mm/yyyy FORMAT! ANSWER: As of PHP 5.3: $paymentDate = DateTime::createFromFormat('d/m/Y', '31/12/2010'); $contrac...
[ "php", "date" ]
3
30
28,817
3
0
2011-06-02T20:14:17.037000
2011-06-02T20:26:15.687000
6,219,852
6,220,711
Problem with accessing google tasks with client login
I'm trying to write application for Android to access Google Tasks. I decided to use ClientLogin authorization method. I'm getting ClientLogin "Auth" marker from first POST request. Then i try to retrieve a user's task lists with GET request. I wrote the following code for this: String requestString = "https://www.goog...
ClientLogin with username / password If you want to use ClientLogin with the Google APIs Client Library for Java, you'll need to setup a HttpRequestFactory that supports authentication. private static HttpTransport transport = new ApacheHttpTransport(); public static HttpRequestFactory createRequestFactory( final Http...
Problem with accessing google tasks with client login I'm trying to write application for Android to access Google Tasks. I decided to use ClientLogin authorization method. I'm getting ClientLogin "Auth" marker from first POST request. Then i try to retrieve a user's task lists with GET request. I wrote the following c...
TITLE: Problem with accessing google tasks with client login QUESTION: I'm trying to write application for Android to access Google Tasks. I decided to use ClientLogin authorization method. I'm getting ClientLogin "Auth" marker from first POST request. Then i try to retrieve a user's task lists with GET request. I wro...
[ "android", "httpurlconnection", "task" ]
0
0
1,489
1
0
2011-06-02T20:15:25.657000
2011-06-02T21:39:57.650000
6,219,857
6,221,785
Swing: Is there a simple way to make 1 component ignore the layout manager?
I have a JPanel with one component that I want to place in an absolute sense, whereas the rest of the components are placed according to a layout manager. Is there a simple way to do this?
Are you saying you want a component painted over top of all the other components? If so then you would need to use a JLayeredPane. Why don't you post a SSCCE that demonstrates what you want to do? You can add components to a frame as you would do normally and make the frame visible. Then you can add this random compone...
Swing: Is there a simple way to make 1 component ignore the layout manager? I have a JPanel with one component that I want to place in an absolute sense, whereas the rest of the components are placed according to a layout manager. Is there a simple way to do this?
TITLE: Swing: Is there a simple way to make 1 component ignore the layout manager? QUESTION: I have a JPanel with one component that I want to place in an absolute sense, whereas the rest of the components are placed according to a layout manager. Is there a simple way to do this? ANSWER: Are you saying you want a co...
[ "java", "swing", "layout-manager" ]
2
4
590
3
0
2011-06-02T20:15:45.203000
2011-06-03T00:15:05.087000
6,219,862
6,219,899
Converting String to List of Bytes
This has to be incredibly simple, but I must not be looking in the right place. I'm receiving this string via a FTDI usb connection: 'UUU' I would like to receive this as a byte array of [85,85,85] In Python, this I would convert a string to a byte array like this: [ord(c) for c in 'UUU'] I've looked around, but haven'...
depends on what kind of encoding you want to use but for UTF8 this works, you could chane it to UTF16 if needed. Dim strText As String = "UUU" Dim encText As New System.Text.UTF8Encoding() Dim btText() As Byte btText = encText.GetBytes(strText)
Converting String to List of Bytes This has to be incredibly simple, but I must not be looking in the right place. I'm receiving this string via a FTDI usb connection: 'UUU' I would like to receive this as a byte array of [85,85,85] In Python, this I would convert a string to a byte array like this: [ord(c) for c in 'U...
TITLE: Converting String to List of Bytes QUESTION: This has to be incredibly simple, but I must not be looking in the right place. I'm receiving this string via a FTDI usb connection: 'UUU' I would like to receive this as a byte array of [85,85,85] In Python, this I would convert a string to a byte array like this: [...
[ "vb.net" ]
4
8
8,644
2
0
2011-06-02T20:16:01.443000
2011-06-02T20:19:54.110000
6,219,868
6,222,949
Can I create an installable Google Chrome web app without going through the Chrome App Store?
My ultimate goal is to use my web site without the URL bar. As far as I can tell (for security reasons), the only way to do this is to make it an installable web app (or a Chrome extension -- maybe there is already such an extension?). Can I simply provide the user with a link that gives Chrome all the necessary metada...
You can create an extension and package it as an app (creating a.crx file) from chrome://extensions/ and then host the crx file on your own site or where ever; no Chrome Web App Store needed. http://code.google.com/chrome/extensions/apps.html
Can I create an installable Google Chrome web app without going through the Chrome App Store? My ultimate goal is to use my web site without the URL bar. As far as I can tell (for security reasons), the only way to do this is to make it an installable web app (or a Chrome extension -- maybe there is already such an ext...
TITLE: Can I create an installable Google Chrome web app without going through the Chrome App Store? QUESTION: My ultimate goal is to use my web site without the URL bar. As far as I can tell (for security reasons), the only way to do this is to make it an installable web app (or a Chrome extension -- maybe there is a...
[ "web-applications", "google-chrome", "app-store" ]
1
2
2,091
2
0
2011-06-02T20:16:28.993000
2011-06-03T04:24:58.783000
6,219,869
6,240,754
Table sorter icons in thead
I have some JavaScript that toggles the class of the th element clicked to "ascending" or "descending". Q: In the css, how can I display a jQuery-UI icon associated with.ascending or.descending? Cust Name... Here's the code, just in case someone spots an inefficiency: jQuery(function($) { $('.thSort th').click(function...
Topic In JavaScript, toggle between ui-icon-circle-triangle-n and ui-icon-circle-triangle-s. If the user clicks on a new th, replace all the html inside the previous th with only the text that is in the first div.
Table sorter icons in thead I have some JavaScript that toggles the class of the th element clicked to "ascending" or "descending". Q: In the css, how can I display a jQuery-UI icon associated with.ascending or.descending? Cust Name... Here's the code, just in case someone spots an inefficiency: jQuery(function($) { $(...
TITLE: Table sorter icons in thead QUESTION: I have some JavaScript that toggles the class of the th element clicked to "ascending" or "descending". Q: In the css, how can I display a jQuery-UI icon associated with.ascending or.descending? Cust Name... Here's the code, just in case someone spots an inefficiency: jQuer...
[ "css", "jquery-ui" ]
2
1
8,393
2
0
2011-06-02T20:16:32.350000
2011-06-05T03:03:11.440000
6,219,874
6,219,930
Append my Event handler before existing handler
Let's suppose there is an element that has some onclick event handler. For example onclick it does alert("OldEventHandler"). I would like to add my event handler there, before the existing one. For example my event handler function does alert("NewEventHandler"). So on click I would like to see "NewEventHandler" popup, ...
You can save the original handler, then call it after yours is done: var oldHandler = myElement.onclick; myElement.onclick = function() { // do your stuff here... // then call the original oldHandler.apply(this, arguments); }
Append my Event handler before existing handler Let's suppose there is an element that has some onclick event handler. For example onclick it does alert("OldEventHandler"). I would like to add my event handler there, before the existing one. For example my event handler function does alert("NewEventHandler"). So on cli...
TITLE: Append my Event handler before existing handler QUESTION: Let's suppose there is an element that has some onclick event handler. For example onclick it does alert("OldEventHandler"). I would like to add my event handler there, before the existing one. For example my event handler function does alert("NewEventHa...
[ "javascript", "dom-events" ]
8
12
3,871
2
0
2011-06-02T20:17:14
2011-06-02T20:22:32.020000
6,219,878
6,219,902
Stack overflow C++
This is my code. When I access dtr array in initImg function it gives a stack overflow exception. What might be the reason? #define W 1000 #define H 1000 #define MAX 100000 void initImg(int img[], float dtr[]) { for(int i=0;i
This: int image[W*H]; float dtr[W*H]; Creates each a 4 * 1000 * 1000 ~ 4 MB array into the stack. The stack space is limited, and usually it's less than 4 MB. Don't do that, create the arrays in the heap using new. int *image = new int[W*H]; float *dtr = new float[W*H];
Stack overflow C++ This is my code. When I access dtr array in initImg function it gives a stack overflow exception. What might be the reason? #define W 1000 #define H 1000 #define MAX 100000 void initImg(int img[], float dtr[]) { for(int i=0;i
TITLE: Stack overflow C++ QUESTION: This is my code. When I access dtr array in initImg function it gives a stack overflow exception. What might be the reason? #define W 1000 #define H 1000 #define MAX 100000 void initImg(int img[], float dtr[]) { for(int i=0;i ANSWER: This: int image[W*H]; float dtr[W*H]; Creates ea...
[ "c++", "exception", "stack-overflow", "callstack" ]
10
20
56,093
8
0
2011-06-02T20:17:30.680000
2011-06-02T20:20:05.920000
6,219,888
6,220,097
Why are my map pins getting more inaccurate the further you zoom out? Google maps API V3
http://www.dissentskateshop.co.uk/store-locator/ You can see the map pin sits in the sea, but if you zoom in, it's in the location I set it. I'm pulling my hair out with this one...
From this behaviour I would guess that the anchor point is not properly set: the anchor seems to be at the bottom left of the image, although the "visible" anchor (the pin) is more right, thus always offset. If you look at the distance in pixels, the offset from the original coordinate is always constant, no matter on ...
Why are my map pins getting more inaccurate the further you zoom out? Google maps API V3 http://www.dissentskateshop.co.uk/store-locator/ You can see the map pin sits in the sea, but if you zoom in, it's in the location I set it. I'm pulling my hair out with this one...
TITLE: Why are my map pins getting more inaccurate the further you zoom out? Google maps API V3 QUESTION: http://www.dissentskateshop.co.uk/store-locator/ You can see the map pin sits in the sea, but if you zoom in, it's in the location I set it. I'm pulling my hair out with this one... ANSWER: From this behaviour I ...
[ "google-maps" ]
2
4
2,584
2
0
2011-06-02T20:18:37.963000
2011-06-02T20:35:40.087000
6,219,904
6,220,388
How do I coalesce processing of related events in NServiceBus?
I have a situation where I have a service subscribing to event messages and performing some work when they arrive. There is a certain class of events which can arrive in short bursts of many events which reference the same underlying data. I would like to be able to defer processing of related events for a short period...
Yes, a saga could be the way to go - however consider the performance of the saga persistence (NHibernate over a DB in the current version, RavenDB in the next version) as compared to your fault-tolerance needs (if a machine crashes, would it be acceptable to lose some messages). No easy answers, I'm afraid.
How do I coalesce processing of related events in NServiceBus? I have a situation where I have a service subscribing to event messages and performing some work when they arrive. There is a certain class of events which can arrive in short bursts of many events which reference the same underlying data. I would like to b...
TITLE: How do I coalesce processing of related events in NServiceBus? QUESTION: I have a situation where I have a service subscribing to event messages and performing some work when they arrive. There is a certain class of events which can arrive in short bursts of many events which reference the same underlying data....
[ "nservicebus", "publish-subscribe" ]
0
1
124
1
0
2011-06-02T20:20:10.437000
2011-06-02T21:05:10.770000
6,219,905
6,220,020
Adding carriage returns in a format string
I am trying to get Carriage returns after each string in my email body. I am drawing a blank. This is the code I’m using at the moment: - (IBAction)mailButtonPressed { MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:@"Pr...
Add a \n in your format string wherever you want a new line.
Adding carriage returns in a format string I am trying to get Carriage returns after each string in my email body. I am drawing a blank. This is the code I’m using at the moment: - (IBAction)mailButtonPressed { MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeD...
TITLE: Adding carriage returns in a format string QUESTION: I am trying to get Carriage returns after each string in my email body. I am drawing a blank. This is the code I’m using at the moment: - (IBAction)mailButtonPressed { MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; contr...
[ "cocoa-touch", "email", "string-formatting" ]
0
3
1,316
1
0
2011-06-02T20:20:13.877000
2011-06-02T20:29:30.130000
6,219,908
6,220,666
How do programs like LogMeIn work in the aspect of file transfer
I use LogMeIn primarily because most of the time I need to access files from my computer. Lets say that the file that I want to access is in computer A and I am using computer B. If I get a file from computer A that means that that file goes to some server computer X then to computer B? Another way where I can access a...
In order to make a connection, you must open a port on one side or the other. Services like LogMeIn do what you suspect by using a computer in the middle as a proxy. There's really no need to reinvent the wheel with secure file transfer. Find yourself some reputable sftp server software, open a port on your router, cho...
How do programs like LogMeIn work in the aspect of file transfer I use LogMeIn primarily because most of the time I need to access files from my computer. Lets say that the file that I want to access is in computer A and I am using computer B. If I get a file from computer A that means that that file goes to some serve...
TITLE: How do programs like LogMeIn work in the aspect of file transfer QUESTION: I use LogMeIn primarily because most of the time I need to access files from my computer. Lets say that the file that I want to access is in computer A and I am using computer B. If I get a file from computer A that means that that file ...
[ "networking", "file-upload", "file-transfer" ]
1
0
621
1
0
2011-06-02T20:20:26.530000
2011-06-02T21:35:23.013000
6,219,909
6,228,957
Creating custom user attributes in Active Directory using JNDI
I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign it to the user via: mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, new...
Not sure what you want to do. But Active-Directory is a Directory, so it use a SCHEMA to define which attributes can be used in an object. This means that you can modify (add, delete, replace) the value of an attribut that exists (in the SCHEMA) for a given class, but can'nt add a custom attribut to a class without mod...
Creating custom user attributes in Active Directory using JNDI I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign it to the user vi...
TITLE: Creating custom user attributes in Active Directory using JNDI QUESTION: I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign...
[ "java", "active-directory", "jndi" ]
1
1
1,698
1
0
2011-06-02T20:20:27.660000
2011-06-03T15:13:38.007000
6,219,914
6,219,922
Can you add custom compiler warnings in Objective-C?
(I found the answer to this elsewhere while writing the question, but I thought it might be helpful to others if I posted it since I couldn't find anything here.) I want to mark methods that need better error handling. I'd like them to show up as compiler warnings so other developers (who may be responsible for that ar...
It's very easy to do: #warning Needs better error handling, please.
Can you add custom compiler warnings in Objective-C? (I found the answer to this elsewhere while writing the question, but I thought it might be helpful to others if I posted it since I couldn't find anything here.) I want to mark methods that need better error handling. I'd like them to show up as compiler warnings so...
TITLE: Can you add custom compiler warnings in Objective-C? QUESTION: (I found the answer to this elsewhere while writing the question, but I thought it might be helpful to others if I posted it since I couldn't find anything here.) I want to mark methods that need better error handling. I'd like them to show up as co...
[ "objective-c", "xcode", "compiler-construction", "compiler-warnings" ]
26
51
11,318
2
0
2011-06-02T20:21:09.163000
2011-06-02T20:21:37.823000
6,219,925
6,219,968
Having trouble with pure CSS navigation
Fiddle here: http://jsfiddle.net/csaltyj/3A78u/ I want the sub-sub nav menu to align with the top of its parent (hence top: 0) but it aligns with the parent's parent for some reason. I'm not sure what's going on.. any ideas? HTML: Item One Item Two Item two has babies Baby #2 Sub-babies This is fun Last Item SubSub Ano...
You need to add position: relative to the "level 2" li elements: #nav > ul ul li { position: relative } Here's a version where the babies are all lined up: http://jsfiddle.net/3A78u/2/ If you'd like to use >, it would be #nav > ul > li > ul > li.
Having trouble with pure CSS navigation Fiddle here: http://jsfiddle.net/csaltyj/3A78u/ I want the sub-sub nav menu to align with the top of its parent (hence top: 0) but it aligns with the parent's parent for some reason. I'm not sure what's going on.. any ideas? HTML: Item One Item Two Item two has babies Baby #2 Sub...
TITLE: Having trouble with pure CSS navigation QUESTION: Fiddle here: http://jsfiddle.net/csaltyj/3A78u/ I want the sub-sub nav menu to align with the top of its parent (hence top: 0) but it aligns with the parent's parent for some reason. I'm not sure what's going on.. any ideas? HTML: Item One Item Two Item two has ...
[ "css", "navigation" ]
1
2
118
2
0
2011-06-02T20:22:01.413000
2011-06-02T20:25:51.270000
6,219,926
6,219,976
How to make a "push notification" service in Windows in C#, WPF?
I have a WPF Browser application, written in C#. In which have a process where i need to notify users of its status. (i.e. notifying users when tasks are assigned to them). The client doesn't want those notifications to be sent by mail, they want to have a tray icon that notifies each of the users when a "task" is assi...
Assuming you're using WCF to communicate between client/server, consider duplex services: http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx
How to make a "push notification" service in Windows in C#, WPF? I have a WPF Browser application, written in C#. In which have a process where i need to notify users of its status. (i.e. notifying users when tasks are assigned to them). The client doesn't want those notifications to be sent by mail, they want to have ...
TITLE: How to make a "push notification" service in Windows in C#, WPF? QUESTION: I have a WPF Browser application, written in C#. In which have a process where i need to notify users of its status. (i.e. notifying users when tasks are assigned to them). The client doesn't want those notifications to be sent by mail, ...
[ "c#", "wpf", "windows", "sql-server-2008" ]
7
3
4,816
1
0
2011-06-02T20:22:04.190000
2011-06-02T20:26:15.157000
6,219,927
6,219,950
How to reference parent using child's text?
In jQuery, how can I reference only the element with the child's h2 equal to "Recipe Test 2"? Recipe Test 1 May 23, 2011 Recipe Test 2 May 23, 2011 Recipe Test 3 May 23, 2011
You could try: $('a:contains("Recipe Test 2")').closest('h2'); JS Fiddle demo. References::contains(). closest().
How to reference parent using child's text? In jQuery, how can I reference only the element with the child's h2 equal to "Recipe Test 2"? Recipe Test 1 May 23, 2011 Recipe Test 2 May 23, 2011 Recipe Test 3 May 23, 2011
TITLE: How to reference parent using child's text? QUESTION: In jQuery, how can I reference only the element with the child's h2 equal to "Recipe Test 2"? Recipe Test 1 May 23, 2011 Recipe Test 2 May 23, 2011 Recipe Test 3 May 23, 2011 ANSWER: You could try: $('a:contains("Recipe Test 2")').closest('h2'); JS Fiddle d...
[ "javascript", "jquery", "jquery-selectors" ]
1
2
68
2
0
2011-06-02T20:22:08.603000
2011-06-02T20:24:33.347000
6,219,933
6,219,948
How does one define double-lines for edge and node shapes in graphviz dot?
How can edges and nodes be styled using graphviz dot with doubled lines as shown the in the "LEGAL" and "TAX DISC" nodes of the following diagram?
Doubled shapes can be done by using [peripheries=2] on the node Doubled edges can be done by specifying more than one colour for the edge, separated by a colon. In this case use the same colour twice: [color="black:black"] (or, to separate them slightly more, do [color="black:invis:black"] ) I got there eventually! Sor...
How does one define double-lines for edge and node shapes in graphviz dot? How can edges and nodes be styled using graphviz dot with doubled lines as shown the in the "LEGAL" and "TAX DISC" nodes of the following diagram?
TITLE: How does one define double-lines for edge and node shapes in graphviz dot? QUESTION: How can edges and nodes be styled using graphviz dot with doubled lines as shown the in the "LEGAL" and "TAX DISC" nodes of the following diagram? ANSWER: Doubled shapes can be done by using [peripheries=2] on the node Doubled...
[ "diagram", "graphviz", "dot", "entity-relationship" ]
36
57
12,681
3
0
2011-06-02T20:22:48.420000
2011-06-02T20:24:23.313000
6,219,938
6,219,970
C# store a string variable to a text file .txt
How can i store the contents of a string variable to a text file? How can i search in a string variable for specific text for example find if the word book is in the string?
To save the file to text you can do: System.IO.File.WriteAllText("C:\your_path\your_file", Your_contents); To Search for something in the string: var position = Your_string.IndexOf("Book"); If position equals -1 then what you are searching for isn't there.
C# store a string variable to a text file .txt How can i store the contents of a string variable to a text file? How can i search in a string variable for specific text for example find if the word book is in the string?
TITLE: C# store a string variable to a text file .txt QUESTION: How can i store the contents of a string variable to a text file? How can i search in a string variable for specific text for example find if the word book is in the string? ANSWER: To save the file to text you can do: System.IO.File.WriteAllText("C:\you...
[ "c#", "string", "text", "store", "text-files" ]
10
23
39,588
5
0
2011-06-02T20:23:33.610000
2011-06-02T20:25:56.967000
6,219,940
6,220,013
resetting a set interval for slideshow
I'm just beginning in Jquery and learning pretty quickly, but I spent the past few hours trying to figure out how to reset an interval, if someone could please explain this concept to me it would help me out a lot. I have an interval firing a click that changes the image every 6s. I would like to be able to reset that ...
You can clear an interval if you assign it to a variable using window.clearInterval(intervalID) and to assign an interval you would use, var intervalID = setInterval(func, 6000); In your case you could either overwrite the interval when they click, which in effect will reset the interval, or you can use clearInterval a...
resetting a set interval for slideshow I'm just beginning in Jquery and learning pretty quickly, but I spent the past few hours trying to figure out how to reset an interval, if someone could please explain this concept to me it would help me out a lot. I have an interval firing a click that changes the image every 6s....
TITLE: resetting a set interval for slideshow QUESTION: I'm just beginning in Jquery and learning pretty quickly, but I spent the past few hours trying to figure out how to reset an interval, if someone could please explain this concept to me it would help me out a lot. I have an interval firing a click that changes t...
[ "jquery", "slideshow", "setinterval" ]
1
3
5,298
1
0
2011-06-02T20:23:46.957000
2011-06-02T20:29:10.150000
6,219,941
6,219,983
What does __declspec(uuid(" ComObjectGUID ")) expand to?
I have a piece of code that uses Microsoft-specific extension to the C++: interface __declspec(uuid("F614FB00-6702-11d4-B0B7-0050BABFC904")) ICalculator: public IUnknown { //... }; What does this sentence expand to? How can I rewrite it with ANSI C++?
It's not a macro so it doesn't "expand" to anything. It merely decorates the type with a given UUID in the object file metadata, which can then be extracted later with the __uuidof operator.
What does __declspec(uuid(" ComObjectGUID ")) expand to? I have a piece of code that uses Microsoft-specific extension to the C++: interface __declspec(uuid("F614FB00-6702-11d4-B0B7-0050BABFC904")) ICalculator: public IUnknown { //... }; What does this sentence expand to? How can I rewrite it with ANSI C++?
TITLE: What does __declspec(uuid(" ComObjectGUID ")) expand to? QUESTION: I have a piece of code that uses Microsoft-specific extension to the C++: interface __declspec(uuid("F614FB00-6702-11d4-B0B7-0050BABFC904")) ICalculator: public IUnknown { //... }; What does this sentence expand to? How can I rewrite it with ANS...
[ "c++", "declspec" ]
6
6
5,801
2
0
2011-06-02T20:23:53.360000
2011-06-02T20:26:52.413000
6,219,949
6,220,076
Detecting mobile browsers in Rails 3
I'm looking to do some mobile-specific layouts in my app, and have been researching ways to detect mobile browsers and serve mobile specific layouts. I came across this: http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens But using an array of keywords seems a little fragile to me. Wh...
There is actually a much simpler regular expression you can use. The approach is outlined in this Railscast and allows you to load different JS and define different page interactions for mobile devices. Essentially you end up with a function that simply checks that the user-agent contains 'Mobile' or 'webOS': def mobil...
Detecting mobile browsers in Rails 3 I'm looking to do some mobile-specific layouts in my app, and have been researching ways to detect mobile browsers and serve mobile specific layouts. I came across this: http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens But using an array of keyw...
TITLE: Detecting mobile browsers in Rails 3 QUESTION: I'm looking to do some mobile-specific layouts in my app, and have been researching ways to detect mobile browsers and serve mobile specific layouts. I came across this: http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens But usin...
[ "ruby-on-rails-3" ]
19
20
17,714
3
0
2011-06-02T20:24:24.180000
2011-06-02T20:33:18.027000
6,219,952
6,220,436
How do I reference variables when executing a shell command in PowerShell?
I'm a newbie to PowerShell. What's wrong with my script below? It's not wanting to emit the value of $config. However, when I wrap that command in double quotes, everything looks okay. param($config, $logfolder) # Must run log analysis in chronological order. ls $logfolder | Sort-Object LastWriteTime | % { perl D:\Web...
If putting quotes around it produces the correct commandline, one way to execute the contents of a string is with Invoke-Expression (alias iex ): $v = "myexe -myarg1 -myarg2=$someVar" iex $v
How do I reference variables when executing a shell command in PowerShell? I'm a newbie to PowerShell. What's wrong with my script below? It's not wanting to emit the value of $config. However, when I wrap that command in double quotes, everything looks okay. param($config, $logfolder) # Must run log analysis in chron...
TITLE: How do I reference variables when executing a shell command in PowerShell? QUESTION: I'm a newbie to PowerShell. What's wrong with my script below? It's not wanting to emit the value of $config. However, when I wrap that command in double quotes, everything looks okay. param($config, $logfolder) # Must run log...
[ "powershell" ]
1
3
413
3
0
2011-06-02T20:24:49.413000
2011-06-02T21:10:36.867000
6,219,956
6,225,833
Loading A single business object via properties on a related business object
I am tring to Load a single Business object based on properties in its related object. In this case there is an ExtendedMaterial which has a single relationship to Material and to Plant. this method is on an AppServer class. When I run the attached test with this code I get the correct result and a passing test but if ...
This does work if your DataAccessor is a DataAccessorDB but I noticed recently in some unit tests that it doesn't work against a DataAccessorInMemory. Try your test using a db and see if that works. If it doesn't please log a bug at http://redmine.habanerowiki.com/
Loading A single business object via properties on a related business object I am tring to Load a single Business object based on properties in its related object. In this case there is an ExtendedMaterial which has a single relationship to Material and to Plant. this method is on an AppServer class. When I run the att...
TITLE: Loading A single business object via properties on a related business object QUESTION: I am tring to Load a single Business object based on properties in its related object. In this case there is an ExtendedMaterial which has a single relationship to Material and to Plant. this method is on an AppServer class. ...
[ "orm", "habanero" ]
1
3
40
1
0
2011-06-02T20:25:03.890000
2011-06-03T10:22:35.007000
6,219,960
6,220,203
JavaScript match against array
I would like to know how to match a string against an array of regular expressions. I know how to do this looping through the array. I also know how to do this by making a long regular expression separated by | I was hoping for a more efficient way like if (string contains one of the values in array) { For example: str...
How about creating a regular expression on the fly when you need it ( assuming the array changes over time ) if( (new RegExp( '\\b' + array.join('\\b|\\b') + '\\b') ).test(string) ) { alert('match'); } demo: string = "the word tree is in this sentence"; var array = []; array[0] = "dog"; array[1] = "cat"; array[2] = "bi...
JavaScript match against array I would like to know how to match a string against an array of regular expressions. I know how to do this looping through the array. I also know how to do this by making a long regular expression separated by | I was hoping for a more efficient way like if (string contains one of the valu...
TITLE: JavaScript match against array QUESTION: I would like to know how to match a string against an array of regular expressions. I know how to do this looping through the array. I also know how to do this by making a long regular expression separated by | I was hoping for a more efficient way like if (string contai...
[ "javascript", "arrays", "match" ]
10
22
43,019
4
0
2011-06-02T20:25:19.357000
2011-06-02T20:47:11.253000
6,219,963
6,220,066
javascript form submit problem stopping link flow
I have a form, I want to track if its dirty, if it is, if the user clicks links to go away from page, I want to prompt them to save, ideally I want to pass the url to the server, if the server save works, it redirects the url, if not, it comes back to the same page with validation errors. Here is my code: var isDirty; ...
In your tag, change the onclick handler to this: onclick="return checkSave();" The href will be followed unless onclick explicitly returns false, so you need to pass the return value from checkSave().
javascript form submit problem stopping link flow I have a form, I want to track if its dirty, if it is, if the user clicks links to go away from page, I want to prompt them to save, ideally I want to pass the url to the server, if the server save works, it redirects the url, if not, it comes back to the same page with...
TITLE: javascript form submit problem stopping link flow QUESTION: I have a form, I want to track if its dirty, if it is, if the user clicks links to go away from page, I want to prompt them to save, ideally I want to pass the url to the server, if the server save works, it redirects the url, if not, it comes back to ...
[ "javascript", "validation", "forms" ]
0
1
145
2
0
2011-06-02T20:25:29.903000
2011-06-02T20:32:36.480000
6,219,972
6,220,278
Why embedding functions inside of strings is different than variables
I've asked a question like this before but this one is different, this is more about parsing logic. My previous questions was about how to embed a function inside of a string (double-quoted) and I received this answer: $date = "date"; echo "This page is under construction Current Date: {$date('l jS \of F Y')}"; And aft...
From the documentation: Note: Functions, method calls, static class variables, and class constants inside {$} work since PHP 5. However, the value accessed will be interpreted as the name of a variable in the scope in which the string is defined. Using single curly braces ({}) will not work for accessing the return val...
Why embedding functions inside of strings is different than variables I've asked a question like this before but this one is different, this is more about parsing logic. My previous questions was about how to embed a function inside of a string (double-quoted) and I received this answer: $date = "date"; echo "This page...
TITLE: Why embedding functions inside of strings is different than variables QUESTION: I've asked a question like this before but this one is different, this is more about parsing logic. My previous questions was about how to embed a function inside of a string (double-quoted) and I received this answer: $date = "date...
[ "php", "php-parser" ]
3
4
909
2
0
2011-06-02T20:26:00.440000
2011-06-02T20:54:33.477000
6,219,980
6,238,011
fast parsing links out of a page in python
I need to parse a large number of pages (say 1000) and replace the links with tinyurl links. right now i am doing this using a regex href_link_re = re.compile(r" ]+?href\s*=\s*(\"|')(.*?)\1[^>]*>", re.S) but its not fast enough. i am thinking so far state machine (the success of this will depend on my ability to write ...
LXML is probably your best bet for this task. See Beautiful Soup vs LXML Performance. Parsing links is easy in LXML and it's fast. root = lxml.html.fromstring(s) anchors = root.cssselect("a") links = [a.get("href") for a in anchors]
fast parsing links out of a page in python I need to parse a large number of pages (say 1000) and replace the links with tinyurl links. right now i am doing this using a regex href_link_re = re.compile(r" ]+?href\s*=\s*(\"|')(.*?)\1[^>]*>", re.S) but its not fast enough. i am thinking so far state machine (the success ...
TITLE: fast parsing links out of a page in python QUESTION: I need to parse a large number of pages (say 1000) and replace the links with tinyurl links. right now i am doing this using a regex href_link_re = re.compile(r" ]+?href\s*=\s*(\"|')(.*?)\1[^>]*>", re.S) but its not fast enough. i am thinking so far state mac...
[ "python", "parsing", "beautifulsoup" ]
1
2
837
2
0
2011-06-02T20:26:30.147000
2011-06-04T16:40:44.053000
6,219,981
6,221,720
How to get rid of JList's preselection
The issue is that when the file runs JList already makes its own selection and so when the user makes a selection the list is no longer in the right position. Ultimately, I want to make this a recursive method and have the user select a word and it be removed from the list until there are no words left... Does anyone k...
Does anyone know how to set the whatever autoselection is going on to null? setSelectedIndex( -1 );
How to get rid of JList's preselection The issue is that when the file runs JList already makes its own selection and so when the user makes a selection the list is no longer in the right position. Ultimately, I want to make this a recursive method and have the user select a word and it be removed from the list until t...
TITLE: How to get rid of JList's preselection QUESTION: The issue is that when the file runs JList already makes its own selection and so when the user makes a selection the list is no longer in the right position. Ultimately, I want to make this a recursive method and have the user select a word and it be removed fro...
[ "java", "arraylist", "selection", "listener", "jlist" ]
0
0
228
1
0
2011-06-02T20:26:38.943000
2011-06-03T00:05:22.513000
6,219,986
6,220,728
Pthreads dying in the middle of a mutex lock
I was thinking of the following scenario happening while a pthread is running: pthread_mutex_lock(...);... // <- Thread dies here pthread_mutex_unlock(...); in other words, a pthread starts, at some point it locks a mutex, and for some reason, it dies before it is able to call the matching unlock function, either becau...
Killing threads is never very useful. (unless you can afford to SIGKILL/abort the whole process anyway). Instead unwind the stack with an exception and use RAII. If your process/OS has become so unstable that random thread aborts happen, I think you'll have other worries and the resulting mess is not the process' respo...
Pthreads dying in the middle of a mutex lock I was thinking of the following scenario happening while a pthread is running: pthread_mutex_lock(...);... // <- Thread dies here pthread_mutex_unlock(...); in other words, a pthread starts, at some point it locks a mutex, and for some reason, it dies before it is able to ca...
TITLE: Pthreads dying in the middle of a mutex lock QUESTION: I was thinking of the following scenario happening while a pthread is running: pthread_mutex_lock(...);... // <- Thread dies here pthread_mutex_unlock(...); in other words, a pthread starts, at some point it locks a mutex, and for some reason, it dies befor...
[ "c++", "android", "pthreads", "android-ndk", "mutex" ]
4
5
2,020
2
0
2011-06-02T20:27:12.863000
2011-06-02T21:42:43.610000
6,219,993
6,220,022
Operator ! can't be applied to operand ushort
Possible Duplicate: How do you return 'not uint' in C#? Hi Everyone, I'm trying to convert the following from VB.NET to C# and I'm getting a syntax error. VB.NET: Dim CurrentCRC As UInt16 CurrentCRC = &HFFFF CurrentCRC = Not CurrentCRC C#: UInt16 currentCRC = default(UInt16); currentCRC = 0xFFFF; currentCRC =!currentCR...
If you're looking for the bitwise NOT operator (i.e. the one that flips every bit in the value), use ~.! is the logical NOT operator (for boolean logic).
Operator ! can't be applied to operand ushort Possible Duplicate: How do you return 'not uint' in C#? Hi Everyone, I'm trying to convert the following from VB.NET to C# and I'm getting a syntax error. VB.NET: Dim CurrentCRC As UInt16 CurrentCRC = &HFFFF CurrentCRC = Not CurrentCRC C#: UInt16 currentCRC = default(UInt16...
TITLE: Operator ! can't be applied to operand ushort QUESTION: Possible Duplicate: How do you return 'not uint' in C#? Hi Everyone, I'm trying to convert the following from VB.NET to C# and I'm getting a syntax error. VB.NET: Dim CurrentCRC As UInt16 CurrentCRC = &HFFFF CurrentCRC = Not CurrentCRC C#: UInt16 currentCR...
[ "c#", "vb.net", "syntax" ]
1
8
762
3
0
2011-06-02T20:27:41.023000
2011-06-02T20:29:43.817000
6,220,000
6,220,049
c# #region/#endregion mismatch
Anyone know a good way to find out where i have an extra #region or #endregion in my code? I have about 5000 lines of c# code and i'm trying to do it manually right now. Any help is appreciated.
Do CTRL + M CTRL + L - to close up all the regions. Then expand them one at a time on the left (little + sign) until you see #region XXX that doesnt have matching #endregion Should look like this:
c# #region/#endregion mismatch Anyone know a good way to find out where i have an extra #region or #endregion in my code? I have about 5000 lines of c# code and i'm trying to do it manually right now. Any help is appreciated.
TITLE: c# #region/#endregion mismatch QUESTION: Anyone know a good way to find out where i have an extra #region or #endregion in my code? I have about 5000 lines of c# code and i'm trying to do it manually right now. Any help is appreciated. ANSWER: Do CTRL + M CTRL + L - to close up all the regions. Then expand the...
[ "c#", "visual-studio", "region" ]
4
8
2,865
4
0
2011-06-02T20:28:32.330000
2011-06-02T20:31:28.650000
6,220,006
6,220,103
Hashing, polygonal shapes relative to to x,y location
I am trying to build a polygonal shape tool and have it calculate against its area to find if a point exists inside or out side the area. These examples work well you you want to calculate on every object every time, but I am looking for a way to "HASH" the shape/area of a polygon relative to a spacial location, then T...
http://en.wikipedia.org/wiki/Geometric_hashing I think this explains everything nicely. Given that it can really only be used to determine if two objects are similar (given that the difference is a simple set of transformations), it can be shown that actual spatial information is lost. Therefore the answer to your ques...
Hashing, polygonal shapes relative to to x,y location I am trying to build a polygonal shape tool and have it calculate against its area to find if a point exists inside or out side the area. These examples work well you you want to calculate on every object every time, but I am looking for a way to "HASH" the shape/ar...
TITLE: Hashing, polygonal shapes relative to to x,y location QUESTION: I am trying to build a polygonal shape tool and have it calculate against its area to find if a point exists inside or out side the area. These examples work well you you want to calculate on every object every time, but I am looking for a way to "...
[ "php", "javascript", "c++", "geometry" ]
1
1
847
3
0
2011-06-02T20:28:50.350000
2011-06-02T20:35:56.590000
6,220,012
6,220,056
Filteration in SQL Query by using Join Query
I have a Complex SQL Query which is written with lot many Joins and Conditions. ComplexQuery has few columns and most notable column names are WeightCode and DrugName. [Assumption]: Select * from ComplexQuery. I have a second Table: Select DrugName from Table2. My requirement is such a way that, If WeightCode = 2, Then...
Make use of Case..When may resolve your issue Example SELECT column1, column2 FROM TABLE WHERE column1 = CASE @locationType WHEN 'val1' THEN column1 WHEN 'val2' THEN column1 END Note: this is just example
Filteration in SQL Query by using Join Query I have a Complex SQL Query which is written with lot many Joins and Conditions. ComplexQuery has few columns and most notable column names are WeightCode and DrugName. [Assumption]: Select * from ComplexQuery. I have a second Table: Select DrugName from Table2. My requiremen...
TITLE: Filteration in SQL Query by using Join Query QUESTION: I have a Complex SQL Query which is written with lot many Joins and Conditions. ComplexQuery has few columns and most notable column names are WeightCode and DrugName. [Assumption]: Select * from ComplexQuery. I have a second Table: Select DrugName from Tab...
[ "sql", "sql-server", "sql-server-2005", "sql-server-2008" ]
0
2
131
4
0
2011-06-02T20:29:09.273000
2011-06-02T20:31:59.830000
6,220,018
6,220,078
Two tier xml feeds, get data from xml link
I use the new wordpress plugin, google xml sitemap. Hello, lets say I have 100 posts. My sitemap xml file, instead of having 100 entries on it, has 5 links, each link linking to 20 posts. What I'm trying to do.. is get every name of the post into a file on my server. The sitemap.xml has this schema: <>sitemap... <>cate...
You could use XPath to filter the data directly from the XML. If you could link me the XML I may be able to assist you a little bit with coding. XPath @ Wikipedia Xpath explained Seeing your problem as resolving XML files which are mentioned inside an XML file I didn't find an easy solution on the web. I'd go with foll...
Two tier xml feeds, get data from xml link I use the new wordpress plugin, google xml sitemap. Hello, lets say I have 100 posts. My sitemap xml file, instead of having 100 entries on it, has 5 links, each link linking to 20 posts. What I'm trying to do.. is get every name of the post into a file on my server. The sitem...
TITLE: Two tier xml feeds, get data from xml link QUESTION: I use the new wordpress plugin, google xml sitemap. Hello, lets say I have 100 posts. My sitemap xml file, instead of having 100 entries on it, has 5 links, each link linking to 20 posts. What I'm trying to do.. is get every name of the post into a file on my...
[ "php", "xml" ]
1
0
153
1
0
2011-06-02T20:29:24.377000
2011-06-02T20:33:23.597000
6,220,043
6,220,338
SharePoint development requires administrative network privileges?
My company has a project for which I proposed using SharePoint Enterprise 2010. We are a Microsoft shop, currently using SQL Server 2005 and moving to 2008, but have not used SharePoint previously. A server has been made available for configuring Windows Server 2008 for this proof-of-concept. That server would be my de...
You should be local Admin on the Box and Farm Admin on SharePoint, but you don't need Domain Admin access, no. Your Admin may need to create some service accounts and set up the SQL Server Access for your farm account, but that's it. user Profile Import and Kerberos Authentication require some extra settings that a Dom...
SharePoint development requires administrative network privileges? My company has a project for which I proposed using SharePoint Enterprise 2010. We are a Microsoft shop, currently using SQL Server 2005 and moving to 2008, but have not used SharePoint previously. A server has been made available for configuring Window...
TITLE: SharePoint development requires administrative network privileges? QUESTION: My company has a project for which I proposed using SharePoint Enterprise 2010. We are a Microsoft shop, currently using SQL Server 2005 and moving to 2008, but have not used SharePoint previously. A server has been made available for ...
[ "sharepoint-2010", "network-security" ]
1
2
650
1
0
2011-06-02T20:31:00.657000
2011-06-02T21:01:12.390000
6,220,055
6,220,104
Pipe() fork() and exec
I try to add pipe in a mini-shell. I'm confused, when I type ls | sort, nothing is displayed, I don't understand why: int fd[2]; if (tube == 1){ int pipeling = pipe(fd); if (pipeling == -1){ perror("pipe"); } } tmp = fork(); //FORK A if (tmp < 0){ perror("fork"); continue; } if (tmp!= 0) { //parent while(wait(0)!= ...
The second fork is not going to be reached in case execvp succeeds, because the latter should replace the image of the process and will stop executing the current code. You have to restructure your program.
Pipe() fork() and exec I try to add pipe in a mini-shell. I'm confused, when I type ls | sort, nothing is displayed, I don't understand why: int fd[2]; if (tube == 1){ int pipeling = pipe(fd); if (pipeling == -1){ perror("pipe"); } } tmp = fork(); //FORK A if (tmp < 0){ perror("fork"); continue; } if (tmp!= 0) { //...
TITLE: Pipe() fork() and exec QUESTION: I try to add pipe in a mini-shell. I'm confused, when I type ls | sort, nothing is displayed, I don't understand why: int fd[2]; if (tube == 1){ int pipeling = pipe(fd); if (pipeling == -1){ perror("pipe"); } } tmp = fork(); //FORK A if (tmp < 0){ perror("fork"); continue; } ...
[ "c", "shell", "unix", "fork", "pipe" ]
1
2
1,340
1
0
2011-06-02T20:31:58.933000
2011-06-02T20:36:01.660000
6,220,060
6,220,239
How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file
I have a directory full of zip files. Each called something like 'files1.zip'. My instinct is to use a bash for loop to unzip each file. Trouble is, many of the files will unzip their contents straight into the parent directory, rather then unfolding everything into their own unique directory. So, I get file soup. I'd ...
for f in *.zip; do dir=${f%.zip} unzip -d "./$dir" "./$f" done
How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file I have a directory full of zip files. Each called something like 'files1.zip'. My instinct is to use a bash for loop to unzip each file. Trouble is, many of the files will unzip their contents s...
TITLE: How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file QUESTION: I have a directory full of zip files. Each called something like 'files1.zip'. My instinct is to use a bash for loop to unzip each file. Trouble is, many of the files will unzi...
[ "bash", "unzip" ]
13
20
9,006
3
0
2011-06-02T20:32:17.603000
2011-06-02T20:50:53.663000
6,220,063
6,220,168
EF Code First not returning object as DynamicProxies until after the HTTP Request is complete
I'm getting some strange behaviour from EF Code First when I add an object to the database and select it back from the database in the same HTTP request. When I retrieve it, it is returned as the object type rather than of type System.Data.Entity.DynamicProxies so the lazy loading doesn't work. If I retrieve the same o...
In C#, if you call new Post(), then you're going to get a Post instance, not an instance of a proxy subtype of Post. To get a proxy, you have to call something different. You can, e.g., call DbSet.Create: var post = blogContext.Posts.Create(); post.PublishDate = DateTime.Now;
EF Code First not returning object as DynamicProxies until after the HTTP Request is complete I'm getting some strange behaviour from EF Code First when I add an object to the database and select it back from the database in the same HTTP request. When I retrieve it, it is returned as the object type rather than of typ...
TITLE: EF Code First not returning object as DynamicProxies until after the HTTP Request is complete QUESTION: I'm getting some strange behaviour from EF Code First when I add an object to the database and select it back from the database in the same HTTP request. When I retrieve it, it is returned as the object type ...
[ "asp.net-mvc", "entity-framework", "asp.net-mvc-3", "ef-code-first", "code-first" ]
1
3
860
3
0
2011-06-02T20:32:27.603000
2011-06-02T20:43:46.353000
6,220,077
6,220,146
pass a string with white space in javascript
Hello I have a php code which by echo calls the javascript function expand(txt) with the parameter 'txt' echo " $valueX "; function expand(txt) { document.getElementById("targetDiv").value=txt; } my problem is that this script works only if the '$hint1' is a string without white space, example if $hint="car" everyth...
change this line: echo " $valueX "; to this: echo " $valueX "; the onclick-event has to be in "" and you don't need the javascript:-label (but the last one shouldn't make a difference, it's just senseless)
pass a string with white space in javascript Hello I have a php code which by echo calls the javascript function expand(txt) with the parameter 'txt' echo " $valueX "; function expand(txt) { document.getElementById("targetDiv").value=txt; } my problem is that this script works only if the '$hint1' is a string withou...
TITLE: pass a string with white space in javascript QUESTION: Hello I have a php code which by echo calls the javascript function expand(txt) with the parameter 'txt' echo " $valueX "; function expand(txt) { document.getElementById("targetDiv").value=txt; } my problem is that this script works only if the '$hint1' ...
[ "php" ]
1
1
2,501
3
0
2011-06-02T20:33:23.090000
2011-06-02T20:40:30.540000
6,220,084
6,220,223
Get Relational Items - Fastest
I am storing relational items in fields as comma delimited IDs like so:,4,12,8,16,198, The reason for the leading and trailing commas are for searching with LIKE '%,id,%' I am trying to write a bootstrap function to retrieve all these items based on the ID in the order of the IDs. My question is what is the most effici...
I'd go for ORDER BY FIELD(`id`, 4, 12, 8, 16, 198) in combination with the IN
Get Relational Items - Fastest I am storing relational items in fields as comma delimited IDs like so:,4,12,8,16,198, The reason for the leading and trailing commas are for searching with LIKE '%,id,%' I am trying to write a bootstrap function to retrieve all these items based on the ID in the order of the IDs. My ques...
TITLE: Get Relational Items - Fastest QUESTION: I am storing relational items in fields as comma delimited IDs like so:,4,12,8,16,198, The reason for the leading and trailing commas are for searching with LIKE '%,id,%' I am trying to write a bootstrap function to retrieve all these items based on the ID in the order o...
[ "php", "optimization", "pdo", "query-optimization", "relational-database" ]
1
1
47
1
0
2011-06-02T20:34:00.127000
2011-06-02T20:49:26.710000
6,220,094
6,220,399
Cant get xammp to send email through PHP
Having big problems trying to get my php script to send email. Using this script on my mac: setSubject('Your subject') /*Set the from address with an associative array*/ ->setFrom(array('email'=>'Name')) /*Set the to addresses with an associative array*/ ->setTo(array('email')) /*Give it a body*/ ->setBody('Email'); $m...
On Linux systems, mail is sent from PHP via the mail() function which uses Sendmail. Whenever I use Swiftmailer on windows, I use SMTP, which gmail allows. http://www.swiftmailer.org/wikidocs/v3/smtpauth
Cant get xammp to send email through PHP Having big problems trying to get my php script to send email. Using this script on my mac: setSubject('Your subject') /*Set the from address with an associative array*/ ->setFrom(array('email'=>'Name')) /*Set the to addresses with an associative array*/ ->setTo(array('email')) ...
TITLE: Cant get xammp to send email through PHP QUESTION: Having big problems trying to get my php script to send email. Using this script on my mac: setSubject('Your subject') /*Set the from address with an associative array*/ ->setFrom(array('email'=>'Name')) /*Set the to addresses with an associative array*/ ->setT...
[ "php", "gmail", "xampp" ]
0
0
2,463
1
0
2011-06-02T20:35:24.640000
2011-06-02T21:06:27.020000
6,220,110
6,220,710
Display different context menu
Goal: Display different context menu if right clicking a row from the listview or right clicking inside of listview without making a selection of a row. Problem: Having difficult to find a solution that enable to display different context menu once clicking on something. private void lstvdMonth_MouseRightButtonUp(objec...
I think what you should test in the if is whether any items are selected in the ListView (e.g. SelectedItem == null ). How exactly do you expect the mouse button to ever be down in the MouseUp event?
Display different context menu Goal: Display different context menu if right clicking a row from the listview or right clicking inside of listview without making a selection of a row. Problem: Having difficult to find a solution that enable to display different context menu once clicking on something. private void lstv...
TITLE: Display different context menu QUESTION: Goal: Display different context menu if right clicking a row from the listview or right clicking inside of listview without making a selection of a row. Problem: Having difficult to find a solution that enable to display different context menu once clicking on something....
[ "c#", "wpf", "contextmenu" ]
0
0
483
1
0
2011-06-02T20:36:28.243000
2011-06-02T21:39:48.377000
6,220,121
6,220,173
How do I seperate my SQL and Business Logic in this example?
I have been looking for help online on how to design my php classes to separate my business logic and my data layers. I had started to design a class I thought was pretty cool but then discovered PDO and ADODB and had a nice facepalm moment realizing I was recreating the wheel. My problem now is I still don't quite und...
It's hard to tell just how much this would apply to your real-world situation, but you should probably look up what an ORM (Object-Relational Mapping) can do for you. There are many, many very useful ORM solutions out there, that can make this stuff much simpler. They're not all right for every solution, of course, but...
How do I seperate my SQL and Business Logic in this example? I have been looking for help online on how to design my php classes to separate my business logic and my data layers. I had started to design a class I thought was pretty cool but then discovered PDO and ADODB and had a nice facepalm moment realizing I was re...
TITLE: How do I seperate my SQL and Business Logic in this example? QUESTION: I have been looking for help online on how to design my php classes to separate my business logic and my data layers. I had started to design a class I thought was pretty cool but then discovered PDO and ADODB and had a nice facepalm moment ...
[ "php", "abstraction", "data-layers" ]
1
2
678
2
0
2011-06-02T20:38:01.723000
2011-06-02T20:44:35.747000
6,220,125
6,220,456
what does the error message 'Operation now in progress' mean?
When trying to open a file using this command: $fd = fopen('majestic_files/majestic_record.txt','w'); I get the following error message: Warning: fopen(majestic_files/majestic_record.txt) [ function.fopen ]: failed to open stream: Operation now in progress in What does it mean, and how do I fix it?
This occurs when there is an outstanding blocking operation. In this context, the error implies that another process has a lock on the file, most likely due to the file being open and written to by whichever process holds the lock.
what does the error message 'Operation now in progress' mean? When trying to open a file using this command: $fd = fopen('majestic_files/majestic_record.txt','w'); I get the following error message: Warning: fopen(majestic_files/majestic_record.txt) [ function.fopen ]: failed to open stream: Operation now in progress i...
TITLE: what does the error message 'Operation now in progress' mean? QUESTION: When trying to open a file using this command: $fd = fopen('majestic_files/majestic_record.txt','w'); I get the following error message: Warning: fopen(majestic_files/majestic_record.txt) [ function.fopen ]: failed to open stream: Operation...
[ "php", "fopen" ]
11
13
16,087
5
0
2011-06-02T20:38:22.923000
2011-06-02T21:12:06.800000
6,220,126
6,220,179
ExecuteReader taking time, not in SQL server?
I am executing stored procedure using ExcuteReader() command. If I execute Stored Procedure in SQL server it is taking 2 secs. But in code taking around 2 mins. I tried DataAdapter.Fill(). Still the same. What is wrong in the code? spString = "usp_graph" sqlcmd_q.Connection = sqlCnn sqlcmd_q.CommandText = spString sqlc...
Slow in the Application, Fast in SSMS?. Everything you need to know about this subject, and more.
ExecuteReader taking time, not in SQL server? I am executing stored procedure using ExcuteReader() command. If I execute Stored Procedure in SQL server it is taking 2 secs. But in code taking around 2 mins. I tried DataAdapter.Fill(). Still the same. What is wrong in the code? spString = "usp_graph" sqlcmd_q.Connection...
TITLE: ExecuteReader taking time, not in SQL server? QUESTION: I am executing stored procedure using ExcuteReader() command. If I execute Stored Procedure in SQL server it is taking 2 secs. But in code taking around 2 mins. I tried DataAdapter.Fill(). Still the same. What is wrong in the code? spString = "usp_graph" s...
[ "asp.net", "sql", "vb.net" ]
5
5
2,636
1
0
2011-06-02T20:38:29.750000
2011-06-02T20:45:00.087000
6,220,133
6,220,161
Javascript OOP return value from function
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new Array(); var tabUrl; this.getTabUrl=function() { logToConsole("getTabUrl is called"); chrome.tabs.getSelected(null, function(tab) { tabUrl = tab.url; logToConsole(tabUrl); }); return tabUrl; } ` Then I cal...
In the second example, you are calling logToConsole as if it is a function of the miner object, which is is not. miner.logToConsole Edit Per comments about github example, this should make the logToConsole function par of the SocialMiner object. However, I didn't read the class thoroughly, so proceed with caution with ...
Javascript OOP return value from function I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new Array(); var tabUrl; this.getTabUrl=function() { logToConsole("getTabUrl is called"); chrome.tabs.getSelected(null, function(tab) { tabUrl = tab.url; logToConsole(ta...
TITLE: Javascript OOP return value from function QUESTION: I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new Array(); var tabUrl; this.getTabUrl=function() { logToConsole("getTabUrl is called"); chrome.tabs.getSelected(null, function(tab) { tabUrl = tab.ur...
[ "javascript", "google-chrome" ]
0
2
597
2
0
2011-06-02T20:39:23.143000
2011-06-02T20:42:36.170000
6,220,144
6,220,955
Idempotent hash associations
I have some names: ["James", "John", "Krieg"] and some colors: ["Red", "Green", "Blue", "Yellow"]. I want to map names to colors, using some hashing function: f(name) -> color. This association is idempotent. For example, if in the original list, f(James) -> Red, then after I add names or colors to their respective lis...
I'm going to say that such a thing does not exist without relying on persistence. We can rule out any mapping based on list position. Let's start with N names and 1 color - that means that all names map to a single color. If we later have N names and M colors, unless we can store which N names map to that first color, ...
Idempotent hash associations I have some names: ["James", "John", "Krieg"] and some colors: ["Red", "Green", "Blue", "Yellow"]. I want to map names to colors, using some hashing function: f(name) -> color. This association is idempotent. For example, if in the original list, f(James) -> Red, then after I add names or c...
TITLE: Idempotent hash associations QUESTION: I have some names: ["James", "John", "Krieg"] and some colors: ["Red", "Green", "Blue", "Yellow"]. I want to map names to colors, using some hashing function: f(name) -> color. This association is idempotent. For example, if in the original list, f(James) -> Red, then afte...
[ "python", "hash" ]
1
2
869
6
0
2011-06-02T20:40:23.363000
2011-06-02T22:08:46.577000
6,220,154
6,220,322
PHP Object definitions cached? Trouble deleting methods with reflection
I am working on an object to allow us to modify PHP files containing PHP objects. (Specifically, they are Doctrine entity files that we have to modify.) Anyway, without the boring details here is what is happening. I am first finding the location of the class file, and INCLUDEing it. I then create an instance of the cl...
This is not possible the way you put it. PHP can only load a class definition once. After it's loaded and in memory, the only way to "refresh" it is to terminate the script and re-execute it. If you try re-including the file, you'll obviously get a " class already defined error ". No matter how long your script runs, o...
PHP Object definitions cached? Trouble deleting methods with reflection I am working on an object to allow us to modify PHP files containing PHP objects. (Specifically, they are Doctrine entity files that we have to modify.) Anyway, without the boring details here is what is happening. I am first finding the location o...
TITLE: PHP Object definitions cached? Trouble deleting methods with reflection QUESTION: I am working on an object to allow us to modify PHP files containing PHP objects. (Specifically, they are Doctrine entity files that we have to modify.) Anyway, without the boring details here is what is happening. I am first find...
[ "php", "reflection" ]
3
4
1,313
4
0
2011-06-02T20:41:26.183000
2011-06-02T20:59:05.637000
6,220,155
6,220,248
MVC Razor: How to mix html helpers and text in same line?
I would like to use multiple html helpers in the same line, but I'm not succeding. The result I search is: Name: (note the ":") @Html.LabelFor(x=>x.Name) ":" @Html.EditorFor(x => x.Name) //doesn't work How can I achive this?
Use @: syntax. @using (Html.BeginForm()) { @Html.LabelFor(x=>x.Name) @:: @Html.EditorFor(x => x.Name) } Or the special tag text (this tag is not rendered, it allows you to put text between codes like this) @using (Html.BeginForm()) { @Html.LabelFor(x=>x.Name): @Html.EditorFor(x => x.Name) }
MVC Razor: How to mix html helpers and text in same line? I would like to use multiple html helpers in the same line, but I'm not succeding. The result I search is: Name: (note the ":") @Html.LabelFor(x=>x.Name) ":" @Html.EditorFor(x => x.Name) //doesn't work How can I achive this?
TITLE: MVC Razor: How to mix html helpers and text in same line? QUESTION: I would like to use multiple html helpers in the same line, but I'm not succeding. The result I search is: Name: (note the ":") @Html.LabelFor(x=>x.Name) ":" @Html.EditorFor(x => x.Name) //doesn't work How can I achive this? ANSWER: Use @: syn...
[ "asp.net" ]
3
7
2,665
2
0
2011-06-02T20:41:37.620000
2011-06-02T20:51:53.057000
6,220,160
6,220,246
Custom font in iPhone
I'm new in iphone themes develop, and i want to know how to use custom TTF or OTF fonts on iphone, like one font type for phone pad, other for messages, etc... Can help me?
Yes, you can easily use custom TTF fonts in your application. All you need to do is to add the font as a resource and set a key in your Info.plist. See also this step-by-step guide.
Custom font in iPhone I'm new in iphone themes develop, and i want to know how to use custom TTF or OTF fonts on iphone, like one font type for phone pad, other for messages, etc... Can help me?
TITLE: Custom font in iPhone QUESTION: I'm new in iphone themes develop, and i want to know how to use custom TTF or OTF fonts on iphone, like one font type for phone pad, other for messages, etc... Can help me? ANSWER: Yes, you can easily use custom TTF fonts in your application. All you need to do is to add the fon...
[ "iphone", "iphone-sdk-3.0" ]
5
11
6,087
1
0
2011-06-02T20:42:13.453000
2011-06-02T20:51:48.040000
6,220,164
6,220,214
jquery: break text into boxes
How can I turn the html below, Break me to B r e a k m e $("h3").text(); that's all I can think of! (feeling ashamed...) css,.box-letter { display:block; clear:both; width:50px; border:1px solid #000; } Thanks.
// Splits the string into a "character array" var charArray = $('h3').text().split(''); // Clear the html of h3 so we can change it $('h3').html(''); for (var i = 0; i < charArray.length; i++) { // for each character, append it to h3 with a span wrapper $('h3').append(' ' + ((charArray[i] == ' ')? ' ': charArray[i]) + ...
jquery: break text into boxes How can I turn the html below, Break me to B r e a k m e $("h3").text(); that's all I can think of! (feeling ashamed...) css,.box-letter { display:block; clear:both; width:50px; border:1px solid #000; } Thanks.
TITLE: jquery: break text into boxes QUESTION: How can I turn the html below, Break me to B r e a k m e $("h3").text(); that's all I can think of! (feeling ashamed...) css,.box-letter { display:block; clear:both; width:50px; border:1px solid #000; } Thanks. ANSWER: // Splits the string into a "character array" var ch...
[ "jquery", "text", "each" ]
0
1
229
5
0
2011-06-02T20:43:20.207000
2011-06-02T20:48:33.983000
6,220,174
6,220,256
Validate URL by regex and filter_val
I have been searching for the best way to validate a URL in php and decided to use both regex and filter_val() I would like to share my code and get some feedback please. function _valid_urls($str) { $regex = "/^(http):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i"; if(!filter_var($str, FILTER_VALI...
You've made a few errors in the regex. Nothing fatal, I don't think but nevertheless, just a few miscellaneous things you can do to clean it up. You have put parentheses around http, and they don't need to be there. It looks like you're not capturing it for use later. If you're trying to make the http:// part optional,...
Validate URL by regex and filter_val I have been searching for the best way to validate a URL in php and decided to use both regex and filter_val() I would like to share my code and get some feedback please. function _valid_urls($str) { $regex = "/^(http):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/...
TITLE: Validate URL by regex and filter_val QUESTION: I have been searching for the best way to validate a URL in php and decided to use both regex and filter_val() I would like to share my code and get some feedback please. function _valid_urls($str) { $regex = "/^(http):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_...
[ "php", "regex", "security", "validation", "url" ]
0
3
1,380
1
0
2011-06-02T20:44:37.557000
2011-06-02T20:52:24.157000
6,220,180
6,220,226
jQuery slidetoggle function breaks when additional div is added
The function below acts as an slidetoggle accordion (for a list of Wordpress posts) and it does a number of things, like toggle, add active classes and "declick" the open toggle div. Worked fine with the three divs -.entry-post,.entry-title and.entry-content - until... wait for it... I needed to add another div in the ...
You can't change next(), it always looks at the next sibling element: ( next() gets) the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. [emphasis mine.] You could, however, use parent() and find(): ...
jQuery slidetoggle function breaks when additional div is added The function below acts as an slidetoggle accordion (for a list of Wordpress posts) and it does a number of things, like toggle, add active classes and "declick" the open toggle div. Worked fine with the three divs -.entry-post,.entry-title and.entry-conte...
TITLE: jQuery slidetoggle function breaks when additional div is added QUESTION: The function below acts as an slidetoggle accordion (for a list of Wordpress posts) and it does a number of things, like toggle, add active classes and "declick" the open toggle div. Worked fine with the three divs -.entry-post,.entry-tit...
[ "jquery", "slidetoggle", "jquery-ui-accordion" ]
0
2
403
1
0
2011-06-02T20:45:03.310000
2011-06-02T20:49:37.307000
6,220,187
6,220,393
IE settimeout loses event variable
This seems to work fine in Firefox but, in IE8 specifically (it may work in other version of IE), I have an issue where the event variable is lost. There is an event (mousedown) that calls a function that stores a parameter set. One of the parameters is the event itself. The function that is called stores the parameter...
onmousedown="eventFired(event);" does something subtly different in the event model of IE<9 than it does in other browsers. In most browsers, the above works because onX inline event handlers receive an implicit argument-like local variable called event, which is a newly-minted Event object for each new event. This get...
IE settimeout loses event variable This seems to work fine in Firefox but, in IE8 specifically (it may work in other version of IE), I have an issue where the event variable is lost. There is an event (mousedown) that calls a function that stores a parameter set. One of the parameters is the event itself. The function ...
TITLE: IE settimeout loses event variable QUESTION: This seems to work fine in Firefox but, in IE8 specifically (it may work in other version of IE), I have an issue where the event variable is lost. There is an event (mousedown) that calls a function that stores a parameter set. One of the parameters is the event its...
[ "javascript", "internet-explorer-8", "settimeout" ]
2
4
1,394
2
0
2011-06-02T20:45:56.210000
2011-06-02T21:06:05.383000
6,220,190
6,234,840
Connecting Log4J viewer (chainsaw) to a MySql database
I want to use log4j viewer (Chainsaw) to read error logs logged in a MySql database by log4j. I am a bit struggling as the documentation is really sparse. [strike]Here is my tentative.xml config for Chainsaw:[/strike] Here is my new.xml config: It tells me that: No suitable driver found for jdbc:mysql://: / I have down...
And more info on how to use jars that aren't distributed with Chainsaw: http://logging.apache.org/chainsaw/distributionnotes.html By the way, you may want to try the latest developer snapshot of Chainsaw, available here: http://people.apache.org/~sdeboy Lots of new features... Scott
Connecting Log4J viewer (chainsaw) to a MySql database I want to use log4j viewer (Chainsaw) to read error logs logged in a MySql database by log4j. I am a bit struggling as the documentation is really sparse. [strike]Here is my tentative.xml config for Chainsaw:[/strike] Here is my new.xml config: It tells me that: No...
TITLE: Connecting Log4J viewer (chainsaw) to a MySql database QUESTION: I want to use log4j viewer (Chainsaw) to read error logs logged in a MySql database by log4j. I am a bit struggling as the documentation is really sparse. [strike]Here is my tentative.xml config for Chainsaw:[/strike] Here is my new.xml config: It...
[ "java", "log4j", "log4net", "log4net-configuration" ]
2
3
1,193
2
0
2011-06-02T20:46:11.410000
2011-06-04T05:08:12.530000
6,220,196
6,310,431
Determine if Tomcat is running in Windows using the command prompt
Quite simply, how does one determine whether or not Tomcat is running in Windows, using the command prompt? I am writing a batch script that must do this. This is the Bash version: RESULT=`netstat -na | grep $2 | awk '{print $7}' | wc -l` Where $2 is the port. I am looking for something similar to that. Using Cygwin is...
You could use tasklist to check if the tomcat executable is running. For example: @echo off tasklist /FI "IMAGENAME eq tomcat.exe" | find /C /I ".exe" > NUL if %errorlevel%==0 goto:running echo tomcat is not running goto:eof:running echo tomcat is running:eof It is also possible to check a remove server using the opti...
Determine if Tomcat is running in Windows using the command prompt Quite simply, how does one determine whether or not Tomcat is running in Windows, using the command prompt? I am writing a batch script that must do this. This is the Bash version: RESULT=`netstat -na | grep $2 | awk '{print $7}' | wc -l` Where $2 is th...
TITLE: Determine if Tomcat is running in Windows using the command prompt QUESTION: Quite simply, how does one determine whether or not Tomcat is running in Windows, using the command prompt? I am writing a batch script that must do this. This is the Bash version: RESULT=`netstat -na | grep $2 | awk '{print $7}' | wc ...
[ "windows", "tomcat", "batch-file" ]
17
5
70,010
10
0
2011-06-02T20:46:34.427000
2011-06-10T18:13:39.747000
6,220,197
6,220,271
What is the best way to have a function toggle between two different processes?
I have a function that I want it execute alternating processes every time it's triggered. Any help on how I would achieve this would be great. function onoff(){ statusOn process /*or if on*/ statusOff process }
One interesting aspect of JavaScript is that functions are first-class objects, meaning they can have custom properties: function onoff() { onoff.enabled =!onoff.enabled; if(onoff.enabled) { alert('on'); } else { alert('off'); } } For this to work, your function should have a name. If your function is anonymous (unname...
What is the best way to have a function toggle between two different processes? I have a function that I want it execute alternating processes every time it's triggered. Any help on how I would achieve this would be great. function onoff(){ statusOn process /*or if on*/ statusOff process }
TITLE: What is the best way to have a function toggle between two different processes? QUESTION: I have a function that I want it execute alternating processes every time it's triggered. Any help on how I would achieve this would be great. function onoff(){ statusOn process /*or if on*/ statusOff process } ANSWER: On...
[ "javascript" ]
7
7
277
7
0
2011-06-02T20:46:35.723000
2011-06-02T20:53:58.477000
6,220,204
6,220,368
gethostbyname() only returns the address of local host on linux
I'm trying to portably (Windows & Linux) find all of the IP addresses of the local machine. The method I am using is to first call gethostname(), and then pass the result of that to gethostbyname(), which returns an array of ip addresses. The problem is that on linux, the only address I get back is 127.0.0.1. This work...
It is not the correct way on unix/linux. The correct way involves ioctls to pull the necessary information. struct ifreq ifc_buffer[MAX_NUM_IFREQ]; ioctl(s, SIOCGIFCONF, &ifc) # Interface list num_ifreq = ifc.ifc_len / sizeof(struct ifreq); for(cnt=0;cnt There are also more modern methods involving: if_nameindex() Doin...
gethostbyname() only returns the address of local host on linux I'm trying to portably (Windows & Linux) find all of the IP addresses of the local machine. The method I am using is to first call gethostname(), and then pass the result of that to gethostbyname(), which returns an array of ip addresses. The problem is th...
TITLE: gethostbyname() only returns the address of local host on linux QUESTION: I'm trying to portably (Windows & Linux) find all of the IP addresses of the local machine. The method I am using is to first call gethostname(), and then pass the result of that to gethostbyname(), which returns an array of ip addresses....
[ "sockets", "bsd", "gethostbyname" ]
3
1
6,207
2
0
2011-06-02T20:47:23.030000
2011-06-02T21:03:15.813000
6,220,209
6,231,669
Looking for a good resource for building a SP 2007 WSP package in Visual Studio 2010
I have an event handler feature that I've built for sharepoint 2007 and have deployed by moving the DLL to the GAC and creating Feature.xml and Elements.xml in the necessary folder and then installing them using the stsadm commands. I'm looking to avoid doing all this and instead have a WSP file that I can run to insta...
Here's how I would proceed to convert your unmanaged items into a managed solution package in Visual Studio 2010: Create an "Empty SharePoint Project". Set the deployment target. In Solution Explorer, click the project node and look at the Properties pane. Set the Assembly Deployment Target property between GlobalAssem...
Looking for a good resource for building a SP 2007 WSP package in Visual Studio 2010 I have an event handler feature that I've built for sharepoint 2007 and have deployed by moving the DLL to the GAC and creating Feature.xml and Elements.xml in the necessary folder and then installing them using the stsadm commands. I'...
TITLE: Looking for a good resource for building a SP 2007 WSP package in Visual Studio 2010 QUESTION: I have an event handler feature that I've built for sharepoint 2007 and have deployed by moving the DLL to the GAC and creating Feature.xml and Elements.xml in the necessary folder and then installing them using the s...
[ "sharepoint", "wsp" ]
0
3
411
2
0
2011-06-02T20:47:49.753000
2011-06-03T19:22:46.597000
6,220,211
6,220,284
Move backward through history skipping the same page with different query string
When I refresh a page or redirect to the same one using the same url, I can click in a button with "window.history.back();" code and go back to the previous page. However, If the query string was changed, I just back to the same page when I try to move back. Example 1: page1.html -> page2.html -> page2.html -> [click b...
Use Next to go forward while replacing the link in the history array
Move backward through history skipping the same page with different query string When I refresh a page or redirect to the same one using the same url, I can click in a button with "window.history.back();" code and go back to the previous page. However, If the query string was changed, I just back to the same page when ...
TITLE: Move backward through history skipping the same page with different query string QUESTION: When I refresh a page or redirect to the same one using the same url, I can click in a button with "window.history.back();" code and go back to the previous page. However, If the query string was changed, I just back to t...
[ "javascript", "browser-history" ]
4
1
3,360
1
0
2011-06-02T20:48:09.350000
2011-06-02T20:55:21.113000
6,220,212
6,220,369
Buffer overflow in C
I'm attempting to write a simple buffer overflow using C on Mac OS X 10.6 64-bit. Here's the concept: void function() { char buffer[64]; buffer[offset] += 7; // i'm not sure how large offset needs to be, or if // 7 is correct. } int main() { int x = 0; function(); x += 1; printf("%d\n", x); // the idea is to modify t...
This 32-bit example illustrates how you can figure it out, see below for 64-bit: #include void function() { char buffer[64]; char *p; asm("lea 4(%%ebp),%0": "=r" (p)); // loads address of return address printf("%d\n", p - buffer); // computes offset buffer[p - buffer] += 9; // 9 from disassembling main } int main() { ...
Buffer overflow in C I'm attempting to write a simple buffer overflow using C on Mac OS X 10.6 64-bit. Here's the concept: void function() { char buffer[64]; buffer[offset] += 7; // i'm not sure how large offset needs to be, or if // 7 is correct. } int main() { int x = 0; function(); x += 1; printf("%d\n", x); // th...
TITLE: Buffer overflow in C QUESTION: I'm attempting to write a simple buffer overflow using C on Mac OS X 10.6 64-bit. Here's the concept: void function() { char buffer[64]; buffer[offset] += 7; // i'm not sure how large offset needs to be, or if // 7 is correct. } int main() { int x = 0; function(); x += 1; printf...
[ "c", "buffer-overflow" ]
19
13
13,389
5
0
2011-06-02T20:48:25.323000
2011-06-02T21:03:16.010000
6,220,213
6,220,445
Error when importing framework objective-c
I am trying to add TCMPortMapper (http://code.google.com/p/tcmportmapper/) I have linked the framework in the build phases and tried to run the example code: #import #import int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; TCMPortMapper *pm = [TCMPortMapper share...
Are you using the binary release of TCPPortMapper? It doesn't have x86_64 arch executable. $ file TCMPortMapper.framework/TCMPortMapper TCMPortMapper.framework/TCMPortMapper: Mach-O universal binary with 2 architectures TCMPortMapper.framework/TCMPortMapper (for architecture ppc): Mach-O dynamically linked shared libra...
Error when importing framework objective-c I am trying to add TCMPortMapper (http://code.google.com/p/tcmportmapper/) I have linked the framework in the build phases and tried to run the example code: #import #import int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init...
TITLE: Error when importing framework objective-c QUESTION: I am trying to add TCMPortMapper (http://code.google.com/p/tcmportmapper/) I have linked the framework in the build phases and tried to run the example code: #import #import int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutorelea...
[ "objective-c", "macos", "frameworks", "mac-frameworks" ]
0
1
827
1
0
2011-06-02T20:48:31.580000
2011-06-02T21:11:13.187000
6,220,218
6,220,452
How can I position a layout right above the android on-screen keyboard?
See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code? UPDATE: Here is my layout: And here is my Manifest where I specify the softInputMode:
Make sure your soft input mode is set to adjustResize, then place the layout with your toolbar at the bottom of your activity. Example:
How can I position a layout right above the android on-screen keyboard? See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code? UPDATE: Here is my layout: And here is my Manifest where I s...
TITLE: How can I position a layout right above the android on-screen keyboard? QUESTION: See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code? UPDATE: Here is my layout: And here is my ...
[ "java", "android", "keyboard", "android-linearlayout" ]
27
33
21,184
3
0
2011-06-02T20:49:07.793000
2011-06-02T21:11:52.717000
6,220,230
6,222,338
What is the purpose of the RVM binary if it can be run as a function?
I've recently started using Ruby and was told to look into using RVM. I'm currently trying to understand how it operates but as far as I can tell from the website it can be run either as a binary or as a function in the shell by modifying.bash_profile. What are the binaries for? I noticed they got installed to ~/bin, w...
It is normal and desirable for users of unix to put binaries in ~/bin (you would normally add that to your $PATH ), so don't feel like it's messy to install stuff there. That said, ~/bin/rvm is a script that will let you run rvm commands (like install), but is unable to edit your shell's environment (like all programs)...
What is the purpose of the RVM binary if it can be run as a function? I've recently started using Ruby and was told to look into using RVM. I'm currently trying to understand how it operates but as far as I can tell from the website it can be run either as a binary or as a function in the shell by modifying.bash_profil...
TITLE: What is the purpose of the RVM binary if it can be run as a function? QUESTION: I've recently started using Ruby and was told to look into using RVM. I'm currently trying to understand how it operates but as far as I can tell from the website it can be run either as a binary or as a function in the shell by mod...
[ "ruby", "rvm" ]
3
0
407
1
0
2011-06-02T20:50:19.647000
2011-06-03T02:12:51.160000
6,220,235
6,222,623
Vimeo on Facebook share/
im trying to display the player from Vimeo on the facebook wall (after clicking the link share). Some title using this, facebook doesn't load the video directly. Im not sure why its not working, so anyone with experience - can you tell me where i fail?
Use the new Facebook open graph meta tags. I grabbed the vimeo link by going to a vimeo video, clicking embed, clicked "old embed code", and grabbing the url.
Vimeo on Facebook share/ im trying to display the player from Vimeo on the facebook wall (after clicking the link share). Some title using this, facebook doesn't load the video directly. Im not sure why its not working, so anyone with experience - can you tell me where i fail?
TITLE: Vimeo on Facebook share/ QUESTION: im trying to display the player from Vimeo on the facebook wall (after clicking the link share). Some title using this, facebook doesn't load the video directly. Im not sure why its not working, so anyone with experience - can you tell me where i fail? ANSWER: Use the new Fac...
[ "facebook", "share", "vimeo" ]
3
6
10,619
1
0
2011-06-02T20:50:42.407000
2011-06-03T03:17:06.770000
6,220,237
6,220,282
How to call self component in Java swing?
I have many buttons in a button group that need to search a database using their containing text as the query when toggled. Instead of typing out specific event code for each button, how do I call a button's self? Desired pseudocode: searchDB(genericSelf.getText()) Tried using the this keyword and fiddling with getComp...
How about: public void actionPerformed(ActionEvent evt) { JButton source = (JButton) evt.getSource(); // source is your "this" }
How to call self component in Java swing? I have many buttons in a button group that need to search a database using their containing text as the query when toggled. Instead of typing out specific event code for each button, how do I call a button's self? Desired pseudocode: searchDB(genericSelf.getText()) Tried using ...
TITLE: How to call self component in Java swing? QUESTION: I have many buttons in a button group that need to search a database using their containing text as the query when toggled. Instead of typing out specific event code for each button, how do I call a button's self? Desired pseudocode: searchDB(genericSelf.getTe...
[ "java", "swing", "components", "call", "self" ]
1
2
313
1
0
2011-06-02T20:50:51.893000
2011-06-02T20:54:59.570000
6,220,251
6,220,299
View all text of an element with XmlReader C#
I'm using an XmlReader to iterate through some XML. Some of the XML is actually HTML and I want to get the text content from the node. Example XML: Here is some data Example code: using (XmlReader reader = new XmlReader(myUrl)) { while (reader.Read()) { if (reader.Name == "p") { // I want to get all the TEXT contents f...
Use ReadInnerXml: StringReader myUrl = new StringReader(@" Here is some data "); using (XmlReader reader = XmlReader.Create(myUrl)) { while (reader.Read()) { if (reader.Name == "p") { // I want to get all the TEXT contents from the this node Console.WriteLine(reader.ReadInnerXml()); } } } Or if you want to skip the as ...
View all text of an element with XmlReader C# I'm using an XmlReader to iterate through some XML. Some of the XML is actually HTML and I want to get the text content from the node. Example XML: Here is some data Example code: using (XmlReader reader = new XmlReader(myUrl)) { while (reader.Read()) { if (reader.Name == "...
TITLE: View all text of an element with XmlReader C# QUESTION: I'm using an XmlReader to iterate through some XML. Some of the XML is actually HTML and I want to get the text content from the node. Example XML: Here is some data Example code: using (XmlReader reader = new XmlReader(myUrl)) { while (reader.Read()) { if...
[ "c#", "xml", "xmlreader" ]
4
13
23,372
3
0
2011-06-02T20:52:06.633000
2011-06-02T20:57:15.747000
6,220,258
6,225,169
jQuery SESSION problem with Google Chrome and Safari on MAC OS x 10.5 only
I have a problem with the following code, which doesn't want to work in Chrome and Safari: function updateBasket(data) { if (data!= '') { $.each(data, function(k, v) { if (jQuery.inArray(k, data.remove) == -1 && $('.' + k).length > 0) { $('.' + k).html(v); } }); } } $('.add_to_basket').live('click', function() { var b...
Ok - I've figured out what was causing problems: if (!isset($_SESSION)) { session_start(); } which should simply be: session_start(); as it checks on its own whether the session is set. Thanks for participating everyone!
jQuery SESSION problem with Google Chrome and Safari on MAC OS x 10.5 only I have a problem with the following code, which doesn't want to work in Chrome and Safari: function updateBasket(data) { if (data!= '') { $.each(data, function(k, v) { if (jQuery.inArray(k, data.remove) == -1 && $('.' + k).length > 0) { $('.' + ...
TITLE: jQuery SESSION problem with Google Chrome and Safari on MAC OS x 10.5 only QUESTION: I have a problem with the following code, which doesn't want to work in Chrome and Safari: function updateBasket(data) { if (data!= '') { $.each(data, function(k, v) { if (jQuery.inArray(k, data.remove) == -1 && $('.' + k).leng...
[ "google-chrome", "jquery", "safari" ]
1
0
1,745
2
0
2011-06-02T20:52:31.440000
2011-06-03T09:16:37.260000
6,220,273
6,220,433
Rails: unobtrusive checkin function
I have a simple checkin app: there's a page with a series of pictures of users. They are "checked in" by a simple click on the image. This registers them in the database and displays a "checked in" icon overlaying the image. Right now I'm doing this by a "link_to" in the view which calls the register controller action....
Why not use Rail's:remote => true on the link_to? http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
Rails: unobtrusive checkin function I have a simple checkin app: there's a page with a series of pictures of users. They are "checked in" by a simple click on the image. This registers them in the database and displays a "checked in" icon overlaying the image. Right now I'm doing this by a "link_to" in the view which c...
TITLE: Rails: unobtrusive checkin function QUESTION: I have a simple checkin app: there's a page with a series of pictures of users. They are "checked in" by a simple click on the image. This registers them in the database and displays a "checked in" icon overlaying the image. Right now I'm doing this by a "link_to" i...
[ "javascript", "ruby-on-rails", "ajax", "ruby-on-rails-3" ]
0
3
75
1
0
2011-06-02T20:54:14.297000
2011-06-02T21:10:21.630000
6,220,274
6,220,881
Install python module to non default version of python on Mac
I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on projects that use different versions. Any one know how to accomplish this?...
If you're installing using setup.py, just run it via the appropriate version of Python, e.g.: python2.6 setup.py install If you're using easy_install there should be a version for the corresponding Python version called easy_install-N.N, e.g. easy_install-2.6 some_module If you're working on different projects that req...
Install python module to non default version of python on Mac I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on projects tha...
TITLE: Install python module to non default version of python on Mac QUESTION: I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am worki...
[ "python", "module" ]
8
5
4,943
3
0
2011-06-02T20:54:17.923000
2011-06-02T22:00:10.777000
6,220,280
6,220,346
How do I limit mouse click rate in a Rails app?
I've written a timecard app, and I have a page where people can "punch" in and out. Each person has a button which makes an Ajax call back to change their status. A couple of folks have figured out that it's fun to click on a person's button a hundred times in a row, so that the report page for clock in/out times gets ...
Couldn't you check the updated_at field on your record? It won't limit the "mouse" click rate, but it will keep your record from getting updated more than x many times per minute/hour. For example, in your model, you could have something like: class TimeRecord < ActiveRecord::Base validate:throttled_updates, on::update...
How do I limit mouse click rate in a Rails app? I've written a timecard app, and I have a page where people can "punch" in and out. Each person has a button which makes an Ajax call back to change their status. A couple of folks have figured out that it's fun to click on a person's button a hundred times in a row, so t...
TITLE: How do I limit mouse click rate in a Rails app? QUESTION: I've written a timecard app, and I have a page where people can "punch" in and out. Each person has a button which makes an Ajax call back to change their status. A couple of folks have figured out that it's fun to click on a person's button a hundred ti...
[ "javascript", "ruby-on-rails" ]
2
2
467
4
0
2011-06-02T20:54:49.873000
2011-06-02T21:01:55.963000
6,220,283
6,220,622
Aggregating dates in SQL Server
I have a 2-column table named Assignment. The table contains assignment of Person ( nvarchar(20) ) and Day ( date ), like here: Person Day ------------------ John 2011-05-23 John 2011-05-24 John 2011-05-25 John 2011-05-27 John 2011-05-28 John 2011-05-29 Anna 2011-05-02 Anna 2011-05-03 Anna 2011-05-06 I need to extract ...
declare @T table(Person nvarchar(20), [Day] date) insert into @T values ('John', '2011-05-23'), ('John', '2011-05-24'), ('John', '2011-05-25'), ('John', '2011-05-27'), ('John', '2011-05-28'), ('John', '2011-05-29'), ('Anna', '2011-05-02'), ('Anna', '2011-05-03'), ('Anna', '2011-05-06');WITH cte AS ( SELECT *, DATEDIFF...
Aggregating dates in SQL Server I have a 2-column table named Assignment. The table contains assignment of Person ( nvarchar(20) ) and Day ( date ), like here: Person Day ------------------ John 2011-05-23 John 2011-05-24 John 2011-05-25 John 2011-05-27 John 2011-05-28 John 2011-05-29 Anna 2011-05-02 Anna 2011-05-03 An...
TITLE: Aggregating dates in SQL Server QUESTION: I have a 2-column table named Assignment. The table contains assignment of Person ( nvarchar(20) ) and Day ( date ), like here: Person Day ------------------ John 2011-05-23 John 2011-05-24 John 2011-05-25 John 2011-05-27 John 2011-05-28 John 2011-05-29 Anna 2011-05-02 ...
[ "sql", "t-sql", "sql-server-2008", "date", "aggregate-functions" ]
2
3
129
1
0
2011-06-02T20:55:20.567000
2011-06-02T21:31:00.850000
6,220,285
6,220,357
Read the contents of a webpage after a delay
Is there any way to read the contents of a webpage once it gets loaded completely. I have to read the prices from a site and need to store them in my database. But the prices in the site loads through ajax. As a result, I just get "Loading" instead of values. Is there any way to extract the contents once the file get l...
Can't you read the contents from the file that is requested by that site?
Read the contents of a webpage after a delay Is there any way to read the contents of a webpage once it gets loaded completely. I have to read the prices from a site and need to store them in my database. But the prices in the site loads through ajax. As a result, I just get "Loading" instead of values. Is there any wa...
TITLE: Read the contents of a webpage after a delay QUESTION: Is there any way to read the contents of a webpage once it gets loaded completely. I have to read the prices from a site and need to store them in my database. But the prices in the site loads through ajax. As a result, I just get "Loading" instead of value...
[ "ajax", "html-content-extraction" ]
0
0
63
1
0
2011-06-02T20:55:27.180000
2011-06-02T21:02:33.983000
6,220,289
6,220,370
What is the country code for Estonia on android phone
What is the country code for Estonia on an Android phone? For example French (France) is fr_FR and Danish (Denmark) is da_DK I opened a thread on Google Support but but nobody has replied yet. Google Support: What is the country code for estonia on Android?
Citing Providing Resources from the dev guide: The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r"). http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm ESTONIA EE ...
What is the country code for Estonia on android phone What is the country code for Estonia on an Android phone? For example French (France) is fr_FR and Danish (Denmark) is da_DK I opened a thread on Google Support but but nobody has replied yet. Google Support: What is the country code for estonia on Android?
TITLE: What is the country code for Estonia on android phone QUESTION: What is the country code for Estonia on an Android phone? For example French (France) is fr_FR and Danish (Denmark) is da_DK I opened a thread on Google Support but but nobody has replied yet. Google Support: What is the country code for estonia on...
[ "android", "internationalization" ]
1
5
1,691
3
0
2011-06-02T20:55:43.063000
2011-06-02T21:03:23.307000
6,220,300
6,220,360
JQuery: Keyup, how do I prevent the default behavior of the arrow (up & down) and enter key?
JavaScript (JQuery) $('input').keyup(function(e) { var code = e.keyCode? e.keyCode: e.which; switch(code) { case 38: break; case 40: break; case 13: break; default: return; } }); HTML Submit I have 2 problems: 1) The caret shouldn't move when I hit the up arrow key. For example, in Chrome when I hit the up-key it m...
I don't think you can preventDefault() (which is what you'd need to use to stop the browser from performing the default action for a key) on the keyup event - it is fired after the default event has already occurred. See this page for more. If you can, consider using the keydown instead. As for stopping the form from s...
JQuery: Keyup, how do I prevent the default behavior of the arrow (up & down) and enter key? JavaScript (JQuery) $('input').keyup(function(e) { var code = e.keyCode? e.keyCode: e.which; switch(code) { case 38: break; case 40: break; case 13: break; default: return; } }); HTML Submit I have 2 problems: 1) The caret ...
TITLE: JQuery: Keyup, how do I prevent the default behavior of the arrow (up & down) and enter key? QUESTION: JavaScript (JQuery) $('input').keyup(function(e) { var code = e.keyCode? e.keyCode: e.which; switch(code) { case 38: break; case 40: break; case 13: break; default: return; } }); HTML Submit I have 2 probl...
[ "javascript", "jquery", "onkeyup", "enter" ]
16
52
73,157
5
0
2011-06-02T20:57:16.463000
2011-06-02T21:02:35.407000
6,220,309
6,220,454
How to assign the max value across mulptiple fields to a single column in a select statement using MS-Access-2010 SQL?
I have multiple columns in a table but I only want the highest value from the columns to be selected in a sql. Example Info: D1 D2 D3 D4 ----- ----- ----- ----- 3 2 150 5 1 3 20 10 Output needs to be: MaxPower 150 20 Anyone know a good way to do this? A single sql would be preferred but vba would work also.
select max(v) as maggiore from ( select id,d1 as v from table union all select id,d2 from table union all select id,d3 from table union all select id,d4 from table ) as t group by id
How to assign the max value across mulptiple fields to a single column in a select statement using MS-Access-2010 SQL? I have multiple columns in a table but I only want the highest value from the columns to be selected in a sql. Example Info: D1 D2 D3 D4 ----- ----- ----- ----- 3 2 150 5 1 3 20 10 Output needs to be: ...
TITLE: How to assign the max value across mulptiple fields to a single column in a select statement using MS-Access-2010 SQL? QUESTION: I have multiple columns in a table but I only want the highest value from the columns to be selected in a sql. Example Info: D1 D2 D3 D4 ----- ----- ----- ----- 3 2 150 5 1 3 20 10 Ou...
[ "sql", "vba", "ms-access-2010" ]
0
0
1,046
2
0
2011-06-02T20:57:55.830000
2011-06-02T21:11:55.040000
6,220,310
6,220,584
Multiple action contexts in Zend
I am new to Zend and am working on a project that requires three contexts for a particular action. There is the standard context that will normally be used, an AJAX context for AJAX calls, and finally a print-friendly context. The goal is for each of these to have their own view, so the view files used would be somethi...
It's everything in the documentation. If you want custom contexts, you have to add them first: $this->_helper ->getHelper('contextSwitch') ->addContext('print', array( // context options go here )) ->addActionContext('history', 'print') // more addActionContext()s goes here ->initContext();
Multiple action contexts in Zend I am new to Zend and am working on a project that requires three contexts for a particular action. There is the standard context that will normally be used, an AJAX context for AJAX calls, and finally a print-friendly context. The goal is for each of these to have their own view, so the...
TITLE: Multiple action contexts in Zend QUESTION: I am new to Zend and am working on a project that requires three contexts for a particular action. There is the standard context that will normally be used, an AJAX context for AJAX calls, and finally a print-friendly context. The goal is for each of these to have thei...
[ "php", "zend-framework" ]
1
2
1,203
2
0
2011-06-02T20:58:07.307000
2011-06-02T21:25:48.643000
6,220,312
6,220,462
Is it good to use exception handling in this case?
I am using this kind of code in JavaScript. if(typeof a[x]!= "undefined" && typeof a[x][y]!= "undefined" && typeof a[x][y][z]!= "undefined") { a[x][y][z].update(); } // else do nothing I just thought that using try catch to implement the above logic would simplify the code and reduce the checking of three conditions ea...
Readability matters more, unless you're in an extremely performance optimized loop or function, it shouldn't make a difference. As PleaseStand stated, wrapping the whole thing in a try/catch will hide any errors. You could alternatively do something like this, if you still wanted to try/catch var fn = null; try { fn =...
Is it good to use exception handling in this case? I am using this kind of code in JavaScript. if(typeof a[x]!= "undefined" && typeof a[x][y]!= "undefined" && typeof a[x][y][z]!= "undefined") { a[x][y][z].update(); } // else do nothing I just thought that using try catch to implement the above logic would simplify the ...
TITLE: Is it good to use exception handling in this case? QUESTION: I am using this kind of code in JavaScript. if(typeof a[x]!= "undefined" && typeof a[x][y]!= "undefined" && typeof a[x][y][z]!= "undefined") { a[x][y][z].update(); } // else do nothing I just thought that using try catch to implement the above logic w...
[ "javascript", "exception" ]
2
2
120
5
0
2011-06-02T20:58:15.763000
2011-06-02T21:12:43.740000
6,220,315
6,220,687
bdist_rpm from Ubuntu to CentOs
We develop on Ubuntu/Macs and deploy RPMs to CentOS (this is the settings, can't be changed much). The problem is that when installing from the rpm, the packages go to /usr/local/lib/python2.7/dist-packages (which is the right location for Ubuntu). However the default python path in CentOS is looking at /usr/local/lib/...
You can use a setup.cfg file to override the Python lib install path: setup.cfg: [install] install-lib=/usr/local/lib/python2.7/site-packages Example: % python setup.py bdist_rpm % rpm -qpl dist/foo-0.0.0-1.noarch.rpm | grep foo /usr/local/lib/python2.7/site-packages/foo/__init__.py /usr/local/lib/python2.7/site-packa...
bdist_rpm from Ubuntu to CentOs We develop on Ubuntu/Macs and deploy RPMs to CentOS (this is the settings, can't be changed much). The problem is that when installing from the rpm, the packages go to /usr/local/lib/python2.7/dist-packages (which is the right location for Ubuntu). However the default python path in Cent...
TITLE: bdist_rpm from Ubuntu to CentOs QUESTION: We develop on Ubuntu/Macs and deploy RPMs to CentOS (this is the settings, can't be changed much). The problem is that when installing from the rpm, the packages go to /usr/local/lib/python2.7/dist-packages (which is the right location for Ubuntu). However the default p...
[ "python", "ubuntu", "centos", "rpm" ]
6
10
1,596
1
0
2011-06-02T20:58:27.297000
2011-06-02T21:38:09.647000
6,220,318
6,220,341
get the value of notepad and put it inside the c# string?
Notepad: Hello world! How I'll put it in C# and convert it into string..? So far, I'm getting the path of the notepad. string notepad = @"c:\oasis\B1.text"; //this must be Hello world Please advice me.. I'm not familiar on this.. tnx
You can read text using the File.ReadAllText() method: public static void Main() { string path = @"c:\oasis\B1.txt"; try { // Open the file to read from. string readText = System.IO.File.ReadAllText(path); Console.WriteLine(readText); } catch (System.IO.FileNotFoundException fnfe) { // Handle file not found. } }
get the value of notepad and put it inside the c# string? Notepad: Hello world! How I'll put it in C# and convert it into string..? So far, I'm getting the path of the notepad. string notepad = @"c:\oasis\B1.text"; //this must be Hello world Please advice me.. I'm not familiar on this.. tnx
TITLE: get the value of notepad and put it inside the c# string? QUESTION: Notepad: Hello world! How I'll put it in C# and convert it into string..? So far, I'm getting the path of the notepad. string notepad = @"c:\oasis\B1.text"; //this must be Hello world Please advice me.. I'm not familiar on this.. tnx ANSWER: Y...
[ "c#", "file", "notepad" ]
5
7
8,509
6
0
2011-06-02T20:58:39.847000
2011-06-02T21:01:30.250000
6,220,323
6,220,359
Array List Search
I'm doing some past exam papers in preparation for a forthcoming exam, and have come across this question, and I'm not sure how to solve it, I've written a for-each loop with an if statement but I'm not sure what the header would be and what to return. Any help would be great. Thanks. The question: An ArrayList named c...
Something like: boolean lala( Student given ) { for( Student s: classList ) { if( s.getForename().equals( given.getForename() ) && s.getSurname().equals( given.getSurname() ) ) { return true; } } return false; }
Array List Search I'm doing some past exam papers in preparation for a forthcoming exam, and have come across this question, and I'm not sure how to solve it, I've written a for-each loop with an if statement but I'm not sure what the header would be and what to return. Any help would be great. Thanks. The question: An...
TITLE: Array List Search QUESTION: I'm doing some past exam papers in preparation for a forthcoming exam, and have come across this question, and I'm not sure how to solve it, I've written a for-each loop with an if statement but I'm not sure what the header would be and what to return. Any help would be great. Thanks...
[ "java", "arraylist" ]
2
6
1,804
3
0
2011-06-02T20:59:31.657000
2011-06-02T21:02:34.723000
6,220,337
6,220,432
Code duplication and template specialization (when the specialized function has different return types)
I am creating a templated class D, with a method (operator(), in this case) that returns different types, depending on the value of N. I could only make this work by creating two separate class declarations, but this came at the cost of a lot of code duplication. I also tried to create a common base class to throw the ...
You can use the Curiously Recurring Template Pattern. template typename D> struct d_inner { D operator()(int x) { return D (static_cast *>(this)->yell(x)); } }; template typename D> struct d_inner<1, D> { int operator()(int x) { return static_cast *>(this)->yell(x); } }; template struct D: public d_inner { int s; D(in...
Code duplication and template specialization (when the specialized function has different return types) I am creating a templated class D, with a method (operator(), in this case) that returns different types, depending on the value of N. I could only make this work by creating two separate class declarations, but this...
TITLE: Code duplication and template specialization (when the specialized function has different return types) QUESTION: I am creating a templated class D, with a method (operator(), in this case) that returns different types, depending on the value of N. I could only make this work by creating two separate class decl...
[ "c++", "templates", "template-specialization" ]
7
8
683
2
0
2011-06-02T21:01:08.797000
2011-06-02T21:10:19.057000