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,215,398
6,215,444
Calling the variable property directly vs getter/setters - OOP Design
I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and setters. Understandably I see the performance gain in this but is this really a good design practice to follow? Their Example using getter/setter: ...
A boilerplate answer, I'm afraid but I would suggest the following: If you have no encapsulation problems for your class (enforcing business logic, etc.) by exposing this property to other users, it is perfectly ok to do so.
Calling the variable property directly vs getter/setters - OOP Design I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and setters. Understandably I see the performance gain in this but is this really...
TITLE: Calling the variable property directly vs getter/setters - OOP Design QUESTION: I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and setters. Understandably I see the performance gain in this ...
[ "php", "optimization", "variables", "getter-setter", "design-principles" ]
17
4
14,193
7
0
2011-06-02T13:47:14.743000
2011-06-02T13:51:04.110000
6,215,399
6,215,906
AS2: string in array is undefined
I have the following code on the timeline, but when I try and output date_string from the Slider_Tracker array it says it is undefined. var Days:Array = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday'); var Months:Array = new Array('January', 'February', 'March', 'April', 'May', 'J...
You mean the trace in this._parent.saver.onRelease? That's a different scope unfortunately, it'll be relative to your this._parent.saver MovieClip, so it won't have access to date_string and Slide_Tracker you defined here.
AS2: string in array is undefined I have the following code on the timeline, but when I try and output date_string from the Slider_Tracker array it says it is undefined. var Days:Array = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday'); var Months:Array = new Array('January', 'Febr...
TITLE: AS2: string in array is undefined QUESTION: I have the following code on the timeline, but when I try and output date_string from the Slider_Tracker array it says it is undefined. var Days:Array = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday'); var Months:Array = new Arra...
[ "arrays", "actionscript", "multidimensional-array", "actionscript-2", "undefined" ]
0
1
1,147
1
0
2011-06-02T13:47:17.090000
2011-06-02T14:28:55.297000
6,215,400
6,244,174
boost serialization and doubles
I am trying to serialize a class to a string using the boost serialization library and included in my class are several double member variables. Below is the code I'm using to serialize: #include #include #include std::stringstream ss; boost::archive::text_oarchive oa(ss); oa << mPoint; Here is the serialiation method ...
You could try forcing your stream to use scientific format for floating point before serialising to it: ss << std::scientific; It looks like the boost library sets the precision correctly, but doesn't appear to set the format. Alternatively, you can I think derive and override the logic for saving and/or loading floati...
boost serialization and doubles I am trying to serialize a class to a string using the boost serialization library and included in my class are several double member variables. Below is the code I'm using to serialize: #include #include #include std::stringstream ss; boost::archive::text_oarchive oa(ss); oa << mPoint; ...
TITLE: boost serialization and doubles QUESTION: I am trying to serialize a class to a string using the boost serialization library and included in my class are several double member variables. Below is the code I'm using to serialize: #include #include #include std::stringstream ss; boost::archive::text_oarchive oa(s...
[ "c++", "serialization", "boost", "floating-point", "boost-serialization" ]
8
2
2,693
2
0
2011-06-02T13:47:21.150000
2011-06-05T16:21:55.283000
6,215,402
6,217,732
Spritesheet: tool to get coordinates
I have a one spritesheet image with all sprites, I downloaded this image from Interent. My question: Is there a tool that help me to get the coordinates of each sprite? would I have to search coordinates manually? I've been reading several tutorials like: http://www.raywenderlich.com/1271/how-to-use-animations-and-spri...
You can crop the images using some editor (photoshop for example) and then use the exiting tool to generate the texture and the plist. I think it will be the fastest and the easiest way because in case you would want to generate only plist you will do the same operation - selecting the rectangle.
Spritesheet: tool to get coordinates I have a one spritesheet image with all sprites, I downloaded this image from Interent. My question: Is there a tool that help me to get the coordinates of each sprite? would I have to search coordinates manually? I've been reading several tutorials like: http://www.raywenderlich.co...
TITLE: Spritesheet: tool to get coordinates QUESTION: I have a one spritesheet image with all sprites, I downloaded this image from Interent. My question: Is there a tool that help me to get the coordinates of each sprite? would I have to search coordinates manually? I've been reading several tutorials like: http://ww...
[ "objective-c", "cocos2d-iphone" ]
3
2
3,833
4
0
2011-06-02T13:47:22.927000
2011-06-02T17:06:56.810000
6,215,408
6,216,389
How to shorten the Qt make process?
I have downloaded an open source Qt that target on Windows. Since I am using the VS2010 command prompt to do the installation, it automatically set the platform to msvc-2010. When I am trying to build using nmake, it took about 7-8 hours to complete the installation. During the process, I have notice that Qt is compili...
As @tibur said, you can use jom, which is a kind of "parallel nmake". You can also pass several options to Qt's configure, some of which are: -release or -debug: build only release or debug binaries -nomake demos, -nomake examples, -nomake tools: don't build well, demos, examples or tools. -no-webkit, -no-qt3support, -...
How to shorten the Qt make process? I have downloaded an open source Qt that target on Windows. Since I am using the VS2010 command prompt to do the installation, it automatically set the platform to msvc-2010. When I am trying to build using nmake, it took about 7-8 hours to complete the installation. During the proce...
TITLE: How to shorten the Qt make process? QUESTION: I have downloaded an open source Qt that target on Windows. Since I am using the VS2010 command prompt to do the installation, it automatically set the platform to msvc-2010. When I am trying to build using nmake, it took about 7-8 hours to complete the installation...
[ "qt", "build-process", "nmake" ]
10
17
8,561
4
0
2011-06-02T13:47:52.130000
2011-06-02T15:07:30.877000
6,215,418
6,215,471
how to catch a return value from a ssh task ant
I have defined a macro in ANT that checks if a dir exists on a remote linux box: runcommand is just a wrapper macro for sshexec task that validates some additional stuff, but basically it's just an sshexec. Right now, if i run this, it works in a way that if the directory exists the build go on but if it doesn't exist ...
This is a total stab in the dark, I don't know if ant will let you do this. However if it's invoking bash on the remote host, it should work. This way if the directory exists it will short circuit and return success. If it doesn't exist, it will call mkdir. If mkdir fails, then ant will fail.
how to catch a return value from a ssh task ant I have defined a macro in ANT that checks if a dir exists on a remote linux box: runcommand is just a wrapper macro for sshexec task that validates some additional stuff, but basically it's just an sshexec. Right now, if i run this, it works in a way that if the directory...
TITLE: how to catch a return value from a ssh task ant QUESTION: I have defined a macro in ANT that checks if a dir exists on a remote linux box: runcommand is just a wrapper macro for sshexec task that validates some additional stuff, but basically it's just an sshexec. Right now, if i run this, it works in a way tha...
[ "linux", "ant", "macros", "ssh" ]
1
2
1,466
2
0
2011-06-02T13:48:43.847000
2011-06-02T13:52:53.863000
6,215,424
6,215,660
Missing Request parameters with UTF-8 when javascript escape() is used
I am using jquery ajax api to submit (POST/GET) a text as parameter to a processing page. var dataString = "tmpVar="+ escape( $("#txtboxdata").val() ); $.ajax({ type: "POST", url: "processing.jsp", data: dataString, dataType: "json", success: function(){} }); //dataString holds the parameter and value to be passed. Va...
Using the answer provided by @SLaks did some more research and found a satisfactory answer. Explains why "escape" shouldn't be used and compares it with other method which can be used. encodeURIComponent() encodeURI() http://xkr.us/articles/javascript/encode-compare/
Missing Request parameters with UTF-8 when javascript escape() is used I am using jquery ajax api to submit (POST/GET) a text as parameter to a processing page. var dataString = "tmpVar="+ escape( $("#txtboxdata").val() ); $.ajax({ type: "POST", url: "processing.jsp", data: dataString, dataType: "json", success: functi...
TITLE: Missing Request parameters with UTF-8 when javascript escape() is used QUESTION: I am using jquery ajax api to submit (POST/GET) a text as parameter to a processing page. var dataString = "tmpVar="+ escape( $("#txtboxdata").val() ); $.ajax({ type: "POST", url: "processing.jsp", data: dataString, dataType: "json...
[ "java", "jquery", "jsp", "utf-8", "request" ]
0
1
864
2
0
2011-06-02T13:49:21.477000
2011-06-02T14:08:01.693000
6,215,438
6,215,514
NSData to NSString in ObjectiveC
I am converting the APN Device token which is in NSData format to NSString, but i am some special characters, - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Device Token 111: %@", deviceToken); NSString *deviceStr = [[NSString alloc] i...
Try using the following method with [deviceToken bytes] as the first parameter. const static char hexchar[] = "0123456789ABCDEF"; - (NSString*) bytes2hex:(const char* ) buffer length:(int)buf_len { size_t i; char *p; int len = (buf_len * 2) + 1; p = malloc(len); for (i = 0; i < buf_len; i++) { p[i * 2] = hexchar[(unsig...
NSData to NSString in ObjectiveC I am converting the APN Device token which is in NSData format to NSString, but i am some special characters, - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Device Token 111: %@", deviceToken); NSString...
TITLE: NSData to NSString in ObjectiveC QUESTION: I am converting the APN Device token which is in NSData format to NSString, but i am some special characters, - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Device Token 111: %@", devic...
[ "objective-c", "nsstring", "nsdata" ]
2
2
2,614
2
0
2011-06-02T13:50:35.003000
2011-06-02T13:55:36.610000
6,215,459
6,215,760
T-SQL query to show table definition?
What is a query that will show me the full definition, including indexes and keys for a SQL Server table? I want a pure query - and know that SQL Studio can give this to me, but I am often on "wild" computers that have only the most bare-bones apps and I have no rights to install studio. But SQLCMD is always an option....
There is no easy way to return the DDL. However you can get most of the details from Information Schema Views and System Views. SELECT ORDINAL_POSITION, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Customers' SELECT CONSTRAINT_NAME FROM INFORMATION_S...
T-SQL query to show table definition? What is a query that will show me the full definition, including indexes and keys for a SQL Server table? I want a pure query - and know that SQL Studio can give this to me, but I am often on "wild" computers that have only the most bare-bones apps and I have no rights to install s...
TITLE: T-SQL query to show table definition? QUESTION: What is a query that will show me the full definition, including indexes and keys for a SQL Server table? I want a pure query - and know that SQL Studio can give this to me, but I am often on "wild" computers that have only the most bare-bones apps and I have no r...
[ "sql-server", "t-sql" ]
137
151
327,339
17
0
2011-06-02T13:52:05.270000
2011-06-02T14:18:03.877000
6,215,467
6,215,567
cmath header confusion
What is the namespace for math functions? Global or std? Consider cos function. It has 3 overloads. But there is also legacy cos from math.h. C doesn't know anything about function overloading. Therefore cos(x) can't be resolved to cos(float). The solution is to call the single precision version explicitly cosf(x). Did...
You get the same functions by including and in C++, the only differences is the namespace. I.E. including also gives you the overload. In theory, in C++03, using gives you the symbols defined in the global namespace and also in the std namespace while using gives you the symbols defined in the std namespace and not in ...
cmath header confusion What is the namespace for math functions? Global or std? Consider cos function. It has 3 overloads. But there is also legacy cos from math.h. C doesn't know anything about function overloading. Therefore cos(x) can't be resolved to cos(float). The solution is to call the single precision version ...
TITLE: cmath header confusion QUESTION: What is the namespace for math functions? Global or std? Consider cos function. It has 3 overloads. But there is also legacy cos from math.h. C doesn't know anything about function overloading. Therefore cos(x) can't be resolved to cos(float). The solution is to call the single ...
[ "c++" ]
5
5
2,875
4
0
2011-06-02T13:52:35.303000
2011-06-02T13:58:25.430000
6,215,469
6,215,520
Does Scala achieve good performance on Android? (June 2011)
I'm very new to scala and find many of its ideas very attractive. I've just discovered the scala for android project and I'm wondering if it could be expected to run well or perhaps even better than java? Could it even be expected do some things better than java even if the processors are mostly single core in-order ex...
The only "lag" would be the size of the apk, but if you use something like ProGuard it would represent only around 15k/25k more, nothing significant at all. As of performance, for what i've seen is the same. I mean, it is not worse (as happens with Clojure, being dynamically typed), but i think it's the same as Java.
Does Scala achieve good performance on Android? (June 2011) I'm very new to scala and find many of its ideas very attractive. I've just discovered the scala for android project and I'm wondering if it could be expected to run well or perhaps even better than java? Could it even be expected do some things better than ja...
TITLE: Does Scala achieve good performance on Android? (June 2011) QUESTION: I'm very new to scala and find many of its ideas very attractive. I've just discovered the scala for android project and I'm wondering if it could be expected to run well or perhaps even better than java? Could it even be expected do some thi...
[ "java", "android", "scala", "concurrency" ]
10
8
1,401
3
0
2011-06-02T13:52:40.957000
2011-06-02T13:56:05.783000
6,215,472
6,215,577
How to create custom uitableview like that
I want to create uitableview like the following, also I need to add a third section that contains rows any suggestion please
Do all of this in an UITableViewController with - UITableViewDelegate, UIPickerViewDelegate, UITableViewDataSource, UIPickerViewDataSource - For Patient & ACC => Set a UITextField as a Subview (Do this in the cellForRowAtIndexPath for their respective rows) For Birth and Date => Use the UIDatePickerView and for row ==2...
How to create custom uitableview like that I want to create uitableview like the following, also I need to add a third section that contains rows any suggestion please
TITLE: How to create custom uitableview like that QUESTION: I want to create uitableview like the following, also I need to add a third section that contains rows any suggestion please ANSWER: Do all of this in an UITableViewController with - UITableViewDelegate, UIPickerViewDelegate, UITableViewDataSource, UIPickerV...
[ "iphone", "ipad" ]
1
1
623
2
0
2011-06-02T13:52:55.970000
2011-06-02T13:59:40.070000
6,215,484
6,216,770
how can it do other work except "async_wait" in one single thread using boost.asio.deadline_timer
I rewrite a boost.asio example "Timer.3 - Binding arguments to a handler". I think "worker" can work forever and "print" can be called each second. But "print" only is called once. It is very diffcult for me to think why. If this can't work,how can I do other things except "async_wait" in one single thread. #include #i...
You have an infinite loop void worker() { while(1) { ++num; } } so control never returns the first time print() is invoked.
how can it do other work except "async_wait" in one single thread using boost.asio.deadline_timer I rewrite a boost.asio example "Timer.3 - Binding arguments to a handler". I think "worker" can work forever and "print" can be called each second. But "print" only is called once. It is very diffcult for me to think why. ...
TITLE: how can it do other work except "async_wait" in one single thread using boost.asio.deadline_timer QUESTION: I rewrite a boost.asio example "Timer.3 - Binding arguments to a handler". I think "worker" can work forever and "print" can be called each second. But "print" only is called once. It is very diffcult for...
[ "c++", "boost", "boost-asio" ]
0
2
900
1
0
2011-06-02T13:53:42.360000
2011-06-02T15:36:43.107000
6,215,502
6,215,574
proper phpdoc @return for factory method
I am curious how to document the following scenario. Imagine a group of classes: abstract class Personality {} class Me extends Personality {} class Myself extends Personality {} class Irene extends Personality {} If I am writing a factory-esque method to instantiate and return a subclass of class Personality, how woul...
@return Personality A "Personality" subclass object is the best. And IDE will provide you with autocomplete properties for the Personality class.
proper phpdoc @return for factory method I am curious how to document the following scenario. Imagine a group of classes: abstract class Personality {} class Me extends Personality {} class Myself extends Personality {} class Irene extends Personality {} If I am writing a factory-esque method to instantiate and return ...
TITLE: proper phpdoc @return for factory method QUESTION: I am curious how to document the following scenario. Imagine a group of classes: abstract class Personality {} class Me extends Personality {} class Myself extends Personality {} class Irene extends Personality {} If I am writing a factory-esque method to insta...
[ "php", "phpdoc" ]
4
4
1,296
1
0
2011-06-02T13:55:07.117000
2011-06-02T13:59:13.910000
6,215,504
6,221,701
Azure Blobs: Get Block List in C#
I am working with Block Blobs in Azure Storage. I need to get uncommitted blocks, as far as I have found I need to call "Get Block List". Here is the problem. Does "Get Block List" functionality exists in C# (Microsoft.WindowsAzure.StorageClient.dll)? MSDN only says about doing a HTTP request, not a word about StorageC...
I think what you are looking for is the DownloadBlockList method on CloudBlockBlob http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblockblob.downloadblocklist.aspx There's example code there in MSDN - http://msdn.microsoft.com/en-us/library/ee772860.aspx static void DownloadBlockListFo...
Azure Blobs: Get Block List in C# I am working with Block Blobs in Azure Storage. I need to get uncommitted blocks, as far as I have found I need to call "Get Block List". Here is the problem. Does "Get Block List" functionality exists in C# (Microsoft.WindowsAzure.StorageClient.dll)? MSDN only says about doing a HTTP ...
TITLE: Azure Blobs: Get Block List in C# QUESTION: I am working with Block Blobs in Azure Storage. I need to get uncommitted blocks, as far as I have found I need to call "Get Block List". Here is the problem. Does "Get Block List" functionality exists in C# (Microsoft.WindowsAzure.StorageClient.dll)? MSDN only says a...
[ "c#", "azure", "azure-blob-storage" ]
4
6
5,856
2
0
2011-06-02T13:55:16.250000
2011-06-03T00:01:57.740000
6,215,507
6,215,593
Temporary macro to store another macro and then reverting back
I want to have more control over macros such as assertions (and some logging macros that are not directly under my control). So I decided to do something like this, expecting it to work (in case somebody is wondering, the reason it does not work is that the last undef of MY_ASSERT_COPY invalidates MY_ASSERT right befor...
Some compilers provide #pragma push_macro and #pragma pop_macro to save and restore macro state. Limited portability though.
Temporary macro to store another macro and then reverting back I want to have more control over macros such as assertions (and some logging macros that are not directly under my control). So I decided to do something like this, expecting it to work (in case somebody is wondering, the reason it does not work is that the...
TITLE: Temporary macro to store another macro and then reverting back QUESTION: I want to have more control over macros such as assertions (and some logging macros that are not directly under my control). So I decided to do something like this, expecting it to work (in case somebody is wondering, the reason it does no...
[ "c++", "macros" ]
1
1
586
2
0
2011-06-02T13:55:23.437000
2011-06-02T14:01:13.460000
6,215,511
6,215,646
How to run multiple threads created by loop simultaneous using boost.thread?
I'm using learning the basic of boost.thread. So far, I can create each thread one by one manually to let them run at the same time. However, when creating by loop, it runs sequentially not concurrency anymore. #include #include void workerFunc() { boost::posix_time::seconds workTime(3); std::cout << "Worker: Running" ...
for (int i = 0; i < 2; ++i) { boost::thread z(workerFunc); z.join(); } You are starting your thread and then immediately waiting for it to complete! EDIT One of several alternative hacks besides thread groups. std::vector z; for (int i = 0; i < 2; ++i) z.push_back(new boost::thread(workerFunc)); for (int i = 0; i < 2...
How to run multiple threads created by loop simultaneous using boost.thread? I'm using learning the basic of boost.thread. So far, I can create each thread one by one manually to let them run at the same time. However, when creating by loop, it runs sequentially not concurrency anymore. #include #include void workerFun...
TITLE: How to run multiple threads created by loop simultaneous using boost.thread? QUESTION: I'm using learning the basic of boost.thread. So far, I can create each thread one by one manually to let them run at the same time. However, when creating by loop, it runs sequentially not concurrency anymore. #include #incl...
[ "c++", "boost", "boost-thread" ]
3
15
20,088
3
0
2011-06-02T13:55:32.593000
2011-06-02T14:07:01.430000
6,215,521
6,215,643
Linq to XML, C#
I have a multilevel xml that i receive from queues. I need to break each level and put into database. Below is the example: 3 001 222 765 open Error 009 675 765 Close mesage I tried using ds.ReadXML... it only takes units beceause i give datamember property of datagrid to units i need to put units into different table ...
You can use Linq to XML to navigate through the XML and break it down or you might Deserialize the XML into a C# object Have a look at Deserializing XML to Objects in C#
Linq to XML, C# I have a multilevel xml that i receive from queues. I need to break each level and put into database. Below is the example: 3 001 222 765 open Error 009 675 765 Close mesage I tried using ds.ReadXML... it only takes units beceause i give datamember property of datagrid to units i need to put units into ...
TITLE: Linq to XML, C# QUESTION: I have a multilevel xml that i receive from queues. I need to break each level and put into database. Below is the example: 3 001 222 765 open Error 009 675 765 Close mesage I tried using ds.ReadXML... it only takes units beceause i give datamember property of datagrid to units i need ...
[ "c#", "xml", "linq" ]
0
1
186
1
0
2011-06-02T13:56:07.833000
2011-06-02T14:06:44.227000
6,215,523
6,215,755
Most efficient way in Python to iterate over a large file (10GB+)
I'm working on a Python script to go through two files - one containing a list of UUIDs, the other containing a large amount of log entries - each line containing one of the UUIDs from the other file. The purpose of the program is to create a list of the UUIDS from file1, then for each time that UUID is found in the lo...
Think functionally! Write a function which will take a line of the log file and return the uuid. Call it uuid, say. Apply this function to every line of the log file. If you are using Python 3 you can use the built-in function map; otherwise, you need to use itertools.imap. Pass this iterator to a collections.Counter. ...
Most efficient way in Python to iterate over a large file (10GB+) I'm working on a Python script to go through two files - one containing a list of UUIDs, the other containing a large amount of log entries - each line containing one of the UUIDs from the other file. The purpose of the program is to create a list of the...
TITLE: Most efficient way in Python to iterate over a large file (10GB+) QUESTION: I'm working on a Python script to go through two files - one containing a list of UUIDs, the other containing a large amount of log entries - each line containing one of the UUIDs from the other file. The purpose of the program is to cr...
[ "python", "file", "design-patterns", "matching" ]
12
14
11,140
5
0
2011-06-02T13:56:21.070000
2011-06-02T14:17:18.200000
6,215,526
6,215,572
Idiomatic way to modify a member variable
I know Haskell isn't OO so it isn't strictly a 'member variable'. data Foo = Foo { bar:: Int, moo:: Int, meh:: Int, yup:: Int } modifyBar (Foo b m me y) = (Foo b' m me y) where b' = 2 This is how my code looks at the moment. The problem is I am now making data types with 16 or more members. When I need to modify a sin...
modifyBar foo = foo { bar = 2 } This syntax will copy foo, and then modify the bar field of that copy to 2. This could be naturally extended to more fields, so you don't need to write that modifyBar function at all. (See http://book.realworldhaskell.org/read/code-case-study-parsing-a-binary-data-format.html#id625467 )
Idiomatic way to modify a member variable I know Haskell isn't OO so it isn't strictly a 'member variable'. data Foo = Foo { bar:: Int, moo:: Int, meh:: Int, yup:: Int } modifyBar (Foo b m me y) = (Foo b' m me y) where b' = 2 This is how my code looks at the moment. The problem is I am now making data types with 16 or...
TITLE: Idiomatic way to modify a member variable QUESTION: I know Haskell isn't OO so it isn't strictly a 'member variable'. data Foo = Foo { bar:: Int, moo:: Int, meh:: Int, yup:: Int } modifyBar (Foo b m me y) = (Foo b' m me y) where b' = 2 This is how my code looks at the moment. The problem is I am now making dat...
[ "haskell" ]
2
11
198
2
0
2011-06-02T13:56:25.580000
2011-06-02T13:58:57.810000
6,215,529
6,215,653
MembershipUser business object
I have a separate project that contains all of my business objects. One of the business objects, User, holds login information and I want to convert it to be a MembershipUser object (see here ). However, MembershipUser object requires System.Web. I don't want to add that reference to my BO project. How do I use my busi...
You really can't, at least not directly. The only way I can think of is to write a wrapper class in your web project which inherits from MembershipUser and takes in one of your BOs as a constructor param, then delegates all its functionality to the BO. It's not pretty, but it's pretty much the only way I'm aware of to ...
MembershipUser business object I have a separate project that contains all of my business objects. One of the business objects, User, holds login information and I want to convert it to be a MembershipUser object (see here ). However, MembershipUser object requires System.Web. I don't want to add that reference to my B...
TITLE: MembershipUser business object QUESTION: I have a separate project that contains all of my business objects. One of the business objects, User, holds login information and I want to convert it to be a MembershipUser object (see here ). However, MembershipUser object requires System.Web. I don't want to add that...
[ "c#", "asp.net", "asp.net-membership" ]
0
1
132
1
0
2011-06-02T13:56:43.523000
2011-06-02T14:07:20.697000
6,215,531
6,215,606
How can I check whether an application has already been installed or is being installed for the first time
What will be the best way to check that application is already installed or being installed for the first time.
Bundle version and saving it in user defaults. EDIT: There are three things to note here. Bundle version: This is the version of the your application that you want to release. Old version: This will indicate previous version of your application. We will store this in user defaults so that we will know what was the old ...
How can I check whether an application has already been installed or is being installed for the first time What will be the best way to check that application is already installed or being installed for the first time.
TITLE: How can I check whether an application has already been installed or is being installed for the first time QUESTION: What will be the best way to check that application is already installed or being installed for the first time. ANSWER: Bundle version and saving it in user defaults. EDIT: There are three thing...
[ "ios" ]
2
6
1,158
1
0
2011-06-02T13:56:46.703000
2011-06-02T14:02:41.677000
6,215,532
6,215,576
insert 0 rows without error
Can an insert ever execute without error but not insert anything? I am using sql server 2008 and wondering if I can get away with just checking @@error or is there something I am missing. For an update I check @@error and @@rowcount. Having @@rowcount = 0 for an insert just seems strange to me. edit @Gregory I basicall...
You can run an INSERT command using a select that returns an empty table. The statement will succeed but no rows updated. INSERT INTO myTable (col1, col2) SELECT col1, col2 FROM myOtherTable WHERE 1 = 2
insert 0 rows without error Can an insert ever execute without error but not insert anything? I am using sql server 2008 and wondering if I can get away with just checking @@error or is there something I am missing. For an update I check @@error and @@rowcount. Having @@rowcount = 0 for an insert just seems strange to ...
TITLE: insert 0 rows without error QUESTION: Can an insert ever execute without error but not insert anything? I am using sql server 2008 and wondering if I can get away with just checking @@error or is there something I am missing. For an update I check @@error and @@rowcount. Having @@rowcount = 0 for an insert just...
[ "sql", "sql-server" ]
0
3
1,024
3
0
2011-06-02T13:56:48.373000
2011-06-02T13:59:38.940000
6,215,533
6,215,641
"Couldn't find <object> without an ID"
I'm having problems implementing a kind of comments form, where comments (called "microposts") belong_to both users and posts, users have_many comments, and posts (called "propositions") have_many comments. My code for the comments form is: <%= form_for @micropost do |f| %> <%= f.text_area:content %> <%= f.submit "Subm...
Your params are: "micropost"=>{"proposition_id"=>"", "content"=>"First comment"} So to get proposition_id, you have to do: params[:micropost][:proposition_id] But this is empty. And there is nowhere else to get this id, that's why this line retrieves nil: @proposition = Proposition.find(params[:proposition_id]) Making ...
"Couldn't find <object> without an ID" I'm having problems implementing a kind of comments form, where comments (called "microposts") belong_to both users and posts, users have_many comments, and posts (called "propositions") have_many comments. My code for the comments form is: <%= form_for @micropost do |f| %> <%= f....
TITLE: "Couldn't find <object> without an ID" QUESTION: I'm having problems implementing a kind of comments form, where comments (called "microposts") belong_to both users and posts, users have_many comments, and posts (called "propositions") have_many comments. My code for the comments form is: <%= form_for @micropos...
[ "ruby-on-rails", "ruby-on-rails-3", "forms", "comments" ]
8
3
10,602
2
0
2011-06-02T13:56:50.813000
2011-06-02T14:06:37.030000
6,215,538
6,216,240
Problem embedding a custom framework inside an .app bundle with XCode 4
I've been searching the web (and S.O.) for a while before asking this question. But I'm totally stuck and I don't know how to fix this. I have to embed a custom framework inside an.app bundle, using XCode 4. I know I have to fix the install path of the framework using the install_name_tool utility. I've done it like th...
You want to run install_name_tool on the application's binary. Or you can change the install name of the framework to @executable_path/../ before you link the application to it.
Problem embedding a custom framework inside an .app bundle with XCode 4 I've been searching the web (and S.O.) for a while before asking this question. But I'm totally stuck and I don't know how to fix this. I have to embed a custom framework inside an.app bundle, using XCode 4. I know I have to fix the install path of...
TITLE: Problem embedding a custom framework inside an .app bundle with XCode 4 QUESTION: I've been searching the web (and S.O.) for a while before asking this question. But I'm totally stuck and I don't know how to fix this. I have to embed a custom framework inside an.app bundle, using XCode 4. I know I have to fix t...
[ "xcode", "frameworks", "ios-frameworks" ]
1
1
902
1
0
2011-06-02T13:56:58.747000
2011-06-02T14:55:02.020000
6,215,540
6,215,626
html button on .cs page
i am using html button in.aspx page. but i want to use the button_click event on.cs page.. i am adding html button as: Send and on.cs page i am usng: protected void Submit_Click(object source, EventArgs e) { MessageBox.Show("ggg"); } i don't want to use asp button.. and this is not calling the event from.cs page.. how ...
You have to use onserverclick instead of the onclick method as this is a client side event of the HTML button control. Send
html button on .cs page i am using html button in.aspx page. but i want to use the button_click event on.cs page.. i am adding html button as: Send and on.cs page i am usng: protected void Submit_Click(object source, EventArgs e) { MessageBox.Show("ggg"); } i don't want to use asp button.. and this is not calling the e...
TITLE: html button on .cs page QUESTION: i am using html button in.aspx page. but i want to use the button_click event on.cs page.. i am adding html button as: Send and on.cs page i am usng: protected void Submit_Click(object source, EventArgs e) { MessageBox.Show("ggg"); } i don't want to use asp button.. and this is...
[ "c#", "asp.net", "html", "event-handling" ]
2
2
1,042
1
0
2011-06-02T13:57:10.467000
2011-06-02T14:05:00.157000
6,215,541
6,215,592
jQuery, use the right selector
I have a div, inside which there is a some text and a number of words surrounded by certain span tags. I want to click on those "spanned" words and have the div slide down, showing an "underlying" div with a text related to that certain spanned word. When i click on the div and not on a spanned word, i want the div to ...
You need to use event.stopPropagation(); in the span like so $('div').click(function(){alert('div clicked');}); $('div span').click(function(event){ alert('span clicked') event.stopPropagation(); }); Live Demo Reference
jQuery, use the right selector I have a div, inside which there is a some text and a number of words surrounded by certain span tags. I want to click on those "spanned" words and have the div slide down, showing an "underlying" div with a text related to that certain spanned word. When i click on the div and not on a s...
TITLE: jQuery, use the right selector QUESTION: I have a div, inside which there is a some text and a number of words surrounded by certain span tags. I want to click on those "spanned" words and have the div slide down, showing an "underlying" div with a text related to that certain spanned word. When i click on the ...
[ "jquery", "jquery-selectors" ]
0
3
105
2
0
2011-06-02T13:57:11.063000
2011-06-02T14:01:12.247000
6,215,544
6,216,046
How to randomize and then split an ArrayList<String> into two even ArrayLists
i know virtually no java but i'm trying to learn some for this project. I am trying to modify a program called GyaPickupBot which is basically a "pick up game" bot on IRC where players can type:!add in order to get added to a list of players who want to play a game and once enough players!add the bot announces the ip o...
The code below is untested, but should give you an idea on how to proceed. Good luck. // retrieve all players ArrayList players = mgr.getPlayers(readyGameID); // randomize the list Collections.shuffle(players); // instantiate two arraylists for the teams ArrayList teamRed = new ArrayList (); ArrayList teamBlue = new Ar...
How to randomize and then split an ArrayList<String> into two even ArrayLists i know virtually no java but i'm trying to learn some for this project. I am trying to modify a program called GyaPickupBot which is basically a "pick up game" bot on IRC where players can type:!add in order to get added to a list of players ...
TITLE: How to randomize and then split an ArrayList<String> into two even ArrayLists QUESTION: i know virtually no java but i'm trying to learn some for this project. I am trying to modify a program called GyaPickupBot which is basically a "pick up game" bot on IRC where players can type:!add in order to get added to ...
[ "java", "random", "arraylist", "split" ]
4
7
3,674
1
0
2011-06-02T13:57:17.610000
2011-06-02T14:41:04.297000
6,215,549
6,221,911
Python: 'object in list' checks and '__cmp__' overflow
this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site. I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from http://openbookproject.net/thinkcs/python/english3e/index.html and everything had been quite nice until now, ...
"So I was wondering, maybe it is a problem with Python 3.2, or maybe the syntax has changed somewhere?" Oh, you're running Python 3.2? This'll never work in Python 3: python 3 doesn't use __cmp__! See the data model (look for __eq__ ). Also read the what's new in Python 3 for some other things it's way too easy to miss...
Python: 'object in list' checks and '__cmp__' overflow this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site. I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from http://openbookproject.net/thinkcs/python/english3e/in...
TITLE: Python: 'object in list' checks and '__cmp__' overflow QUESTION: this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site. I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from http://openbookproject.net/thinkcs/p...
[ "python", "list", "object", "playing-cards", "cmp" ]
16
6
2,216
5
0
2011-06-02T13:57:37.590000
2011-06-03T00:43:44.967000
6,215,552
6,216,041
how to detect Empty paragraph in Word Document using Microsoft.Office.Interop.Word in C#4.0?
I want to detect Empty paragraphs in Word Document using Microsoft.Office.Interop.Word. Suppose, if my word document have some empty paragraphs,then Assume paragraph 3 is an empty paragraph... Microsoft.Office.Interop.Word.Paragraph para = wordDoc.Content.Paragraphs[3]; int cSent = para.Range.Sentences.Count; for (int...
Well, first, you may need to iterate through all the headers and footers of all sections if you also want to look for empty paras in those headers/footers. Second, something like this should work for each p in Doc.Content.Paragraphs if (p.Range.End - p.Range.Start) > 1 then (The paragraph is not empty) Next You may nee...
how to detect Empty paragraph in Word Document using Microsoft.Office.Interop.Word in C#4.0? I want to detect Empty paragraphs in Word Document using Microsoft.Office.Interop.Word. Suppose, if my word document have some empty paragraphs,then Assume paragraph 3 is an empty paragraph... Microsoft.Office.Interop.Word.Para...
TITLE: how to detect Empty paragraph in Word Document using Microsoft.Office.Interop.Word in C#4.0? QUESTION: I want to detect Empty paragraphs in Word Document using Microsoft.Office.Interop.Word. Suppose, if my word document have some empty paragraphs,then Assume paragraph 3 is an empty paragraph... Microsoft.Office...
[ "c#-4.0", "ms-word", "interop", "office-interop" ]
2
5
4,862
1
0
2011-06-02T13:57:49.997000
2011-06-02T14:40:40.707000
6,215,556
6,216,728
Help with running the Yesod Development server?
I'm currently trying out web development frameworks for haskell and I recently came across yesod. It seemed pretty interesting so I installed it using cabal, however I'm not able to run the development server. Following their getting started instructions here's the result: $ yesod init $ cd mysite $ yesod devel Config...
I haven't run into this specific issue, but the error message looks like it's a simple question of GHC being unable to find version 3.0.3.2 the package "base." This version has been buildable since GHC 6.9, so you should have it. Try running the following command: ghc-pkg check This will tell you if there is something ...
Help with running the Yesod Development server? I'm currently trying out web development frameworks for haskell and I recently came across yesod. It seemed pretty interesting so I installed it using cabal, however I'm not able to run the development server. Following their getting started instructions here's the result...
TITLE: Help with running the Yesod Development server? QUESTION: I'm currently trying out web development frameworks for haskell and I recently came across yesod. It seemed pretty interesting so I installed it using cabal, however I'm not able to run the development server. Following their getting started instructions...
[ "haskell", "ubuntu", "ghc", "haskell-platform", "yesod" ]
1
4
908
3
0
2011-06-02T13:57:56.577000
2011-06-02T15:32:59.847000
6,215,558
6,220,697
Tool for automated porting and language that can compile into others
I'm just asking this out of curiosity: Is there any tool that can automatically convert a source code of reasonable complexity from one language to another? Is there any "meta-language" that can compile into several other languages? For example CoffeeScript compiles into Javascript. If you know any open-source example,...
GCC converts complex C++ code into machine code and thus technically is an answer to your question. In fact, there are lots of compiler like this, but I don't think these are what you intended to ask. There are tools that are hardwired to translate just one language to another as source code (another poster suggested "...
Tool for automated porting and language that can compile into others I'm just asking this out of curiosity: Is there any tool that can automatically convert a source code of reasonable complexity from one language to another? Is there any "meta-language" that can compile into several other languages? For example Coffee...
TITLE: Tool for automated porting and language that can compile into others QUESTION: I'm just asking this out of curiosity: Is there any tool that can automatically convert a source code of reasonable complexity from one language to another? Is there any "meta-language" that can compile into several other languages? ...
[ "metaprogramming" ]
4
1
361
2
0
2011-06-02T13:58:03.837000
2011-06-02T21:38:40.180000
6,215,565
6,241,499
Configuring WCF Service to run on IIS 6
After deploying to production env' I receive only 404 - File Not Found. The service needs to be configured as a virtual directory ( /v1 ). It has its own Application pool. I enabled ASP.Net 4.0 as per http://www.jamesgoodfellow.com/blog/post/IIS-60---HTTP-404---File-not-found-Internet-Information-Services.aspx I added ...
Turns out that the ISAPI filter was actually blocking the service. So I removed the wildcard, added back windows integrated security - and the website now works.
Configuring WCF Service to run on IIS 6 After deploying to production env' I receive only 404 - File Not Found. The service needs to be configured as a virtual directory ( /v1 ). It has its own Application pool. I enabled ASP.Net 4.0 as per http://www.jamesgoodfellow.com/blog/post/IIS-60---HTTP-404---File-not-found-Int...
TITLE: Configuring WCF Service to run on IIS 6 QUESTION: After deploying to production env' I receive only 404 - File Not Found. The service needs to be configured as a virtual directory ( /v1 ). It has its own Application pool. I enabled ASP.Net 4.0 as per http://www.jamesgoodfellow.com/blog/post/IIS-60---HTTP-404---...
[ "asp.net", "wcf", "iis-6", "wcf-4" ]
1
1
1,692
2
0
2011-06-02T13:58:24.870000
2011-06-05T07:13:46.197000
6,215,579
6,215,751
Optional arguments and InteropServices
I'm using for the firs time optional arguments but I cannot understand difference between those two method definitions: private void method1([Optional, DefaultParameterValue(string.Empty)] string testString) { //do something } private void method2(string testString = "") { //do something } definition of method1 needs:...
Method 1 was present since.NET 1.1. Method 2 was introduced with C# 4 (C# did not support optional parameters until then).
Optional arguments and InteropServices I'm using for the firs time optional arguments but I cannot understand difference between those two method definitions: private void method1([Optional, DefaultParameterValue(string.Empty)] string testString) { //do something } private void method2(string testString = "") { //do s...
TITLE: Optional arguments and InteropServices QUESTION: I'm using for the firs time optional arguments but I cannot understand difference between those two method definitions: private void method1([Optional, DefaultParameterValue(string.Empty)] string testString) { //do something } private void method2(string testStr...
[ "c#", "optional-arguments" ]
3
3
970
1
0
2011-06-02T13:59:51.700000
2011-06-02T14:17:00.367000
6,215,581
6,215,627
Form Based Arrays
I'm trying to access each value in a array without serializing it. I than want this data stored into a datetime field in MySQL. The data is received from my form [collect] => Array ( [0] => 01 [1] => 06 [2] => 2011 [3] => 17 [4] => 41 ) How can i store this array data into my database 'datetime' field column? $dd=$_POS...
From what you wrote, I'm assuming that the form field is called collect[] seeing you're trying to access its indexes. However, you're using wrong method here - $_POST is an array, yet you tried to use it as a function (not that it's impossible, but for this purpose - it's really not the way to do it). $dd = $_POST['col...
Form Based Arrays I'm trying to access each value in a array without serializing it. I than want this data stored into a datetime field in MySQL. The data is received from my form [collect] => Array ( [0] => 01 [1] => 06 [2] => 2011 [3] => 17 [4] => 41 ) How can i store this array data into my database 'datetime' field...
TITLE: Form Based Arrays QUESTION: I'm trying to access each value in a array without serializing it. I than want this data stored into a datetime field in MySQL. The data is received from my form [collect] => Array ( [0] => 01 [1] => 06 [2] => 2011 [3] => 17 [4] => 41 ) How can i store this array data into my databas...
[ "php", "mysql", "arrays", "serialization", "webforms" ]
0
0
56
3
0
2011-06-02T13:59:56.077000
2011-06-02T14:05:02.410000
6,215,603
6,215,708
Turning an ASP.NET Website into an AJAX-Enabled one
I have successfully downloaded and installed AJAX framework, and the control toolkit. While trying to insert any AJAX controls such as UpdatePanels or ScriptManagers into an existent ASP.NET Web Site (which currently has no AJAX functionalities) I get the following error: "Attempret do read or write protected memory. T...
Do you have more than one version of the AJAX libraries. Often times, the versions can be different between what you have set to use in the configuration file and the controls you are slapping on the page. That is the first place I would check. You also need to make sure you have the correct version of both AJAX and th...
Turning an ASP.NET Website into an AJAX-Enabled one I have successfully downloaded and installed AJAX framework, and the control toolkit. While trying to insert any AJAX controls such as UpdatePanels or ScriptManagers into an existent ASP.NET Web Site (which currently has no AJAX functionalities) I get the following er...
TITLE: Turning an ASP.NET Website into an AJAX-Enabled one QUESTION: I have successfully downloaded and installed AJAX framework, and the control toolkit. While trying to insert any AJAX controls such as UpdatePanels or ScriptManagers into an existent ASP.NET Web Site (which currently has no AJAX functionalities) I ge...
[ "c#", ".net", "asp.net" ]
1
1
519
2
0
2011-06-02T14:02:32.527000
2011-06-02T14:13:00.197000
6,215,607
6,215,637
Problem with file dependencies and templates on a C++ program
Possible Duplicates: Templated function being reported as “undefined reference” during compilation Why can templates only be implemented in the header file? Hi, I'm having a problem with dependencies in a c++ program that only originates when I use templates. Apparently the compiler is not able to instantiate the templ...
The reason is described in detail here. In short, you need to provide the full definition in the header-file, otherwise the compiler cannot instantiate the template.
Problem with file dependencies and templates on a C++ program Possible Duplicates: Templated function being reported as “undefined reference” during compilation Why can templates only be implemented in the header file? Hi, I'm having a problem with dependencies in a c++ program that only originates when I use templates...
TITLE: Problem with file dependencies and templates on a C++ program QUESTION: Possible Duplicates: Templated function being reported as “undefined reference” during compilation Why can templates only be implemented in the header file? Hi, I'm having a problem with dependencies in a c++ program that only originates wh...
[ "c++", "templates", "makefile", "dependency-management" ]
0
3
165
1
0
2011-06-02T14:02:42.460000
2011-06-02T14:05:54.193000
6,215,619
6,223,242
NSOperation to perform uitableview cell image
As i am new in iPad application development please help me in simple problem. I want to display images in the tableview from the server. it is displaying correctly. But when i scroll table upside and come back to again there it will again download image data from server. Please help me. EDIT: tableView:cellForRowAtInde...
Your problem is this line UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.abc.com/abc/%@.png", [[arrMyCourses objectAtIndex:indexPath.row] valueForKey:@"CourseNumber"]]]]]; You are downloading the image every time the table view requests f...
NSOperation to perform uitableview cell image As i am new in iPad application development please help me in simple problem. I want to display images in the tableview from the server. it is displaying correctly. But when i scroll table upside and come back to again there it will again download image data from server. Pl...
TITLE: NSOperation to perform uitableview cell image QUESTION: As i am new in iPad application development please help me in simple problem. I want to display images in the tableview from the server. it is displaying correctly. But when i scroll table upside and come back to again there it will again download image da...
[ "ipad", "uitableview", "uiimageview", "nsoperationqueue" ]
0
1
763
1
0
2011-06-02T14:03:53.817000
2011-06-03T05:16:58.157000
6,215,623
6,215,665
css clearing an absolutely positioned div
I have a page with divs 250px x 250px which are all positioned absolutely, when one of these divs are opened an ajax call is made which expands the div to show all its contents, these divs are restricted to 600px in width but can be any height depending on info being presented so when a div has alot of content it seems...
There is no way of clearing an absolutely positioned div, absolutely positioned divs are taken completely out of the document flow. You can have a look at using a sticky footer which should keep your footer at the very bottom of the page which should visually fix up your page as the footer will no longer abruptly end. ...
css clearing an absolutely positioned div I have a page with divs 250px x 250px which are all positioned absolutely, when one of these divs are opened an ajax call is made which expands the div to show all its contents, these divs are restricted to 600px in width but can be any height depending on info being presented ...
TITLE: css clearing an absolutely positioned div QUESTION: I have a page with divs 250px x 250px which are all positioned absolutely, when one of these divs are opened an ajax call is made which expands the div to show all its contents, these divs are restricted to 600px in width but can be any height depending on inf...
[ "html", "css" ]
3
9
2,764
1
0
2011-06-02T14:04:36.610000
2011-06-02T14:08:37.190000
6,215,632
6,223,602
The HTML Doctype is automatically changing from XHTML 1.2 to XHTML 1.0
On a html page the doctype I've used is as follows (for a mobile website): which after uploading on the web server automatically turns into To make it clear this change happens as soon as I save the page on the server. (using cPanel) Any idea on what could be the reason for this (automatic) change? Because of this the ...
Ok, I think I've figured out the exact problem, it happens only when I use the cPanel editor to edit the html page and not when I just upload the file and not open it in their editor. As Jeremy said in the comments below the question, it's cPanel changing (screwing?) it for me! Thanks a lot everyone, especially Jeremy!...
The HTML Doctype is automatically changing from XHTML 1.2 to XHTML 1.0 On a html page the doctype I've used is as follows (for a mobile website): which after uploading on the web server automatically turns into To make it clear this change happens as soon as I save the page on the server. (using cPanel) Any idea on wha...
TITLE: The HTML Doctype is automatically changing from XHTML 1.2 to XHTML 1.0 QUESTION: On a html page the doctype I've used is as follows (for a mobile website): which after uploading on the web server automatically turns into To make it clear this change happens as soon as I save the page on the server. (using cPane...
[ "html", "doctype", "cpanel" ]
0
1
280
1
0
2011-06-02T14:05:27.113000
2011-06-03T06:11:03.363000
6,215,638
6,215,792
C# connecting to a database
I Am Trying to create a program using c# that needs to connect to a database running on a Solaris server, I am not too familiar with the server, we normally use dbVisualizer to connect to it. the driver it uses to connect is mysql-connector-java-5.1.10, which is a jdbc driver. was wondering what drivers to use to conne...
If I read your question correctly you are trying to connect to a MySql database from c#. This can be achieved by downloading the.net connector for MySql - Connector/Net. When you install this driver it will "integrate" with Visual Studio and you will be able to connect to the server directly from Visual Studio and your...
C# connecting to a database I Am Trying to create a program using c# that needs to connect to a database running on a Solaris server, I am not too familiar with the server, we normally use dbVisualizer to connect to it. the driver it uses to connect is mysql-connector-java-5.1.10, which is a jdbc driver. was wondering ...
TITLE: C# connecting to a database QUESTION: I Am Trying to create a program using c# that needs to connect to a database running on a Solaris server, I am not too familiar with the server, we normally use dbVisualizer to connect to it. the driver it uses to connect is mysql-connector-java-5.1.10, which is a jdbc driv...
[ "c#", "sql", "solaris" ]
0
1
2,795
3
0
2011-06-02T14:05:56.333000
2011-06-02T14:20:23.303000
6,215,639
6,215,921
Use of GUIDs as id in public facing data integration web service
To put the question into some context, the system exposing the web service uses GUIDs internally as identifiers for all entities. In such case, when designing a public facing data integration web service (used mainly for importing or exporting data from the system to other, external systems), what would you consider as...
First, let's look at the more generic "how do I set up a public API" question, my first exercise is determining what information is needed by the consumer of the service. I also look and see if there are is company specific naming in the object model. I then create a service model (data contract, if you want WCF specif...
Use of GUIDs as id in public facing data integration web service To put the question into some context, the system exposing the web service uses GUIDs internally as identifiers for all entities. In such case, when designing a public facing data integration web service (used mainly for importing or exporting data from t...
TITLE: Use of GUIDs as id in public facing data integration web service QUESTION: To put the question into some context, the system exposing the web service uses GUIDs internally as identifiers for all entities. In such case, when designing a public facing data integration web service (used mainly for importing or exp...
[ "wcf", "web-services", "soap", "guid" ]
2
2
1,270
1
0
2011-06-02T14:06:09.353000
2011-06-02T14:30:18.037000
6,215,664
6,215,715
what type of windows device driver can modify FindFirstFile and FindNextFile?
i need to add some files to results returned by FindFirstFile and FindNextFile under windows. Is this possible by file system filter driver or what type of drivers? Thank you
You can do this by File System Filter Driver. But you can do this by implementing a system wide API hook. I have not tried it before but you really don't need to take the pains of writing the drivers and making the system unstable in case of spoiling the driver stack. System Wide API Hooking API Hooking Revealed
what type of windows device driver can modify FindFirstFile and FindNextFile? i need to add some files to results returned by FindFirstFile and FindNextFile under windows. Is this possible by file system filter driver or what type of drivers? Thank you
TITLE: what type of windows device driver can modify FindFirstFile and FindNextFile? QUESTION: i need to add some files to results returned by FindFirstFile and FindNextFile under windows. Is this possible by file system filter driver or what type of drivers? Thank you ANSWER: You can do this by File System Filter Dr...
[ "c++", "c", "windows", "device-driver" ]
2
1
648
2
0
2011-06-02T14:08:33.290000
2011-06-02T14:13:38.530000
6,215,673
6,217,578
Rails 3 - Tidying Up Tags?
I'm having an issue with article Tags where a user can write an article once they have signed-in and add tags to the bottom of the article... pretty standard stuff. Am using the.titleised method which works fine, however I notice that if a user enters 3 tags without commas it then displays all these words as a single t...
Just change self.tags = @tag_names.split(/\,/).map do |name| to self.tags = @tag_names.split(/[\,\s]/).reject(&:blank?).map do |name| thus splitting at commas AND whitespaces, and then removing any empty strings, and you should be fine.
Rails 3 - Tidying Up Tags? I'm having an issue with article Tags where a user can write an article once they have signed-in and add tags to the bottom of the article... pretty standard stuff. Am using the.titleised method which works fine, however I notice that if a user enters 3 tags without commas it then displays al...
TITLE: Rails 3 - Tidying Up Tags? QUESTION: I'm having an issue with article Tags where a user can write an article once they have signed-in and add tags to the bottom of the article... pretty standard stuff. Am using the.titleised method which works fine, however I notice that if a user enters 3 tags without commas i...
[ "ruby-on-rails-3" ]
0
1
59
1
0
2011-06-02T14:09:20.493000
2011-06-02T16:51:48.917000
6,215,677
6,215,909
Fast grouping and aggregation of huge data set
I've got a huge amount of data (stored in file, but it is irrelevant - main part is that the data doesn't fit into memory) - let's say 10 9 lines of records. The record consists of time, some set of keys, and data. The keys aren't unique. for example keys: data: A | B | C | ---------------------- 1 | 2 | 3 | 10 1 | 1 |...
well, the comments for the question might be considered as an answer... You can use mapreduce ( hadoop is the framework implementation in java) your map stage will parse each line and extract relevant key and value for each line. your reduce stage will summarize all the data for the given key.
Fast grouping and aggregation of huge data set I've got a huge amount of data (stored in file, but it is irrelevant - main part is that the data doesn't fit into memory) - let's say 10 9 lines of records. The record consists of time, some set of keys, and data. The keys aren't unique. for example keys: data: A | B | C ...
TITLE: Fast grouping and aggregation of huge data set QUESTION: I've got a huge amount of data (stored in file, but it is irrelevant - main part is that the data doesn't fit into memory) - let's say 10 9 lines of records. The record consists of time, some set of keys, and data. The keys aren't unique. for example keys...
[ "language-agnostic", "grouping", "aggregation", "large-data" ]
1
1
1,324
1
0
2011-06-02T14:09:44.440000
2011-06-02T14:29:13.033000
6,215,685
6,215,814
Code condensing/efficiency
I'm writing a string replacing function to replace smiles with there actual image location but the code is going to be very big and messy because of all the nested ifs but i cant think of a more efficient way of writing the code. Public Function exchangeSmilies(ByVal postString As String) As String Dim ChangedString = ...
Use a Dictionary instead. Create a dictionary like the following at the class level: Dim dictionary As New Dictionary(Of String, String) dictionary.Add(":)", GetSmiliePath("smile.gif")) dictionary.Add(":p", GetSmiliePath("tongue.gif"))... In the exchangeSmilies function, you can loop through this dictionary to replace ...
Code condensing/efficiency I'm writing a string replacing function to replace smiles with there actual image location but the code is going to be very big and messy because of all the nested ifs but i cant think of a more efficient way of writing the code. Public Function exchangeSmilies(ByVal postString As String) As ...
TITLE: Code condensing/efficiency QUESTION: I'm writing a string replacing function to replace smiles with there actual image location but the code is going to be very big and messy because of all the nested ifs but i cant think of a more efficient way of writing the code. Public Function exchangeSmilies(ByVal postStr...
[ "vb.net" ]
1
4
264
3
0
2011-06-02T14:10:46.403000
2011-06-02T14:21:55.327000
6,215,690
6,219,842
How to execute a method automatically after entering Qt event loop?
I would like to execute a method which can only be called once my QApplication is displayed, i.e. when it has entered its main event loop exec_(). I'm new to Qt4 (using PyQt4): i was hoping to have a on_start() -like callback, but didn't find one. Do i need to create a thread or a timer? Or is there some callback inclu...
For now i have chosen to use QThread this way: class MyThread(QtCore.QThread): def run(self): ''' reinplemented from parent ''' # make thread sleep to make sure # QApplication is running before doing something self.sleep(2) do_something() class MyWidget(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__...
How to execute a method automatically after entering Qt event loop? I would like to execute a method which can only be called once my QApplication is displayed, i.e. when it has entered its main event loop exec_(). I'm new to Qt4 (using PyQt4): i was hoping to have a on_start() -like callback, but didn't find one. Do i...
TITLE: How to execute a method automatically after entering Qt event loop? QUESTION: I would like to execute a method which can only be called once my QApplication is displayed, i.e. when it has entered its main event loop exec_(). I'm new to Qt4 (using PyQt4): i was hoping to have a on_start() -like callback, but did...
[ "python", "multithreading", "timer", "pyqt4", "event-loop" ]
5
0
5,278
3
0
2011-06-02T14:11:12.803000
2011-06-02T20:15:07.543000
6,215,703
6,215,838
connecting to network registry
In Windows you can launch the registry and them connect to another registry; does anyone know how to accomplish this in c#? or if you know how of an api call that would be helpful. Thanks
The API function is RegConnectRegistry. I've linked to the MSDN documentation, where you'll find a list of all Registry Functions here.
connecting to network registry In Windows you can launch the registry and them connect to another registry; does anyone know how to accomplish this in c#? or if you know how of an api call that would be helpful. Thanks
TITLE: connecting to network registry QUESTION: In Windows you can launch the registry and them connect to another registry; does anyone know how to accomplish this in c#? or if you know how of an api call that would be helpful. Thanks ANSWER: The API function is RegConnectRegistry. I've linked to the MSDN documentat...
[ "c#" ]
0
0
182
2
0
2011-06-02T14:12:23.147000
2011-06-02T14:23:47.293000
6,215,707
6,277,625
AudioQueue How to read the buffer from CallBack
I am Using AUdioQueue to record the audio from built-in mic and send it over socket, I have set the AudioQueue buffer to record buffer of say 30 sec in once shot and allocating bufferSize appropriately, This is the function i am using to set the AudioDataFormat. AudioStreamBasicDescription sRecordFormat; FillOutASBDFor...
Some problem in buffer management, This application needs to send data in 20 ms +- 5 ms possible, in my case, this particular case was not handled.
AudioQueue How to read the buffer from CallBack I am Using AUdioQueue to record the audio from built-in mic and send it over socket, I have set the AudioQueue buffer to record buffer of say 30 sec in once shot and allocating bufferSize appropriately, This is the function i am using to set the AudioDataFormat. AudioStre...
TITLE: AudioQueue How to read the buffer from CallBack QUESTION: I am Using AUdioQueue to record the audio from built-in mic and send it over socket, I have set the AudioQueue buffer to record buffer of say 30 sec in once shot and allocating bufferSize appropriately, This is the function i am using to set the AudioDat...
[ "objective-c", "cocoa", "ios4", "audioqueue" ]
1
0
2,199
1
0
2011-06-02T14:12:58
2011-06-08T10:56:04.333000
6,215,712
6,215,768
log4net is logging all levels, instead of what I've configured it to do
I have the level set to "INFO" but I'm seeing DEBUG events in the log. Config Code private ILog Log { get; set; } static Program() { XmlConfigurator.Configure(); //... this.Log.Info("Started in RunOnce mode."); }
I think that within your root tag you need to set the property for your appender.
log4net is logging all levels, instead of what I've configured it to do I have the level set to "INFO" but I'm seeing DEBUG events in the log. Config Code private ILog Log { get; set; } static Program() { XmlConfigurator.Configure(); //... this.Log.Info("Started in RunOnce mode."); }
TITLE: log4net is logging all levels, instead of what I've configured it to do QUESTION: I have the level set to "INFO" but I'm seeing DEBUG events in the log. Config Code private ILog Log { get; set; } static Program() { XmlConfigurator.Configure(); //... this.Log.Info("Started in RunOnce mode."); } ANSWER: I think...
[ "c#", ".net", "logging", "configuration", "log4net" ]
3
7
4,737
3
0
2011-06-02T14:13:18.557000
2011-06-02T14:18:51.863000
6,215,718
6,219,737
Another "specified named connection" Argument Exception error
I've read several responses to this that I need to copy the app.config of my DAL project to my exe project. This is done so this is not the problem. What is very strange about this is that my app starts and runs fine with no problems. I do not get this at run time. I am getting this error in the xaml designer during de...
I've seen things like this happen if code in a control (or code-behind) is trying to access the database (or other resources that aren't available at design time). Then at design time Visual Studio runs that code and gets errors. Check if this is what you are doing. One way to figure out where its happening is to try d...
Another "specified named connection" Argument Exception error I've read several responses to this that I need to copy the app.config of my DAL project to my exe project. This is done so this is not the problem. What is very strange about this is that my app starts and runs fine with no problems. I do not get this at ru...
TITLE: Another "specified named connection" Argument Exception error QUESTION: I've read several responses to this that I need to copy the app.config of my DAL project to my exe project. This is done so this is not the problem. What is very strange about this is that my app starts and runs fine with no problems. I do ...
[ "wpf", "argumentexception" ]
0
0
99
1
0
2011-06-02T14:14:03.393000
2011-06-02T20:02:30.907000
6,215,723
6,215,767
detect aspx website by google
Is there grammar that using google to search for the website build by asp.net. It's like searching the webpages that end with aspx(*.aspx). Thanks!
Use this search term: filetype:aspx This will not find sites using URL rewriting (including MVC sites).
detect aspx website by google Is there grammar that using google to search for the website build by asp.net. It's like searching the webpages that end with aspx(*.aspx). Thanks!
TITLE: detect aspx website by google QUESTION: Is there grammar that using google to search for the website build by asp.net. It's like searching the webpages that end with aspx(*.aspx). Thanks! ANSWER: Use this search term: filetype:aspx This will not find sites using URL rewriting (including MVC sites).
[ "asp.net" ]
0
2
89
1
0
2011-06-02T14:14:26.423000
2011-06-02T14:18:24.983000
6,215,725
6,215,749
How do I create a list of all possible anagrams of a word in javascript?
How do I create a list of all possible anagrams of a word in javascript?If this question has already been asked please direct me to the answer? Thank You
Here you go: Anagrams finder in javascript I'm not sure whether that's the exact same problem as yours, but there look to be a few good solutions in the answers. EDIT: Actually, this is what you need: Is there any pre-built method for finding all permutations of a given string in JavaScript?
How do I create a list of all possible anagrams of a word in javascript? How do I create a list of all possible anagrams of a word in javascript?If this question has already been asked please direct me to the answer? Thank You
TITLE: How do I create a list of all possible anagrams of a word in javascript? QUESTION: How do I create a list of all possible anagrams of a word in javascript?If this question has already been asked please direct me to the answer? Thank You ANSWER: Here you go: Anagrams finder in javascript I'm not sure whether th...
[ "javascript", "anagram" ]
4
6
14,956
1
0
2011-06-02T14:14:28.357000
2011-06-02T14:16:48.120000
6,215,729
6,216,580
How to cancel editing in Halo/Spark TextInput and TextArea components
I am using Flex 4, ActionScript 3. In the AdvancedDataGrid component, when you are in Edit mode in a cell, you can hit the Escape key to cancel editing (i.e. return to the previous value in the cell). I had expected the same behaviour while in Edit mode in both the Halo and Spark TextInput and TextArea components, and ...
Yes, this is something that will have to be coded. Here's the approach I would take: Create a custom component that extends the TextInput. Let's call it UndoTextInput. Add a new variable to UndoTextInput to store the original text of the TextInput. We'll call it originalText. Add an event listener on the focusIn event....
How to cancel editing in Halo/Spark TextInput and TextArea components I am using Flex 4, ActionScript 3. In the AdvancedDataGrid component, when you are in Edit mode in a cell, you can hit the Escape key to cancel editing (i.e. return to the previous value in the cell). I had expected the same behaviour while in Edit m...
TITLE: How to cancel editing in Halo/Spark TextInput and TextArea components QUESTION: I am using Flex 4, ActionScript 3. In the AdvancedDataGrid component, when you are in Edit mode in a cell, you can hit the Escape key to cancel editing (i.e. return to the previous value in the cell). I had expected the same behavio...
[ "actionscript-3", "textarea", "flex4", "textinput", "flex-spark" ]
4
3
930
1
0
2011-06-02T14:14:49.120000
2011-06-02T15:20:52.233000
6,215,730
6,215,845
Alternative to regular PHP Class
Generally when creating a PHP class I would do something as such class Foo { public function Foo(){} public function RandomFunction(){}; } global $foo; $foo = new Foo(); $foo->RandomFunction(); I have noticed that on the web people are frowning upon the global vars for classes but without it I would not be able to acce...
In good OO practice, if a class needs to access an instance of another class, you pass object in as a parameter and then access it's properties and methods from there. If you have a well designed object model the code should be relatively clean and logical, however if you aren't planning on creating a strict OO applica...
Alternative to regular PHP Class Generally when creating a PHP class I would do something as such class Foo { public function Foo(){} public function RandomFunction(){}; } global $foo; $foo = new Foo(); $foo->RandomFunction(); I have noticed that on the web people are frowning upon the global vars for classes but witho...
TITLE: Alternative to regular PHP Class QUESTION: Generally when creating a PHP class I would do something as such class Foo { public function Foo(){} public function RandomFunction(){}; } global $foo; $foo = new Foo(); $foo->RandomFunction(); I have noticed that on the web people are frowning upon the global vars for...
[ "php", "object", "static" ]
1
4
380
2
0
2011-06-02T14:14:49.323000
2011-06-02T14:24:09.757000
6,215,735
6,215,827
How to check that the to which table the view is currently pointing to in oracle?
I have a situation like, I have two tables having same structure. I have a view which points to one of the table. In my store procedure I have to check first which table the view points to and accordingly update the other table and then finally update the view to point to the updated table. How to check that which tabl...
select referenced_name from all_dependencies where name = 'MYVIEW' and owner = 'MYSCHEMA' and referenced_type = 'TABLE';
How to check that the to which table the view is currently pointing to in oracle? I have a situation like, I have two tables having same structure. I have a view which points to one of the table. In my store procedure I have to check first which table the view points to and accordingly update the other table and then f...
TITLE: How to check that the to which table the view is currently pointing to in oracle? QUESTION: I have a situation like, I have two tables having same structure. I have a view which points to one of the table. In my store procedure I have to check first which table the view points to and accordingly update the othe...
[ "oracle11g" ]
2
1
857
1
0
2011-06-02T14:15:32.923000
2011-06-02T14:22:51.527000
6,215,736
6,215,832
Why do PHP and MySQL unix timestamps diverge on 1983-10-29?
I've been using PHP's strtotime and MySQL's UNIX_TIMESTAMP functions in my app, to convert dates into timestamps. PHP and MySQL are running on my local machine, and these functions generally return the same result, as I expect them to: $ php 1307001600 mysql> SELECT UNIX_TIMESTAMP("2011-06-02") ts; +------------+ | ts...
You say you're on Alaskan time. From http://www.statoids.com/tus.html: 1983-10-30 02:00: All parts of Alaska except the Aleutians and Saint Lawrence Island switched to AT. Prior to the change, Alaska east of 138°W (Juneau) had been on PT; between 138°W and 141°W (Yakutat) had been on Yukon Time, which was UTC-9 with DS...
Why do PHP and MySQL unix timestamps diverge on 1983-10-29? I've been using PHP's strtotime and MySQL's UNIX_TIMESTAMP functions in my app, to convert dates into timestamps. PHP and MySQL are running on my local machine, and these functions generally return the same result, as I expect them to: $ php 1307001600 mysql>...
TITLE: Why do PHP and MySQL unix timestamps diverge on 1983-10-29? QUESTION: I've been using PHP's strtotime and MySQL's UNIX_TIMESTAMP functions in my app, to convert dates into timestamps. PHP and MySQL are running on my local machine, and these functions generally return the same result, as I expect them to: $ php ...
[ "php", "mysql", "datetime", "date" ]
29
22
644
1
0
2011-06-02T14:15:33.660000
2011-06-02T14:23:12.740000
6,215,739
6,215,799
Asp.Net MVC Form[GET]. Correct action url
I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url: (I even have exception: The length of the query string for this request exceeds the configured maxQueryStringLength value.) it's expecting, [0].IsSelected=false&[0].Id=6&[1].IsSelected=false.....
I would do a POST instead, then redirect to the URL you desire. OR You could capture the form with some JavaScript and build the URL there.
Asp.Net MVC Form[GET]. Correct action url I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url: (I even have exception: The length of the query string for this request exceeds the configured maxQueryStringLength value.) it's expecting, [0].IsSele...
TITLE: Asp.Net MVC Form[GET]. Correct action url QUESTION: I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url: (I even have exception: The length of the query string for this request exceeds the configured maxQueryStringLength value.) it's exp...
[ "asp.net-mvc", "forms" ]
0
4
739
2
0
2011-06-02T14:15:41.853000
2011-06-02T14:20:42.913000
6,215,754
6,215,776
Spoof $_SERVER['HTTPS'] on local wamp-server for testing
Is it possible to configure my local setup (running Wampserver) so that my PHP application thinks HTTPS is enabled locally? The application requires HTTPS (by checking $_SERVER['HTTPS'] ) before doing stuff, but I don't want to go through the hassle of a full HTTPS setup locally. Thanks. Edit: I should mention this isn...
You can mock up this variable in your init file by adding: $_SERVER['HTTPS'] = true;
Spoof $_SERVER['HTTPS'] on local wamp-server for testing Is it possible to configure my local setup (running Wampserver) so that my PHP application thinks HTTPS is enabled locally? The application requires HTTPS (by checking $_SERVER['HTTPS'] ) before doing stuff, but I don't want to go through the hassle of a full HTT...
TITLE: Spoof $_SERVER['HTTPS'] on local wamp-server for testing QUESTION: Is it possible to configure my local setup (running Wampserver) so that my PHP application thinks HTTPS is enabled locally? The application requires HTTPS (by checking $_SERVER['HTTPS'] ) before doing stuff, but I don't want to go through the ha...
[ "php", "ssl", "https", "wampserver" ]
3
2
571
3
0
2011-06-02T14:17:17.983000
2011-06-02T14:19:18.150000
6,215,762
6,216,836
mac os 10.6 server: crontab does not fire wget script
I am completely baffled by the behaviour of cron under Mac OS 10.6 Server. I am trying to run two scripts in a cronjob like this: 00 16 * * * /Users/myusername/script.sh 04 16 * * * /Users/myusername/crontest.sh While 'script.sh' contains a wget command: #!/bin/sh wget -r -l3 --no-parent -nc -A ".shtml" 'http://some.ur...
cron runs scripts with a very minimal environment. In particular, its PATH doesn't contain all of the usual binaries directories, just /usr/bin and /bin, so any commands in other binaries directories (like wget) will not be available. There are several ways to fix this. One option is to have your script give the comple...
mac os 10.6 server: crontab does not fire wget script I am completely baffled by the behaviour of cron under Mac OS 10.6 Server. I am trying to run two scripts in a cronjob like this: 00 16 * * * /Users/myusername/script.sh 04 16 * * * /Users/myusername/crontest.sh While 'script.sh' contains a wget command: #!/bin/sh w...
TITLE: mac os 10.6 server: crontab does not fire wget script QUESTION: I am completely baffled by the behaviour of cron under Mac OS 10.6 Server. I am trying to run two scripts in a cronjob like this: 00 16 * * * /Users/myusername/script.sh 04 16 * * * /Users/myusername/crontest.sh While 'script.sh' contains a wget co...
[ "macos", "cron", "wget" ]
0
3
1,196
3
0
2011-06-02T14:18:12.583000
2011-06-02T15:42:07.287000
6,215,765
6,215,829
Is It Okay to use helpers in views?
Simple question about best-practice. I'm using Kohana... is it okay to use helpers in views? For example, to use URL::site(). I could pass it from controller, you know. I assume it's okay, because there are helpers like HTML that is meant to be used in views, right?
The way you're currently doing it is ok, altough the whole practice of having any logics in views is questionable, but it's how Kohana is currently recommending. When you get to use ViewModel pattern (with Kostache?), you'll separate all logics from templates. Until then, it's ok to use methods that don't do anything t...
Is It Okay to use helpers in views? Simple question about best-practice. I'm using Kohana... is it okay to use helpers in views? For example, to use URL::site(). I could pass it from controller, you know. I assume it's okay, because there are helpers like HTML that is meant to be used in views, right?
TITLE: Is It Okay to use helpers in views? QUESTION: Simple question about best-practice. I'm using Kohana... is it okay to use helpers in views? For example, to use URL::site(). I could pass it from controller, you know. I assume it's okay, because there are helpers like HTML that is meant to be used in views, right?...
[ "url", "kohana", "helper" ]
1
2
85
1
0
2011-06-02T14:18:23.567000
2011-06-02T14:22:57.387000
6,215,782
6,215,800
Do unused functions get optimized out?
Compilers these days tend to do a significant amount of optimizations. Do they also remove unused functions from the final output?
It depends on the compiler. Visual C++ 9 can do that - unused static functions are removed at compilation phase (there's even a C4505 warning for that), unused functions with external linkage can be removed at link phase depending on linker settings.
Do unused functions get optimized out? Compilers these days tend to do a significant amount of optimizations. Do they also remove unused functions from the final output?
TITLE: Do unused functions get optimized out? QUESTION: Compilers these days tend to do a significant amount of optimizations. Do they also remove unused functions from the final output? ANSWER: It depends on the compiler. Visual C++ 9 can do that - unused static functions are removed at compilation phase (there's ev...
[ "c++", "c", "compiler-construction", "compiler-optimization" ]
63
36
37,422
8
0
2011-06-02T14:19:54.687000
2011-06-02T14:20:52.783000
6,215,787
6,216,924
Why does this patch applied with a fuzz of 1, and fail with fuzz of 0?
$ vim patch Index: toPatch =================================================================== --- toPatch +++ toPatch @@ -2,4 +2,4 @@ */ -final public class XMLWriter { +public class XMLWriter { $ vim toPatch */ final public class XMLWriter { public static float CURRENT_VERSION=2.2f; $ patch -p0 -ui patch patching f...
Patch does some basic checking of consistency of the diff and your file, and if these checks fail, you get offset or fuzz. You have offset -1, since patch expects the contents of the diff match lines 2--4 of your file. In your file, however, they are lines 1--3. You have fuzz>0, since the first line of the context (two...
Why does this patch applied with a fuzz of 1, and fail with fuzz of 0? $ vim patch Index: toPatch =================================================================== --- toPatch +++ toPatch @@ -2,4 +2,4 @@ */ -final public class XMLWriter { +public class XMLWriter { $ vim toPatch */ final public class XMLWriter { pub...
TITLE: Why does this patch applied with a fuzz of 1, and fail with fuzz of 0? QUESTION: $ vim patch Index: toPatch =================================================================== --- toPatch +++ toPatch @@ -2,4 +2,4 @@ */ -final public class XMLWriter { +public class XMLWriter { $ vim toPatch */ final public clas...
[ "diff", "patch" ]
9
18
20,824
2
0
2011-06-02T14:20:02.987000
2011-06-02T15:51:37.243000
6,215,789
6,215,911
Build condition comparison for if statement
Is this possible? $var_1 = 1; $var_2 = 10; $comparison = '>'; if($var_1 $comparison $var_2) { // do something... } The syntax right now is not valid but is there a way to do this?
Not natively (except of course with eval ). You will need to evaluate the various expressions yourself. Build a wrapper function and use a switch statement. Or for non-expression comparisons a simple map: $var_1 = 1; $var_2 = 10; $comparison = '>'; $map = array( ">" => $var_1 > $var_2, "<" => $var_1 < $var_2, "==" => ...
Build condition comparison for if statement Is this possible? $var_1 = 1; $var_2 = 10; $comparison = '>'; if($var_1 $comparison $var_2) { // do something... } The syntax right now is not valid but is there a way to do this?
TITLE: Build condition comparison for if statement QUESTION: Is this possible? $var_1 = 1; $var_2 = 10; $comparison = '>'; if($var_1 $comparison $var_2) { // do something... } The syntax right now is not valid but is there a way to do this? ANSWER: Not natively (except of course with eval ). You will need to evaluat...
[ "php", "dynamic", "comparison", "if-statement" ]
3
9
4,666
6
0
2011-06-02T14:20:11.353000
2011-06-02T14:29:26.263000
6,215,797
6,217,532
Wordpress Post ID in wp_nav_menu?
I'm looking to add the post ID to the markup of wp_nav_menu but not sure how to approach it. I've found this: http://wordpress.org/support/topic/output-the-post-id-of-wp_nav_menu-items which suggests this, but putting it in my functions.php file doesnt do any thing. // get menu item's content id class pages_from_nav ex...
Have it figured out via some nice chaps on the WP forums. Needed to create a walker, which is a custo nav structure: // nav menu walker class My_Walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth )? str_repeat( "\t", $depth ): ''; $class_names = $v...
Wordpress Post ID in wp_nav_menu? I'm looking to add the post ID to the markup of wp_nav_menu but not sure how to approach it. I've found this: http://wordpress.org/support/topic/output-the-post-id-of-wp_nav_menu-items which suggests this, but putting it in my functions.php file doesnt do any thing. // get menu item's ...
TITLE: Wordpress Post ID in wp_nav_menu? QUESTION: I'm looking to add the post ID to the markup of wp_nav_menu but not sure how to approach it. I've found this: http://wordpress.org/support/topic/output-the-post-id-of-wp_nav_menu-items which suggests this, but putting it in my functions.php file doesnt do any thing. /...
[ "php", "wordpress" ]
3
9
7,665
2
0
2011-06-02T14:20:31.083000
2011-06-02T16:46:53.230000
6,215,808
6,216,054
How to extract text from a web page that requires logging in using python and beautiful soup?
i have to retrieve some text from a website called morningstar.com. To access that data i have to log in. Once i log in and provide the url of the web page, i get the HTML text of a normal user (not logged in).As a result am not able to accees that information. ANy solutions?
BeautifulSoup is for parsing html once you've already fetched it. You can fetch the html using any standard url fetching library. I prefer curl, as you tagged your post, python's built-in urllib2 also works well. If you're saying that after logging in the response html is the same as for those who are not logged in, I'...
How to extract text from a web page that requires logging in using python and beautiful soup? i have to retrieve some text from a website called morningstar.com. To access that data i have to log in. Once i log in and provide the url of the web page, i get the HTML text of a normal user (not logged in).As a result am n...
TITLE: How to extract text from a web page that requires logging in using python and beautiful soup? QUESTION: i have to retrieve some text from a website called morningstar.com. To access that data i have to log in. Once i log in and provide the url of the web page, i get the HTML text of a normal user (not logged in...
[ "python", "urllib2", "beautifulsoup" ]
0
3
651
1
0
2011-06-02T14:21:23.673000
2011-06-02T14:41:41.777000
6,215,817
6,215,863
Extracting 'single item' from Multi Dimensional Array (c#)
Say I have the code var marray = new int[,]{{0,1},{2,3},{4,5}}; Is it possible to get a reference to the first item - i.e. something that looked like: var _marray = marray[0]; //would look like: var _marray = new int[,]{{0,1}}; Instead, when referencing marray from a one dimensional context, it sees marray as having le...
Use a jagged array var marray = new[] { new[] { 0, 1 }, new[] { 2, 3 }, new[] { 4, 5 } }; Console.WriteLine(marray[0][1]);
Extracting 'single item' from Multi Dimensional Array (c#) Say I have the code var marray = new int[,]{{0,1},{2,3},{4,5}}; Is it possible to get a reference to the first item - i.e. something that looked like: var _marray = marray[0]; //would look like: var _marray = new int[,]{{0,1}}; Instead, when referencing marray ...
TITLE: Extracting 'single item' from Multi Dimensional Array (c#) QUESTION: Say I have the code var marray = new int[,]{{0,1},{2,3},{4,5}}; Is it possible to get a reference to the first item - i.e. something that looked like: var _marray = marray[0]; //would look like: var _marray = new int[,]{{0,1}}; Instead, when r...
[ "c#", "multidimensional-array" ]
0
1
263
1
0
2011-06-02T14:21:59.777000
2011-06-02T14:25:37.947000
6,215,819
6,244,179
Get the right node from duplicates xml with NSXML
I'm trying to us NSXML to parse a user's channel from youtube. Parsing works ok, but I can't seem to figure out how to get the link from any specific movie as their are 5 exact the same nodes as following: I've figured out how to get the attribute href from the node link. But since their are 5 different links I don't k...
Found the solution already. I'll check if the link node has an attribute with alternate in it. If it does it has the right link node. Here is the code: NSMutableArray *link; if ([elementName isEqualToString:@"link"]) if (!link) link = [[NSMutableArray alloc] init]; NSString *alternate = [attributeDict objectForKey:@"re...
Get the right node from duplicates xml with NSXML I'm trying to us NSXML to parse a user's channel from youtube. Parsing works ok, but I can't seem to figure out how to get the link from any specific movie as their are 5 exact the same nodes as following: I've figured out how to get the attribute href from the node lin...
TITLE: Get the right node from duplicates xml with NSXML QUESTION: I'm trying to us NSXML to parse a user's channel from youtube. Parsing works ok, but I can't seem to figure out how to get the link from any specific movie as their are 5 exact the same nodes as following: I've figured out how to get the attribute href...
[ "iphone", "objective-c", "xml", "ios", "nsxml" ]
0
0
130
1
0
2011-06-02T14:22:13.470000
2011-06-05T16:22:34.210000
6,215,833
6,216,096
How do I convert an ATL/MFC CString to a QString?
Given the encoding of the project is probably Unicode (but not for sure) what is the best way of converting ATL::CString to QString? What I have thought of is this: CString c(_T("SOME_TEXT")); //... std::basic_string intermediate((LPCTSTR)c); QString q; #ifdef _UNICODE q = QString::fromStdWString(intermediate); #else ...
You don't need the intermediate conversion to a std::string. The CString class can be treated as a simple C-style string; that is, an array of characters. All you have to do is cast it to an LPCTSTR. And once you have that, you just need to create the QString object depending on whether the characters in your CString a...
How do I convert an ATL/MFC CString to a QString? Given the encoding of the project is probably Unicode (but not for sure) what is the best way of converting ATL::CString to QString? What I have thought of is this: CString c(_T("SOME_TEXT")); //... std::basic_string intermediate((LPCTSTR)c); QString q; #ifdef _UNICODE...
TITLE: How do I convert an ATL/MFC CString to a QString? QUESTION: Given the encoding of the project is probably Unicode (but not for sure) what is the best way of converting ATL::CString to QString? What I have thought of is this: CString c(_T("SOME_TEXT")); //... std::basic_string intermediate((LPCTSTR)c); QString q...
[ "c++", "qt", "mfc", "atl", "cstring" ]
5
9
8,439
1
0
2011-06-02T14:23:22.050000
2011-06-02T14:44:10.160000
6,215,841
6,217,714
Create links in HTML canvas
Is it possible to create html links out of text that is rendered in a canvas element?
There is no easy way. You will have to draw the link text onto the canvas and then check for mouseclicks. Here is a demo html page: Canvas not supported.
Create links in HTML canvas Is it possible to create html links out of text that is rendered in a canvas element?
TITLE: Create links in HTML canvas QUESTION: Is it possible to create html links out of text that is rendered in a canvas element? ANSWER: There is no easy way. You will have to draw the link text onto the canvas and then check for mouseclicks. Here is a demo html page: Canvas not supported.
[ "html", "canvas", "hyperlink" ]
34
33
64,200
6
0
2011-06-02T14:23:57.073000
2011-06-02T17:05:13.897000
6,215,844
6,215,886
Trigger a jQuery Event Handler Assigned in a Different Code Block
I have a case where a click handler is defined/assigned in one jQuery code block (file) and I want to trigger it from another click event defined/assigned in a different jQuery code block. How can I accomplish this? The following code is a greatly simplified version of what I am trying to accomplish. The behavior I wan...
You need to trigger a click when you click on the first element. You can use the trigger method for this. function element1Hanlder () { alert('Element One'); } $(document).ready(function() { $('#Element1').click(function() { alert('Element One'); }); }); $(document).ready(function() { $('#Element2').click(function() ...
Trigger a jQuery Event Handler Assigned in a Different Code Block I have a case where a click handler is defined/assigned in one jQuery code block (file) and I want to trigger it from another click event defined/assigned in a different jQuery code block. How can I accomplish this? The following code is a greatly simpli...
TITLE: Trigger a jQuery Event Handler Assigned in a Different Code Block QUESTION: I have a case where a click handler is defined/assigned in one jQuery code block (file) and I want to trigger it from another click event defined/assigned in a different jQuery code block. How can I accomplish this? The following code i...
[ "javascript", "jquery", "jquery-ui", "jquery-events", "jquery-ui-dialog" ]
1
2
1,209
2
0
2011-06-02T14:24:07.543000
2011-06-02T14:27:33.050000
6,215,858
6,222,904
Google Maps Textured Roads
I would like to find a Google Maps API v3 friendly way to add textures (my own images) to elements such as roads, grass, and water. I know you can change the colors of various elements, but I want to do more. I'm curious if anyone knows if this can be done at a large scale (not just a single area but the whole world). ...
If I am understanding your question correctly, I do not believe that there is currently a way to do that easily and reliably using Google Maps API v3. If I wanted to have such a feature, I'd look at OpenLayers and Google Earth API. I have no idea if either support such a feature, but that's where I'd look first. You ma...
Google Maps Textured Roads I would like to find a Google Maps API v3 friendly way to add textures (my own images) to elements such as roads, grass, and water. I know you can change the colors of various elements, but I want to do more. I'm curious if anyone knows if this can be done at a large scale (not just a single ...
TITLE: Google Maps Textured Roads QUESTION: I would like to find a Google Maps API v3 friendly way to add textures (my own images) to elements such as roads, grass, and water. I know you can change the colors of various elements, but I want to do more. I'm curious if anyone knows if this can be done at a large scale (...
[ "javascript", "google-maps" ]
1
1
396
1
0
2011-06-02T14:25:04.593000
2011-06-03T04:17:25.657000
6,215,859
6,215,919
How to get this pattern in iOS?
I am wondering where I can get this pattern in Xcode? Thanks!
You can have it with: [UIColor scrollViewTexturedBackgroundColor]
How to get this pattern in iOS? I am wondering where I can get this pattern in Xcode? Thanks!
TITLE: How to get this pattern in iOS? QUESTION: I am wondering where I can get this pattern in Xcode? Thanks! ANSWER: You can have it with: [UIColor scrollViewTexturedBackgroundColor]
[ "iphone", "cocoa-touch", "xcode", "ios" ]
5
13
637
1
0
2011-06-02T14:25:13.390000
2011-06-02T14:29:55.557000
6,215,861
6,218,102
Avoiding Step Into common functions in Eclipse
It drives me crazy every time I want to step into my function, Eclipse steps into all the internal functions called during parameter construction. For example, simple method call like this: filter( Arrays.copyOfRange( sorted_words, 0, count), "count=" +count+ " words"); Goes through Arrays.copyOfRange, then StringBuild...
Step filters are one way to avoid stepping into types or packages that you want to avoid. You can also use 'Step into Selection' debugger action. Quoting from the JDT Tips and Tricks document - "The Java debugger allows you to step into a single method within a series of chained or nested method calls. Simply select th...
Avoiding Step Into common functions in Eclipse It drives me crazy every time I want to step into my function, Eclipse steps into all the internal functions called during parameter construction. For example, simple method call like this: filter( Arrays.copyOfRange( sorted_words, 0, count), "count=" +count+ " words"); Go...
TITLE: Avoiding Step Into common functions in Eclipse QUESTION: It drives me crazy every time I want to step into my function, Eclipse steps into all the internal functions called during parameter construction. For example, simple method call like this: filter( Arrays.copyOfRange( sorted_words, 0, count), "count=" +co...
[ "eclipse", "debugging" ]
2
4
699
1
0
2011-06-02T14:25:22.130000
2011-06-02T17:38:32.690000
6,215,866
6,226,772
Direct POST to WCF WSDL-first web service
I need some help posting some XML to a WCF service. In essence, the issue I am experiencing is a HTTP response of "400: Bad request" - as descriptive as that sounds, i'm struggling to find any answers! First of all, the service I have built in WCF is based on an existing WSDL, originally from an IBM WebSphere web servi...
Thanks for the Fiddler comment - I managed to get the WCF request traced and using the xml from the request seems to work! I've since tried a full message which works against the WebSphere service against the WCF client and that works too! I think the issue was the Action header. I believe WCF only support a couple of ...
Direct POST to WCF WSDL-first web service I need some help posting some XML to a WCF service. In essence, the issue I am experiencing is a HTTP response of "400: Bad request" - as descriptive as that sounds, i'm struggling to find any answers! First of all, the service I have built in WCF is based on an existing WSDL, ...
TITLE: Direct POST to WCF WSDL-first web service QUESTION: I need some help posting some XML to a WCF service. In essence, the issue I am experiencing is a HTTP response of "400: Bad request" - as descriptive as that sounds, i'm struggling to find any answers! First of all, the service I have built in WCF is based on ...
[ "wcf", "web-services", "post", "httpwebrequest", "http-status-code-400" ]
0
0
1,377
1
0
2011-06-02T14:25:42.547000
2011-06-03T11:53:11.977000
6,215,874
6,217,474
Magento: how to configure cron settings using GUI?
It's not a problem to set cron intervals using xml-config file, but it'll be great to have ability to do that using config panel of custom module any time if needed. Friendly GUI instead of "terrible" XML, which could be accessible via FTP. I have one idea only: catch some event when admin updates configuration of a gi...
Magento usually grabs all the cron data from the XML files you don't seem to be in favor of, but there's no reason you couldn't override it to use some other data model that gets retrieved from the database. Then you could have a simple interface to manage the cron details in the admin.
Magento: how to configure cron settings using GUI? It's not a problem to set cron intervals using xml-config file, but it'll be great to have ability to do that using config panel of custom module any time if needed. Friendly GUI instead of "terrible" XML, which could be accessible via FTP. I have one idea only: catch ...
TITLE: Magento: how to configure cron settings using GUI? QUESTION: It's not a problem to set cron intervals using xml-config file, but it'll be great to have ability to do that using config panel of custom module any time if needed. Friendly GUI instead of "terrible" XML, which could be accessible via FTP. I have one...
[ "php", "user-interface", "magento", "cron" ]
0
1
313
1
0
2011-06-02T14:26:16.720000
2011-06-02T16:40:33.770000
6,215,875
6,217,699
Codeigniter how to map a class sent to a model
I have a SectorModel with this function: public function update(Sector $sector) { $this->db->where('sector_id', $sector->getScetor_id()); return $this->db->update(_SECTOR_, $sector); } There are times that I’ll change only the name of the Sector object: $Sector = new Sector(); $Sector->setSector_name = 'test'; $this->...
Just loop through all your object's properites and then if any is NULL just drop it with unset. Here is your model's method edited to achieve that: public function update(Sector $sector) { foreach($sector as $k=>$v) { if($v === NULL) unset($sector->$k) } $this->db->where('sector_id', $sector->getScetor_id()); return $...
Codeigniter how to map a class sent to a model I have a SectorModel with this function: public function update(Sector $sector) { $this->db->where('sector_id', $sector->getScetor_id()); return $this->db->update(_SECTOR_, $sector); } There are times that I’ll change only the name of the Sector object: $Sector = new Secto...
TITLE: Codeigniter how to map a class sent to a model QUESTION: I have a SectorModel with this function: public function update(Sector $sector) { $this->db->where('sector_id', $sector->getScetor_id()); return $this->db->update(_SECTOR_, $sector); } There are times that I’ll change only the name of the Sector object: $...
[ "php", "database", "codeigniter", "frameworks", "model" ]
0
2
1,203
2
0
2011-06-02T14:26:26.717000
2011-06-02T17:03:46.237000
6,215,879
6,215,938
How to get pass this error "Value cannot be null. Parameter name: entity"
private void button1_Click(object sender, EventArgs e) { DataClasses1DataContext dc = new DataClasses1DataContext(); var rec = dc.reportsSents.FirstOrDefault(); int rowCount = dc.reportsSents.Count(); if (rec!= null) { for(int i = 0; i <= rowCount;) { var matchedCaseNumber = (from CaseNumberKey in dc.GetTable () se...
matchedCaseNumber is probably null when passed to DeleteOnSubmit if(matchedCaseNumber!= null) { dc.reportsSents.DeleteOnSubmit(matchedCaseNumber); dc.SubmitChanges(); } EDIT: If I understand correctly what you're trying to do, this would be better: private void button1_Click(object sender, EventArgs e) { DataClasses1D...
How to get pass this error "Value cannot be null. Parameter name: entity" private void button1_Click(object sender, EventArgs e) { DataClasses1DataContext dc = new DataClasses1DataContext(); var rec = dc.reportsSents.FirstOrDefault(); int rowCount = dc.reportsSents.Count(); if (rec!= null) { for(int i = 0; i <= rowC...
TITLE: How to get pass this error "Value cannot be null. Parameter name: entity" QUESTION: private void button1_Click(object sender, EventArgs e) { DataClasses1DataContext dc = new DataClasses1DataContext(); var rec = dc.reportsSents.FirstOrDefault(); int rowCount = dc.reportsSents.Count(); if (rec!= null) { for(in...
[ "c#", "linq-to-sql" ]
2
2
10,953
3
0
2011-06-02T14:26:59.443000
2011-06-02T14:31:39.217000
6,215,883
6,216,050
Make DIV fixed inside a scrollable DIV
Does anyone now how to make a DIV inside another DIV that is scroll-able fixed, so that no matter how much I scroll by, the DIV always stays in the same place? Any help would be greatly appreciated.
Try this out: im scrollable im scrollable im scrollable im scrollable im scrollable im scrollable and I'm fixed
Make DIV fixed inside a scrollable DIV Does anyone now how to make a DIV inside another DIV that is scroll-able fixed, so that no matter how much I scroll by, the DIV always stays in the same place? Any help would be greatly appreciated.
TITLE: Make DIV fixed inside a scrollable DIV QUESTION: Does anyone now how to make a DIV inside another DIV that is scroll-able fixed, so that no matter how much I scroll by, the DIV always stays in the same place? Any help would be greatly appreciated. ANSWER: Try this out: im scrollable im scrollable im scrollable...
[ "javascript", "html" ]
8
7
14,319
4
0
2011-06-02T14:27:25.967000
2011-06-02T14:41:15.723000
6,215,885
6,216,463
Optimize the code
I am new to python. I would like all the python gurus to suggest some ways to make the following code more pythonic and hence more efficient. Its a simple code to find the edit distance between two words. P.S. I would like improvements in code, not in the logic or algorithm optimization. class test: def __init__(self,a...
Pythonic would be: Write lots of unit tests. Don't reinvent the wheel: search online for previous solutions to the problem. See the comments. Don't optimise prematurely: profile your code to work out whether this really is a bottleneck and if it is improve the algorithm. Meaningful variable names Don't start local vari...
Optimize the code I am new to python. I would like all the python gurus to suggest some ways to make the following code more pythonic and hence more efficient. Its a simple code to find the edit distance between two words. P.S. I would like improvements in code, not in the logic or algorithm optimization. class test: d...
TITLE: Optimize the code QUESTION: I am new to python. I would like all the python gurus to suggest some ways to make the following code more pythonic and hence more efficient. Its a simple code to find the edit distance between two words. P.S. I would like improvements in code, not in the logic or algorithm optimizat...
[ "python" ]
2
3
253
3
0
2011-06-02T14:27:28.120000
2011-06-02T15:12:08.240000
6,215,888
6,283,636
HTTP GET request to get binary content of an XML file
I'm trying to get the binary content of an XML file through HTTP but the server just want to give me kind of interpreted format (wich removes \r for every \r\n). My HTTP GET request is simple: "GET http://%s%s%s HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n" It works for extention except.xml. And if I change the.xml in.no...
It was caused by my FTP Client (FileZilla). If I transfer.nxml and rename in.xml by FTP, the file is OK. Thanks for trying to help me.
HTTP GET request to get binary content of an XML file I'm trying to get the binary content of an XML file through HTTP but the server just want to give me kind of interpreted format (wich removes \r for every \r\n). My HTTP GET request is simple: "GET http://%s%s%s HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n" It works f...
TITLE: HTTP GET request to get binary content of an XML file QUESTION: I'm trying to get the binary content of an XML file through HTTP but the server just want to give me kind of interpreted format (wich removes \r for every \r\n). My HTTP GET request is simple: "GET http://%s%s%s HTTP/1.0\r\nConnection: Keep-Alive\r...
[ "xml", "http", "binary", "get", "format" ]
4
1
1,077
3
0
2011-06-02T14:27:44.173000
2011-06-08T18:44:05.093000
6,215,889
6,216,427
Getting accurate file size in megabytes?
How can I get the accurate file size in MB? I tried this: compressed_file_size = File.size("Compressed/#{project}.tar.bz2") / 1024000 puts "file size is #{compressed_file_size} MB" But it chopped the 0.9 and showed 2 MB instead of 2.9 MB
Try: compressed_file_size = File.size("Compressed/#{project}.tar.bz2").to_f / 2**20 formatted_file_size = '%.2f' % compressed_file_size One-liner: compressed_file_size = '%.2f' % (File.size("Compressed/#{project}.tar.bz2").to_f / 2**20) or: compressed_file_size = (File.size("Compressed/#{project}.tar.bz2").to_f / 2**20...
Getting accurate file size in megabytes? How can I get the accurate file size in MB? I tried this: compressed_file_size = File.size("Compressed/#{project}.tar.bz2") / 1024000 puts "file size is #{compressed_file_size} MB" But it chopped the 0.9 and showed 2 MB instead of 2.9 MB
TITLE: Getting accurate file size in megabytes? QUESTION: How can I get the accurate file size in MB? I tried this: compressed_file_size = File.size("Compressed/#{project}.tar.bz2") / 1024000 puts "file size is #{compressed_file_size} MB" But it chopped the 0.9 and showed 2 MB instead of 2.9 MB ANSWER: Try: compress...
[ "ruby" ]
24
35
38,799
4
0
2011-06-02T14:27:47.070000
2011-06-02T15:09:31.873000
6,215,890
6,216,184
how to parse xml with php
I am trying to read a weather feed from Yahoo to my site. Using the code below I was able to print the xml. What I really want to achieve now is to put the temperature and image in two different variables $zipCode = "44418"; $url = "http://weather.yahooapis.com/forecastrss"; $zip = "?w=$zipCode"; $fullUrl = $url. $zip....
You should go ahead and use simplexml or DOM to parse the XML and then you can iterate over the results. With SimpleXML this looks like this: $zipCode = "44418"; $url = "http://weather.yahooapis.com/forecastrss"; $zip = "?w=$zipCode"; $fullUrl = $url. $zip.'&u=c'; $curlObject = curl_init(); curl_setopt($curlObject,CURL...
how to parse xml with php I am trying to read a weather feed from Yahoo to my site. Using the code below I was able to print the xml. What I really want to achieve now is to put the temperature and image in two different variables $zipCode = "44418"; $url = "http://weather.yahooapis.com/forecastrss"; $zip = "?w=$zipCod...
TITLE: how to parse xml with php QUESTION: I am trying to read a weather feed from Yahoo to my site. Using the code below I was able to print the xml. What I really want to achieve now is to put the temperature and image in two different variables $zipCode = "44418"; $url = "http://weather.yahooapis.com/forecastrss"; ...
[ "php", "drupal", "drupal-6" ]
1
3
1,910
2
0
2011-06-02T14:27:47.570000
2011-06-02T14:51:32.490000
6,215,891
6,216,061
R - Repetitions of an array in other array
From a dataframe I get a new array, sliced from a dataframe. I want to get the amount of times a certain repetition appears on it. For example main <- c(A,B,C,A,B,V,A,B,C,D,E) p <- c(A,B,C) q <- c(A,B) someFunction(main,p) 2 someFunction(main,q) 3 I've been messing around with rle but it counts every subrepetion also...
You can use one of the regular expression tools in R since this is really a pattern matching exercise, specifically gregexpr for this question. The p and q vectors represent the search pattern and main is where we want to search for those patterns. From the help page for gregexpr: gregexpr returns a list of the same le...
R - Repetitions of an array in other array From a dataframe I get a new array, sliced from a dataframe. I want to get the amount of times a certain repetition appears on it. For example main <- c(A,B,C,A,B,V,A,B,C,D,E) p <- c(A,B,C) q <- c(A,B) someFunction(main,p) 2 someFunction(main,q) 3 I've been messing around wi...
TITLE: R - Repetitions of an array in other array QUESTION: From a dataframe I get a new array, sliced from a dataframe. I want to get the amount of times a certain repetition appears on it. For example main <- c(A,B,C,A,B,V,A,B,C,D,E) p <- c(A,B,C) q <- c(A,B) someFunction(main,p) 2 someFunction(main,q) 3 I've been...
[ "r" ]
1
4
475
4
0
2011-06-02T14:27:49.410000
2011-06-02T14:42:15.153000
6,215,901
6,215,967
Why does calling a Bash command from Ruby throw an error?
I'm attempting to execute the following bash command on some images using Ruby: class Pingcrush def initialize Dir.foreach('drawable') do |item| next if item == '.' or item == '..' # do work on real items if item.end_with?(".png") then %x["wine pngcrush.exe -brute drawable/#{item} new/#{item}"] end end end end Pingcrus...
Its executing your shell but can't find wine. Try setting the full path to where wine is installed. which wine
Why does calling a Bash command from Ruby throw an error? I'm attempting to execute the following bash command on some images using Ruby: class Pingcrush def initialize Dir.foreach('drawable') do |item| next if item == '.' or item == '..' # do work on real items if item.end_with?(".png") then %x["wine pngcrush.exe -bru...
TITLE: Why does calling a Bash command from Ruby throw an error? QUESTION: I'm attempting to execute the following bash command on some images using Ruby: class Pingcrush def initialize Dir.foreach('drawable') do |item| next if item == '.' or item == '..' # do work on real items if item.end_with?(".png") then %x["wine...
[ "ruby", "directory" ]
3
5
158
3
0
2011-06-02T14:28:40.893000
2011-06-02T14:33:48.363000
6,215,908
6,216,055
Expire unix or time() code after x hours
I am trying to create a forgot password feature which will expire the link created after x hours. So I am storing time() data in database value when a user requests a password reset. So how can I expire it?
three options: compare the time you saved on the db with the one you get when the user click the link Use a cron job and make it run periodically Just don't save in the db and make the link to care about everything. You could use a signature + a salt to avoid users to modify this link like: $now = time(); $sk = sh1($u...
Expire unix or time() code after x hours I am trying to create a forgot password feature which will expire the link created after x hours. So I am storing time() data in database value when a user requests a password reset. So how can I expire it?
TITLE: Expire unix or time() code after x hours QUESTION: I am trying to create a forgot password feature which will expire the link created after x hours. So I am storing time() data in database value when a user requests a password reset. So how can I expire it? ANSWER: three options: compare the time you saved on ...
[ "php" ]
0
1
1,890
4
0
2011-06-02T14:29:11.400000
2011-06-02T14:41:44.303000
6,215,913
6,216,126
Script to execute 1 of 2 functions randomly?
Is it possible to modify the script below so that the value of each option is a function? Obviously, this doesn't work: function get_ads_rotation(){ $option[0] = get_ad_option1(); $option[1] = get_ad_option2(); echo $option[rand()%count($option)]; } (Props to yes123 for the randomization script above)
Direct answer to the question: variables can store anonymous functions since PHP 5.3 only. It would be like this: $option[1] = function($args) { /* do something here with $args */ }; However in preceding versions you could achieve something similar with call_user_func(), by storing function names in your options, and t...
Script to execute 1 of 2 functions randomly? Is it possible to modify the script below so that the value of each option is a function? Obviously, this doesn't work: function get_ads_rotation(){ $option[0] = get_ad_option1(); $option[1] = get_ad_option2(); echo $option[rand()%count($option)]; } (Props to yes123 for the ...
TITLE: Script to execute 1 of 2 functions randomly? QUESTION: Is it possible to modify the script below so that the value of each option is a function? Obviously, this doesn't work: function get_ads_rotation(){ $option[0] = get_ad_option1(); $option[1] = get_ad_option2(); echo $option[rand()%count($option)]; } (Props ...
[ "php", "dynamic-function" ]
1
1
290
2
0
2011-06-02T14:29:36.903000
2011-06-02T14:46:41.150000
6,215,922
6,217,079
How do I edit this "GO" button in Magento?
I have a simple Magento website. It's still very basic cause I'm a beginner. I tried but have failed badly. This is what I want to do: Remove the "GO" button (submit) and place a small image instead. this is my website: http://gale.dev4.webenabled.net/ any help? Please... I tried editting so many files but I can't get ...
Add what you need to the end of styles.css.header.form-search button.button span span { display:none; }.header.form-search button.button span { width:50px; background-color:red; } That will give you a red box, you should be able to take it from there.
How do I edit this "GO" button in Magento? I have a simple Magento website. It's still very basic cause I'm a beginner. I tried but have failed badly. This is what I want to do: Remove the "GO" button (submit) and place a small image instead. this is my website: http://gale.dev4.webenabled.net/ any help? Please... I tr...
TITLE: How do I edit this "GO" button in Magento? QUESTION: I have a simple Magento website. It's still very basic cause I'm a beginner. I tried but have failed badly. This is what I want to do: Remove the "GO" button (submit) and place a small image instead. this is my website: http://gale.dev4.webenabled.net/ any he...
[ "magento", "php" ]
0
1
1,216
1
0
2011-06-02T14:30:18.873000
2011-06-02T16:04:47.377000
6,215,942
6,215,986
XCode 4 Tutorials for Cocoa OS X Applications
There's obviously a lot of buzz around writing Cocoa Touch applications, but there doesn't seem to be much around creating applications for OS X apps using XCode 4. Does anyone know of any resources that cover OS X Application Development using XCode 4? Are tutorials for XCode 3 usable for XCode 4 Development? Thanks.
I would say tutorials for Xcode 3 are valid/close-to-ideal for learning OS X development, and then perhaps go through a tutorial on the changes between Xcode 3 and 4, as they are quite significant (but relatively easy to grasp/get used to/not too crucial to actual development). The differences between 3 and 4 are more ...
XCode 4 Tutorials for Cocoa OS X Applications There's obviously a lot of buzz around writing Cocoa Touch applications, but there doesn't seem to be much around creating applications for OS X apps using XCode 4. Does anyone know of any resources that cover OS X Application Development using XCode 4? Are tutorials for XC...
TITLE: XCode 4 Tutorials for Cocoa OS X Applications QUESTION: There's obviously a lot of buzz around writing Cocoa Touch applications, but there doesn't seem to be much around creating applications for OS X apps using XCode 4. Does anyone know of any resources that cover OS X Application Development using XCode 4? Ar...
[ "macos", "xcode4" ]
5
4
12,656
4
0
2011-06-02T14:32:03.817000
2011-06-02T14:35:37.997000
6,215,943
6,217,910
Browser "Back" Button vs. jQuery-animated page
I have a challenging problem I've been battling for some time now. The Problem: when I go back to previous page using browser's back button, the page is displayed in its final state after all the animations had played. I want it to display in its initial state and replay the animations. My site uses some basic jQuery a...
Disclaimer: The following isn't exactly a robust solution, but I found it amusing and thought I ought to share. I had a similar requirement in the past, and strangely enough, the solution I ended up with was to downgrade to jQuery to take advantage of a bug in jQuery 1.3. I only tested this on one version of Firefox, s...
Browser "Back" Button vs. jQuery-animated page I have a challenging problem I've been battling for some time now. The Problem: when I go back to previous page using browser's back button, the page is displayed in its final state after all the animations had played. I want it to display in its initial state and replay t...
TITLE: Browser "Back" Button vs. jQuery-animated page QUESTION: I have a challenging problem I've been battling for some time now. The Problem: when I go back to previous page using browser's back button, the page is displayed in its final state after all the animations had played. I want it to display in its initial ...
[ "jquery", "browser", "animation", "back" ]
13
7
5,217
3
0
2011-06-02T14:32:08.103000
2011-06-02T17:24:18.140000
6,215,950
6,216,017
How to load a word doc in Rich Textbox WPF
I am trying to load a word document into Rich Textbox control so that user can edit the contents and eventually save it. Following is the code I use: string fileName = @"..\..\Files\test.doc"; TextRange range; FileStream fStream; if (File.Exists(fileName)) { range = new TextRange(RTB.Document.ContentStart, RTB.Docu...
A word document isn't a rich text document. The doc would need to be first saved as an RTF file before you can do this.
How to load a word doc in Rich Textbox WPF I am trying to load a word document into Rich Textbox control so that user can edit the contents and eventually save it. Following is the code I use: string fileName = @"..\..\Files\test.doc"; TextRange range; FileStream fStream; if (File.Exists(fileName)) { range = new Te...
TITLE: How to load a word doc in Rich Textbox WPF QUESTION: I am trying to load a word document into Rich Textbox control so that user can edit the contents and eventually save it. Following is the code I use: string fileName = @"..\..\Files\test.doc"; TextRange range; FileStream fStream; if (File.Exists(fileName))...
[ "wpf", "ms-word", "richtextbox" ]
1
0
2,095
1
0
2011-06-02T14:32:40.440000
2011-06-02T14:37:43.597000
6,215,976
6,217,389
Control loaded swish animation in AS 3.0
I'm developing an AS 3.0 wrapper to add some extra stuff that has to load some old and plain frame to frame SwishMax 3 animations and then be able to stop them, play them, and so... Here is my code: package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flas...
I tested your code and it works on my machine. The SWF that I loaded had its animation in the main timeline. Is it possible that the swishy.swf has animation that is not on the main timeline? Perhaps the animation is in another symbol instead, and an instance of that symbol is on the stage. Anyway, when you call stop()...
Control loaded swish animation in AS 3.0 I'm developing an AS 3.0 wrapper to add some extra stuff that has to load some old and plain frame to frame SwishMax 3 animations and then be able to stop them, play them, and so... Here is my code: package { import flash.display.Sprite; import flash.display.StageAlign; import ...
TITLE: Control loaded swish animation in AS 3.0 QUESTION: I'm developing an AS 3.0 wrapper to add some extra stuff that has to load some old and plain frame to frame SwishMax 3 animations and then be able to stop them, play them, and so... Here is my code: package { import flash.display.Sprite; import flash.display.S...
[ "actionscript-3", "actionscript", "swish" ]
0
0
745
2
0
2011-06-02T14:34:39.850000
2011-06-02T16:33:58.590000
6,215,988
6,216,025
How to remove portions of Web page title using Javascript
I'm new at this Javascript stuff, so please excuse my basic question. I'm trying to find a way to remove some portion of a web page title using Javascript in a userscript. Take for example the title of this page: How to remove portions of Web page title using Javascript - Stack Overflow I want to yank out the '-' and W...
This should do it: document.title.substr(0,document.title.lastIndexOf("-")); It removes everything from the last occurrence of "-". http://jsfiddle.net/niklasvh/TA69F/
How to remove portions of Web page title using Javascript I'm new at this Javascript stuff, so please excuse my basic question. I'm trying to find a way to remove some portion of a web page title using Javascript in a userscript. Take for example the title of this page: How to remove portions of Web page title using Ja...
TITLE: How to remove portions of Web page title using Javascript QUESTION: I'm new at this Javascript stuff, so please excuse my basic question. I'm trying to find a way to remove some portion of a web page title using Javascript in a userscript. Take for example the title of this page: How to remove portions of Web p...
[ "javascript", "userscripts", "page-title" ]
3
4
378
1
0
2011-06-02T14:35:45.597000
2011-06-02T14:38:46.053000
6,215,989
6,216,618
How to send via my iphone application a planned emails and without launching the email application?
I know how to send email from my application by launching the iPhone Mail application, then return to my app. But I have two concerns: 1 / My first concern is how my application can send emails without opening the mail application? So I will inform the user that the email has been sent successfully or failure on failur...
You can send mail from your app using MFMailComposeViewController. http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
How to send via my iphone application a planned emails and without launching the email application? I know how to send email from my application by launching the iPhone Mail application, then return to my app. But I have two concerns: 1 / My first concern is how my application can send emails without opening the mail a...
TITLE: How to send via my iphone application a planned emails and without launching the email application? QUESTION: I know how to send email from my application by launching the iPhone Mail application, then return to my app. But I have two concerns: 1 / My first concern is how my application can send emails without ...
[ "iphone", "email", "launching" ]
1
1
202
2
0
2011-06-02T14:35:50.773000
2011-06-02T15:23:55.180000
6,215,997
6,216,179
Can I sniff UDP packets addressed another Linux machine using Python?
I have a Python process on one Linux machine server1 that receives and processes raw UDP packets. I want to have another Linux machine server2 capable of listening to the same UDP packets server1 is receiving. Is there any Python solution capable of sniffing UDP packets addressed to the another (Linux) machine?
If you want more than one machine to process the same data, you'd be better off going to mulitcast (if you can control the sender and the infrastructure) Else, http://sourceforge.net/projects/pylibpcap/ will enable packet capture via python. You will still have to configure the infrastructure to get the packets to the ...
Can I sniff UDP packets addressed another Linux machine using Python? I have a Python process on one Linux machine server1 that receives and processes raw UDP packets. I want to have another Linux machine server2 capable of listening to the same UDP packets server1 is receiving. Is there any Python solution capable of ...
TITLE: Can I sniff UDP packets addressed another Linux machine using Python? QUESTION: I have a Python process on one Linux machine server1 that receives and processes raw UDP packets. I want to have another Linux machine server2 capable of listening to the same UDP packets server1 is receiving. Is there any Python so...
[ "python", "linux", "networking", "ubuntu", "network-programming" ]
2
3
2,377
3
0
2011-06-02T14:36:25.467000
2011-06-02T14:51:06.527000
6,215,998
6,216,566
Complex For & If loop confusion, returning and accessing classes. Objective-C
I have a view which has a number of subviews. I need to find a particular UIImageView with a particular UIImage. Here is the code I'm using to loop through: BOOL fileExistsAtLocation; for (id subview in drawGallery.subviews){ if ([[subview class] isSubclassOfClass: [UIImageView class]]){ // I need to detect the subview...
[UIImage imageNamed:image] will return a new instance of that image so it will NEVER be equal. I'd suggest tagging all of your subviews. So when you create the image views, assign a unique tag (this could just be an auto incrementing number). Then you can detect of interest based on the tag. BOOL fileExistsAtLocation; ...
Complex For & If loop confusion, returning and accessing classes. Objective-C I have a view which has a number of subviews. I need to find a particular UIImageView with a particular UIImage. Here is the code I'm using to loop through: BOOL fileExistsAtLocation; for (id subview in drawGallery.subviews){ if ([[subview cl...
TITLE: Complex For & If loop confusion, returning and accessing classes. Objective-C QUESTION: I have a view which has a number of subviews. I need to find a particular UIImageView with a particular UIImage. Here is the code I'm using to loop through: BOOL fileExistsAtLocation; for (id subview in drawGallery.subviews)...
[ "objective-c", "class", "uiimageview", "for-loop" ]
0
3
121
2
0
2011-06-02T14:36:25.733000
2011-06-02T15:19:44.167000
6,216,005
6,216,053
How to make cells in UITableView not turn blue?
I am using a UITableView and the cells I am using in this view should do nothing when I click them. I can't turn off UserInteraction though because then I am not able to click on the accessory (detailDisclosureButton). So how can I make them stop turning blue and still allow them to click on the accessory?
By default, the selectionStyle property of cell is UITableViewCellSelectionStyleBlue. Change it to UITableViewCellSelectionStyleNone.
How to make cells in UITableView not turn blue? I am using a UITableView and the cells I am using in this view should do nothing when I click them. I can't turn off UserInteraction though because then I am not able to click on the accessory (detailDisclosureButton). So how can I make them stop turning blue and still al...
TITLE: How to make cells in UITableView not turn blue? QUESTION: I am using a UITableView and the cells I am using in this view should do nothing when I click them. I can't turn off UserInteraction though because then I am not able to click on the accessory (detailDisclosureButton). So how can I make them stop turning...
[ "iphone", "objective-c", "uitableview" ]
15
19
1,639
8
0
2011-06-02T14:36:52.673000
2011-06-02T14:41:39.833000
6,216,007
6,216,213
Graphical debugger for bash
Is it there any graphical debugger for bash on mac os x or linux? I mean something in the same fashion that the debugging mode of Visual Studio or Eclipse, where one can stop the program hover the mouse pointer over variables and get instantly values, modify them and go backwards and try modifications without the need ...
for debugging execute your script with: bash -x gui debugger: http://bashdb.sourceforge.net/
Graphical debugger for bash Is it there any graphical debugger for bash on mac os x or linux? I mean something in the same fashion that the debugging mode of Visual Studio or Eclipse, where one can stop the program hover the mouse pointer over variables and get instantly values, modify them and go backwards and try mod...
TITLE: Graphical debugger for bash QUESTION: Is it there any graphical debugger for bash on mac os x or linux? I mean something in the same fashion that the debugging mode of Visual Studio or Eclipse, where one can stop the program hover the mouse pointer over variables and get instantly values, modify them and go bac...
[ "debugging", "macos", "bash", "ide" ]
16
11
10,474
4
0
2011-06-02T14:36:57.917000
2011-06-02T14:53:19.583000
6,216,010
6,216,227
Replicating system libraries for Android from Eclipse to Ant
I have a Android project which I'm building in Ant and I'm stuck on system libraries: In Eclipse I've defined two system libraries, each consisting of a few jars, which I then include in my projects. I've tried copying these jar files to the libs dir of the projects which use them and I'm still getting the same errors ...
In Ant, you generally need to put jars on classpath explicitly. They are not automatically added to classpath just by putting them in a lib directory. Find where javac is done in your Ant buildfile and look at the classpath used. You will need to update this classpath to include each jar.
Replicating system libraries for Android from Eclipse to Ant I have a Android project which I'm building in Ant and I'm stuck on system libraries: In Eclipse I've defined two system libraries, each consisting of a few jars, which I then include in my projects. I've tried copying these jar files to the libs dir of the p...
TITLE: Replicating system libraries for Android from Eclipse to Ant QUESTION: I have a Android project which I'm building in Ant and I'm stuck on system libraries: In Eclipse I've defined two system libraries, each consisting of a few jars, which I then include in my projects. I've tried copying these jar files to the...
[ "android", "ant", "system", "libraries" ]
0
0
344
1
0
2011-06-02T14:37:13.290000
2011-06-02T14:54:19.383000
6,216,011
6,216,089
External Static(.a) Libraries in iPhone projects
Over the last few months I've come across various chatter of external/private libraries not being allowed in iPhone apps.[Just to be clear, this is not something thats going to come, its something I was wrongly under the impression that already exists.] I was looking at the WunderRadio source: http://www.wunderradio.co...
Static libraries have always been allowed for iOS development and there is no sign that position is going to change at any point (why would it?). Dynamic libraries are not allowed and will result in the rejection of your app.
External Static(.a) Libraries in iPhone projects Over the last few months I've come across various chatter of external/private libraries not being allowed in iPhone apps.[Just to be clear, this is not something thats going to come, its something I was wrongly under the impression that already exists.] I was looking at ...
TITLE: External Static(.a) Libraries in iPhone projects QUESTION: Over the last few months I've come across various chatter of external/private libraries not being allowed in iPhone apps.[Just to be clear, this is not something thats going to come, its something I was wrongly under the impression that already exists.]...
[ "iphone", "objective-c" ]
3
3
223
3
0
2011-06-02T14:37:13.233000
2011-06-02T14:43:52.553000