fasttext_score
float32
0.02
1
id
stringlengths
47
47
language
stringclasses
1 value
language_score
float32
0.65
1
text
stringlengths
49
665k
url
stringlengths
13
2.09k
nemo_id
stringlengths
18
18
is_filter_target
bool
1 class
word_filter
bool
2 classes
word_filter_metadata
dict
bert_filter
bool
2 classes
bert_filter_metadata
dict
combined_filter
bool
2 classes
0.068669
<urn:uuid:be39063f-ae24-45fd-8861-9dbd874f32a3>
en
0.826793
Take the 2-minute tour × What should I do to set coffeescript in Locomotivejs. It seems very easy, but I couldn't figure that out. I set options in "all.js", without luck. I think I'm almost there or very far to get it right. :( Any help is appreciated. share|improve this question add comment 1 Answer up vote 2 down vote accepted You'll want to add a server.js file and boot Locomotive with CoffeeScript support, like so: locomotive = require('locomotive') locomotive.boot('.', 'development', {"coffeeScript": true}, (err, server) -> throw err if (err) server.listen(3000, 'localhost', ()-> addr = this.address() console.log('listening on %s:%d', addr.address, addr.port); To start the app: $ node server There's more info in this pull request: https://github.com/jaredhanson/locomotive/pull/44 Support for a --coffee option to the lcm command line will be added to an upcoming release. share|improve this answer Shouldn't it rather be server.coffee and coffee server? –  punund Feb 17 '13 at 11:29 add comment Your Answer
http://stackoverflow.com/questions/14489677/how-do-i-set-coffescript-in-locomotivejs
dclm-gs1-102900001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.464255
<urn:uuid:73224ddf-fc21-48ba-ae97-63ce0bbb44c9>
en
0.923343
Take the 2-minute tour × In some projects of mine I used SQL code, this is nothing special. But I was rethinking this strategy. I searched SO for something to separate my code and SQL statements. I found one answer which I liked, Collecting all your SQL statements in a properties file. I think it's nice and clean. But what if you want to insert variables. Another solution I found was the use of DAO objects. I you for instance create a MYSQLFactory class with the following methods: addCustomer(Customer customer), deleteCustomer(int CustomerId) etc. You would have centralized your SQL code. Still wouldn't call it separated. Is there a better way to do this without using ORM's like Hibernate. The more I read, the more I become convinced that there isn't a neat way of doing this with JAVA. Searched Sources Java - Storing SQL statements in an external file Separating SQL from the Java Code Thanks for the great responses. I was just curious about this. @Gilbert, I think it's a great solution, As a matter of fact I already used your solution at one time, so thanks for that. :) Sometimes I just like to research new approches to certain problems. share|improve this question "there isn't a neat way of doing this with JAVA"? Have you found neat approach with any other language? If so, you could try re-engineering that approach. –  Nambari Jan 29 '13 at 14:49 This answer is what I do. What is wrong with this approach? stackoverflow.com/a/10873022/300257 –  Gilbert Le Blanc Jan 29 '13 at 14:55 Personally I say maximum you can do is separating it in properties file, and if you want to substitute variables instead of using "?", the your query is subjected to injection attacks. –  Pradeep Simha Jan 29 '13 at 14:55 @GilbertLeBlanc there is nothing wrong with that approach. But your are making your own orm at that point. The only difference between what you are doing and any other orm is you are generating the code by hand. There isnt any logical difference. –  gh9 Jan 29 '13 at 14:57 add comment 4 Answers No, there isnt. If you do not use an ORM you will need to make direct SQL calls somewhere in your code. If you start obfuscating the sql calls out in a factory pattern you are just making a bad ORM. share|improve this answer add comment You don't state what your goals are. I'm not sure if you are just looking for a technical solution to put all SQL code in one place or advice on how to manage applications across multiple languages. For managing SQL code in another language, the following are your friends: • Stored Procedures • Views The following are not your friends: • Ad hoc queries The issue is the "API" to the database. SQL is the interface to raw data tables. However, typically the database is a component of an application that should have its own API. This layer should, in general, consist of views and stored procedures. So, for instance, updates and inserts (which are ad hoc queries) should be wrapped in stored procedures. share|improve this answer add comment I personally prefer to have the SQL query in the Java file where it's executed. That makes it easier to maintain the code: no need to switch between several files. That said, storing the SQL queries in an external file (properties or XML or whatever) is very simple. If you need to insert a variable, you would use a prepared statement anyway, so your SQL would look like select foo.* from Foo foo where foo.id = ? The only difficulty is with the SQL queries that are dynamically generated (fom a set of optional search criteria for example). But there are APIs that allow generating this kind of SQL queries without concatenating parts of a query. share|improve this answer add comment Regarding your question: There is no ideal way, there are several solutions: A. Use ORM - not sure why you don't want it. B. Use a properties file as you suggested - regarding parameters, You will need to handle it, consider using some framework to perform the parameter substitution for you. C. You can abstract some of your SQL queries with stored procedures/views layer at your DB. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/14585593/separating-sql-from-java-code
dclm-gs1-102910001
false
false
{ "keywords": "engineering" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.653542
<urn:uuid:307ab6f3-63cf-448f-824a-e1a470272c4e>
en
0.895931
Take the 2-minute tour × pg_dump compress option has the following description: Specify the compression level to use. Zero means no compression. For the custom archive format, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip; but the default is not to compress. The tar archive format currently does not support compression at all. Does it mean that the archive will have gzip format? share|improve this question I believe it's zlib under the covers, but that doesn't mean you can run gunzip against it. –  Richard Huxton Feb 8 '13 at 15:02 add comment 1 Answer The GZIP File Format has a header starting with the bytes 0x1f, 0x8b. On the other hand, a file produced by pg_dump custom archive format (option -Fc) starts with the letters P,G,D,M,P, which is enough to conclude that it's not in the gzip format. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/14773279/pg-dump-compression-format
dclm-gs1-102930001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.981301
<urn:uuid:06dded50-be75-4f0c-a2ec-d998cf5f89ed>
en
0.862021
Take the 2-minute tour × I have recently started learning the wonders of pthreads according to POSIX 1003.1c. PThreads may seem complex, but they are basically simple threads that we use in the class to create parallel behavior: https://computing.llnl.gov/tutorials/pthreads/ As I am still learning, my teacher gave us a C code to toy with: /* Creates two threads, one printing 10000 "a"s, the other printing 10000 "b"s. Illustrates: thread creation, thread joining. */ #include <stddef.h> #include <stdio.h> #include <unistd.h> #include "pthread.h" void * process(void * arg) int i; fprintf(stderr, "Starting process %s\n", (char *) arg); // fprintf(stdout, (char *) arg, 1); return NULL; int main() int retcode; pthread_t th_a, th_b; void * retval; retcode = pthread_create(&th_a, NULL, process, "a"); if (retcode != 0) fprintf(stderr, "create a failed %d\n", retcode); retcode = pthread_create(&th_b, NULL, process, "b"); if (retcode != 0) fprintf(stderr, "create b failed %d\n", retcode); retcode = pthread_join(th_a, &retval); if (retcode != 0) fprintf(stderr, "join a failed %d\n", retcode); retcode = pthread_join(th_b, &retval); if (retcode != 0) fprintf(stderr, "join b failed %d\n", retcode); return 0; Instructions to run and compile (for linux): • Run command: `sudo apt-get install build-essential` • Donwload this code (obviously xD) • Use the following command to compile: `gcc -D_REENTRANT filenName.c -lpthread` • Run the result by using the command: `./a.out` Everything works but I don't understand why my output order is different depending on the use of write or fprintf. When I use write I get a random output of letters like the following: Starting process a aaaaaaaaaaaaaaaaaaaaaaaaaaaaStarting process b But when I use fprintf I always get the get an output similar to: Starting process a Starting process b In this case, the text "Starting process" always appears first and is not mixed with the rest of the output. Why is this happening? Is it because write is very fast and fprintf is slower? As a C programmer, which one should I use and why? share|improve this question add comment 2 Answers up vote 7 down vote accepted write is a system call: it sends the given characters directly to the operating system, which (in theory, and often in practice) sends them immediately to the output device such as the screen or disk. fprintf (and fwrite and anything that takes a FILE * argument) is a library call, which buffers, or collects, the data inside your program before sending it. This allows it to send larger, more uniform chunks of data, which improves efficiency. What you see with write is that each call causes a thread switch as the program waits for the operating system to confirm whether the write succeeded. When one thread is waiting, the other thread gets time. With fprintf, it never does anything so exceptional. It's actually just one thread filling an array with a's until it's done. The operating system is none the wiser until it receives the filled buffer (via write). Then since the first thread has no more work, it runs the second. If you printed more characters, you would see fprintf also interleave a's and b's as the chunks get sent to the operating system. As for "fast" and "slow", write is more immediate in sending its output, but fprintf is faster in pretty much every other way and is the general correct choice (or fwrite which is more similar to write). share|improve this answer +1 - as an addition: write and fwrite are designed for writing binary data instead of strings. fprintf is for strings. –  Andreas Grapentin Feb 26 '13 at 6:34 add comment Write wraps a kernel call, and it's not buffered. It just copies n bytes from the buffer to the file descriptor. fprintf is buffered and also it is meant to do string processing and replace the various %d, %s with the parameters, so it is much more complex to execute for this reason, having to parse the string that it receives. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/15079049/write-vs-fprintf-why-different-and-which-is-better
dclm-gs1-102940001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.022438
<urn:uuid:ec4e046f-ecc0-478c-bd16-8a4dcd072b01>
en
0.771237
Take the 2-minute tour × After building APPS.war with the Tomcat stock server.xml, I copied the WAR to $TOMCAT_HOME/webapps. After I started Tomcat, the WAR exploded, but then, when I navigate to h_ttp://localhost:8080/APPS/, I get a 404 error. Any ideas? share|improve this question What is shown in the logs? –  Larry Shatzer Mar 1 '13 at 22:08 Also check you have welcome-file-list filled out in the web.xml –  Larry Shatzer Mar 1 '13 at 22:16 add comment 1 Answer Edit web.xml to include where index.jsp is your default page. Otherwise you have to navigate through to the page directly. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/15167107/hosting-multiple-wars-in-tomcat/15196743
dclm-gs1-102960001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.131343
<urn:uuid:2636dcad-8e13-49a8-ad31-cf802af2addf>
en
0.857861
Take the 2-minute tour × I have several tables in my database. Blogs, Users, Posts, Tags are the main ones. Also I have linking tables: User_blogs, Blog_posts & Post_tags. My question is how to use Laravel's classes and methods like belogs_to(), has_many(). I need someone shed light on it. I've read many articles and documentation, but I'm still confused. share|improve this question add comment 1 Answer Generally laravel is smart enough to detect many-to-many relationships if you set up your tables properly Both table names should be not pluralized in the intermediate/pivot table so you should have Users, Blogs, Posts, Tags as your individual tables and User_Blog, Blog_Post, Post_Tag as your intermediate tables. In those tables the cols should properly reflect the tablename_id (in lowercase) so in User_Blog it should have 3 cols id, user_id, blog_id etc and so on for the other columns. In your models you just need to set up the many-to-many relationships class User extends Eloquent public function blogs() return $this->has_many_and_belongs_to('Blog'); And so on for each model. If changing the structure isn't an option then simply add the table name in the many-to-many relationship like so return $this->has_many_and_belongs_to('Blog', 'User_blogs'); share|improve this answer I'd just like to add in that you will thank yourself later if you go ahead and adopt the standard Laravel ORM table naming convention now. ie: blogs, users, blog_user –  Collin James Mar 8 '13 at 19:31 I do not know why but it's asking me for columns: user_blogs.created_at & user_blogs.updated_at. Are those necessary? –  Ivanka Todorova Mar 15 '13 at 23:42 They are expected. Just put public static $timestamps = false; in your model to disable Laravel's built in timestamps. –  bgallagh3r May 16 '13 at 13:45 add comment Your Answer
http://stackoverflow.com/questions/15228152/laravel-working-with-models-my-db-tables
dclm-gs1-102970001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.2683
<urn:uuid:d60623d0-3f3e-4113-bef6-fef45055cd5a>
en
0.744364
Take the 2-minute tour × When I use a test device running ios 5.1.1 I get sigabrt. I think i need code which is compatible with ios 5. When using an exception breakpoint it stops at this line of code. [self.window makeKeyAndVisible]; Here is code in my appDelegate. I haven't done much in my viewController except add a button. // Override point for customization after application launch. self.viewController = [[JHNViewController alloc] init]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; If you can make any sense of this then please explain cause it doesn't mean anything to me. 2013-03-08 08:53:38.367 HelloWorld[66084:707] * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint' * First throw call stack: (0x30fe688f 0x37324259 0x30fe6789 0x30fe67ab 0x3095854d 0x309586bb 0x30958423 0x308e9001 0x308573c7 0x30734c59 0x306aac17 0x306a9461 0x3069be87 0x3070c7d5 0x44281 0x306a9cab 0x306a37dd 0x30671ac3 0x30671567 0x30670f3b 0x32fb722b 0x30fba523 0x30fba4c5 0x30fb9313 0x30f3c4a5 0x30f3c36d 0x306a286b 0x3069fcd5 0x43fe1 0x43f68) terminate called throwing an exception(lldb) share|improve this question can you please paste the StackTrace of the Crash or the crash report? –  Rajan Balana Mar 8 '13 at 6:48 I've added it above. –  user1898829 Mar 8 '13 at 6:54 add comment 2 Answers up vote 1 down vote accepted As I can see, Autolayout is supported for iOS 6.0 + and you are making your app compatible with ios 5.1.1. then you need to remove the AutoLayout from your Viewcontroller's XIB. Do one thing, the viewController which is your first viewController to be loaded on the app. Go to file Inspector of the XIB of that viewController. Remove AutoLayout Check. It will be fine. Hope that helps! share|improve this answer I've unchecked autoresize subviews and it still gives same error. –  user1898829 Mar 8 '13 at 7:11 @user1898829 You don't have to uncheck Autoresize Subviews , Go to file inspector of that viewcontroller's XIB and uncheck the Use Autolayout option :) –  Rajan Balana Mar 8 '13 at 7:13 add comment You should remove the Auto layout options from you .xib files in IB. Auto layout is supported in iOS 6 + and your app complains that : 'Could not instantiate class named NSLayoutConstraint' share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/15288257/sigabrt-on-launch-when-using-ios-5-1-1/15288437
dclm-gs1-102980001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.937411
<urn:uuid:a6ab3036-419a-4c4c-b017-447b233d320e>
en
0.827358
Take the 2-minute tour × OpenGL is very confusing for me and I'm not used to a lot of graphic terminology, etc. which is very rampant in many tutorials. I understand how to draw triangles, circles, and quads, polygons, etc. but now I'm trying to understand how textures work. Could someone point me in the right direction for understanding textures? Since I could only get JOGL to work in Netbeans, I tried putting an image, entitled "Tiki Mask" into the build path. When I ran this, it had no exception thrown so I assume it found the image file? gl.glGenTextures(1, glu, 0); gl.glBindTexture(gl.GL_TEXTURE_2D, glu[1]); try { Texture tex = TextureIO.newTexture(new File("tikimask.jpg"), true); gl.glTexCoord2d(-tex.getWidth(), -tex.getHeight()); gl.glVertex2d(-25, -25); gl.glTexCoord2d(-tex.getWidth(), tex.getHeight()); gl.glTexCoord2d(tex.getWidth(), tex.getHeight()); gl.glVertex2d(.05f, .05f); gl.glTexCoord2d(tex.getWidth(), -tex.getHeight()); gl.glVertex2d(0, .05f); } catch (IOException ex) { Logger.getLogger(SimpleJOGLwee.class.getName()).log(Level.SEVERE, null, ex); } catch (GLException ex) { share|improve this question If you're still trying to learn OpenGL in Java, I would suggest these tutorials. They should give you a good understanding of textures and other OpenGL concepts, and they also use LWJGL which IMHO is better than JOGL. –  Forgive Goto Mar 17 '13 at 17:20 Also, your question isn't very clear. What exactly aren't you understanding? –  Forgive Goto Mar 17 '13 at 17:22 add comment 1 Answer Your problem is that you never bound the texture that you loaded. Try adding these lines: after you load the texture. Also, I would recommend loading your texture in your init function, not your draw function, and then simply enable and bind them in your drawing function. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/15463674/jogl-confusion-how-do-textures-work
dclm-gs1-102990001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.114871
<urn:uuid:0ee5c468-7970-491a-b3a1-18f183b97526>
en
0.890793
Take the 2-minute tour × I have google analytics installed for my own domain, http://mydomain.com. Will a user that enters http://www.mydomain.com be counted by the analytics script too? To me it seems logical that it would, since it is so common to have the naked domain address be the same site as the www-prefixed one, but the analytics documentation doesn't state it explicitly. share|improve this question add comment 2 Answers up vote 2 down vote accepted Yes, users will be tracked, but the same visitor coming from www.datalookups.com and datalookups.com will be counted as two different visitors. GA uses cookies to store session information on visitors, and since www.datalookups.com and datalookups.com are different hosts, different cookies belong to them. To get over this issue, I suggest to set up a proper HTTP redirection that brings permanently either user from www.datalookups.com to datalookups.com or vice versa—it's a matter of taste. (Not to mention that this method balks search engine crawlers to index your web content twice.) For the sake of completeness, there is a way to tell Google Analytics to share session information between to different hosts with the pageTracker._setDomainName function, but that is not the right answer for the current situation. share|improve this answer Nice reply. It's important that you also mentioned the user permanently redirect (ie. HTTP Status 302 - Permanent Redirection) is very important. Search Engines don't like indexing the same site more than once (when url's a different, but point to the same site). –  Pure.Krome Oct 14 '09 at 8:02 @Pure.Krome: to be precise, HTTP 301 is the status code for permanent redirection. –  Török Gábor Oct 14 '09 at 8:14 This is completely false: www.domain.tld and domain.tld are treaded just the same, and get the same value for the HASH code (the number at the start of each __utm cookie). This an exception: every other subdomain.domain.tld will be handeld as a distinct web site –  Open SEO Mar 20 '12 at 21:14 add comment Yes, that has been my experience. share|improve this answer Thank you, that was exactly the answer I was looking for. –  Björn Lindqvist Oct 13 '09 at 17:29 add comment Your Answer
http://stackoverflow.com/questions/1561514/does-google-analytics-combine-naked-domains-with-the-www-subdomain
dclm-gs1-103000001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.033552
<urn:uuid:da9796aa-9cf1-4796-ba5b-c28b6a4f8951>
en
0.872466
Take the 2-minute tour × I have this strange issue I can't overcome apparently, I am trying to retireve a Twitter JSON feed using the script tag at the bottom of my page: <script src="http://api.twitter.com/1/statuses/user_timeline/haunted85.json?count=15&callback=listTweets" type="text/javascript"></script> I want the data to be handed over a callback function I have named listTweets. The thing is if I load my page and try to get the output in my Chrome console tab via javascript function, then I get a Failed to load resource error, but if I manually copy and enter the URI in the address bar, I am returned all the Twitter data in the browser. What am I missing here? share|improve this question Does listTweets get called at all? Try and inspect the "Network" tab in Chrome Inspector/Firebug. Did the twitter API call return 200 OK? I dynamically inserted that script element into this StackOverflow page, and it successfully called listTweets. –  Julian H. Lam Apr 7 '13 at 17:34 I just tried it locally and it tries to call listTweets, both running as localhost and as a local file. Whereabouts are you including the script? –  Lewis Apr 7 '13 at 17:38 listTweets doesn't get called at all because there's no event triggering it, I suspect and I've just looked in the Network tab and the twitter api returns just (failed) with no error code. –  haunted85 Apr 7 '13 at 17:38 @Lewis I am including it just before the closing </body> tag at the end of my page. I have also tried to place it elsewhere in the page, but no change whatsoever. –  haunted85 Apr 7 '13 at 17:40 Why don't you use a standard JSONP-Call to fetch the data? Works just fine: jsfiddle.net/hDy3Y –  m90 Apr 7 '13 at 17:41 show 7 more comments Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/15865381/cant-load-twitter-json-feed-within-script-tag
dclm-gs1-103010001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.317226
<urn:uuid:d03e8987-638d-49ae-959f-ee5fa3ce8344>
en
0.9349
Take the 2-minute tour × I need to know what are the numbers means when i convert wav file to binary array.. I understand the first ~44 bytes are the header but how can I interpreter the bytes data?? There is some table for this values? share|improve this question A bit more detail could be helpful. What do you want to do? What have you tried? –  Cedric Reichenbach Apr 12 '13 at 12:59 Please read this : stackoverflow.com/questions/how-to-ask –  Aboutblank Apr 12 '13 at 12:59 add comment closed as not a real question by jlordo, duffymo, Andrew Thompson, nwinkler, Andremoniy Apr 12 '13 at 14:17 1 Answer up vote 1 down vote accepted Here is more information on how a WAV file is structured: http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/WAVE.html If you are writing your code in Java you have at least the three following ways to read the WAVE file: 1. using the com.sun.media.sound.WaveFileReader. If you are interested in knowing HOW it's done, then you can just look at the source code to see how it's done. 2. using the musigcg API. You will be able to read the WAV audio data, and also do pretty stuff like showing the audio data as a picture. 3. check out this article on reading wave files with Java with a WavFile class included in the article. Since the source is included, again, you will be able to understand how it's done. I would suggest you to take a look at the WaveFileReader first since it's well known and available in the java jdk for years, but you may do as you like. Edit: should have done that first, by I just summarized the answers to this this SO question. share|improve this answer Jalayn thanks for your answer.. The basic manipulations on wav files I already know but i need more info. In general my assignment is to find in audio file the "silent" sections and "plant" there another (short) wav file. Do you have any suggestions how can I find those sections? there need to be some threshold but how to calculate and how recognize where is the "silent"? –  David Apr 12 '13 at 19:01 Have you read stackoverflow.com/questions/3594228/… ? He suggests that you choose a threshold yourself. Maybe you can put the threshold as a parameter of your application. –  Jalayn Apr 12 '13 at 19:09 add comment
http://stackoverflow.com/questions/15972003/wave-file-in-java-wav-as-numbers-explain-urgent/15973053
dclm-gs1-103020001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.548619
<urn:uuid:13fc9204-256d-44b6-b003-4c1b1166ff86>
en
0.966453
Take the 2-minute tour × We've just experienced an issue where a newly attached Dev instance "picked up" schema changes that had been made to the previous Dev database but were not present in the Live DB replica before it was renamed and attached as Dev. The Dev DB starts as a log shipping standby that is fully restored, detached, files are renamed and then re-attached as the new Dev DB. Note that the previous Dev database is not being deleted just detached. Also note that the old and new Dev DBs are both "forks" of the same original database. Now this is a Dev/Test environment so it's not particularly problematic but it makes me worry that we'll create something against a silently changed Dev that will break Live when it's applied. So my working theory is that this relates to the unique identifiers used by the SQL Server internals and possibly the timing of the changes to Dev. Can anyone confirm this or shed any light on the issue? EDIT: Further detail The schema changes involved the addition of new nullable columns at the end of a few tables. So they were admittedly minor and importantly did not involve any actual data. Also, the log shipping copy was in Standby until it was reattached (so read only) and I've reviewed the query logs to verify that no DDL changes were run. That said, unfortunately I cannot replicate the issue. It does not happen with a small DB created just to test it and I deleted the Dev DB and recreated it from a full backup to resolve the issue so I cannot repeat the exact process. My goal in asking the question is to ascertain whether we've experienced an exceptional fluke or our process is fundamentally unsound. I'm leaning toward exceptional fluke at the moment. share|improve this question SQL Server doesn't perform magic. If you attached a database and the schema changes were there, then the changes were in the file before you attached it. –  Aaron Bertrand Apr 18 '13 at 13:26 Your working theory cannot possibly be correct my good man. I'm not sure where your process has gone wrong but SQL server cannot just change schema like that. Not sure what else to tell you on this one. Double check your process. –  Zane Apr 18 '13 at 13:31 Thanks for your insightful comments folks. :-/ SQL Server stores schema info outside of the DB in the 'msdb' system database as well as database identity data, backup history, etc. So, having confirmed that it really happened, the question is whether anyone else has experienced this. –  Joe Harris Apr 18 '13 at 14:25 You haven't given many details. What "schema changes" are you referring to exactly and how have you observed them? What happens if you use backup/restore instead of attach/detach? Since the DB in question is a log shipping target, are you certain that the state of the database was 'stable' when it was detached? What version of SQL Server? Can you show the script you use to detach/rename/attach? There is no way that just attaching a database changes the schema, so it's much more likely that there is an error in your script, but we don't know exactly what you're doing. –  Pondlife Apr 18 '13 at 16:24 @Pondlife Added further detail, I have script written to try and replicate it but in fact it works fine in the test. I guess we'll see if the question flushes out anyone else who's had a similar experience. –  Joe Harris Apr 19 '13 at 9:43 add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/16084231/attaching-a-db-inherits-schema-changes-from-db-previously-attached-with-same-n
dclm-gs1-103030001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.075182
<urn:uuid:3c71274c-8897-4eba-a29b-740306f56063>
en
0.903928
Take the 2-minute tour × My app needs to run on 10.4 or later. If I launch it on 10.3 it just fails to launch or crashes. How do you tactfully enforce minimum system requirements? Can you customize the message it shows? share|improve this question Honestly, does anyone even use 10.3 anymore? If this is a commercial product, you're totally safe to say that 10.3 is a deprecated OS (even Apple doesn't support 10.3 anymore). –  Dave DeLong Feb 5 '10 at 6:22 It is a commercial product and it has a very niche audience. I hope no one is using 10.3, but because we supported it and tested it up until now, this is how I have to phase it out. –  zekel Dec 28 '10 at 16:22 add comment 3 Answers up vote 2 down vote accepted I have not used either of these techniques/advice, just passing along the information I have gathered. You might try something like the SystemVersionCheck “shim” executable to provide a working OS version check for versions that do not honor LSMinimumSystemVersion (e.g. 10.3). The pre-compiled executable is PPC-only. You might need to rebuild it to support PPC and Intel machines so that it works with 10.3, but also so that 10.6 users are not prompted to needlessly install Rosetta. I found a blog entry that has a hint on how to setup the PPC build to target 10.3 and the Intel build to target 10.4u (it was written about 10.5 and Xcode 3.0 though—do the latest versions of Xcode even include the 10.3 SDK?). share|improve this answer Nope. You get 10.4u, 10.5, and 10.6. Likewise, there was once a 10.2.something SDK, which they killed off a few versions of Xcode ago (either 3 or the one before that). –  Peter Hosey Feb 5 '10 at 6:45 I logged into ADC and looked through the “About” PDFs for Xcode 3.2.1, 3.2 (10.6), 3.1.4 (10.5). The 10.3 SDK is mentioned as an optional install in Xcode 3.1.4, but not mentioned at all in 3.2+. Looks like 10.3 development is limited to at most 10.5 with Xcode 3.1.x (maybe the 10.3 SDK from 3.1.x could be installed with 3.2.x, but that seems dicey). –  Chris Johnsen Feb 5 '10 at 7:28 I was able to build for 10.3 from 10.6, see my question here: stackoverflow.com/questions/2074444/… –  zekel Feb 5 '10 at 15:15 add comment Add a key to your applications Info.plist, specifying LSMinimumSystemVersion as 10.4.X for whatever X you need as a minor version. For more, see Apple's documentation. share|improve this answer You can also set this by architecture using a separate key. For x86_64, you'd want to require either 10.5 or 10.6. –  Peter Hosey Oct 24 '09 at 2:07 I set LSMinimumSystemVersion to 10.4.11 and my app still launches on 10.3 and crashes... I thought I read somewhere that it ignores LSMinimumSystemVersion? –  zekel Oct 27 '09 at 19:06 add comment If you experience a crash after adding the LSMinimumSystemVersion key to your app's plist manually, then this is due to the Finder not recognizing the changed state of the app properly. Either restart the Finder (e.g. log out) or duplicate the app in the Finder. The copy will then behave correctly. share|improve this answer Good to know. That might have saved me a week. –  zekel Jan 4 '11 at 22:00 add comment Your Answer
http://stackoverflow.com/questions/1616063/how-do-you-enforce-the-minimum-os-requirements-in-a-cocoa-app?answertab=oldest
dclm-gs1-103040001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.028483
<urn:uuid:37e7431b-161a-450b-9bb6-a158f99bb29b>
en
0.892436
Take the 2-minute tour × I am trying to write a desktop app for Windows 7 using NFC technology. I could not find any API for it. The Proximity API - http://msdn.microsoft.com/en-us/library/windows/apps/br212057.aspx can only support Windows 8, it is disappointing. Where can I found a API for NFC that is not tied to a manufacturer? share|improve this question Anything in the Windows. namespace has dependencies on the version of windows that the app is running on, that is why it is under Windows. instead of System. –  Scott Chamberlain Jan 14 at 14:46 add comment 1 Answer I had success using pcsc-sharp and NDEF Library (via nuget) together with reader hardware from ACS and Mifare Tags. pcsc-sharp only provides access to the PC/SC API (which is supported by readers from multiple manufacturers). You still have to write the whole communication flow yourself. The flow itself depends on which cards you are going to use. Mifare Classic for example provides access control, therefore you need to authenticate every block first before you read or write. Simpler cards like the Mifare Ultralight don't need this step. The cards itself often vary vastly in terms of how the memory is organized. Recommended reading: • specifications at NFC-Forum • documentation of the cards you are using (provided by the manufacturer) • SDK documentation of your reader • examples in the pcsc-sharp repository share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/16261123/does-net-4-5-support-nfc-proximity-api
dclm-gs1-103050001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.254076
<urn:uuid:c0212ada-7b16-46c0-8196-5d4e25c42219>
en
0.913446
Take the 2-minute tour × Is there a way to show the complete internal structure of an R object in an unambiguous and human readable way? The str function doesn't exactly do this, as it shows custom representations. For example, applying it to an igraph object gives something like IGRAPH U--- 3 3 -- Full graph + attr: name (g/c), loops (g/x) + edges: [1] 1--2 1--3 2--3 This is nice and readable, but it's specific to igraph objects (it's clear that it uses a custom formatting for them). I'm looking for something general. I found dput, and for a while I thought that this provides complete information. The same igraph object is shown as structure(list(3, FALSE, c(1, 2, 2), c(0, 0, 1), c(0, 1, 2), c(0, 1, 2), c(0, 0, 1, 3), c(0, 2, 3, 3), list(c(1, 0, 1), structure(list(name = "Full graph", loops = FALSE), .Names = c("name", "loops")), list(), list())), class = "igraph") But then I read about pairlists in the R Language Definition and I noticed that dput(pairlist(1,2)) gives list(1,2). The information that we started with a pairlist is gone. So is there something similar to dput that shows the internal structure of an R object and gives complete information about it? (The main reason I want this is that it would help me understand the structure of R objects better.) If there isn't, how would I query an R object to get enough information about it (in a human readable way---not machine readable) to be able to reconstruct it completely? share|improve this question How about .Internal(inspect(foo))? –  Joshua Ulrich May 3 '13 at 20:16 I think dput is what you want and the pairlist exception is just that - an exception. As far as I understand you're not supposed to use pairlist's, so the issue of dput'ing it is a bit moot. –  eddi May 3 '13 at 20:18 Thanks for the reply @eddi, why don't you put that as an answer? –  Szabolcs May 3 '13 at 20:31 I read in your dput output in and str-ed it. I got the standard output for a list with an extra class. I guess you're getting something different because igraphs come from some package. I wonder if there's something like base::str (which doesn't exist) that you can use here. –  Frank May 3 '13 at 20:45 add comment 2 Answers up vote 8 down vote accepted I don't have much more to add besides my comment, so this is just for completeness for future generations :) dput is doing what you want. With rare exceptions, one of them being pairlist (I assume there might be other exceptions as well, but I don't actually know what they are), it will not be exactly the same object, but, at least in the case of pairlist there is a reason for that. Since pairlist is not supposed to be used outside of internal code, the output of dput can be considered to be doing the user a favor by converting an internal object into the equivalent external one. share|improve this answer There are more exceptions. Environments are dput'ed simply as "<environment>", even if they have attributes. Closures lose srcref attributes, the enclosing environment and the bytecode (if present). –  Ferdinand.kraft May 4 '13 at 1:33 add comment dput is a somewhat disappointing solution, as the result is very messy. (It is, however, better than what I was doing before.) I'd suggest (1) dput, (2) make a copy, (3) assign the base class to the result (as seen in the dput) and (4) str it. In this case: > x<-dput(my_graph) > class(x)<-"list" > str(x) List of 9 $ : num 3 $ : logi FALSE $ : num [1:3] 1 2 2 $ : num [1:3] 0 0 1 $ : num [1:3] 0 1 2 $ : num [1:3] 0 1 2 $ : num [1:4] 0 0 1 3 $ : num [1:4] 0 2 3 3 $ :List of 4 ..$ : num [1:3] 1 0 1 ..$ :List of 2 .. ..$ name : chr "Full graph" .. ..$ loops: logi FALSE ..$ : list() ..$ : list() share|improve this answer I haven't used dput before, so I don't know how general this approach is. This is basically the same solution @eddi gave, but with some new steps. I learned a lot from his answer and the comments above. What I've written here was just too long to be a comment on his answer, which is already good enough. I hope someone comes along with a more satisfying answer, though. (I starred the question.) .Internal(inspect()) (which @Joshua Ulrich mentioned) might be the next best thing, but I'm not yet programmer enough to read that output at a glance. –  Frank May 4 '13 at 2:37 add comment Your Answer
http://stackoverflow.com/questions/16366733/show-internal-structure-of-an-r-object
dclm-gs1-103070001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.496755
<urn:uuid:5a1447f3-b9ac-4431-bb64-4436bd01d357>
en
0.872071
Take the 2-minute tour × -injars ${dist}/${jarname} -target 5 -libraryjars '${java.home}/lib/rt.jar' -optimizationpasses 4 -repackageclasses '' -keep public class * { public static void main(java.lang.String[]); according to the stack of the exception it crashes when accessing a static public member of a class with a nullpointer. here is the code: public static Texture ring, dust, spikering, thinring, crystal, clouds; public static void init() { Field [] fields = TexturePool.class.getDeclaredFields(); for (Field field : fields) { if(field.getType() == Texture.class) { field.set( null, /*imagine new object here*/ ); share|improve this question I can't really believe that accessing (retrieving, or do you mean something else) the member will throw a NullPointerException. Do you mean that the member can be accessed, but is itself null, so that a NullPointerException is thrown, when trying to use the member? If so, where is the expected value coming from? –  jarnbjo Nov 8 '09 at 19:28 thanks, well the member is initialized in a function i call before accessing it. –  clamp Nov 8 '09 at 20:17 I asked about it, but why don't you care to tell us what exactly goes wrong? What is the cause of the NullPointerException? Some VM-internal error when accessing the member (as your post seem to imply) or simply that the member is null, so that a NullPointerException is thrown, when you try to access the member instance? –  jarnbjo Nov 8 '09 at 21:48 This is a great example why obfuscators should normally not be used unless you REALLY have a good reason to. You basically need to retest your application as you have no idea what has been done to the poor bytecode that the compiler produced. –  Thorbjørn Ravn Andersen Nov 8 '09 at 23:18 @jarnbjo: ok i will try to provide a testcase. @thorbjorn: i agree, still i would be very interested as why proguards optimization leads to a crash –  clamp Nov 9 '09 at 13:01 add comment 2 Answers up vote 2 down vote accepted ok, i just found out myself. i think the optimization completely optimized that classmembers away, since they are not directly accessed in this class. if i specify the option: -keepclassmembers public class com.package.** { public static * ; it works even with optimization. share|improve this answer add comment According to http://stackoverflow.com/questions/93290/best-java-obfuscation-application-for-size-reduction: "I was always able to fix the problem by not using the Proguard argument "-overloadaggressively"." Perhaps you should try the same? EDIT: The problem could easily be that an assignment is optimized away. The initializations happening in the source code, where a field is defined, is actually done by the compiler in a static code blokc. Appears that the optimizations tinker with that. What happens with fewer optimization passes? share|improve this answer thanks, but even if i dont put the overloadaggressively option, i get the same crash. –  clamp Nov 9 '09 at 11:23 Lovely. Time to tweak options one at a time. You must obfuscate? –  Thorbjørn Ravn Andersen Nov 9 '09 at 11:44 thanks! well, only when i specify 0 optimization passes, it works: -optimizationpasses 0 –  clamp Nov 9 '09 at 12:58 @Thorbjorn: it is not obfuscation, but optimization (in proguard there is a difference!) –  clamp Nov 9 '09 at 12:59 matt, I read the snippet wrong, and as "--obfuscate" where you had the opposite. –  Thorbjørn Ravn Andersen Nov 9 '09 at 13:53 add comment Your Answer
http://stackoverflow.com/questions/1697025/java-proguard-library-doesnt-work-after-optimization?answertab=active
dclm-gs1-103100001
false
false
{ "keywords": "spike" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.619684
<urn:uuid:0d79365c-76f7-46e1-b0d4-8bd7c0b9f335>
en
0.918609
Take the 2-minute tour × I was reading this defense of MongoDB by 10gen. On issue #3, it says getLastError doesn’t work pipelined. What does it mean by that? What exactly does 'pipelined' mean in this context? share|improve this question add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/17651966/what-does-pipelining-mean-with-respect-to-a-database-context
dclm-gs1-103130001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.086012
<urn:uuid:53fe3b3b-a95e-4a0c-99e2-b6bc361e57ed>
en
0.824107
Take the 2-minute tour × I want to send a HTML email using HTML template. I would like to just replace some value's from that HTML template. Any idea how to achieve this? share|improve this question This question has been answered here before: http://stackoverflow.com/questions/620265/can-i-set-up-html-email-templates-in-‌​c-on-asp-net –  Alison R. Nov 20 '09 at 14:50 add comment 4 Answers If your needs are more complex than can be achieved with @Anuraj's suggestion then I'd suggest looking at XSLT - you package your data as a lump of XML and transform the XML into whatever (HTML in this case) using an XSLT template. Support in .NET for this kind of transformation is excellent and once you have got over the initial challenges (XSLT is different) you will have added a very capable set of tools to your toolkit. share|improve this answer add comment string emailTemplate = @" bla bla bla dear ##USERNAME## bla bla bla! Best regards, string email = emailTemplate .Replace("##USERNAME##", userName) .Replace("##MYNAME##", myName); share|improve this answer add comment Place place holders in the HTML content with {0},{1} etc and use String.format() to replace it. share|improve this answer add comment DotLiquid is another option. You specify values from a class model as {{ user.name }} and then at runtime you provide the data in that class, and the template with the markup, and it will merge the values in for you. The nice thing is these are "safe" so that user's who create the templates can't crash your system or write unsafe code: http://dotliquidmarkup.org/try-online share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/1769917/net-c-sharp-email-using-email-template/1770016
dclm-gs1-103140001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.34411
<urn:uuid:8b3c739e-d3d4-4fe2-8413-83b654e2777b>
en
0.897335
Take the 2-minute tour × I am going to improve a web site in Apache and PHP which has a page with a table containing a list of files. My goal is to allow the user to set one of those files as the “important” one based on some specific and subjective criteria. In order to do that, I want to store the information regarding the most “important” file in some way, with the restriction that I am able to use neither databases nor files (constraints imposed by supervisor). My questions are: • Is it possible? • How can I do this? I already did a search in this site, but I did not find an answer. EDIT: By the way, finally I solved my problem using an XML file. Thanks a lot to everyone. share|improve this question Your supervisor is an idiot if he expects you to persist data without actually saving it anywhere. –  Martin Bean Jul 26 '13 at 8:25 Please make sure you make your supervisor read the above comment –  Mr. Alien Jul 26 '13 at 8:27 You might want to find a different supervisor .. –  tereško Jul 26 '13 at 8:29 I expect there is a misunderstanding here somewhere - ask the supervisor (work supervisor? or teacher?) which means of storage are acceptable. Is it supposed to be user specific? or persistent? Nobody is likely to willingly ask you to do something that's not possible, unless that's the point of the task - for you to conclude/say it's not possible. –  AD7six Jul 26 '13 at 8:36 Yes, your supervisor is a fool. First, get yourself a job where your 'supervisor' actually wants you to better yourself, but in the mean time, either use sessions / cookies... or memcache / apc (warn the idiot that once the server is restarted, the list of importants are gone). –  Jimbo Jul 26 '13 at 9:12 show 4 more comments 5 Answers up vote 4 down vote accepted Assuming these criteria are client-side rather than server-side, because if they're server-side and it's supposed to be one 'important' file for all users then there's no way to do this without storage. The supposed answer to your solution is localStorage()... It's Javascript dependent and definitely not a perfect solution, but HTML5 localStorage allows you to store preferences on your users' computers. First, detect support for localStorage(): if (Modernizr.localstorage) { // with Modernizr if (typeof(localStorage) != 'undefined' ) { // Without Modernizr Then set a parameter if it's supported: localStorage.setItem("somePreference", "Some Value"); And then later retrieve it, as long as your user hasn't cleared local storage out: var somePreference = localStorage.getItem("somePreference"); When you want to clear it, just use: For those using unsupported (older) browsers, you can use local storage hacks abusing Flash LSOs, but those are definitely not ideal. What about sessions or cookies? Both of these are intentionally temporary forms of storage. Even Flash LSOs are better than cookies for long-term storage. The constraint is literally encouraging poor practices... All of these options are browser-side. If the user moves to another PC, his/her preferences will be reset on that PC, unlike with a database-powered authentication system where you can save preferences against a login. The best way to store this kind of data is in a database. If you can't run a database service, you could use SQLite or store the data in JSON or XML files. share|improve this answer Thanks a lot to everyone for your suggestions! Since it is a client side decision which must be propagated to the server side I guess that the answer to my questions is that it is not possible if I am not able to relief the constrints. Thanks! –  pafede2 Jul 26 '13 at 8:56 add comment Cookies might be helpful. I can't think of any other secure way. This isn't too graceful either. share|improve this answer Do you know how much data can a cookie hold? –  Mr. Alien Jul 26 '13 at 8:29 Its 4kb. It should be ample for the stuff you would be using . –  trunks175 Jul 26 '13 at 8:44 add comment You can persist data temporarily using sessions and cookies. They don't require files or database; However, as mentioned, it is temporary because the data is gone when the browser is closed or the cookie expires. If you are told to persist data permanently without the use of files or database, your supervisor has already set you up to fail. Hope this helps. share|improve this answer Sessions are typically persisted with either files or a database. Of course, an in-memory database could be used. –  Jack Jul 26 '13 at 8:32 I know; those files are created by the system and not the OP; so, in a way, he's still complying with the requirements. –  Kneel-Before-ZOD Jul 26 '13 at 8:33 add comment The only options I can see would be to either use cookies (which aren't permanent and are stored as files on the client). Another option may be to use something like Parse which is allows you to store data in the cloud. It depends how strict your supervisor is however since the first solution uses (client) files and the latter will be using a database on another server. share|improve this answer add comment You could try using a cookie to store the data To set the filename use: setcookie("important", $importantFileName); To read the data use: $importantFileName = $_COOKIE["important"]; But this wil only work for the current user and other users wont be able to view this. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/17876424/php-store-information-with-no-database
dclm-gs1-103150001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.064307
<urn:uuid:6de65717-acef-42fd-9e62-e533402e9fcb>
en
0.903253
Take the 2-minute tour × I'm new to the red5 server and only a basic understanding of programming. I managed to set up red5 on a windows 7 64 bit environment and am able to reach the server from my local network. The reason that I want to use this server is to host videos of a lan party. My idea was/is to capture every game/webcam of every pc with Open Broadcaster Software and send it to the red5 server and the red5 server displays the sources on a webpage of the server. Following that I want to also capture that website with obs to stream it to twitch.tv. I am so far that I should be able to connect to the server but when I try I get the following error when I try to upload my live stream to red5: 14:13:38: librtmp error: RTMPSockBuf_Fill, remote host closed connection 14:13:38: librtmp error: RTMP_Connect1, handshake failed. 14:13:38: Connection to rtmp:// failed: Can not connect to the server. 14:13:38: RTMPSockBuf_Fill, remote host closed connection 14:13:38: RTMP_Connect1, handshake failed. I guess that I need a specific application for red5 to manage this? share|improve this question add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/18017070/red5-application
dclm-gs1-103160001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.492197
<urn:uuid:ec137896-88b2-42a9-b016-5e5f1cc9ee24>
en
0.84304
Take the 2-minute tour × I am using ng-grid to display a list of items. I want to give my users ability to rearrange the rows in the list. i.e move the rows up and down as they please. Now, However when I update the grid data in the backend i.e say change the index of a particular row, that row does not automatically change locations in the front-end. What am i missing here ? I have created a plunker to describe the problem http://plnkr.co/edit/s1hrTSqF2zeZo3Btaln0 share|improve this question add comment 1 Answer up vote 0 down vote accepted The grid doesn't use the index of the array to order it, so even if you are changing it, because the data is still there nothing happens. What you could do is define an order field and update the value then changing the values as shown in this plukr. The order field you can hide it from the grid if required using columnDefs to explicitly defined which column should be shown. share|improve this answer thanks.. that works –  James Hans Aug 21 '13 at 17:54 add comment Your Answer
http://stackoverflow.com/questions/18361988/grid-not-updating-upon-change-in-model-in-angularjs
dclm-gs1-103180001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.73785
<urn:uuid:bef2b08a-aac1-41fa-aff1-692c61d1ca0c>
en
0.784878
Take the 2-minute tour × I've been trying a few combinations but can't seem to come up with something that works. More information about the API I'm asking about can be found here https://developers.google.com/admin-sdk/directory/v1/reference/users/insert . I have a feeling I'm just not setting up the request correctly. The following bit of code is known to work. I use it to set up the client that is able to query all the users. client = Google::APIClient.new(:application_name => "myapp", :version => "v0.0.0") client.authorization = Signet::OAuth2::Client.new( :scope => "https://www.googleapis.com/auth/admin.directory.user", :issuer => issuer, :signing_key => key, :person => user + "@" + domain) api = client.discovered_api("admin", "directory_v1") When I try to use the following code parameters = Hash.new parameters["password"] = "ThisIsAPassword" parameters["primaryEmail"] = "tstacct2@" + domain parameters["name"] = {"givenName" => "Test", "familyName" => "Account2"} parameters[:api_method] = api.users.insert response = client.execute(parameters) I always get back the same error "code": 400, "message": "Invalid Given/Family Name: FamilyName" I've observed a few things while looking into this particular API. If I print out the parameters for both the list and the insert functions e.g puts "--- Users List ---" puts api.users.list.parameters puts "--- Users Insert ---" puts api.users.insert.parameters Only the List actually displays the parameters --- Users List --- --- Users Insert --- This leaves me wondering if the ruby client is unable to retrieve the api and therefore unable to submit the request correctly or if I'm just doing something completely wrong. I'd appreciate any idea's or direction that might help set me on the right path. Thank you, share|improve this question add comment 1 Answer up vote 2 down vote accepted You need to supply an Users resource in the request body, which is also the reason why you don't see it in the params. So the request should look like: # code dealing with client and auth api = client.discovered_api("admin", "directory_v1") new_user = api.users.insert.request_schema.new({ 'password' => 'aPassword', 'primaryEmail' => 'testAccount@myDomain.mygbiz.com', 'name' => { 'familyName' => 'John', 'givenName' => 'Doe' result = client.execute( :api_method => api.users.insert, :body_object => new_user share|improve this answer I should have realized that from using the Drive API. Thank you for the help. I successfully created a user following your example. –  James Woodward Aug 30 '13 at 13:07 add comment Your Answer
http://stackoverflow.com/questions/18457099/has-anyone-figured-how-how-the-create-a-user-with-the-admin-directory-api-using
dclm-gs1-103190001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.336106
<urn:uuid:d935eba2-233d-4c8b-8323-7a7d1e852646>
en
0.750383
Take the 2-minute tour × I adapted this plugin for jQuery that uses the parallax effect for my website. Problem is (even in the demo in the link above) that Chrome and IE have a really NOT smooth scroll.. it only works well when you press the middle button on the mouse and the scroll is continuous (not "step-by-step" when you scroll the mouse wheel). So when you use the mouse wheel to scroll, the parallax effect is completely ruined. In Firefox instead the scroll is continous even when scrolling with the mouse wheel. Is there a way to have continous scrolling in IE and Chrome too (javascript?). Here's my website (as you can see, if you visit it whit Firefox the effect is completely different). share|improve this question check stackoverflow.com/a/14905953/1055987 if that helps –  JFK Sep 1 '13 at 23:26 This helped me stackoverflow.com/q/14905779. The fiddle in the "EDIT" field works perfectly. :) –  MultiformeIngegno Sep 2 '13 at 9:14 @MultiformeIngegno I'm having the exact same issue. Can you please post your correct solution as an answer? Your website now works perfectly on Chrome and IE, I wish to accomplish the same. Thanks. –  Cthulhu Oct 4 '13 at 10:40 Yep, done. It's a shame on Chrome to behave like that BTW.. :( –  MultiformeIngegno Oct 4 '13 at 12:34 add comment 1 Answer up vote 6 down vote accepted I solved the problem with this jQuery script (which adds EventListener for both keyboard and mouse scroll), hope it helps. :) window.onmousewheel = document.onmousewheel = wheel; var time = 1300; var distance = 270; function wheel(event) { if (event.wheelDelta) delta = event.wheelDelta / 120; else if (event.detail) delta = -event.detail / 3; if (event.preventDefault) event.preventDefault(); event.returnValue = false; function handle() { scrollTop: $(window).scrollTop() - (distance * delta) }, time); $(document).keydown(function (e) { switch (e.which) { case 38: scrollTop: $(window).scrollTop() - distance }, time); case 40: scrollTop: $(window).scrollTop() + distance }, time); share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/18563802/chrome-and-ie-parallax-jquery-animate-is-not-smooth-when-using-mouse-wheel-to
dclm-gs1-103200001
false
true
{ "keywords": "mouse, delta" }
false
null
false
0.345613
<urn:uuid:abc89bcb-8393-4129-88e4-3a9d00728499>
en
0.866792
Take the 2-minute tour × I'm pulling my hair out trying to write a script, powershell or VBS, that will recursively search for user PST files and move them to dedicated DFS shares for each user. (As part of log off users have been running the "move open/connected pst files" script sourced from this site, so any pst files left behind will not be in use/open by users) Source would be: E:\users[user logon name]\ Destination would be: \share\pst[user logon name]\Not_Connected[archive name]-[appended with date created].pst Many users have multiple archive.pst files in various different directories under their E:\users[user logon name]\ directory so need to ensure that as files are moved over there's no chance of them overwriting each other. I've started with $include = @("*.pst") $filestocopy = Get-ChildItem "E:\users*" -recurse -force -include $include foreach ($file in $filestocopy) { $destfilpath = ([IO.DirectoryInfo](Split-Path $.FullName -Parent)).Name Write-Host "Renaming $ to $($destfilename).pst..." But I'm stuck as to where to go from here! Any help would be really really appreciated! Thanks folks! share|improve this question add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/18583098/find-and-move-user-files-to-dfs-server
dclm-gs1-103210001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.24815
<urn:uuid:b07d1a99-e7f6-4e44-9be9-d66213c54a78>
en
0.850417
Take the 2-minute tour × When I load my action CarsController#show in browser, I get this error message: Timeout::Error in CarsController#show execution expired And the error pointing out on this line: country = GeoIp.geolocation(ip, :precision => :country) The whole action: def show @car = Item.find_by_car_key(params[:car_key]) ip = request.remote_ip geo_key = 'my geo key' GeoIp.api_key = geo_key puts country.inspect respond_to do |format| format.html # show.html.erb format.json { render json: @item } How can I avoid this error message and use it always when this action will be loaded? Thank you share|improve this question What does GeoIp.geolocation do? Perhaps it's running a long process that's causing your request to time out? –  Chris Peters Sep 9 '13 at 17:14 GeoIp.geolocation(ip, :precision => :country) just find out the current location of the user who browse the website. "Perhaps it's running a long process that's causing your request to time out?" -> No, because I see the error like 1 second after entering the URL. The gem is called geo_ip. –  user984621 Sep 9 '13 at 17:23 Ruby debugger can help solve this type of problem. Put a debug statement in and check line by line to see what's failing and why. github.com/cldwalker/debugger –  mr.ruh.roh Sep 9 '13 at 18:14 If you made a question, please take time to give us feedback, you have a couple of asks, please review it –  rderoldan1 Sep 19 '13 at 3:26 add comment 2 Answers I would recommend using the geocoder gem in combination with maxmind or freegeoip works well in my production app (freegeoip sometimes detects the wrong country, but its free) share|improve this answer add comment Assuming you are using the GeoIP gem found here The error is related with the time out, maybe geoip gem is taking to much time to fetch the ip info, so after your Api Key set GeoIp timeout According to the gem readme, It is possible to set a timeout for all requests. By default it is one second, but you can easily set a different value. Just like you would set the api_key you can set the timeout: GeoIp.timeout = 5 # In order to set it to five seconds I will recommend you another gem, because geoip is nor uptodate, take a look at Geocoder https://github.com/alexreisner/geocoder, it can take the ip address from the request automatically like share|improve this answer maybe provide some doc of what the default timeout is.. if it's the same time that the OP is experiencing, this could be very valuable –  sircapsalot Sep 9 '13 at 17:34 It depends on which gem are you using, can you tell me? because in github.com/jeroenj/geo_ip#timeout the default is 1 second –  rderoldan1 Sep 9 '13 at 17:41 edited your answer- –  sircapsalot Sep 9 '13 at 17:44 I would recommend setting up the client in a initializer, instead of each request. –  nicooga Sep 9 '13 at 17:54 add comment Your Answer
http://stackoverflow.com/questions/18703297/rails-error-in-action-timeouterror-in-carscontrollershow
dclm-gs1-103220001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.635254
<urn:uuid:a8b06ef0-111b-4563-8830-6582f5aee6d1>
en
0.866273
Take the 2-minute tour × my problem "should" be simple but I am still not able to solve it. I am currently working on a project that requires some heavy computations (done in C++) and some post-simulations data analysis (done in Python). However, now I am changing the main algorithm and I will need to "cycle" some computations back and forth from C++ and Python. That is, I will need to move back and forth from C++ and Python a matrix of doubles. In C++ the matrix of data is a "gsl_matrix" object while in python the same matrix is implemented as a "numpy array". At the moment, I am running my C++ code, saving the matrix to file, reading it from python, writing it back to file and then opening it back again in C++ for further computations. Since this is VERY inefficient, I would like to ask if somebody can give me an example on how to do it in a "clean" way. I have been reading (and trying for 10 days) SWIG, Cython, Boost.Python and Boost.Numpy but I'm still not able to crack it. Does anyone have a worked example to share? share|improve this question How do you see things happening? Converting a gsl_matrix struct pointer to a PyArrayObject pointer using PyArray_SimpleNewFromData seems pretty straightforward, but how to handle everything around it depends very much on what/how you want things to happen. –  Jaime Sep 11 '13 at 19:37 well, the idea would be to have something live: " import numpy as np import MYCPP as mycpp DATA = np.loadtxt(...) # here DATA would be a TxN matrix out = mycpp.run(DATA, params) # here out would be a Nx1 vector " In C++, DATA needs to be a gsl_matrix in order to work and the "out" vector returned from the C++ code will be a gsl_vector –  Rene Sep 11 '13 at 19:53 add comment 1 Answer I think you don't need to implement yourself the wrapper, because you may use pygsl. If you really want to implement your own version, here is the routine from pygsl that might be worth to you #include <gsl/gsl_matrix_double.h> #include <gsl/gsl_matrix_complex_double.h> %include typemaps.i // gsl_matrix typemaps %typemap(in) gsl_matrix* %{ PyArrayObject *_PyMatrix$argnum; gsl_matrix_view matrix$argnum; _PyMatrix$argnum = (PyArrayObject*) PyArray_ContiguousFromObject($input, PyArray_DOUBLE, 2, 2); if (_PyMatrix$argnum == NULL) return NULL; = gsl_matrix_view_array((double*)_PyMatrix$argnum->data, $1 = &matrix$argnum.matrix; share|improve this answer I am still not sure how to use this. Anyway, I don't think pygsl is a solution. I don't need to call gsl functions, I need to be able to pass a gsl_matrix to my C++ program from python. I.e. I need to make my C++ program "seen" as a python module to send and return gsl_matrices. –  Rene Sep 15 '13 at 6:08 I put this pygsl implementation code because it seems to be the way pygsl sends the python array to GSL ("(double*)_PyMatrix$argnum->data"). So, it seems the conversion to C/c++ gsl_matrix has to be somewhat similar to this. –  Vinicius Miranda Sep 16 '13 at 18:26 I still have no idea of what to do with this. –  Rene Sep 24 '13 at 8:41 add comment Your Answer
http://stackoverflow.com/questions/18748836/extend-and-embed-python-and-numpy-with-c-and-gsl-pass-gsl-matrix-to-pytho?answertab=active
dclm-gs1-103230001
false
false
{ "keywords": "vector" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.158311
<urn:uuid:f7f7dbaa-bd0e-47bb-a0e1-3f1b897e1ff2>
en
0.770754
Take the 2-minute tour × I have a text file which contains 2 columns separated by a tab, containing some data that I would like to read into arrays and perform some simple operations for instance plot the data. The data in the second column is in scientific notation and can takes extremely small values such varying from order of magnitude 10e-27 10e-50. For instance here is a sample of the data 0.00521135 -1.197189e-31 0.00529274 -7.0272737e-32 0.00530917 -6.0163467e-32 0.00532565 -4.9990405e-32 0.00534218 -3.9747722e-32 0.00535876 -2.9457271e-32 0.0053754 -1.9094542e-32 0.00539208 -8.6847519e-33 0.00540882 1.7851373e-33 0.00542561 1.2288483e-32 0.00544245 2.2850705e-32 0.00545934 3.3432858e-32 0.00547629 4.4084594e-32 0.00549329 5.4765499e-32 0.00551034 6.5491709e-32 Here is what my code looks like : import numpy as np import matplotlib.pyplot as plt with open('data.dat', 'r') as f2: lines = f2.readlines() data = [line.split()for line in lines] data2 = np.asfarray(data) x1 = data2[:,0] y1 = data2[:,1] plt.plot(x1, y1) I have used this code to test on sample data (in .dat format) files and it seems to work fine, however when I run this code on my data set it gives me the following error. Traceback (most recent call last): File "read_txt_col.py", line 17, in <module> data2 = np.asfarray(data) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages /numpy/lib/type_check.py", line 103, in asfarray return asarray(a,dtype=dtype) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/numeric.py", line 235, in asarray ValueError: setting an array element with a sequence. Could someone please help!! share|improve this question There are plenty of SO answers on this: stackoverflow.com/questions/4674473/… stackoverflow.com/questions/13310347/… THe basic problem is that you appear to have sequences of different lengths. I would try to find the problem in your data by binary search: load half the data. Successful? Add half of the data and test that. Successful? Add another half, etc. –  hughdbrown Sep 26 '13 at 8:59 add comment 1 Answer Don't reinvent the wheel!, it would be much more easy to use numpy.loadtxt: >>> import numpy as np >>> import matplotlib.pyplot as plt >>> data = np.loadtxt('data.dat') >>> x1 = data[:,0] >>> y1 = data[:,1] >>> plt.plot(x1, y1) >>> plt.show() enter image description here share|improve this answer For some more power, especially in error checking it is worth mentioning numpy.genfromtxt() –  Greg Sep 26 '13 at 11:55 add comment Your Answer
http://stackoverflow.com/questions/19023512/error-with-reading-float-from-two-column-text-file-into-an-array-in-python/19023597
dclm-gs1-103250001
false
false
{ "keywords": "a sequence" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.060225
<urn:uuid:9c6105a8-c1b7-4877-b972-c3079ed09044>
en
0.842057
Take the 2-minute tour × I'm working with datastax 3.1 on a single node with 4Go of RAM. I have not change anything in cassandra-en.sh and cassandra.yaml except the "--Xss" (because of my java version which require a little more) So by default Cassandra set to 1Go my -Xms and -Xmx parameters: -Xms1024M -Xmx1024M But while inserting my data after around 200 000 rows (in 3 different column_families), Solr and cassandra logs keep repeat this kind of warning: WARN StorageService Flushing CFS(Keyspace='OpsCenter',​ ColumnFamily='rollups60') to relieve memory pressure 17:58:07 So, OK my heap is full, but why after flushing, is my heap still full ? If I stop inserting data at this point. Warning keep repeating. If I stop and restart cassandra. No problem raise It looks like memory leak issue right? So where should I look at? Thanks for futur help. share|improve this question add comment 2 Answers Cassandra is trying to clear up heap space, however flushing memtables doesn't flush Solr heap data structures. For the index size you have, combined with possibly queries that load the Lucene field caches there is not enough heap space allocated. The best advice is to allocate more heap space. To view the field cache memory usage: share|improve this answer I'm confused. Is there a way to force Solr to swap in physical memory to avoid JVM heap to be full? I know, it will be time costing, but if not, that means that for one node I can only set around 1G0 of indexing data, so (in my case) around 2 Go of real data... –  hebus Oct 15 '13 at 10:37 add comment One thing that's a memory hog is Solr's caches. Take a look at your solrconfig.xml file inside the "conf" dir of each of your Solr cores, and look at the value configured for caches such as: <filterCache class="solr.FastLRUCache" There may be multiple entries like this one. Make sure that, at least the autowarmCount and initialSize are set to 0. Further more, lower the "size" value to something small, like 100 or something. All these values refer to number of entries in the cache. Another thing that may help is configuring Solr to do hard-commits more often. Look for an entry such as: <!-- stuff ommited for brevity --> The above settings will commit to disk each time 5000 documents have been added or 15 seconds have passed since the last commit, which ever comes first. Also set openSearcher to false. Finally, look for these entries and set them as follows: Now, making all this modifications on Solr at once will surely make it run a lot slower. Try instead to make them incrementally, until you get rid of the memory error. Also, it may simply be that you need to allocate more memory to your Java process. If you say the machine has 4 Gb of RAM, why not try your test with -Xmx2g or -Xmx3g ? share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/19364883/datastax-solr-cassandra-will-now-flush-up-to-the-two-largest-memtables-to-free
dclm-gs1-103260001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.409453
<urn:uuid:76a67e0d-771b-4152-a522-36c494eb2932>
en
0.767894
Take the 2-minute tour × Is it possible to "disable" or lock the selection of a ng-grid using the inbuilt functionality? I want the user to be able to select a row, click a button and then the grid will stay locked until the user presses another button. share|improve this question add comment 1 Answer up vote 2 down vote accepted Yes, you can return false from beforeSelectionChange to disable changing the selected rows on the grid. $scope.option = { enableRowSelection: true, $scope.gridOptions = { data: 'myData', beforeSelectionChange: function() { return $scope.option.enableRowSelection; //, ... <button ng-click="option.enableRowSelection=false">Freeze Selection</button> <button ng-click="option.enableRowSelection=true">Unfreeze Selection</button> <div class="gridStyle" ng-grid="gridOptions"></div> Example Code: http://plnkr.co/edit/PbhPzv?p=preview See also: https://github.com/angular-ui/ng-grid/wiki/Configuration-Options share|improve this answer That works, but now ive realized i need to move some input boxes out of the div where the grid is built so they arent locked, problem is i dont think they have access to the scope of the grid outside of there, is it possible to pass the scope out? The use case is being able to edit the current selected row, after pressing an edit button. –  Tim Nov 4 '13 at 7:32 Yes, it is possible to find the grid scope and pass it to another function and then call $gridScope.apply, but might be easier to edit the the gridOptions.data directly instead. Changes to the data (myData in the example above) usually automatically show up in the grid. –  user508994 Nov 6 '13 at 16:16 add comment Your Answer
http://stackoverflow.com/questions/19688400/howto-disable-selection-in-grid/19745002
dclm-gs1-103270001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.353095
<urn:uuid:b3bf9e04-b6be-48ad-88a1-da3b429e3be3>
en
0.897225
Take the 2-minute tour × I'm trying to backup my shared bzr repository. I have looked at bzr export hotcopy.tgz but it seems only to take a snapshot of the latest revision. Is there a command for doing backups, or do I have to 1. full checkout into a tmp dir 2. compress the tmp dir 3. remove the tmp dir Or is there a better way to backup a bzr repository? share|improve this question add comment 1 Answer up vote 1 down vote accepted You could try something like this: mkdir /tmp/emptyrepos && bzr init /tmp/emptyrepos && bzr send -r 1..last:1 -o - /tmp/emptyrepos | gzip > mybackup.bzr.gz That will create a bazaar native format merge-directive which you could apply to an empty repository to re-create all state. Alternatively, it's likely safe to just tar up the current checkout. The on-disk format should be designed to safely deal with partial updates you may grab with tar. share|improve this answer When running this command, I'm experiencing this: ERROR: Not a branch: "/private/tmp/". I'm on Mac OS X. The I have tried inserting /private/tmp, but it gives same error. I'm new to bazaar so I don't quite understand the error message yet. –  neoneye Dec 29 '09 at 21:28 The basic idea is to create an empty branch to diff against - you can make an empty directory somewhere and run bzr init within it; I just used something in /tmp/ because it's a good place to put temporary stuff. That said, are you sure you didn't mistype it? –  Steven Schlansker Dec 29 '09 at 21:53 Here is the terminal output pastebin.im/1408 Thank you very much, but I think I go for the checkout temporary repository instead of using send, since it seems more simple. –  neoneye Dec 29 '09 at 23:59 Just as a note, to restore a branch backed up in this way, you need to do "bzr init ." then "bzr pull <merge_directive_file_>". Merging into an empty branch is currently not supported (bug bugs.launchpad.net/bzr/+bug/82555) but pulling the merge directive will work. Just be sure to extract the merge directive from the .gz file, or else it will say it is not a branch. –  mgrandi Nov 9 '12 at 1:33 'bzr send' is slow, not optimized for size, and not tuned to be used for entire repositories. Creating a temporary standalone branch without a tree (" bzr branch --no-tree") is the best way to create the data you need to back up. –  jelmer Feb 7 at 0:02 add comment Your Answer
http://stackoverflow.com/questions/1976857/bzr-create-tgz-file-containing-full-repository
dclm-gs1-103280001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.853031
<urn:uuid:ae448051-a7d9-4683-9d2a-f8d3c9b5e5cd>
en
0.874009
Take the 2-minute tour × I have text data that I read from a file; I need to place it in the body of an email message. There are about 50 such data items to be placed into existing text. It seems I should be able to put a marker (dataItem1, dataItem2, etc.) and replace that with the matching text data from the file. Searches only turn up replacing field data such as Recipient, Subject, etc., or replacing the entire body. Would I have to generate the entire body in the code? Seems like I should be able to "insert" a data item into existing body text. Any suggestions will be much appreciated. share|improve this question add comment 1 Answer Use the Body property of the MailItem you're working with. Assign it to a variable and you can edit it: Dim body As String body = myMessage.Body body = Replace(body,"dataItem1","your replacement here") Then assign the variable to the Body: myMessage.Body = body share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/20136576/vba-how-to-replace-text-in-the-body-of-an-outlook-email-message
dclm-gs1-103290001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.553384
<urn:uuid:09bac9fa-5cd9-452e-adc1-225f739e2232>
en
0.862121
Take the 2-minute tour × Do I need to use regex to ensure that the user has typed in English? All characters are valid except non English characters. How do I validate this textbox? share|improve this question "English characters" is an ambiguous specification. Is "6" an "English character"? What about "é"? (Before you say no, consider words like café, resumé, fiancé, et cetera.) You're going to need to be more specific. –  John Feminella Jan 17 '10 at 15:41 its duplicate question you can get the answer here stackoverflow.com/questions/150033/… –  GuruKulki Jan 17 '10 at 15:43 Not only what @John Feminella already stated but also all the punctuation characters. Is such a symbol as "™" to be considered part of the English characters? –  Miguel Ventura Jan 17 '10 at 15:44 @John - For the purpose of validating this textbox, yes 6 is an English character. @Miguel - Yes TM is a valid character as well. –  Nick Jan 17 '10 at 16:25 add comment 3 Answers A regex would work quite well for this. Something like ^[a-zA-Z0-9 ?!.,;:$]*$ would be a good starting point. It would allow all alphabetical and numerical characters, as well as some common punctuation. You would need to change it depending on what your definition of English characters is. See the regex docs here for more information. share|improve this answer Good regex. Just to add, you could implement this regex using a RegularExpressionValidator and assigning the textbox as the 'ControlToValidate': msdn.microsoft.com/en-us/library/eahwtc9e(VS.71).aspx –  keyboardP Jan 17 '10 at 16:01 My definition of english characters are any english alphabets, numbers and symbols. Here's the context of what I am trying to do. I have an app that converts text to a different format. Currently, the plugin I am using supports only english. I need to validate before I pass this through the 3rd party component. –  Nick Jan 17 '10 at 16:32 In that case, I would go with Kibbee's answer :-) +1 to Kibbee –  IrishChieftain Jan 17 '10 at 17:18 @Kibbee - Would this regex accept or reject symbols such as Copyright, trademark etc? –  Nick Jan 18 '10 at 16:29 Yes it would. Basically, it only allows letters, numbers, space, and ? ! . , ; : You would have to alter it (refer to linked docs) to meet your specific needs. –  Kibbee Jan 19 '10 at 1:16 add comment This has nothing to do with regular expressions and the link referred to by gurukulki does not answer the question either. To change language, you need to implement localization in your website: http://www.west-wind.com/presentations/wwdbResourceProvider/introtolocalization.aspxlink text share|improve this answer add comment You might use the FilteredTextBox form ASP.NET AJAX. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2081469/how-to-limit-users-from-entering-english-characters-in-a-textbox/2081492
dclm-gs1-103300001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.022757
<urn:uuid:29ccca40-77dd-429b-a0c3-e57911992dfd>
en
0.89213
Take the 2-minute tour × In my project, where I adopted Aho-Corasick algorithm to do some message filter mode in the server side, message the server got is string of multibyte character. But after several tests I found the bottleneck is the conversion between mulitbyte string and unicode wstring. What I use now is the pair of mbstowcs_s and wcstombs_s, which takes nearly 95% time cost of the whole mode. Also, I have tried MultiByteToWideChar/WideCharToMultiByte, it got just the same result. So I wonder if there is some other more efficient way to do the job? My project is built in VS2005, and the string converted will contain Chinese characters. Many thanks. share|improve this question add comment 4 Answers There are a number of possibilities. Firstly, what do you mean by "multi-byte character"? Do you mean UTF8 or an ISO DBCS system? If you look at the definition of UTF8 and UTF16 there scope to do a highly optimised conversion, ripping out the "x" bits and reformatting them. See for example http://www.faqs.org/rfcs/rfc2044.html talks about UTF8<==>UTF32. Adjusting for UTF16 would be simple. The second option might be to work entirely in UTF16. Render your Web page (or UI Dialog or whatever) in UTF16 and get the user input that way. If all else fails, there aare other string algorithms than Aho-Corasick. Possibly look for an algorithm that works with your original encoding. [Added 29-Jan-2010] See http://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt for more on conversions, including two C implementations of mbtowc() and wctomb(). These are designed to work with arbitrarily large wchar_ts. If you just have 16-bit wchar_ts then you can simplify it a lot. These would be much faster than the generic (code-page-sensitive) versions in the standard library. share|improve this answer Thanks Michael, I'll have a try of this new mbtowc/wctomb. –  Avalon Jan 30 '10 at 2:38 add comment Deprecated (I believe) but you could always use the non-safe versions (mbstowcs and wcstombs). Not sure if this will have a marked improvement though. Alternatively, if your character set is limited (a - z, 0 - 9, for instance), you could always do it manually with a lookup table..? share|improve this answer Unfortunately, the character set must support many other character such as Chinese. And also I tried mbstowcs, the result is just the same. –  Avalon Jan 27 '10 at 11:05 add comment Perhaps you can reduce the amount of calls to MultiByteToWideChar? share|improve this answer When check one message, it just call MultiByteToWideChar once, so it could not reduce any more. –  Avalon Jan 27 '10 at 11:00 Can you combine multiple messages into one, larger buffer, then call it on that? –  Alex Budovski Jan 27 '10 at 11:44 The logical requires the filtering process as soon as possible. –  Avalon Jan 28 '10 at 2:22 add comment You could also probably adopt Aho-Corasick to work directly on multibyte strings. share|improve this answer The original version of AC is for ASCII, then I make it to support wide character. Because the character of multibyte may contain one char or two, considering the AC depends on the state machine, I'm not sure how to change the AC algorithm to work on that. –  Avalon Jan 27 '10 at 10:59 Right. I meant that you could include in the state machine knowledge about the width of each character, so that the internal trie and the state machine are aware of how many bytes to skip for each character. Admittedly, this isn't trivial. –  Avi Jan 27 '10 at 11:48 Thanks, I have modified the original code to support the multibyte characters with some trick. Now it worked well. –  Avalon Jan 29 '10 at 7:08 Thanks, @Avalon. It's good to know for sure that it is possible to modify AC like this. –  Avi Jan 29 '10 at 8:56 add comment Your Answer
http://stackoverflow.com/questions/2145862/is-there-even-fast-implementaion-about-multibyte-character-string-convert-to-uni
dclm-gs1-103330001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.888493
<urn:uuid:216da942-3f0d-4c5b-8da2-4991ca44420e>
en
0.74246
Take the 2-minute tour × the code that didn't work: login_form = page.form_with(:method => 'post') and code that works login_form = page.form_with(:method => 'POST') I inspected the form object via puts page.forms.inspect and got {name nil} {method "POST"} html source: <form class="login" method="post"> <fieldset> <legend>Members Login</legend> <label for="auth_username">Username</label> <input id="auth_username" name="auth_username"> <label for="auth_password">Password</label> <input id="auth_password" name="auth_password" type="password"> <div class="buttons"> <input name="auth_login" type="submit" value="Login"><p class="note"><a href="/forgotpassword">Forgot your password?</a></p> share|improve this question add comment 1 Answer up vote 1 down vote accepted Looking at the source, it could be that Mechanize is supposed to work like that. It forces the form method to uppercase when it fetches the form; you are expected to supply the method in uppercase when you want to match it. You might ping the mechanize person(s) and ask them if it's supposed to work like that. Here in Mechanize.submit, it forces the form method to uppercase before comparing it: def submit(form, button=nil, headers={}) case form.method.upcase when 'POST' when 'GET' and here again in Form.initialize, the method is forced to uppercase: def initialize(node, mech=nil, page=nil) @method = (node['method'] || 'GET').upcase But in page.rb is the code where mechanize is matching a form (or link, base, frame or iframe) against the parameters you gave, the parameter you passed in is not forced to uppercase, so it's a case sensitive match: def #{type}s_with(criteria) criteria = {:name => criteria} if String === criteria f = #{type}s.find_all do |thing| criteria.all? { |k,v| v === thing.send(k) } yield f if block_given? Well, it's a case sensitive match if you pass in a string. But if you pass in a regex, it's a regex match. So you ought to be able to do this: login_form = page.form_with(:method => /post/i) and have it work fine. But I would probably just pass in an uppercase String, send the Mechanize person(s) an email, and move on. share|improve this answer @Wayne Conrad: thank you Wayne. Very nice explanation, even myself understood :-) –  Radek Jan 30 '10 at 2:23 @Radek, My pleasure. –  Wayne Conrad Jan 30 '10 at 2:31 add comment Your Answer
http://stackoverflow.com/questions/2165834/bug-or-desired-behaviour-couldnt-identify-form-using-string-post-but-post
dclm-gs1-103340001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.303119
<urn:uuid:072a1bcd-d8a2-4aa6-bf2a-88c055621302>
en
0.860884
Take the 2-minute tour × The wx.Cursor class automatically scales the image I give it to 32x32 and I need to use a cursor that is larger than that. On http://support.microsoft.com/kb/307213 I saw what might be the reason for this behavior Although cursors can, in theory, be any size, the system imposes a standard size that is exposed by means of the SM_CXCURSOR and SM_CYCURSOR values. These metrics are read-only. On standard, low-DPI systems, these metrics are set to 32x32 pixels (32 bytes/row). When the system loads cursors by means of the standard LoadCursor function, the cursor is stretched to this dimension. but I also saw that it can be done The system also provides the SetSystemCursor API function that you can use to change the system cursor for specific categories. You can use this function to set a cursor of any size. However, you must call the function programmatically, and you can only use it to set a cursor for a specific category. You cannot use it to make all cursors on the system the same size. Is there something I am missing in the wx docs or must I directly call the windows api? share|improve this question add comment 1 Answer up vote 0 down vote accepted It turns out wx doesn't do anything to support non standard sized cursors. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2267986/how-can-i-use-a-large-wxcursor
dclm-gs1-103360001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.906523
<urn:uuid:03196b99-1bcd-411d-b0ae-698d044ea832>
en
0.82001
Take the 2-minute tour × How to create a PHP function only visible within a file? Not visible to external file. In other word, something equivalent to static function in C share|improve this question When you include files on PHP it is as if you are appending them together, in C/C++ you are "importing" the variables/functions/classes. –  Rook Mar 8 '10 at 22:23 add comment 3 Answers There is no way to actually make a function only visible within a file. But, you can do similar things. For instance, create a lambda function, assign it to a variable, and unset it when your done: $func = function(){ return "yay" }; $value = $func(); This is provided that your script is procedural. You can also play around with namespaces. Your best bet is to create a class, and make the method private share|improve this answer Closures/lambda functions (note these require at least php 5.3) are probably your only option, besides re-thinking your need hide the function from other files. You probably don't actually need to do this. –  meagar Mar 8 '10 at 18:53 add comment Create a class and make the method private. class Foo private $bar = 'baz'; public function doSomething() return $this->bar = $this->doSomethingPrivate(); private function doSomethingPrivate() return 'blah'; share|improve this answer add comment Use namespace, for apply your own visibility. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2403602/how-to-create-a-php-function-only-visible-within-a-file/2403732
dclm-gs1-103400001
false
false
{ "keywords": "importin" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.023393
<urn:uuid:1703da9a-e312-4a79-a84c-2811682cc151>
en
0.882612
Take the 2-minute tour × I noted that when I show up the EOL listchars in a text the linebreaks are losen this is my text of this becomes after set list ..eol this is my text of this mess age(EOL CHAR) I would like to see the EOL characters without breaking the words at window border. Is that possible? share|improve this question add comment 1 Answer up vote 1 down vote accepted Unfortunately it sounds like this is a documented limitation of Vim. From the documentation of linebreak (the option which causes per-word line breaks instead of per-character): Alternate solution: highlight end-of-lines. The simple one-time way would be to just search for them (/$). Beyond that, you can use highlighting: :highlight endofline ctermbg=Green :match endofline /$/ That'll give your EOLs green backgrounds. See :help highlight-args for more on how you can specify the highlight. Original answer This is not the OP's actual problem, but could sometimes happen, so I'll leave it here for others to find when they search. From the help on 'list': Note that list mode will also affect formatting (set with 'textwidth' or 'wrapmargin') when 'cpoptions' includes 'L'. See 'listchars' for changing the way tabs are displayed. From the help on 'cpoptions': L    When the 'list' option is set, 'wrapmargin', 'textwidth', 'softtabstop' and Virtual Replace mode (see |gR|) count a as two characters, instead of the normal behavior of a . 'cpoptions' is all about vi-compatibility - are you launching vim as vi? Or are you manually setting any of those flags? Check the output of echo &cpoptions, be sure to launch as vim, and if it's still set (no idea why it would be) you can unset the flag (set cpoptions-=L). And of course, make sure that the settings for wrap, wrapmargin, linebreak, and textwidth are what you want. share|improve this answer I use GVIM. I don't have textwidth/wrapmargin active because they do put a EOL character at the end of the line. I tried to unset the flag settings cpoptions-=L but it still change the formatting with set list. –  remio Mar 18 '10 at 16:04 Oh, wow. It looks like 'list' turns off 'linebreak'. That's bizarre. I wonder if maybe it's because internally space becomes a real character (even if you're not showing it) and it can't tell where word breaks are? –  Jefromi Mar 18 '10 at 16:32 thank you :match endofline /$/ is a good solution. The only problem is that the end of line spaces is flickering when I enter text in a document ;) –  remio Mar 18 '10 at 20:25 Flickering, huh? My version of vim (7.2 with patches 1-394, and some extra features...) doesn't do that, though it does lose the highlighting if you type at the end of the line. It comes back with ctrl-L, so clearly it's not supposed to disappear! –  Jefromi Mar 18 '10 at 21:23 @remio: I really don't think there's any better solution, and you said this one's good - you might want to accept the answer so it doesn't continue to show up as unanswered. –  Jefromi Mar 19 '10 at 16:25 show 1 more comment Your Answer
http://stackoverflow.com/questions/2470833/vim-showing-listchars-changes-the-screen-wrapping
dclm-gs1-103410001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.717528
<urn:uuid:a378a996-18ba-4201-8adb-6a3c2f9b49bb>
en
0.90951
Take the 2-minute tour × I'm currently building a Javascript library that can be used to easily create embeddable media based on the URL of a media file, and then be controlled using Javascript methods and events (think something like the Flash / Silverlight JW player). Of course, i could simply cat all the html tags from the Javascript library and send that to the browser: function player(url) { document.write('<object type="foo"><param name="something" value="bar">' + <param name="source" value=" + url + '/></object>'); But i think this is a very ugly practice that tends to create unmanageable code that is unreadable when you review it a few weeks later. So, a templating solution seems to be the way to go. I've been looking to EJS because it loads the templates using AJAX, so you can manage your templates in separate file instead of directly on the HTML page. There's one 'gotcha' with that: my library needs to be completely cross-domain: the library itself could be located on foo.com while the serving site could be located on bar.com. So if bar.com would want to add a media player using the library it needs to do an AJAX call to a template located on foo.com, which won't work because of the same-origin policy in browsers. AFAIK, there's no library that uses something like JSONP to read and write templates to get around this problem. Could anyone point me to a solution for this problem? share|improve this question add comment 1 Answer Answering my own question: you need some kind of server-side solution that delivers JSONP to solve this problem. Let's say tou have a template on server foo.com, you could have a server-side script that answers to requests like these: Which would return: "html" : "<p>i'm a template!</p>" Then you can use any template language you want and parse the template in your app. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2551588/cross-domain-templating-with-javascript/4951935
dclm-gs1-103420001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.729871
<urn:uuid:b9049360-54bf-4d9f-957a-a5adec7bff32>
en
0.7763
Take the 2-minute tour × I'm working on a browser-game and I can't help but wonder about what's the lightest way to make the grid/board on which the game takes place. Right now, as a mere sample, I'll show you this: -link no longer active, it was basically a 25x25 table+tr+td grid- Now, as the grid gets bigger and bigger, the table and its td's create a very heavy filepage which in turn...sucks in more resources from the browser engine and computer. So, is a table with td's the most lightweight way to craft a huge grid-like board or is there something lighter that you recommend? Cheers Sotkra share|improve this question What kind of lightweight do you mean? Some interpreted your question as performance optimization of HTML sent from the server to the browser. But I believe that the DOM size in the browser might be an issue as well, which might be unrelated. –  Grzegorz Oledzki Apr 6 '10 at 10:52 Both ways: Both the 'burden' on the server when dispatching and the user's computer when loading up the html. –  Sotkra Apr 7 '10 at 20:21 add comment 7 Answers up vote 4 down vote accepted Computing a table layout is a very complex work for a browser, because it has to know the dimensions of the last cell to calculate the exact width of each column. So, if you use a table, add table-layout:fixed early. Floating boxes or relative positioning may be faster to render. share|improve this answer I did some tests and wow. The loading time with layout set to fixed is incredibly faster. I'll try all the other suggestions too. I'm afraid I can only 'approve' one answer. Thanks to all! –  Sotkra Apr 8 '10 at 2:18 add comment You could try getting rid of the table, instead positioning the pieces with CSS {position: relative; top: 20px; left: 20px} etc. and draw a repeating backrgound grid. share|improve this answer Yes but, keep in mind that, table or no table, we'd still have LOTS of individual pieces. Imagine 400x400 for instance. Last time I tried that with a table, my browser froze for 20 seconds while loading it. I wonder if using individual 'pieces', be them divs or span's or whatever will actually reduce the file size/load. –  Sotkra Apr 3 '10 at 18:51 Thinking about it, he needs to have triggers to select each square. –  ANeves Apr 6 '10 at 9:55 add comment Removing the links and handling them via the click event in Javascript (preferably with something like JQuery) should cut down a lot on the filesize. share|improve this answer add comment You could build the table by using JavaScript to manipulate the DOM. If the grid's contents are very regular, the code to do that would be much smaller than having 400x400 times <td></td> plus markup. Of course performance then depends on the JavaScript engine. But if that does not suck completely, it could even be faster than parsing all the HTML, independant of the network transfer time. share|improve this answer add comment My suggestion is having the tiles absolutely positioned inside the board, to save on HTML (transfer time) and position calculations (load time) by the browser. JS to register the clicks and handle it (less HTML = less transfer and load time). So, you could have this base CSS: #board { display: block; width: [BoardWidth]px; /* TileWidth * NumberOrColumns */ height: [BoardHeight]px; /* TileHeight * NumberOfRows */ position: relative; .tile { display: block; width: [TileWidth]px; height: [TileHeight]px; float: left; Then having the html generated like that: <div id="board"> <div class="tile" style="position: absolute; left:0px; top:0px;"></div> <div class="tile" style="position: absolute; left:20px; top:0px;"></div> <div class="tile" style="position: absolute; left:40px; top:0px;"></div> <div class="tile" style="position: absolute; left:60px; top:0px;"></div> <div class="tile" style="position: absolute; left:0px; top:20px;"></div> <div class="tile" style="position: absolute; left:20px; top:20px;"></div> <div class="tile" style="position: absolute; left:40px; top:20px;"></div> <div class="tile" style="position: absolute; left:60px; top:20px;"></div> <div class="tile" style="position: absolute; left:0px; top:40px;"></div> In which every tile has position left: [X*TileWidth]px; top: [Y*TileHeight]px;. That, or David M's suggestion. You can also cut on page load time if you make the page size smaller - so, like suggested, using JQuery or another JavaScript framework to create the trigger for the click on each div would be ideal. I'm not very savvy, but using JQuery it would be something like: $(document).ready(function() { $(".tile").click(function() { // find out which square was clicked, and perhaps redirect to a page with get variables share|improve this answer add comment You could build it with CSS floats, e.g if the squares are 20x20px: <style type="text/css"> div.container { width: Xpx; /* 20px [square box width]+1px [border width of each square])) * number of squares */ height: Xpx; /* similar to above] */ border: solid black; border-width: 1px 0px 0px 1px;} /* North East South West */ div.square { float: left; width: 20px; height: 20px; border: solid black; border-width: 0px 1px 1px 0px;} div.row { clear: both;} <div class="container"> <div class="row"> <div class="square"> Remember to use IE with a valid doctype http://htmlhelp.com/tools/validator/doctype.html or to use box model hacks in quirks mode [http://tantek.com/CSS/Examples/boxmodelhack.html]. You could probably make the above take up less if you use IDs instead of classes and use single letters in the CSS. What's fastest usually depends wildly on the browser though, e.g. I wouldn't be surprised if IE performs better with tables, while other browsers perform better with relative DIVs/floats. (I haven't tested the above, but something similar should work.) You could then convert the above to JavaScript to reduce page load times, e.g: function GenHTML(NumRows, NumCols) { var LRows = [] for (var x=0; x<NumRows; x++) { var LCols = [] for (var y=0; y<NumCols; y++) { var HTML = '<div class="square"></div>' LRows.push('<div class="row">'+ LCols.join('') +'</div>')} return LRows.join('')} function SetHTML(NumRows, NumCols) { document.getElementById('container').innerHTML = GenHTML(NumRows, NumCols)} share|improve this answer add comment <map name="planetmap"> If you use an imagemap to produce the triggers for your checkered board you would just need the repeated background and a transparent image that fills the total with and height. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2571720/what-is-the-lightest-way-to-make-a-huge-chess-like-grid
dclm-gs1-103430001
false
false
{ "keywords": "t cell" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.072546
<urn:uuid:00c1600a-69bb-49ed-8189-22a449f356ec>
en
0.941165
Take the 2-minute tour × So, there have been several posts here about importing and saving data from an external data source into Core Data. Apple documents a reasonable pattern for this: "import and save on background thread, merge saved objects to main thread." All fine and good. I have a related but different problem: the user is modifying data in the UI and main thread, and thus modifies state of some objects in the managed object context (MOC). I would like to save these changes from time to time. What is a good way to do that? Now, you could say that I could do the same: create a background thread with its own MOC and pass the changed objectID-s there. The catch-22 for me with this is that an object's ID changes when it is saved, and I cannot guarantee the order of things happening. I may end up passing a different objectID into the background thread for the same object, based on whether the object has been previously saved or not, and I don't know if Core Data can resolve this and see that different objectID-s are pointing to the same object and not create duplicates for me. (I could test this, but I'm lazywebbing with this question first.) One thought I had: I could always do MOC saves on a background thread, and queue them up with operationqueue, so that there is always only one save in progress. I would not create a new MOC, I would just use the same MOC as in main thread. Now, this is not thread safe and when someone modifies the MOC in main thread while it is being saved in background thread, the results will probably be catastrophic. But, minus the thread safety, you can see what kind of solution I'd wish for. To be clear, the problem I need to fix is that if I just do the save in main thread, it blocks the UI for an unacceptably long period of time, I want to move the save to background thread. So, questions: 1. what about the reasoning of an object ID changing during saving, and Core Data being able to resolve them to the same object? Would this be the right way of addressing this problem? 2. any other good ways of doing this? share|improve this question I don't think an object's ID changes during saves. That doesn't sound right to me at all. –  Giao Apr 9 '10 at 17:19 An object has one ID before it is first saved, and another, permanent ID after it is saved, which stays the same. Read CD docs. –  Jaanus Apr 9 '10 at 17:38 add comment 2 Answers up vote 2 down vote accepted Simply put, you can't move the save to the background thread. Changes are relative to the NSManagedObjectContext and therefore are invisible to a NSManagedObjectContext on another thread. I would suggest profiling your saves to find out why they are taking so long. Perhaps make them more frequently or find out what else might be causing the performance issue. You are using a SQLite store right? If you are using Binary it is definitely going to be an issue as I believe I mentioned to you before. Binary must be loaded 100% into memory and therefore must also be written 100% out to disk. share|improve this answer I am still using the binary store for reasons discussed in another thread (efficient runtime processing as whole store is in memory). This might be a good enough reason to go back to SQLite store. Binary store save performance seems to degrade linearly based on how much info has changed. –  Jaanus Apr 9 '10 at 16:57 add comment It may not solve all of your troubles, but there is a method -[NSManagedObjectContext obtainPermanentIDsForObjects:error:] that you can use to obtain the permanent ID for a managed object prior to saving it to the store. So that should be helpful in any synchronization you end up doing. share|improve this answer Which won't matter because unsaved changes are local to the context that created/loaded the object. –  Marcus S. Zarra Apr 10 '10 at 0:20 add comment Your Answer
http://stackoverflow.com/questions/2609115/how-to-efficiently-save-changes-made-in-ui-main-thread-with-core-data
dclm-gs1-103440001
false
false
{ "keywords": "importin" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.370222
<urn:uuid:1b6c5eef-5bee-4df9-975c-c7374ae4745a>
en
0.919469
Take the 2-minute tour × when I do git rebase master I get conflict sometimes. And sometimes it becomes very difficult to track down an issue even with error messages. It would be a real help if I could find out which commit git is trying to reapply and is causing conflict. How can I find out which commit is causing the conflict? share|improve this question add comment 1 Answer Look in the conflicting file(s), the lines starting with >>>>>>> show the commit hash which caused the conflict. share|improve this answer I don't think you will find any SHA1 in a rebase conflict file (in a merge conflict file, yes, not in a rebase one) –  VonC May 1 '10 at 20:27 add comment Your Answer
http://stackoverflow.com/questions/2730627/git-rebase-conflict-was-caused-by-which-commit
dclm-gs1-103460001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.144119
<urn:uuid:ea8aecfc-7e38-446f-b9a5-6907b20ff2b3>
en
0.84262
Take the 2-minute tour × OK, my statement executes well in phpMyAdmin, but not how I expect it in my php page. This is my statement: SELECT `egid`, `group_name` , `limit`, MAX( `date` ) FROM employee_groups GROUP BY `egid` ORDER BY `egid` DESC ; This is may table: CREATE TABLE `employee_groups` ( `egid` int(10) unsigned NOT NULL, `date` date NOT NULL, `group_name` varchar(50) NOT NULL, `limit` smallint(5) unsigned NOT NULL, PRIMARY KEY (`egid`,`date`) I want to extract the most recent list of groups, e.g. if a group has been changed I want to have only the last change. And I need it as a list (all groups). share|improve this question Can you post the PHP code you're using? –  awgy May 8 '10 at 11:25 "not how I expect it" What did you expect, and what did you get? –  Mark Byers May 8 '10 at 13:45 add comment 2 Answers up vote 1 down vote accepted Your query might be broken. You should not select fields that aren't in the group by unless one of the following two conditions apply: • You use an aggregate function. • The value is functionally dependant on the grouped by columns. The two fields group_name and limit appear to break these rules. This means that you will get indeterminate results for these columns. If you are trying to select the max per group then you should use a slightly different technique. See Quassnoi's article MYSQL: Selecting records holding a groupwise maximum for a variety of methods you could use. Here's one way to do it: SELECT di.* FROM ( SELECT egid, MAX(date) AS date FROM employee_groups d GROUP BY egid ) dd JOIN employee_groups di ON di.egid = dd.egid AND di.date = dd.date share|improve this answer mark, again. this is mysql. in mysql you can select fields outside of the group with*out* using an aggregate function. i know this does not work in standard sql and most implementations, but it does work in mysql (the actual row to be returned is undefined [most of the time it's the first row], but it compiles, works and returns a resultset!) –  knittl May 8 '10 at 13:32 This works great!!! Thank you. I posted my question on three other forums but nobody was able to help me. You are a smart man, Mark. –  kdobrev May 9 '10 at 9:34 @kdobrev: Glad to help. Remember to accept an answer when your problem is solved. Accepting answers will encourage people here to help you more. :) –  Mark Byers May 9 '10 at 10:01 add comment aggregate functions will work in mysql, different to the sql standard. to access the value of max(date) from php, you have to alias it: SELECT `egid`, `group_name` , `limit`, MAX( `date` ) as maxdate you can then select it like any other colum from php with while($row = mysqli_fetch_row($result)) { echo htmlspecialchars($row['maxdate']); hope that helps share|improve this answer Mark's answer was what I was looking for. Thanks anyway. –  kdobrev May 9 '10 at 9:36 add comment Your Answer
http://stackoverflow.com/questions/2793860/select-maxdate-works-in-phpmyadmin-but-not-in-my-code?answertab=active
dclm-gs1-103470001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.354248
<urn:uuid:7607a2b2-5488-4c03-ae07-c75f1966cc95>
en
0.777312
Take the 2-minute tour × I'm working on a client app that uses a restful service to look up companies by name. It's important that I'm able to include literal ampersands in my queries since this character is quite common in company names. However whenever I pass %26 (the URI escaped ampersand character) to System.Uri, it converts it back to a regular ampersand character! On closer inspection, the only two characters that aren't converted back are hash (%23) and percent (%25). Lets say I want to search for a company named "Pierce & Pierce": var endPoint = "http://localhost/companies?where=Name eq '{0}'"; var name = "Pierce & Pierce"; Console.WriteLine(new Uri(string.Format(endPoint, name))); Console.WriteLine(new Uri(string.Format(endPoint, name.Replace("&", "%26")))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeUriString(name)))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeDataString(name)))); All four of the above combinations return: http://localhost/companies?where=Name eq 'Pierce & Pierce' This causes errors on the server side since the ampersand is (correctly) interpreted as a query arg delimiter. What I really need it to return is the original string: http://localhost/companies?where=Name eq 'Pierce %26 Pierce' How can I work around this behavior without discarding System.Uri entirely? I can't replace all ampersands with %26 at the last moment because there will usually be multiple query args involved and I don't want to destroy their delimiters. Note: A similar problem was discussed in this question but I'm specifically referring to System.Uri. share|improve this question add comment 3 Answers up vote 7 down vote accepted It's not only the ampersand that is incorrect in the URL. A valid URL can not contain spaces. The EscapeDataString method works just fine to encode the string properly, and you should encode the entire value, not just the name: Uri.EscapeDataString("Name eq 'Pierce & Pierce'") When you create an Uri using this string, it will be correct. To see the URL you can use the AbsoluteUri property. If you just convert the Uri to a string (which calls the ToString method) the URL will be unescaped and thus appear incorrect. share|improve this answer Ah, now I get it. ToString() is an un-escaped human readable version of the uri. –  Nathan Baulch May 20 '10 at 10:44 add comment I encount the same problem. Though the query string is escaped with Uri.EscapeDataString, and the property AbsoluteUri do reprent it correctly, but WebBrowser send the Uri in unescaped format. currentUri = new System.Uri(ServerAgent.urlBase + "/MailRender?uid=" + Uri.EscapeDataString(uid); Plus sign ('+') is convert to %2B, but the server still get + in URL, which is then convert to space (' ') via HttpServeletRequest.getParameter() call share|improve this answer add comment I have resolved this problem by create a derived class of Uri class Uri2 : System.Uri public Uri2(string url) : base(url) public override string ToString() return AbsoluteUri; In any place System.Uri is used, use Uri2 replaced. I don't know whether this is a bug of .NetCF, WebBrowser should send URL in encoded format, i.e. the value of AbsoluteUri, but not value from ToString() share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2872430/literal-ampersands-in-system-uri-query-string/3044757
dclm-gs1-103480001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.332968
<urn:uuid:66f474db-8630-4b12-afc0-a219cd947fa6>
en
0.781261
Take the 2-minute tour × This object always uses the default on the system, so on an x64 machine, it will use an x64 Internet Explorer object. Is there any way I can force it to use the x86 IE? The web page element the browser accesses does not work on x64 and is out of my control. share|improve this question add comment 2 Answers You can force the Forms Application to compile in x86 within the property pages of the Visual Studio project. Properties -> Build -> Platform Target share|improve this answer Does this force the embedded browser object to use X86 IE too? –  heap Jun 3 '10 at 10:47 It does, WebBrowser uses Internet Explorer in-process. 64-bit and 32-bit components cannot be mixed inside a process. –  Hans Passant Jun 3 '10 at 12:46 add comment Compile your program in X86 mode. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/2965165/system-windows-forms-webbrowser-force-x86
dclm-gs1-103490001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.035702
<urn:uuid:a1f5490d-fa99-4559-9baa-a58f916d98d3>
en
0.663036
Take the 2-minute tour × I am doing some stuff that needs to output xml(utf-8) using PHP scripts. It has strict format requirements, which means the xml must be well formed. I know 'htmlspecialchars' to escape, but I don't know how to ensure that. Is there some functions/libraries to ensure everything is well formed? share|improve this question add comment 2 Answers You can use PHP DOM or SimpleXML. These will also handle escaping for you. share|improve this answer add comment The Matthew answer indicates the "framework" for produce your XML code. If you need only simple functions to work with your XML class or do "XML-translations", here is a didactic example (replace xmlsafe function by htmlspecialchars function). PS: remember that safe UTF-8 XML not need a full entity encode, you need only htmlspecialchars... Not require all special characters to be translated to entities. Only 3 or 4 characters need to be escaped in a string of XML content: >, <, &, and optional ". See also the XML specification, http://www.w3.org/TR/REC-xml/ "2.4 Character Data and Markup" and "4.6 Predefined Entities". The following PHP function will make a XML completely safe: // it is for illustration, use htmlspecialchars($s,flag). function xmlsafe($s,$intoQuotes=0) { if ($intoQuotes) return str_replace(array('&','>','<','"'), array('&amp;','&gt;','&lt;','&quot;'), $s); // SAME AS htmlspecialchars($s) return str_replace(array('&','>','<'), array('&amp;','&gt;','&lt;'), $s); // SAME AS htmlspecialchars($s,ENT_NOQUOTES) function xmlTag( $element, $attribs, $contents = NULL) { $out = '<' . $element; foreach( $attribs as $name => $val ) $out .= ' '.$name.'="'. xmlsafe( $val,1 ) .'"'; // convert quotes if ( $contents==='' || is_null($contents) ) $out .= '/>'; $out .= '>'.xmlsafe( $contents )."</$element>"; // not convert quotes return $out; In a CDATA block you not need use this function... But, please, avoid the indiscriminate use of CDATA. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/3106802/how-to-output-xml-safe-string-in-php
dclm-gs1-103510001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.07958
<urn:uuid:82e69b56-5342-4e0d-8625-55e7158e8600>
en
0.827259
Take the 2-minute tour × HI all, I would like to call from my C# code, unamanaged library functions like presented below. There are two options and the both works. In this moment "Beep" function is simple and have no input/output parameters, pointers, references... I am wondering in more complex cases what would be adventages and disadvantage of both approches ? Thanks, Milan. public void TestBeep() Beep(300, 3000); internal delegate bool DelegBeep(uint iFreq, uint iDuration); internal static extern IntPtr LoadLibrary(String dllname); public void BeepIt() IntPtr kernel32 = LoadLibrary("Kernel32.dll"); IntPtr procBeep = GetProcAddress(kernel32, "Beep"); delegBeep(50, 1000);//Hz,ms share|improve this question add comment 2 Answers up vote 3 down vote accepted Your second one is much more complicated than the first but achieves the same thing in this case. If the name of the DLL and the name of the function are known at compile time, then stick with the first approach. If you don't know the name of the DLL and/or function until run time then the LoadLibary/GetProcAddress approach is your only option. share|improve this answer The name of dll I have to know in both cases right ? Otherwise LoadLibrary will return error, or maybe I can give full part to LoadLibrary function ? –  milan Jul 2 '10 at 16:27 Right, but with [DllImport] you have to pass a constant string, whereas a call to LoadLibrary lets you determine the DLL name at runtime. –  Tim Robinson Jul 2 '10 at 16:38 I try to comment out [DllImport("kernel32.dll")] in the second example but then I get exception that LoadLibray have no implementation. How I should call then LoadLibrary ? –  milan Jul 2 '10 at 17:53 I don't follow... why are you commenting out the [DllImport("kernel32.dll")] next to LoadLibrary? –  Tim Robinson Jul 2 '10 at 18:25 Yes I commented out all [DllImport("kernel32.dll")] because I thougt your idea is to use just LoadLibrary with correct library path, or I got it wrong ? –  milan Jul 2 '10 at 18:28 show 6 more comments The P/Invoke marshaller finds an entrypoint in a DLL by using LoadLibrary() and GetProcAddress(). And knows how to convert a C# declaration to the equivalent of a delegate declaration. Doing this yourself has no advantage beyond maybe a wee bit of efficiency. Which you'd better measure, it is no slamdunk. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/3166797/referencing-unmanaged-librararies-from-managed-code-adventages-and-disadvantage
dclm-gs1-103520001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.596786
<urn:uuid:9f2769a3-f989-498d-9b7a-ec5c361e2336>
en
0.794702
Take the 2-minute tour × As you know, the javascript's parseFloat function works only until it meets an invalid character, so for example parseFloat("10.123") = 10.123 parseFloat("12=zzzz") = 12 parseFloat("z12") = NaN Is there a way or an implementation of parseFloat that would return NaN if the whole string is not a valid float number? share|improve this question add comment 3 Answers up vote 15 down vote accepted Use this instead: var num = Number(value); Then you can do: if (isNaN(num)) { // take proper action share|improve this answer This is a better idea than my answer :) –  rfunduk Jul 15 '10 at 15:30 Just be careful about some specific cases, e.g.: isNaN(parseFloat("")); // true and Number("") == 0; // true –  CMS Jul 15 '10 at 15:38 @exoboy - You don't need to deal with illegal characters with this solution. Try this and you'll see: var x = Number("#!"); if (isNaN(x)) alert("bad"); –  dcp Jul 15 '10 at 16:01 @exoboy - I'm not sure I understand, when I run your example I get NaN for num, which is what I would expect since ")(*(*&()*H3.4" isn't a valid float. Also, you left off an else clause before your second alert call, so perhaps you should test your code ;). Anyway, no need to get hostile here. –  dcp Jul 15 '10 at 17:07 @exoboy: Number doesn't 'coerce' a number out of a string. It's a function to convert a string into a number, if it is a valid number. The question asked to only yield a number if the whole string is a valid number. –  rfunduk Jul 15 '10 at 18:05 show 2 more comments Maybe try: var f = parseFloat( someStr ); if( f.toString() != someStr ) { // string has other stuff besides the number Update: Don't do this, use @dcp's method :) share|improve this answer +1 for providing an answer that solves the problem and then pointing the OP to use an answer you consider better. –  NG. Jul 15 '10 at 15:33 It's indeed a bad way to solve this problem since it won't work with value like "12.5000". –  HoLyVieR Jul 15 '10 at 16:43 @HoLyVieR: Yea, it really depends on where your data is coming from. Most languages serializing out values wont pad with zeroes unless you explicitly say so. Since Number() solves these sorts of problems (with a few caveats of it's own) there's no need to do this. –  rfunduk Jul 15 '10 at 18:01 add comment var asFloat = parseFloat("12aa"); if (String(asFloat).length != "12aa".length) { // The value is not completely a float else { // The value is a float share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/3257112/is-it-possible-to-parsefloat-the-whole-string
dclm-gs1-103530001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.593348
<urn:uuid:b5407ffc-d0fb-4cbb-9f4c-8371d1176ca0>
en
0.930584
Take the 2-minute tour × I am looking for an open source C implementation of a hash table that keeps all the data in one memory block, so it can be easily send over a network let say. I can only find ones that allocate small pieces of memory for every key-value pair added to it. Thank you very much in advance for all the inputs. EDIT: It doesn't necessarily need to be a hash table, whatever key-value pair table would probably do. share|improve this question add comment 4 Answers up vote 0 down vote accepted On a unix system I'd probably utilise a shared memory buffer (see shm_open()), or if that's not available a memory-mapped file with the MAP_SHARED flag, see the OS-specific differences though http://en.wikipedia.org/wiki/Mmap If both shm_open and mmap aren't available you could still use a file on the disk (to some extent), you'd have to care about the proper locking, I'd send an unlock signal to the next process and maybe the seek of the updated portion of the file, then that process locks the file again, seeks to the interesting part and proceeds as usual (updates/deletes/etc.). In any case, you could freely design the layout of the hashtable or whatever you want, like having fixed width key/seek pairs. That way you'd have the fast access to the keys of your hashtable and if necessary you seek to the data portion, then copy/delete/modify/etc. Ideally this file should be on a ram disk, of course. share|improve this answer Thank you for your input hroptatyr. However in my question, I am not asking about how to share data between processes, I have a technique for doing that (in fact I am using shared memory available on Linux that you mentioned). What I am looking for is a library which I can give a nice block of memory to work with and I can put key-value pairs in for as long as there is enough space in the data block. Once the data in, I can go and look up the values by their keys. No dynamic memory allocations. –  p3k Jul 20 '10 at 20:59 I once wrote a thing like that, it even supported a clever cuckoo hashing scheme where the keys got swapped but the satellite data didn't. I did write it with serialisation in mind just like you but I found that it didn't perform at all compared to a separated key block/satellite data block approach due to cache pollution. It was part of a distributed hashing setup and my primary objective was lookup speed, I did about 1 (de)serialisation per 20M lookups. –  hroptatyr Jul 20 '10 at 21:27 Oh and to actually contribute ideas: I now use xdr which is the serialisation backend of rpcgen. The data remain in their structs and rpcgen generates the (de)serialiser functions. And seeing as array serialisation is possible it could meet your requirements, only that it's not natively a hash table. –  hroptatyr Jul 20 '10 at 21:59 add comment The number of times you would serialize such data structure (and sending over network is serializing as well) vs the number of times you would use such data structure (in your program) is pretty low. So, most implementations focus more on the speed instead of the "maybe easier to serialize" side. If all the data would be in one allocated memory block a lot of operations on that data structure would be a bit expensive because you would have to: • reallocate memory on add-operations • most likeley compress / vacuum on delete-operations (so that the one block you like so much is dense and has no holes) Most network operations are buffered anyway, just iterate over the keys and send keys + values. share|improve this answer add comment I agree completely with akira (+1). Just one more comment on data locality. Once the table gets larger, or if the satellite data is large enough, there's most certainly cache pollution which slows down any operation on the table additionally, or in other words you can rely on the level-1/2/3 cache chain to serve the key data promptly whilst putting up with a cache miss when you have to access the satellite data (e.g. for serialisation). share|improve this answer add comment Libraries providing hashtables tend to hide the details and make the thing work efficiently (that is normally what programmers want when they use an hashtabe), so normally the way they handle the memory is hidden from the final programmer's eyes, and programmers shouldn't rely on the particular "memory layout", that may change in following version of the library. Write your own function to serialize (and unserialize) the hashtable in the most convenient way for your usage. You can keep the serialized content if you need it several times (of course, when the hashtable is changed, you need to update the serialized "version" kept in memory). share|improve this answer Thank you very much for all your input. I used the network example just so this question isn't too specific to my project and can be useful to others. I am sending packets of data between number of processes on a single machine and I need to accompany the data with some sort of meta data, where each process just looks up or changes couple values and sends it to the next process. WOuldn't it be inefficient to serialize and "unserialize" all of the meta data if each process only wants to deal with couple of them? Maybe hash table is not at all what I want to use in this case? Any suggestions? –  p3k Jul 20 '10 at 16:25 add comment Your Answer
http://stackoverflow.com/questions/3287769/ansi-c-hash-table-implementation-with-data-in-one-memory-block/3288703
dclm-gs1-103540001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.245471
<urn:uuid:c4761b13-3421-4e85-a4b4-39d8b0cea56a>
en
0.921674
Take the 2-minute tour × Edit: I discovered a partial answer to my own question in the process of writing this, but I think it can easily be improved upon so I will post it anyway. Maybe there's a better solution out there? I am looking for an easy way to define recursive functions in a let form without resorting to letfn. This is probably an unreasonable request, but the reason I am looking for this technique is because I have a mix of data and recursive functions that depend on each other in a way requires a lot of nested let and letfn statements. I wanted to write the recursive functions that generate lazy sequences like this (using the Fibonacci sequence as an example): (let [fibs (lazy-cat [0 1] (map + fibs (rest fibs)))] (take 10 fibs)) But it seems in clojure that fibs cannot use it's own symbol during binding. The obvious way around it is using letfn (letfn [(fibo [] (lazy-cat [0 1] (map + (fibo) (rest (fibo)))))] (take 10 (fibo))) But as I said earlier this leads to a lot of cumbersome nesting and alternating let and letfn. To do this without letfn and using just let, I started by writing something that uses what I think is the U-combinator (just heard of the concept today): (let [fibs (fn [fi] (lazy-cat [0 1] (map + (fi fi) (rest (fi fi)))))] (take 10 (fibs fibs))) But how to get rid of the redundance of (fi fi)? It was at this point when I discovered the answer to my own question after an hour of struggling and incrementally adding bits to the combinator Q. (let [Q (fn [r] ((fn [f] (f f)) (fn [y] (r (fn [] (y y)))))) fibs (Q (fn [fi] (lazy-cat [0 1] (map + (fi) (rest (fi))))))] (take 10 fibs)) What is this Q combinator called that I am using to define a recursive sequence? It looks like the Y combinator with no arguments x. Is it the same? (defn Y [r] ((fn [f] (f f)) (fn [y] (r (fn [x] ((y y) x)))))) Is there another function in clojure.core or clojure.contrib that provides the functionality of Y or Q? I can't imagine what I just did was idiomatic... share|improve this question I noticed that writing fibs in this way results in terrible performance because (I presume) the combinator doesn't store results under the symbol fibs, but rather re-generates values on the fly? How can I make this more performant? –  ivar Jul 30 '10 at 15:59 add comment 2 Answers up vote 8 down vote accepted I have written a letrec macro for Clojure recently, here's a Gist of it. It acts like Scheme's letrec (if you happen to know that), meaning that it's a cross between let and letfn: you can bind a set of names to mutually recursive values, without the need for those values to be functions (lazy sequences are ok too), as long as it is possible to evaluate the head of each item without referring to the others (that's Haskell -- or perhaps type-theoretic -- parlance; "head" here might stand e.g. for the lazy sequence object itself, with -- crucially! -- no forcing involved). You can use it to write things like which is normally only possible at top level. See the Gist for more examples. As pointed out in the question text, the above could be replaced with (letfn [(fibs [] (lazy-cat [0 1] (map + (fibs) (rest (fibs)))))] for the same result in exponential time; the letrec version has linear complexity (as does a top-level (def fibs (lazy-cat [0 1] (map + fibs (rest fibs)))) form). Self-recursive seqs can often be constructed with iterate -- namely when a fixed range of look-behind suffices to compute any given element. See clojure.contrib.lazy-seqs for an example of how to compute fibs with iterate. c.c.seq provides an interesting function called rec-seq, enabling things like (take 10 (cseq/rec-seq fibs (map + fibs (rest fibs)))) It has the limitation of only allowing one to construct a single self-recursive sequence, but it might be possible to lift from it's source some implementation ideas enabling more diverse scenarios. If a single self-recursive sequence not defined at top level is what you're after, this has to be the idiomatic solution. As for combinators such as those displayed in the question text, it is important to note that they are hampered by the lack of TCO (tail call optimisation) on the JVM (and thus in Clojure, which elects to use the JVM's calling conventions directly for top performance). top level There's also the option of putting the mutually recursive "things" at top level, possibly in their own namespace. This doesn't work so great if those "things" need to be parameterised somehow, but namespaces can be created dynamically if need be (see clojure.contrib.with-ns for implementation ideas). final comments I'll readily admit that the letrec thing is far from idiomatic Clojure and I'd avoid using it in production code if anything else would do (and since there's always the top level option...). However, it is (IMO!) nice to play with and it appears to work well enough. I'm personally interested in finding out how much can be accomplished without letrec and to what degree a letrec macro makes things easier / cleaner... I haven't formed an opinion on that yet. So, here it is. Once again, for the single self-recursive seq case, iterate or contrib might be the best way to go. share|improve this answer Thanks for the great reply! I'm aware of iterate but it is hard to use in my particular problem (because the real structure of the problem uses data from multiple irregularly shaped trees, not a simple Fibonacci). I will definitely study that macro and rec-seq though! –  ivar Jul 31 '10 at 11:48 add comment fn takes an optional name argument with that name bound to the function in its body. Using this feature, you could write fibs as: (def fibs ((fn generator [a b] (lazy-seq (cons a (generator b (+ a b))))) 0 1)) share|improve this answer Nice catch! I forgot about that one. –  ivar Aug 1 '10 at 21:55 add comment Your Answer
http://stackoverflow.com/questions/3373157/how-to-create-a-lazy-seq-generating-anonymous-recursive-function-in-clojure?answertab=oldest
dclm-gs1-103550001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.081571
<urn:uuid:c6eddaeb-b878-435d-a3df-2d4a872ad502>
en
0.806048
Take the 2-minute tour × Is there a way to easily export R tables to a simple HTML page? share|improve this question add comment 2 Answers up vote 8 down vote accepted The xtable function in the xtable package can export R tables to HTML tables. This blog entry describes how you can create HTML pages from Sweave documents. share|improve this answer print(xtable(tb), type = "html"), to be precise. Thanks for the link! –  aL3xa Aug 9 '10 at 8:49 add comment Apart from xtable mentioned by nullglob there are three more packages that might come handy here: share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/3438226/exporting-r-tables-to-html?answertab=votes
dclm-gs1-103570001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.518924
<urn:uuid:a1880d60-8146-4aa6-9ed9-b871d123bc8c>
en
0.802759
Take the 2-minute tour × I'm trying to synchronize the timezone between a PHP script and some JavaScript code. I want a PHP function that returns a timestamp in UTC. Does gmmktime() do that? On the JavaScript side, I have: var real_date = new Date(); real_date -= real_date.getTimezoneOffset() * 60000; real_date /= 1000; Does this convert the timestamp to UTC? share|improve this question add comment 2 Answers up vote 4 down vote accepted Just time() will do what you want. If you want an arbitrary timestamp, instead of the current time, then gmmktime will do that, yes. You can use the .UTC() method of a Date object to get # of milliseconds in UTC. However, your current solution should also work, if you're starting with a timestamp. share|improve this answer Thanks. So just to confirm... time() in PHP is timezone-independent? –  Nathan Osman Aug 14 '10 at 18:50 Yes. time() always returns UTC timestamps. –  Amber Aug 14 '10 at 19:01 add comment You can use time() For the Javascript question UTC share|improve this answer Why not just $utc = (int) gmdate('U');? Er, or just time()... –  eyelidlessness Aug 14 '10 at 18:21 actually gmdate returns the Greenwich Mean Time, I was wrong, I'll edit it. –  dierre Aug 14 '10 at 18:33 FWIW, unless you're concerned about accuracy down to fractional seconds (and if you are, you probably aren't using PHP), GMT and UTC should be equivalent. –  eyelidlessness Aug 14 '10 at 18:48 I'll keep that in mind. –  dierre Aug 14 '10 at 20:28 add comment Your Answer
http://stackoverflow.com/questions/3484535/getting-timezone-for-javascript-and-php-all-mixed-up
dclm-gs1-103580001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.257327
<urn:uuid:5d5ab084-3d8d-4198-8ee6-1f5414d0aa1f>
en
0.875666
Take the 2-minute tour × If number of users login and use a same wcf service then my application hangs and i have to logout ? so please give the solution so that n number of user can login and works at a time. Thank you in advance... share|improve this question There's not enough information here to be able to answer this. Voting to close as "not a real question". –  Mark Byers Aug 19 '10 at 18:24 WCF can easily handle hundred or thousands of concurrent callers - that's definitely not the problem. –  marc_s Aug 19 '10 at 18:31 add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/3524939/n-number-of-user-logged-and-use-a-wcf-service
dclm-gs1-103590001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.481476
<urn:uuid:bdc17030-e18f-4f63-bcd3-c7828ee9ecfa>
en
0.883664
Take the 2-minute tour × I have a hash of hashes, like so: %hash = ( a => { b => 1, c =>2, d => 3}, a1 => { b => 11, c =>12, d => 13}, a2 => { b => 21, c =>22, d => 23} ) I want to extract the "b" element and put it into an array. Right now, I am looping through the hash to do this, but I think I can improve efficiency slightly by using map instead. I'm pretty sure that if this was an array of hashes, I'd use something like this: @hasharray = ( { b => 1, c =>2, d => 3}, @array = map { ($_->{b} => $_) } @hasharray Forgive me if I'm wrong, I'm still learning how map works. But what I'd like to know is how would I go about mapping the hash of hashes? Is this even possible using map? I have yet to find any examples of doing this. Even better, the next step in this code is to sort the array once it's populated. I'm pretty sure this is possible, but I'm not smart enough on using map to figure it out myself. How would I go about doing this all in one shot? Thanks. Seth share|improve this question add comment 3 Answers up vote 9 down vote accepted This extracts and sorts all "b"s: my @array = sort { $a <=> $b } map $_->{b}, values %hash; share|improve this answer That worked great, exactly what I was looking for. I replaced 26 lines of code with this one, and improved the performance of that function from about O(n) to O(1). Thanks! –  sgsax Aug 27 '10 at 16:15 Well, it still has to iterate through the values of the hash and sort them, so it's not actually O(1). –  Corey Aug 27 '10 at 21:48 add comment Take your second solution, and substitute values %hash for @hasharray: @array = map { ($_->{b} => $_) } values %hash; (And don’t forget the ; to terminate the statement.) share|improve this answer add comment This fills @array with a sorted list of array references, each containing the value of b and the hashref it came from. my @array = sort {$$a[0] <=> $$b[0]} map { [$$_{b} => $_] } values %hash; my @sorted_hashes = map {$$_[1]} @array; share|improve this answer $a->[0] is easier to read than $$a[0]; similarly $_->{b} rather than $$_{b}. –  Philip Potter Aug 27 '10 at 15:22 It's better to use the <=> operator instead of cmp when sorting numbers. –  eugene y Aug 27 '10 at 15:26 @eugene => good point, fixing. @Philip => I prefer the doubled sigils for two reasons. First, it holds with other forms of dereferencing like @$a[1, 2]. Second, the -> operator is used for method calls, so I prefer only using it in situations where code is called. –  Eric Strom Aug 27 '10 at 16:27 add comment Your Answer
http://stackoverflow.com/questions/3585408/how-do-i-map-and-sort-values-from-a-hash-of-hashes?answertab=oldest
dclm-gs1-103610001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.050845
<urn:uuid:5e74ae1d-8016-4e24-a690-50b626a87b9c>
en
0.863534
Take the 2-minute tour × I have declared a structure that look like typedef struct char* key; char* value; and in the session structure, i declared a variable as struct session char* id; ..... // other session variables kvPair* pair; Now in the session_start I have initialised the values for the pair variable and I have to access these values in /ext/mysql extension. A suggestion on how to achieve it would be greatly appreciated share|improve this question OK, what are you trying to do? And what has the mysql extension to do with this? –  Artefacto Sep 1 '10 at 1:38 @Artefacto: Well since hes posted C code im going to guess hes customizing the mysql extension... Sill more explanation would be nice... as well as a tag for the actual language hes working with (i only guessed at C) –  prodigitalson Sep 1 '10 at 1:42 I am trying to control the access to the database based on the user information. Thats a part of my research on securing the server-side-database access. I tried to include the /ext/php_session.h in /ext/mysql.c . Is this the right way to do? or is there a better way of doing things? –  Karthick Sep 1 '10 at 1:45 omg, who adviced you to do in this way? –  zerkms Sep 1 '10 at 2:06 @zerkms. Are u talking about the scheme or the inclusion of session.h file in /ext/mysql.c? –  Karthick Sep 1 '10 at 2:16 show 1 more comment 1 Answer up vote 0 down vote accepted I'm not sure what you're trying to do, but if you want to read data that was saved in the session e.g. through this script: $_SESSION["key"] = "data"; Then yes, you can use the API exposed by the session extension: #include "ext/session/php_session.h" Then you have these functions: void php_session_start(TSRMLS_D); /* analogue to session_start() in userspace */ int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC); share|improve this answer once I use that. I am able to directly access the session structure variables. For example. to access id variable, i just did PS(id) and it worked like charms. Thank you for your suggestions though! –  Karthick Sep 1 '10 at 2:13 @Karth Just because you can, doesn't mean you should. The session extension provides an API, use it. If you violate the abstractions, your code will stop working when the internal structures you're accessing change in some future version. –  Artefacto Sep 1 '10 at 2:26 @Karth Well, in the particular case of fetching the current id, doesn't seem to exist any API. –  Artefacto Sep 1 '10 at 2:27 add comment Your Answer
http://stackoverflow.com/questions/3614469/accessing-session-variables-in-ext-mysql-extension
dclm-gs1-103620001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.106208
<urn:uuid:75c4e0d4-b7d3-4126-8996-aa057b17f5eb>
en
0.821093
Take the 2-minute tour × I have an application in which you select an area of a map and our product price list changes (dependant of map area, size etc.) So in my test, I use runScript() to call the JS method underlying the map, the prices update and I do a simple check on the price that is set ala Assert.AreEqual(priceValue, selenium.GetText(priceElement)); I use RC and C# to run tests. The problem is that when I dont run the test with my debugging switched on the price check fails. I'm pretty sure the problem is the check is run before the price is updated however if I put in a selenium.WaitForPageToLoad() at whatever value it times out. Given that the script I call selects the area on the map and updates the price plus I can see it on the screen why cant my test? share|improve this question add comment 2 Answers up vote 1 down vote accepted Thread.sleep (5000) - This is not a best practice because your tests will run slowly. You should to try waitForElementPresent better share|improve this answer Yeah I didnt like the thread.sleep option so using selenium.WaitForCondition("selenium.getText('price2048') != '--.--'", "60000"); instead. –  DazManCat Sep 9 '10 at 9:40 add comment Quite a simple answer really. WaitForPageToLoad times out as the script doesnt trigger a page load. So using thread.Sleep(5000) gives the element a chance to refresh then doing the Assert has got it working. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/3667350/assert-areequal-not-recognising-dynamically-updated-values
dclm-gs1-103630001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.063998
<urn:uuid:961c7283-b29e-455e-a5c4-542f1d9ad514>
en
0.88069
Take the 2-minute tour × I can easily find how to submit an existing form using jQuery. But how can I, given a URL, and some parameters create and submit this form on the fly? share|improve this question add comment 1 Answer up vote 8 down vote accepted This sounds like a bad solution to a problem that can probably be better solved another way... That being said, you can create a form and trigger the submit method on it easily enough: '<form action="url.php" method="post">', '<input type="hidden" name="param1" value="foo"/>', If you need to be able to specify the parameters and the url then you could write a function similar to this one: function submitValues(url, params) { var form = [ '<form method="POST" action="', url, '">' ]; for(var key in params) form.push('<input type="hidden" name="', key, '" value="', params[key], '"/>'); and call it this way: submitValues('url.php', { foo: 'bar', boo: 'far' }); share|improve this answer Hi Prestaul. This was a simple and great idea. I used it to post the values to a new window, using target blank. For that I added an argument to set the target of the from, and a remove() call after the submit (so I won't have any form leftovers in my markup) –  Mohoch Feb 9 '12 at 9:14 @Mohoch, I'm glad this was helpful to you, but I should reiterate that I cannot think of a good reason to do this... If you find yourself needing this technique you most likely are abusing the POST method (i.e. you should be using GET) or someone has designed a workflow that is going to be as painful for users as it is for developers... My 2 cents. –  Prestaul Feb 13 '12 at 17:27 what we were trying to do is to redirect the user to somewhere and pass parameters so they will not be visible to the user. We thought that a post is very simple, and it was. Why do you think this will be painful? –  Mohoch Feb 14 '12 at 7:39 It just is not the way that the web was designed to work. POST is designed for modifying data on the server, GET is designed for retrieving data. If you use this technique your users will get prompted to "repost" if they refresh those pages. They also will not be able to bookmark those pages unless the params are in the url. "Painful" is probably an overstatement, but I still believe it is a degraded experience. The correct way to deal with this is to use a better routing layer to allow you to have prettier urls. –  Prestaul Feb 27 '12 at 18:00 Also, if you are worried about SEO then you absolutely cannot use the technique you described. The search spiders will never index via POST and if your params are not part of the url then those pages are invisible as far as Google is concerned. –  Prestaul Feb 27 '12 at 18:15 add comment Your Answer
http://stackoverflow.com/questions/3671420/jquery-dynamic-form-submission
dclm-gs1-103640001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.029812
<urn:uuid:3b36d776-4d10-409c-bea5-c81bfe3dd7fe>
en
0.924666
Take the 2-minute tour × I am developing a python app, using python and sqlite and GUI to re-create a Access 2007 report generating app. Since the app is portable, I'm looking for GUI solution for python that user doesn't need to install addition things before using the app. Is there any GUI solution suits my need? Thanks! share|improve this question add comment 2 Answers up vote 4 down vote accepted wxPython is very portable share|improve this answer So are tkinter, PyGTK and PyQt. –  delnan Sep 24 '10 at 12:39 Yes, but wxPython is also fun. ;) –  FogleBird Sep 24 '10 at 12:54 wxPython cannot be installed via the Fink package manager on Mac OS X, I believe because of technical issues: wxPython is currently less portable than PyQt. –  EOL Sep 24 '10 at 13:20 So is easygui, which is simpler to use and allows access to tkinter if you would still like to use that –  inspectorG4dget Sep 24 '10 at 13:26 add comment The only fully portable GUI for Python is the standard TkInter, if you don't want any additional install beside Python. The Themed Tk version is quite nice looking, compared to the older Tk version (the themed version is available through the ttk module). A few weeks ago, I had to answer the same question as you. I came to the conclusion that PyQt is currently the best choice for a modern, powerful, well-maintained, and portable GUI, mainly because of some of the shortcomings of its main contender (wxPython, see below). (Tk, and Themed Tk would be good for simpler needs.) Two words of warning against wxPython: it is not possible to install it via the popular Fink package manager on Mac OS X, currently, which makes it far less portable than PyQt and TkInter; it is also not yet Python 3-compatible, as far as I know. PS (Dec. 2012): PySide is currently a strong alternative to PyQt. There are a few Stackoverflow questions about the respective merits of these two Python bindings. share|improve this answer standard doesn't mean what it used to mean, in this case. tkinter is present by default in the official, mainline standard library. However, a number of common linux distributions (notably Ubuntu), slice that library up and only install it if the user asks for it or something that is dependent on it. –  IfLoop Sep 26 '10 at 19:16 @TokenMacGuy: Interesting info. Thank you for sharing! –  EOL Sep 26 '10 at 20:23 add comment Your Answer
http://stackoverflow.com/questions/3787065/python-gui-for-portable-app/3787083
dclm-gs1-103650001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.492688
<urn:uuid:b4245003-b463-40e0-95f6-edf94d03d9e7>
en
0.939375
Take the 2-minute tour × I'm used to setting up a server for nginx with php and mysql. I understand that just fine. But I'm extremely confused at where to even start with django. I know nothing about python by the way. I'm running ubuntu 10.04 Python is already installed (not sure what version though. I read I need less than 3 or something) So firstly, how do I get fastcgi running and using python? I know how to pass to it from nginx once it's running. I also read something about needing "flup". How do I install that? And then where do python files go? I thought I saw something about generating a sort of skeleton set up? Maybe I'm wrong on that. Maybe point me to a super simplified tutorial or something - not the instructions on django's site - I'm just not getting it. share|improve this question add comment 4 Answers up vote 1 down vote accepted I did some serious flailing around when I was faced with an existing Django app that I had to re-host. I had experience with Rails but none with Django. I wound up with Nginx serving static resources and proxying framework requests to Apache and mod_python -- if I recall correctly my app had a mod_python dependency. Here are the resources which came in handy for me: The phrasing of your question made me think that, like me, you had a more-or-less functioning app that you're now trying to put in production. (If you're starting from scratch, Seitaridis has the answer for you.) One or two of these links should get you to the point where you have error messages you can search here. share|improve this answer add comment The best step you can make is to read the Django Tutorial It's the best starting point. When you have problems you can put another questions. share|improve this answer You can also take a look at the Django Book: djangobook.com –  Jordan Reiter Oct 26 '10 at 6:23 add comment I've found this blog post by Brandon Konkle very helpful for setting up a new Django server on Ubuntu. He goes the Nginx/Gunicorn route rather than Nginx/fcgi but it's a server setup that is becoming more common and popular in the Django community recently. share|improve this answer add comment lighttpd is great for fcgi. for maximum flexibilty start the django fcgi as tcp-listener, and have the lighttpd connect to it. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4020644/setting-up-django-for-the-first-time
dclm-gs1-103670001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.154345
<urn:uuid:97bf92e1-0b81-4b57-8281-184a59e81f05>
en
0.965905
Take the 2-minute tour × I'm trying to print a section of a web page and there are multiple css files, and several of those files contribute to the "print" media type. Some of the plugins I've seen assume that you only have one media="print" css file and that's all it needs. I have looked at PrintArea and jsprint and am not very impressed by either of them, I believe I can tweak them to get what I need, but I'm hoping there is a better library out there that I have yet to discover. share|improve this question add comment 1 Answer I was just looking at PrintArea's source, and it seems that it does take into account multiple stylesheets. It would help if you told us what exactly you don't like about the libraries. Also, I'm not sure how much more you'll be able to accomplish with a JS-only solution than the a plugin such as PrintArea already does. share|improve this answer By JS-only as an option, I just didn't want some other library introduced into the solution like prototype.js or the like. And for other features, I was looking for more options, perhaps formatting, perhaps table layout features for reports, or more UI features that dialog the user options about the print job. Just something more robust. –  vaskin Nov 24 '10 at 15:57 add comment Your Answer
http://stackoverflow.com/questions/4268478/what-is-the-best-browser-printing-library-plugin-or-snippet-for-javascript-j
dclm-gs1-103690001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.019442
<urn:uuid:f9c0e169-6fdb-41e1-88d0-d59ebed45d8b>
en
0.901375
Take the 2-minute tour × I want an auto updater that detect modified files (by comparing files on the client-side and a server) and only download modified files. I also want it to give me its status lively (To show it on a process bar or something) The scenario is that there's about one thousand clients in a network, that use same application. If a new version of the application is available, they all have to get the new version. But, the bandwidth is limited, so it's not very efficient to give them a full installer each time. (Which we do currently) I searched around a little, and I found IcePatch2. It do the exact thing I want: Getting the newest files from server when the patcher is run. But the problem is that clients wrote in C#, and I can't use IcePatch2 inside my application. (I have to run it as a separate process, or write a COM or something to interact with the IcePatch2Client) So far, the best solution I found is to get .NET Application Updater Component and customize it to fit my needs. But I prefer a solution that dose not require me to maintain another application. Any idea? share|improve this question You can post link, now) –  The_Smallest Dec 1 '10 at 11:45 Thanks! (^L^) I edit the question. –  Aidin Dec 1 '10 at 13:30 Fully running an updater inside your application doesn't work well. Windows locks the files of running programs so they can't be replaced. So you either need an outside patcher or a launcher which gets(almost) never patched. –  CodesInChaos Dec 1 '10 at 15:45 add comment 2 Answers We use wyBuild. It produces binary delta patches - even better than file-level. It also has a client auto-update component too: wyUpdate. share|improve this answer add comment We use AppLifeUpdate. You can create update packages that contain only the chnaged files. I'm not sure if it does binary deltas though. It is a .NET component and can optionally use a service that you install to do elevated installer updates (only really needed for changes affecting all users on a system). share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4323839/auto-patcher-efficient-auto-updater
dclm-gs1-103700001
false
false
{ "keywords": "delta" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.962153
<urn:uuid:f13bac25-7c6d-427a-bd8b-d041bf4a10ab>
en
0.761235
Take the 2-minute tour × Can anyone point me to any perl script to calculate relative entropy or mutual information from a set of data? share|improve this question add comment 1 Answer up vote 1 down vote accepted check cpan.org: e.g. Data::Password::Entropy or the Data::Entropy modules. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4327288/perl-script-to-calculate-relative-entropy-or-mutual-information
dclm-gs1-103710001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.956907
<urn:uuid:cbf24a45-db13-4dbf-9df9-c3af24e043ed>
en
0.822333
Take the 2-minute tour × I would to populate the database (MySQL) with some dummy entries as the application starts. I created: class DatabaseInitializer def populate_database in lib/database_initializer.rb. I understand that all files in the lib directory should have been loaded automatically. Question 1: Is there any command to see a list of all files that have been loaded ? Then, in controllers/main_controller.rb I have: require 'lib/database_initializer.rb' class MainController < ApplicationController def initialize def index But, I got the following error: LoadError in MainController#index no such file to load -- lib/database_initializer.rb Question 2: Why it cannot find database_initializer.rb ? Question 3: Is this "Rails enough" way to pre-populate a database ? Would you do this otherwise (put database_initializer.rb in other place, call DatabaseInitializer.new.populate_database from other place, e.t.c.) ? share|improve this question add comment 3 Answers up vote 3 down vote accepted Question 1 Question 2 # the 'lib' directory is already added to the load # path in the Rails initialization process, so simply: require 'database_initializer` Question 3 # db/seeds.rb c = Company.create! :name => 'ABC Inc.' p = Person.create! :name => 'Jeremy', :company => c $ rake db:seed share|improve this answer Thanks! This really helps. One more question: what is the difference between create! and create in your code ? –  Misha Moroshko Dec 9 '10 at 4:47 create! throws an exception if it fails whereas create just returns false. It's a common pattern in ActiveRecord however generally in ruby a bang_method! indicates that the method alters the receiver directly rather than returning a new object. See Array#reverse and Array#reverse! –  noodl Dec 9 '10 at 10:41 Thanks! Is it always recommended to use create! rather than create when creating records in database (I do want to know if something goes wrong) ? –  Misha Moroshko Dec 11 '10 at 4:38 add comment When requiring files from ruby you generally drop the file extension. Try require database_initializer. lib/ was briefly removed from the load path in rails-3 but I think it's back now. If not, see config.autoload_paths in config/application.rb. However, I think this is probably a bad idea in general. If you need to ensure that you always have a consistent and immutable set of data available to your app, why not just define it in ruby in a model? Also, there is already a mechanism for adding seed data in rails. See db/seeds.rb and the command rake db:seed share|improve this answer Thanks, I will definitely use db/seeds.rb from now! –  Misha Moroshko Dec 9 '10 at 4:47 add comment For any file in lib, you should only have to use: require 'database_initializer'. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4394646/why-require-cannot-find-a-file-in-ruby-on-rails-3-application
dclm-gs1-103720001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.686089
<urn:uuid:13f87607-ac0d-4618-855a-5156ee48d865>
en
0.743121
Take the 2-minute tour × var myObject = content.get_response().get_object(); However it just throws a "Microsoft JScript runtime error: Object doesn't support this property or method" when trying to invoke the Ajax POST. My code: public ActionResult Index(string message) <!DOCTYPE html> <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> <script type="text/javascript"> function JsonAdd_OnComplete(mycontext) { var myObject = mycontext.get_response().get_object(); @using(Ajax.BeginForm("Index", "Home", new AjaxOptions() { HttpMethod = "POST", OnComplete = "JsonAdd_OnComplete" })) Thanks in advance. share|improve this question I don't know ASP but are you sure that OnComplete = "JsonAdd_OnComplete" shouldn't maybe be OnComplete = JsonAdd_OnComplete ?? In other words, don't quote the function name ... –  Pointy Dec 27 '10 at 15:58 Yes, according to the documentation it should be "FunctionName". - I've tried OnComplete = JsonAdd_OnComplete too, however it just returns a compile error because its not a string. –  ebb Dec 27 '10 at 16:01 add comment 3 Answers up vote 3 down vote accepted AFAIK in ASP.NET MVC 3 RC MS AJAX has been deprecated in favor of jQuery which is used by all Ajax.* helper methods. Javascript has become unobtrusive as well. This means that you no longer have to call .get_response().get_object() but simply: function JsonAdd_OnComplete(myObject) { // here myObject is already the JSON object // as returned by the controller action share|improve this answer Actually, I gave that a shot when I wrote the code in my answer and it doesn't seem to work that way in the OnComplete method...assuming you use the old MicrosoftAjax methods :) –  BuildStarted Dec 27 '10 at 18:56 add comment Have you looked at the OnSuccess method? When that method is called the object passed to it is a JSON object based on a JSONResult so you could do this... <script type="text/javascript"> function JsonAdd_OnSuccess(mycontext) { new AjaxOptions() { HttpMethod = "POST", OnSuccess = "JsonAdd_OnSuccess" })) { In addition the OnComplete method returns an object that contains the following properties You'll have to eval() the responseText to convert the text to JSON though. share|improve this answer I was soo hoping that your answer would work, but I get the following error when I do the eval(): Uncaught SyntaxError: Unexpected token : –  Serj Sagan Mar 22 '13 at 22:04 @SerjSagan sounds like your json might be invalid. –  BuildStarted Mar 22 '13 at 22:42 The Json is being returned by the MVC Controller JsonResult with return Json(new { result = true, inputs = mylist.ToList() }); See my answer to see how I got it to work... –  Serj Sagan Mar 22 '13 at 22:49 add comment if you are using the method provided by BuildStarted, here's how to structure the eval: var json = eval("(" + context.responseText + ")"); share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4539853/asp-net-mvc3-bug-using-javascript
dclm-gs1-103730001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.406457
<urn:uuid:74c51afb-7a0f-4d4c-a92c-93b91c7af0a2>
en
0.913448
Take the 2-minute tour × In Access 2003 I was easily able to get to all the tables and edit/view data directly. However, in 2007, I'm unable to find this functionality. I have an MDB with a form, and I can only view the main table of user input data in the Datasheet View. I'm trying to copy a list of options (there's a lot of them) set to a Combo Box into another program, and it would be easier if I could just get to the Control Source table. share|improve this question add comment 1 Answer up vote 1 down vote accepted You should be able to see the access objects (tables, queries, macros, forms) in the Navigation Pane on the left side of the screen. It may be hidden in that .mdb, though. If you create a new .mdb and a couple of tables, can you see them? The UI's a little different and it takes some getting used to. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4660144/how-do-i-view-my-control-source-tables-in-access-2007
dclm-gs1-103740001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.039113
<urn:uuid:81b19c9d-cca6-4f2c-80c0-341079d9f088>
en
0.856422
Take the 2-minute tour × I want to know if this is possible in c# winform. create control when ever button is pressed and place it at given location. I think it is possible like this private TextBox txtBox = new TextBox(); private Button btnAdd = new Button(); private ListBox lstBox = new ListBox(); private CheckBox chkBox = new CheckBox(); private Label lblCount = new Label(); but the problem lies when ever button is pressed same name controls are created.How to avoid that What da........ i wrote and no exception i was expecting it because control already contains btnAdd instead as many button create as many you want. Accessing them will be issue but it will be solved by @drachenstern method correct? private void button1_Click_1(object sender, EventArgs e) Button btnAdd = new Button(); btnAdd.BackColor = Color.Gray; btnAdd.Text = "Add"; btnAdd.Location = new System.Drawing.Point(90, 25+i); btnAdd.Size = new System.Drawing.Size(50, 25); i = i + 10; share|improve this question add comment 3 Answers up vote 1 down vote accepted You could try the solution I posted here. It will dynamically create 5 buttons in the constructor. Just move the code to the button click event and it should add the buttons dynamically and register with the Click events. share|improve this answer add comment int currentNamingNumber = 0; txtBox.Name = "txtBox" + currentNamingNumber++; Rinse, Repeat. Gives each element a unique numeric name, allows you to find out how many elements have been created (notice that you don't want to decrement to track all created objects, because then you may create two elements with the same name). I don't think you can pass the name you want into the new function, but you can always set the name after creating it. share|improve this answer add comment It sounds like your looking for a List<TextBox>. share|improve this answer ok then later on can we treat it like real text box like all its properties events etc etc –  Afnan Bashir Jan 18 '11 at 0:51 idk, he's never setting the .Name property to anything unique... –  jcolebrand Jan 18 '11 at 0:52 @Afnan: It is a real textbox. –  SLaks Jan 18 '11 at 0:54 Good point friend –  Afnan Bashir Jan 18 '11 at 0:54 @Drach: The Name doesn't matter. –  SLaks Jan 18 '11 at 0:54 show 3 more comments Your Answer
http://stackoverflow.com/questions/4719476/create-controls-dynamically/4719499
dclm-gs1-103750001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.515809
<urn:uuid:b6db369d-399c-452e-bb04-52fc4e9a37ef>
en
0.919829
Take the 2-minute tour × I would like to be able to channel two text streams to a single console window with a vertical split view. The ideal solution would be if I could simply write to two different std::ostream objects. The reason I need it is to compare the output of two different versions of a program. I know there are simple workarounds like redirecting to file and using a diff program to view the differences. But that doesn't matter because this project is mostly just for fun. I'm not sure however how to achieve this. Suppose that the left half has writtten 20 lines of output ahead of the right half. How do I move the cursor up to write the right half? Can anyone give me some pointers on how to get started? Can this be done in pure C++ or do I need platform specific features? share|improve this question I think you would be better of saying "can the C++ language do this alone, or do I need a library of some kind". What exactly do you mean by a Platform? A version of a C++ Compiler? A library that ships with some particular compiler? –  Warren P Jan 28 '11 at 18:37 add comment 3 Answers up vote 6 down vote accepted This cannot be done using "pure c++" alone. You will need additional, potentially platform specific, libraries to implement the behavior you desire. For example, look at the ncurses library. share|improve this answer ncurses is a cross platform library, but as the question asks about if you can do this in C++ "only", perhaps the better way to say this is "you need a library of some kind, the C++ language itself doesn't provide console features, terminal emulation, and so on". –  Warren P Jan 28 '11 at 18:36 @Warren I've updated my answer –  Sam Miller Jan 28 '11 at 19:44 add comment You can probably find some open source code in the olde terminal apps for text chat which did the same with a horizontal split. Go back far enough and you will find usage of ansi escape sequences. Writing something new ncurses is probably the way to go. As an aside I reckon the diff/merge tool from tortoise is preatty good, from usage it really shows that simply putting code next to each other is probably not enough to make a useful eyeball comparison. You really get alot from the colourising and extra value add of the computer finding the differences for you. share|improve this answer add comment Jlib may help. A console library capable of colored input and output. Includes user definable menus, ASCII character windows, save/restore a screen worth of characters, 256 console color combinations, and a smart coloring. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4831569/how-to-create-split-screen-console-output?answertab=votes
dclm-gs1-103760001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.985833
<urn:uuid:5d319257-136a-46ca-b19c-1fb851770643>
en
0.93498
Take the 2-minute tour × I am a little confused by the definition of interarrival time, does it mean the time between two successfully sent packets? and by using opnet, I observed that the shorter the interarrival time is, the higher the network load, is that a correct conclusion? Thanks share|improve this question add comment 1 Answer up vote 1 down vote accepted In short: yes. Interarrival time is defined as the time between the "start" of two events. (So if you had a network capable of processing two packets at the exact same time, and two packets come in, the interarrival time between those two packets would be zero.) It sounds like you have some sort of monitoring utility measuring interarrival time. In that case, you should consult the documentation for the tool to see exactly what their definition is and how they calculate it. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4910693/network-load-and-interarrival-time
dclm-gs1-103770001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.989278
<urn:uuid:d750292e-c7e7-47cc-a289-e14191737f33>
en
0.76537
Take the 2-minute tour × I have a html snippet that looks like this (of course surrounded by other html): <p class="finfot3"><b>Header:</b></p> How can I get Text from this? I'm using simple_html_dom, but I can use something else if simple_html_dom can't do this. share|improve this question add comment 3 Answers up vote 3 down vote accepted This is untested, but you might be looking for simple_html_doms next_sibling() method. $html->find('p[class=finfot3]')->next_sibling()->innertext() should return the contents of the second <p> element. share|improve this answer next_sibling() did the trick. Thanks mate. –  Marwelln Feb 7 '11 at 11:47 add comment Find the p element with the class. Then use where $e is the element with the class. For better alternatives to SimpleHtmlDom, see Best Methods to parse HTML share|improve this answer add comment preg_match('~<p>(.*)</p>~', $html, $matches); share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/4920695/get-text-from-next-tag
dclm-gs1-103780001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.41072
<urn:uuid:d042c3d4-6d69-4c71-891b-d51cbf3c0f56>
en
0.901537
Take the 2-minute tour × Can anybody suggest a way to process the information and analyze the data from the comments users post on a article in my website. I exactly want to process the comments as follows: Example: Like on a article on computerization may get the following comments: 1. I love computerization as it makes the work easier. 2. Computerization is spreading unemployment as 1 computer can work better than 4 people. How i process this information - : I take the comments and try to recognize some predefined[and extensible] keywords in it. share|improve this question add comment 1 Answer up vote 1 down vote accepted Assuming that you are trying to extract some useful information from the comments, you could apply some machine learning to the comments to classify or categorize the data contained within, the sentiments etc. There are number of different types of learning you can do on the text, however I personally recommend using support vector machines or a naive bayes classifier to be able to categorize and analyze the comments. You could also possibly use clustering, but there needs to be an element of natural language processing in the solution you choose. There are number of different libraries that you can use to implement the code to use either, i.e. svmlight, javaml, etc. I have personally used javaml and it is a good library. share|improve this answer Thanks David.Can You suggest some resources to learn machine learning. –  Lokesh Sah Feb 14 '11 at 5:39 What type of resources would you prefer? Research articles, books, web sites, etc? I know of quite a few of all of them. –  davidstites Feb 14 '11 at 5:55 articles ,ebooks –  Lokesh Sah Feb 14 '11 at 9:41 Machine Learning, Introduction to machine learning - Ethem ALPAYDIN. Let me know if you need more, this is a fairly broad topic and definitely not something that can be easily answered on SO without a fair amount of work on your part. –  davidstites Feb 14 '11 at 19:25 show 3 more comments Your Answer
http://stackoverflow.com/questions/4988929/how-to-analyze-information-from-the-comments-of-users-on-my-site/4988974
dclm-gs1-103790001
false
false
{ "keywords": "vector" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.070778
<urn:uuid:cb9ae084-0d87-4773-8c7f-38f7dbe41f52>
en
0.885713
Take the 2-minute tour × I have a shell-like console for my app, which prompts with ">>>" after every command. The problem is every time I have my shell WriteText(">>> "), it also appends a new line. The user can backspace up to the correct line, but this just looks terrible. Any way to fix it? share|improve this question Forgot to mention, this is a wxpython TextCtrl.WriteText() operation –  Shaunak Mar 5 '11 at 1:15 (Something somewhere is adding a newline... find out where it is :p) –  user166390 Mar 5 '11 at 3:53 Tried it. Yes really awful. Got no solution for it –  joaquin Mar 5 '11 at 10:23 add some minimal code demonstrating the problem –  Anurag Uniyal Mar 6 '11 at 4:10 add comment 1 Answer up vote 4 down vote accepted I suspect you are declaring your TextCtrl to be of style wx.TE_PROCESS_ENTER and then binding the EVT_TEXT_ENTER event - only because I ran into the same problem when I tried that. My first instinct was to write a method to process wx.EVT_TEXT_ENTER that would then use the TextCtrl:Remove() method. This method only seems to remove visible characters, unfortunately. My next thought was to use the EmulateKeyPress() method along with backspace (WKX_BACK) to erase the newline character. This might be doable though I couldn't come up with a good way to spoof a wx.KeyEvent (can't just use event.m_keyCode since EVT_TEXT_ENTER sends a CommandEvent, and not a KeyEvent) so I gave up on that approach... err, I mean this solution is left as an exercise to the reader. wx.EVT_TEXT_ENTER being a CommandEvent finally led to a third angle which did work. Instead of binding wx.EVT_TEXT_ENTER, I bound wx.EVT_CHAR and put in logic with special processing for the Return key (ASCII key code 13). I then planned to implement the EmulateKeyPress() bit I talked about earlier but when I removed wx.TE_PROCESS_ENTER from the TextCtrl style, I discovered that the \n was no longer being surreptitiously added. Code follows: import wx class TestRun(wx.Frame): def __init__(self,parent): wx.Frame.__init__(self, parent, title="StackO Test", size=(400,400)) self.control = wx.TextCtrl(self, id=wx.ID_ANY, style=wx.TE_MULTILINE) self.control.Bind(wx.EVT_CHAR, self.OnPress) def OnPress(self, event): if event.GetKeyCode() == 13: if __name__ == '__main__': app = wx.App(False) The event.Skip() line is crucial; during my research into this, I learned that a KeyEvent is usually followed by a CharEvent. The CharEvent is the part where the character is written to the TextCtrl. When you intercept the KeyEvent, the CharEvent is only called if you do so explicitly - event.skip() is therefore vital if you want your TextCtrl to otherwise behave as normal. Without it, any keyboard input not equal to ASCII keycode 13 would do nothing. From my tests, it appears that there is something about declaring the TextCtrl to have style wx.TE_PROCESS_ENTER that makes it print a newline after each call to WriteText(). My way gets around this though you will have more work to do with regard to making sure the insertion point is always in the right place, etc. Best of luck! share|improve this answer Yea figured this out after a little tinkering, but great answer. –  Shaunak Mar 25 '11 at 18:17 add comment Your Answer
http://stackoverflow.com/questions/5200961/preventing-newline-after-wxpython-textctrl-writetext
dclm-gs1-103820001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.192922
<urn:uuid:3cd60758-1be4-4a66-9fec-fe31a72fe897>
en
0.912729
Take the 2-minute tour × I want to do message embedding in audio/video files using Python. Does anyone have information about some libraries I can use for bit manipulation in audio/video ? share|improve this question add comment 2 Answers There is a list of audio-related modules on the python website (as well as this list), and there are other questions dealing with video here, here and here. From looking further into it, GStreamer appears to have support for both audio and video editing, and also seems quite favored. Also, if you're interested in steganography in images as well, there is the Python Imaging Library. share|improve this answer add comment I read a article on it describes message embedding in audio/video files . share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/5258402/steganography-on-audio-video-with-python?answertab=oldest
dclm-gs1-103830001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.719561
<urn:uuid:8bca48ec-d6dd-486f-9970-329363d02fb2>
en
0.900647
Take the 2-minute tour × def different(s): x = len(s) for i in range(1, 1 << x): u.append([s[j] for j in range(x) if (i & (1 << j))]) It takes a list and makes different combinations (a,b,c) = ((a,b,c),(a,b),(a,c) etc..) But what does the range do? From 1 to what. I don't understand the "<<" and also, if (i & (1 << j)) what does this do? it checks if i and 2 to the power of j?? doesn't make any sense to me :/ share|improve this question Lots of people put effort into helping you out. Deleting this question would result in them losing rep. If your issue is solved by some other means, leave an answer with your solution and select it when the option becomes available. Helps people who have similar issues and doesn't penalize those that tried to help. (also fixed some stuff you were concerned about) –  Will Apr 11 '11 at 12:36 add comment 2 Answers up vote 4 down vote accepted The range function returns a list of numbers from zero to the given number minus one. It also has two- and three-argument forms (see the doc for more info): range(n) == [0, 1, 2, ..., n - 1] << is the left-shift operator, and has the effect of multiplying the left hand side by two to the power of the right hand side: x << n == x * 2**n Thus the above range function (range(1, 1 << x)) returns [1, 2, 3, ..., 2**x - 1]. In the seconds usage of <<, the left-shift is being used as a bit-mask. It moves the 1-bit into the j-th bit, and performs a bit-wise and with i, so the result will be non-zero (and pass the if test) if and only if the j-th bit of i is set. For example: j = 4 1 << j = 0b1000 (binary notation) i = 41 = 0b101001 i & (1 << j) = 0b101001 & 0b001000 = 0b001000 (non-zero, the if-test passes) i = 38 = 0b100110 i & (1 << j) = 0b100110 & 0b001000 = 0b000000 (zero, the if-test fails) In short, x & (1 << y) is non-zero iff the y-th bit of x is set. share|improve this answer add comment << is the binary left shift operator. 1 << x is a way of saying two to the power of x. share|improve this answer so it's the same as 2**x? –  nils Mar 22 '11 at 8:45 @nils: Yes, pretty much. –  icktoofay Mar 22 '11 at 8:52 @nils, yes, but 3 << 10 is twice as fast as 3 * 2 ** 10 –  eumiro Mar 22 '11 at 9:10 @nils: "so it's the same as 2**x?"? Please actually try the code. Please run an experiment. Please execute it interactively at the Python >>> prompt. You can prove they're the same all by yourself. –  S.Lott Mar 22 '11 at 9:53 add comment Your Answer
http://stackoverflow.com/questions/5388639/please-help-me-understand-a-bit-shift-operation
dclm-gs1-103860001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.971239
<urn:uuid:82f99b69-e1cb-491d-8810-3a6818e3848b>
en
0.893581
Take the 2-minute tour × the same as: share|improve this question add comment 4 Answers up vote 13 down vote accepted No, they're not exactly the same. They'll both return the element's ID, but if the element has no ID, then this.id will return a blank string while $(this).attr("id") will return undefined. share|improve this answer add comment Almost (see Jeff's answer). jQuery abstracts away attribute getting, but it isn't always the most terse option. It is however shorter than getAttribute('id'). share|improve this answer add comment Same result, but this.id is much faster as it doesn't require all the jQuery stuff around it. You will also get different results if that item doesn't have an id. share|improve this answer add comment Exactly the same, it'll get the element's ID... honestly don't know what more I can say here for a more in-depth answer. share|improve this answer Thanks thedixon! I appreciate you trying to help out. Q: How are you monitoring jQuery questions? Is it through email or some other method? The reason why I ask is because I currently don't monitor any tags but have been thinking about doing so. –  Phillip Apr 8 '11 at 15:52 Hi there - I currently monitor tags by adding to my favorite tags and then just refreshing the newest questions ever now and again, the jQuery ones pop up in orange so are easy to spot :) –  Chris Dixon Apr 8 '11 at 15:59 They aren't exactly the same, see Jeff's answer for why. –  Bala Clark Jan 23 '13 at 10:27 add comment Your Answer
http://stackoverflow.com/questions/5597317/this-id-vs-this-attrid
dclm-gs1-103890001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.542531
<urn:uuid:4f905f53-e81b-4b1a-acde-6a062fc09a98>
en
0.856764
Take the 2-minute tour × Has anyone ever successfully integrated django-math-captcha into django-registration? I've changed the form in django-registration to be as such: class RegistrationForm(MathCaptchaForm) The form displays just fine, and it recognizes when I input anything other than numbers. However, it does not flag wrong answers. For example I input 2+1 = 6 and my registration completed just fine. Any ideas? share|improve this question add comment 1 Answer up vote 2 down vote accepted To answer my own question, it is because MathCaptchaForm.clean() was being overridden by RegistrationForm.clean(). I called super() from within RegistrationForm.clean() and it worked. New code within RegistrationForm.clean(): def clean(self): super(RegistrationForm, self).clean() if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data: if self.cleaned_data['password1'] != self.cleaned_data['password2']: raise forms.ValidationError(_("The two password fields didn't match.")) return self.cleaned_data share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/5651606/django-registration-with-django-math-captcha
dclm-gs1-103900001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.631714
<urn:uuid:eceefc33-dc71-49ae-978a-e3b87219568a>
en
0.831783
Take the 2-minute tour × I have a Rails 3 application on Ruby 1.9.2 in which users enter business hours and they are stored in a MySQL database. When a user does this, however, the entered time "8:00 AM" gets stored as 3pm in the database. I want it to be stored as they entered it, regardless of time zone. I figured the best way to do this is to set everything to UTC and have it ignore my time zone (Arizona), but Rails seems to be ignoring my setting. Example: Time.zone = 'UTC' mon_open_date = Time.parse(params[:venue][:mon_open_at]) rescue nil # => 2011-04-27 08:00:00 -0700 The result in MySQL: | mon_open_at | | 15:00:00 | 1 row in set (0.00 sec) Any ideas? share|improve this question add comment 2 Answers up vote 4 down vote accepted Time.parse always parses the string into your computer's local timezone. You need to use Time.zone.parse in order to parse it as the specified timezone, UTC. share|improve this answer That did the trick, thanks! –  huertanix Apr 27 '11 at 12:09 add comment MySQL always uses the server's time zone setting, by default (though you can change that, if you are the database admin). If you store your date/time values in TIMESTAMP columns, they are stored in a time-zone agnostic manner (being converted to UTC for storage, and then back to the server's time zone again for usage). If you store your date/times in a DATETIME column, the values are stored exactly as you enter them - if you change the server's time zone, and then SELECT old values out of a DATETIME column, you will see exactly the same values as when you entered them. Check out the documentation on DATETIME/TIMESTAMP columns for the finer points. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/5802913/how-do-i-set-time-zone-to-utc-and-keep-it-that-way?answertab=oldest
dclm-gs1-103920001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.600831
<urn:uuid:8cd98596-dc48-414a-9a3b-b929b7892e55>
en
0.85777
Take the 2-minute tour × I would like to modify the spinner pop up dialog . I would like to implement my own custom spinner pop up. Is it possible or not ? Can anyone provide me solution to implement custom spinner pop up ? This is an effort of uniformity for my various pop ups in my application. share|improve this question add comment 1 Answer up vote 2 down vote accepted see this here is the simple example which gives you the idea how to build custom spinner... share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/6314411/custom-spinner-pop-up
dclm-gs1-103970001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.986213
<urn:uuid:2ac985c0-6395-4449-b0ba-4bfbed9c0ac2>
en
0.923454
Take the 2-minute tour × Unlike (most) RISC arch, x86 instructions have different length. The start/end of an instruction don't have to align. so if the compiler don't care, they will generate some instructions which just lying across the page margin. Assume that if the head of an instruction start from the last byte of a page: PAGE-1, which is marked as executable. and the rest of the instruction is in the second page: PAGE-2, which is marked as forbid to execute. In such case, what will hardware do? Does compiler need to care such cases? share|improve this question Upvoted unexplained downvote. –  EJP Jul 12 '11 at 8:24 add comment 1 Answer up vote 4 down vote accepted Hardware will (should, haven't tested) generate a GPF. Compiler shouldn't care. share|improve this answer I seem to recall a bug relating to that with early iapx286 chips in protected mode. Either it would fail to GPF on an instruction going over a boundary, or would erroneously GPF on an instruction that should just fit inside. Can't recall at the moment... #trivia :-) –  Brian Knoblauch Jul 12 '11 at 17:59 add comment Your Answer
http://stackoverflow.com/questions/6659998/how-does-hardware-and-compiler-deal-with-x86-instruction-which-happend-to-be-acr
dclm-gs1-104000001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.899682
<urn:uuid:e3742da5-8563-444b-95ba-412099be126d>
en
0.811672
Take the 2-minute tour × Any way to have a NSButton title to wrap when it's width is longer than the button width, instead of getting clipped? I'm trying to have a radio button with a text that can be long and have multiple lines. One way I thought about having it work is to have an NSButton of type NSRadioButton but can't get multiple lines of text to work. Maybe my best alternative is to have an NSButton followed by an NSTextView with the mouseDown delegate function on it triggering the NSButton state? share|improve this question Read the Apple Human Interface Guidelines, they should give some insight as to how to deal with the need for descriptive choices. –  dreamlax Mar 23 '09 at 23:07 add comment 3 Answers up vote 7 down vote accepted I don't believe you can. You'd have to subclass NSButtonCell to add support for this. That said, it's typically a bad idea to have multiple lines of text on a button. A button label should concisely represent the action performed: The label on a push button should be a verb or verb phrase that describes the action it performs—Save, Close, Print, Delete, Change Password, and so on. If a push button acts on a single setting, label the button as specifically as possible; “Choose Picture…,” for example, is more helpful than “Choose…” Because buttons initiate an immediate action, it shouldn’t be necessary to use “now” (Scan Now, for example) in the label. What are you trying to do? share|improve this answer add comment I'm with Sören; If you need a longer description, think about using a tool tip or placing descriptive text in a wrapped text field using the small system font below the radio choices if the descriptive text is only a few lines. Otherwise, you could provide more information in a help document. Figuring out a way to say what you need to say in a concise way is your best bet, though. share|improve this answer I absolutely need to show the associated text with each radio button option "as is", each is a possible answer to a question shown on top, all coming from db and resuming is not an option. I ended up adding a wrapped text view on the right of each radio button and controlling the height dynamically. –  Carlos Barbosa Mar 24 '09 at 20:50 Ah, context. That makes a lot more sense! –  Wevah Apr 21 '09 at 20:48 add comment Well here's my excuse for needing multiline buttons: I'm writing an emulator for an IBM 701, complete with front panel, and, bless their hearts, the designers of that front panel used multi-line labels. Here's my code. You only have to subclass NSButtonCell (not NSButton), and only one method needs to be overridden. // In Xcode 4.6 (don't know about earlier versions): Place NSButton, then double-click it // and change class NSButtonCell to ButtonMultiLineCell. @interface ButtonMultiLineCell : NSButtonCell @implementation ButtonMultiLineCell NSAttributedString *as = [[NSAttributedString alloc] initWithString:[title.string stringByReplacingOccurrencesOfString:@" " withString:@"\n"]]; NSFont *sysFont = [NSFont systemFontOfSize:10]; NSMutableParagraphStyle *paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; [paragraphStyle setAlignment:NSCenterTextAlignment]; NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: sysFont, NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, NSSize textSize = [as.string sizeWithAttributes:attributes]; NSRect textBounds = NSMakeRect(0, 0, textSize.width, textSize.height); // using frame argument seems to produce text in wrong place NSRect f = NSMakeRect(0, (controlView.frame.size.height - textSize.height) / 2, controlView.frame.size.width, textSize.height); [as.string drawInRect:f withAttributes:attributes]; return textBounds; // not sure what rectangle to return or what is done with it share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/671136/wrap-nsbutton-title
dclm-gs1-104010001
false
false
{ "keywords": "mouse" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.231635
<urn:uuid:681376ab-75e3-4de5-acc0-15c177171465>
en
0.786798
Take the 2-minute tour × I am writing a program in c#. I need to know if there an option to open an URL of a site and look for keywords in the text. For example if my program gets the URL http://www.google.com and the keyword "gmail" it will return true. So for conclusion i need to know if there a way to go to URL download the HTML file convert it to text so i could look for my keyword. share|improve this question add comment 4 Answers up vote 1 down vote accepted You should be able to open the HTML file as-is. HTML files are plaintext, meaning that FileStream and StreamReader should be sufficient to read the file. If you really want the file to be a .txt, you can simply save the file as filename.txt instead of filename.html when you download it. share|improve this answer I think his problem is actualy downloading the page not converting it to text. Is there such function to do so? –  atoMerz Aug 18 '11 at 17:36 and how can i download the html using url ? –  yoni2 Aug 18 '11 at 17:39 @yoni2: Take a look at this: stackoverflow.com/questions/599275/… –  asfallows Aug 18 '11 at 19:54 add comment It sounds like you want to remove all the HTML tags and then search the resulting text. My first reaction was to use a Regular Expression: String result = Regex.Replace(htmlDocument, @"<[^>]*>", String.Empty); Shamelessly stole this from: Using C# regular expressions to remove HTML tags Which suggests the HTML Agility Pack which sounds exactly like what you're looking for. share|improve this answer i am looking to know if there a way to download an html file and convert it to txt file –  yoni2 Aug 18 '11 at 17:37 add comment In visual basic this works: Imports System Imports System.IO Imports System.Net Function MakeRequest(ByVal url As String) As String Dim request As WebRequest = WebRequest.Create(url) ' If required by the server, set the credentials. ' request.Credentials = CredentialCache.DefaultCredentials ' Get the response. ' Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse) ' Get the stream containing content returned by the server. ' Dim dataStream As Stream = response.GetResponseStream() ' Open the stream using a StreamReader for easy access. ' Dim reader As New StreamReader(dataStream) Dim text As String = reader.ReadToEnd Return text End Function Edit: For future reference for others that find this page, you pass in a URL, and this function will go to the page, read all the html text, and return it as a text string. then all you have to do is parse it (search for text in the file) or you could use a stream writer to save it to a text or html file if you wanted to. share|improve this answer add comment Do not use regular expressions for parsing html, as html is fairly complex for regular expresions. Check out ling discussion on SO for this RegEx match open tags except XHTML self-contained tags Use instead already implemented HTML parsers for this purpose. Here is another discussion on SO where you can find a links you need Looking for C# HTML parser Search also on internet by yourself. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7111544/download-html-file-and-convert-it-to-txt/7111630
dclm-gs1-104030001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.398623
<urn:uuid:82bfaea0-2b12-40aa-880a-89d8f1070e10>
en
0.886292
Take the 2-minute tour × I just spent 2 hours hunting a bug which apparently comes from a foreach iteration with &value. I have a multidimentional array and when a ran this: foreach($arrayOfJsonMods as &$item){ //TODO memcached votes and PHP returned an array with the same element count, BUT with a DUPLICATE last record. Is there something i don't understand about this structure? I ran the code on a different machine, and the result was the same. share|improve this question show us your code –  Jacek Kaniuk Aug 23 '11 at 9:19 This shouldn't happen, can you provide some example? –  XzKto Aug 23 '11 at 9:20 add comment 1 Answer up vote 12 down vote accepted I'll guess that you're reusing &$item here and that you're stumbling across a behavior which has been reported as bug a thousand times but is the correct behavior of references, which is why the manual advises: Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). foreach($arrayOfJsonMods as &$item) //TODO memcached votes See https://bugs.php.net/bug.php?id=29992 share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7158741/why-php-iteration-by-reference-returns-a-duplicate-last-record
dclm-gs1-104040001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.204376
<urn:uuid:ae9c3607-5377-4e0c-937d-cddd9604a12e>
en
0.908794
Take the 2-minute tour × What I want to achieve is to make links on my site move 1px down when they are in an active state (user clicks on them) I am doing this by applying this global style: a:active { And it of course works - in most cases. Problem is when I try to do the same on links that are positioned absolutely. Since the above style will change their position to relative and thus return them to to document flow, distorting the layout, so I have applied this style for them: #absolutly-positioned-link:active { /*and here I state their current position - 1px*/ Now instead of moving the element a pixel down, from some reason this sends it to the top of the wrapper element. Here is a simple demo of what happens -> http://jsfiddle.net/Husar/ns5L7/ In the fiddle I have both examples, as you can see, the header links works just fine, but clicking the prev/next links at the bottom just launches them to the top. The only solution I found so far is that instead of the global a:active style I explicitly state which links are not absolutly positioned (ie something like a long nav a:active, p a:active, h2 a:active, li a:active selector), and than apply the styles for the absolutely positioned elements by just changing their coordinates, without stating in the :active selector that they are absolutely positioned. Simplified, this fiddle demonstrates it -> http://jsfiddle.net/Husar/HfvCs/ This works fine, however I don't think it to be the most elegant solution nor do I understand why this behavior is occurring. If anyone knows something more about this issue and how it can be solved, help will surly be appreciated. share|improve this question add comment 1 Answer up vote 3 down vote accepted The problem is that you override the position: absolute; with your position: relative; so the positioning is totally screwed :P I usually use margin as a work-around. But of course this only works if your element is not supposed to have any other top margin... a:active { share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7234351/position-absolute-on-active-is-behaving-weird
dclm-gs1-104050001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.085748
<urn:uuid:a4604479-9de8-4708-a53b-9c8883a44671>
en
0.816592
Take the 2-minute tour × I have a 5MB xml file I'm using the following code to get all nodeValue $dom = new DomDocument('1.0', 'UTF-8'); $games = $dom->getElementsByTagName("game"); foreach($games as $game) This takes 76 seconds and there are around 2000 games tag. Is there any optimization or other solution to get the data? share|improve this question I can't imagine optimizing a loop without knowing what the loop does. –  Herbert Sep 4 '11 at 15:15 look this link [enter link description here][1] [1]: stackoverflow.com/questions/188414/best-xml-parser-for-php –  steve Sep 4 '11 at 15:15 @steve: maybe you can elaborate and put that in the form of an answer. How can SimpleXML speed up the loop to get at the data? –  Herbert Sep 4 '11 at 15:18 You can find some useful suggestion in this [link][1] [1]: stackoverflow.com/questions/188414/best-xml-parser-for-php –  monish Sep 4 '11 at 15:19 The loop is empty... –  run Sep 4 '11 at 15:19 show 1 more comment 2 Answers up vote 0 down vote accepted You shouldn't use the Document Object Model on large XML files, it is intended for human readable documents, not big datasets! If you want fast access you should use XMLReader or SimpleXML. XMLReader is ideal for parsing whole documents, and SimpleXML has a nice XPath function for retreiving data quickly. For XMLReader you can use the following code: // Parsing a large document with XMLReader with Expand - DOM/DOMXpath $reader = new XMLReader(); while ($reader->read()) { switch ($reader->nodeType) { case (XMLREADER::ELEMENT): if ($reader->localName == "game") { $node = $reader->expand(); $dom = new DomDocument(); $n = $dom->importNode($node,true); $xp = new DomXpath($dom); $res = $xp->query("/game/title"); // this is an example echo $res->item(0)->nodeValue; The above will output all game titles (assuming you have /game/title XML structure). For SimpleXML you can use: $xml = file_get_contents($url); $sxml = new SimpleXML($xml); $games = $sxml->xpath('/game'); // returns an array of SXML nodes foreach ($games as $game) print $game->nodeValue; share|improve this answer Thanks for your help. I have two questions what is the slash before the games. and How can I get the string in this element: object(SimpleXMLElement)[8991] string 'Handball' (length=8), I want the handball –  run Sep 4 '11 at 17:30 No probs... The slash in /game shows the root of the document. This is how XPath works (Google XPath for more info). In order to answer your second question I would need to see an example of the XML you are using. If you edit your question and paste it in, I can see it. –  AlexW Sep 4 '11 at 21:16 SimpleXML also loads the whole file, which brings absolutely no speed improvements. DOM itself has XPath support, too. –  cweiske Sep 5 '11 at 9:15 @cweiske - Did you not notice I suggested XMLReader first? This is faster. To OP: Please read through these pages for everything you need to know about PHP and XML ibm.com/developerworks/xml/library/x-xmlphp1/index.html –  AlexW Sep 5 '11 at 13:22 add comment I once wrote a blog article about loading huge XML files with XMLReader - you probably can use some of it. Using DOM or SimpleXML is no option, since both load the whole document into memory. share|improve this answer SimpleXml is quite good, I tested on an xml file, the DOM took around 30sec and the SimpleXML took 1sec:) –  run Sep 5 '11 at 11:01 SimpleXML has proved perfectly useful for OP and DOM is too slow - exactly as I suggested. XMLReader is the fastest along with SAX. –  AlexW Sep 5 '11 at 13:23 add comment Your Answer
http://stackoverflow.com/questions/7299957/xml-domdocument-optimization
dclm-gs1-104060001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.573562
<urn:uuid:3a8d7fef-8491-4b31-9ca2-5abdcff1a0c0>
en
0.861642
Take the 2-minute tour × Here's my problem. If I run the test using the ruby command the tests all pass. However, if I use the rake test:functionals they all fail with the error below. I'm not sure what I have to do differently to get them to pass when using the rake task, but I'd greatly appreciate any guidance you might offer. class TasksControllerTest < ActionController::TestCase set_fixture_class :Action => 'Task' fixtures :Action setup :initialize_test test "the truth" do assert true def initialize_test @user = users :one sign_in @user @task = Action :one # Here's the line that is throwing the error. 1) Error: FixtureClassNotFound: No class attached to find. test/functional/tasks_controller_test.rb:20:in `initialize_test' share|improve this question If I understand correctly, you have a Task model whose table name is Action. This means you should have app/models/task.rb and test/fixtures/Action.yml (or csv). Did I get that right? –  Benoit Garret Sep 22 '11 at 14:39 add comment 3 Answers This is a very strange way of handling the problem. With rails, out of the box, if you have fixtures, they will load them before each test. You don't need to explicity load them in the controller test. share|improve this answer That's only true if your models map directly to the tables. This is required because I am using a legacy database. So my problem still remains. :( –  Altonymous Sep 26 '11 at 0:44 add comment up vote 0 down vote accepted It looks like no one is able to solve this problem. So I'm simply closing it at this point. Perhaps I'll switch over to Factory_Girl or Machinist. share|improve this answer add comment The error suggests that Rails can't figure out what fixture to load for the test. I assume the fixture is named Action.yml. Does Rails accept fixture filenames that have uppercase letters? Per the documentation at http://apidock.com/rails/ActiveRecord/TestFixtures/ClassMethods/set_fixture_class, the set_fixture_class is expecting a classname rather than a string. So I would try: set_fixture_class :myaction => Task And I'd rename the fixture file to myaction.yml share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7441171/fixtureclassnotfound-no-class-attached-to-find
dclm-gs1-104090001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.250373
<urn:uuid:ed63b236-44f6-4e78-bbaa-117e8834a2ca>
en
0.914847
Take the 2-minute tour × Can I install Cern's ROOT on win32 without MSVS but with mingw32? I want to develop some C/C++ programs, which will use ROOT. share|improve this question add comment 1 Answer up vote 0 down vote accepted As far as I know, compiling with mingw32 is currently not supported. I guess it would technically be possible, as mingw32 is based on gcc, but it would be a lot of work. The best way seems to be to use MSVC++ (even the free express version will do). ROOT builder is a nice tool that uses mingw32 (but the MS compiler) and builds ROOT for you, without the need for the command line. Another option would be to use cygwin, but that is also unsupported, and it's probably slower, because it introduces a layer of indirection to convert posix calls to windows. Here are some links to further information: share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7520088/using-root-cern-with-mingw32
dclm-gs1-104100001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.172032
<urn:uuid:b2a3f0e7-7b55-41d7-a0a6-1ef7920108ab>
en
0.891024
Take the 2-minute tour × I've just bough VPS account for testing and development. Is there a function of PHP to parse Apache config file, PHP config, FTP Server config, zone files, etc? Also a way to insert data into config file. I want to create a simple Control Panel to add ftp accounts and web account (with domain). If you have done it before - how did you do it? It would be quite challenging to learn share|improve this question Is parse_ini_file() the function you are looking for? –  Pete171 Sep 26 '11 at 8:34 add comment 3 Answers up vote 2 down vote accepted No, PHP has no functions to parse the config files of those programs - you'll have to write a custom parser for most of those formats. However, for php.ini you might be able to use PHP's ini functions. Most webhosting control panels either create the whole config file based on their database - i.e. they never read it but only (over)write it or they require you to include (apache and bind support that for example, for PHP you can use php_admin_value in the apache virtualhosts) their generated file - which is also never read by the tool. If you really want to create a tool that actually modifies existing files, don't forget that you cannot simply skip comments as nobody would want an application to rewrite his config file stripping all comments. share|improve this answer thanks for answer. You say "create the whole config file based on their database" - That is interesting and I didnt know that can be done.. Where I can look into this more details? Thanks. –  I'll-Be-Back Sep 26 '11 at 9:16 It means simply writing the whole config file. Some applications can take config data directly from a DB though (some ftp servers for example) –  ThiefMaster Sep 26 '11 at 9:20 Ahh I understood what you meant now.. cool idea. Thanks! –  I'll-Be-Back Sep 26 '11 at 9:26 add comment You may be able to use the follow pear library to parse apache config files: Parsing a php.ini file, depending on what you want to do, is probably best done with ini_get share|improve this answer add comment I'm not aware of such functions and I highly doubt they exist for the simple reason that there are just too many HTTP / FTP / SMTP / ... server implementations. Control panels like cPanel, WebMin and others usually do the heavy lifting for you and some even provide an API to automatize things from PHP. For the PHP configuration the following functions will probably do the trick: Bare in mind however that not all PHP configuration directives can be changed with ini_set(). share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/7552485/how-to-parse-apache-config-file-php-config-ftp-server-config
dclm-gs1-104110001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.055407
<urn:uuid:b064d4f7-49b9-4ba7-a6e3-7403c7c52c35>
en
0.897965
Take the 2-minute tour × I've been trying to practice testing my modules by adding if __name__ == '__main__': to the end of the module. The idea is to run the module as a script, and get an output and able to import it from another script or an interactive python session. I'm using Python 2.6.6 here's the whole code class Prac: This module is a practice in creating a main within a module. def Fun(self): print "testing function call" if __name__ == ' __main__': Thanks ! wbg share|improve this question thanks Ignacio....duh...forgot to instantiate the object. Will try again and post –  wbg Oct 2 '11 at 3:24 what exactly is the qeustion this time? –  Foo Bah Oct 2 '11 at 3:47 Ok, it looks like you have working code... did you have a question to go with that? –  Jeff Mercado Oct 2 '11 at 3:54 I was confusing import of the file containing the class object and the obj themselves...Now I can get good output from interactive python, but the main is not working calling from bash $. –  wbg Oct 2 '11 at 4:01 There seems to be more missing from this than just the question itself. You go on to talk about issues you were having in the interactive session with the TypeError when trying to call the module as a callable. What is your entire process that you are leaving out of this post? –  jdi Oct 2 '11 at 5:13 show 1 more comment 1 Answer That isn't a function, it's a method. You need to call the method off an object. p = Prac() Read this. share|improve this answer I tried calling the method from an interactive session, but got TypeError: 'module' object is not callable –  wbg Oct 2 '11 at 3:42 add comment Your Answer
http://stackoverflow.com/questions/7624372/python-novice-class-object-prac-and-main?answertab=active
dclm-gs1-104120001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.044269
<urn:uuid:396d1d36-970d-4b38-a722-f935e248f7c5>
en
0.826089
Take the 2-minute tour × I have two tables with a join table between them: Parent: Pages Child: Things Join: Grids In my models they are set up with a many to many relationship (has_many through): class Page < ActiveRecord::Base belongs_to :books has_many :grids has_many :things, :through => :grids class Thing < ActiveRecord::Base has_many :grids has_many :pages, :through => :grids class Grid < ActiveRecord::Base belongs_to :page belongs_to :thing Now I want to be able to sort "things" using an ordering id from grid, called number, how can I do that ? share|improve this question your definition of the Thing model is missing –  Tilo Oct 8 '11 at 13:13 Apologies.. it's the relationship between page and things, not the book, I fixed it in the original post : ) –  jakobk Oct 8 '11 at 14:43 add comment 1 Answer up vote 2 down vote accepted you need the ":include(s)" option in your find method, and then "order_by()" ... you would use something like this: Thing.where(...some condition or all..., :include => :grid ).order_by(grid.number) share|improve this answer Should that be has_many :pages, :through => :things? –  mliebelt Oct 8 '11 at 14:16 And is that ...order_by(grid.number) valid? What is that grid in that context? Should it be ...order_by('grid.number')? –  mliebelt Oct 8 '11 at 14:21 Thanks! - It worked except it's ".order(grids.number)" Also great links, just what I've been looking for .. –  jakobk Oct 8 '11 at 14:42 add comment Your Answer
http://stackoverflow.com/questions/7696985/how-to-order-by-using-has-many-through
dclm-gs1-104140001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.469267
<urn:uuid:5ba90c38-0274-432b-b52b-b4a81e1c4d60>
en
0.81713
Take the 2-minute tour × I am creating a search using MySQL & PHP on an existing table structure. Multiple search keywords can be entered and the user can opt to either match ALL or ANY. The any form is not too difficult, but i am breaking my head on writing an efficient solution for the AND form. The following is about the AND form, so all the search keywords must be found. The 2 tables i have to work with (search in) have a structure as follows: Table1 - item_id (non-unique) - text Table2 - item_id (unique) - text_a - text_b - text_c (The real solution will also have a 3rd table, but that is structure the same way as Table1. Table2 will have around 20 searchable columns) Table1 can have multiple rows for each item_id with different text. Consider having only 2 search keywords (can be more in real live), then both must exist in: - both in a single row/column or: - in 2 different columns of maybe different tables. or: - in 2 different rows with the same item_id (in case of both keywords found in different rows of Table1) All i could come up with are very intensive sub-queries but that would bring the server down or the response times would be huge. As i am using PHP i could use intermediate queries and store the results for use in a later final query. Anyone some good suggestions? Edit: There where requests for real examples, so here it goes. Consider the following 2 tables with data: Table 1 | item_id | t1_text_a | t1_text_b | t1_text_c | t1_text_d | | 1 | aaa bbb | NULL | ccc | ddd | | 2 | aaa ccc | ddd | fff | ggg | | 3 | bbb | NULL | NULL | NULL | | item_id | sequence | t2_text | | 1 | 1 | kkk lll | | 2 | 1 | kkk | | 2 | 2 | lll | | 3 | 1 | mmm | PS In the real database (which i can not change, so full text indexes or changes to table definition are not an option) Table1 has about 20 searchable columns and there are 2 tables like Table2. This should not make a difference to the solution, although it is something to consider from a performance perspective. Example searches: Keywords: aaa bbb Should return: - item_id=1. Both keywords are found in column t1_text_a. Keywords: ccc ddd Should return: - item_id=1. "ccc" is found in t1_text_c, "ddd" is found in t1_text_d. - item_id=2. "ccc" is found in t1_text_a, "ddd" is found in t1_text_b. Keywords: kkk lll Should return: - item_id=1. Both keywords found in a single row of Table2 in column t2_text. - item_id=2. Both keywords found in Table2, but in separate rows with the same item_id. Keywords: bbb mmm Should return: - item_id=3. "bbb" is found in table1.t1_text_a, "mmm" is found in table2.t2_text. My progress so far I actually, for now, gave up on trying to catch this in mostly SQL. What i did do is to create a query for each table retrieving any row that matches at least 1 of the search keywords. If there is only 1 search keyword the query uses a LIKE, otherwise a REGEXP 'keyword1|keyword2'. These rows are put in a PHP array with the item_id as the index, and a concatenation of all the strings (searchable columns) as value. When finished retrieving all possible rows, i search the array for rows that match all keywords in the concatenated field. Most likely not the best solution and it will not scale very well if the search will return many candidate rows with at least 1 match. share|improve this question Don't be shy... show what you've tried –  Tom H. Oct 19 '11 at 15:58 Nobody got an idea? –  Marco Oct 24 '11 at 4:22 add comment 1 Answer It's hard to provide you with a finite answer since you do not give a lot of details about your case. But maybe this can give you a starting point: SELECT * FROM table1 AS tbl1 INNER JOIN table2 AS tbl2 tbl1.text LIKE %search_word1% AND tbl1.text LIKE %search_word2% AND tbl2.text_a LIKE %search_word1% AND tbl2.text_a LIKE %search_word2% AND tbl2.text_b LIKE %search_word1% AND tbl2.text_b LIKE %search_word2% AND tbl2.text_c LIKE %search_word1% AND tbl2.text_c LIKE %search_word2% You can adapt with JOIN, INNER JOIN, LEFT JOIN, RIGHT JOIN and the different LIKE and AND/OR statements to obtain the result you're looking for. Google some join examples with LIKE statements for more details. But as Tom H. said, it'd be better if you could post a more precise table structure and a real exemple of search terms... share|improve this answer Thanks for trying to answer my question, but this doesn't work. If it was only this simple... Your query will only return rows where all search keywords are found in all columns. The search should return values where all keywords are found in any column or row. I thought that my original post contained enough information, but will try to create a real example test case and update the question. –  Marco Oct 20 '11 at 2:52 First post updated with better examples. –  Marco Oct 20 '11 at 3:49 add comment Your Answer
http://stackoverflow.com/questions/7823695/mysql-query-to-search-for-multiple-values-on-multiple-tables-some-rows-some
dclm-gs1-104150001
false
false
{ "keywords": "candida" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.602733
<urn:uuid:fe68c3a9-5f55-4a35-b1f4-82f6ca50471e>
en
0.84593
Take the 2-minute tour × Is it possible to iterate over a binary tree in O(1) auxiliary space (w/o using a stack, queue, etc.), or has this been proven impossible? If it is possible, how can it be done? Edit: The responses I've gotten about this being possible if there are pointers to parent nodes are interesting and I didn't know that this could be done, but depending in how you look at it, that can be O(n) auxiliary space. Furthermore, in my practical use case, there are no pointers to parent nodes. From now on, please assume this when answering. share|improve this question I consider link to parent as O(n) auxiliary space. You should edit your question to explicitly mention your binary tree doesn't have such a property. –  LeakyCode Apr 26 '09 at 15:35 How can you not have pointers to your parent nodes? how can you iterate over your tree at all without them? is that where the stack is coming in? you will need parents pointers anyway to do balancing. –  user82238 May 21 '09 at 22:15 add comment 10 Answers Geez, I'll have to actually type it up from Knuth. This solution is by Joseph M. Morris [Inf. Proc. Letters 9 (1979), 197-200]. As far as I can tell, it runs in O(NlogN) time. static void VisitInO1Memory (Node root, Action<Node> preorderVisitor) { Node parent = root ; Node right = null ; Node curr ; while (parent != null) { curr = parent.left ; if (curr != null) { // search for thread while (curr != right && curr.right != null) curr = curr.right ; if (curr != right) { // insert thread assert curr.right == null ; curr.right = parent ; preorderVisitor (parent) ; parent = parent.left ; continue ; } else // remove thread, left subtree of P already traversed // this restores the node to original state curr.right = null ; } else preorderVisitor (parent) ; right = parent ; parent = parent.right ; class Node public Node left ; public Node right ; share|improve this answer this destroys the tree though doesn't it? –  Brian R. Bondy Apr 26 '09 at 23:55 No, it just temporarily adds backreferences from certain leaves. –  Svante Apr 27 '09 at 0:01 ah, very nice :) –  Brian R. Bondy Apr 27 '09 at 11:00 This solution is simply amazing. –  Mehrdad Jan 19 '11 at 15:54 Actually, it would be O(n): You only touch a node constant number of times (note that the inner while loop only touches paths that go right and only when curr was the path's leftmost node's parent on entry to the outer while loop; that happens once when you enter the subtree and once you leave it. Then, size of those paths combined = O(size of the whole tree). –  jpalecek Apr 24 '12 at 22:17 add comment It is possible if you have a link to the parent in every child. When you encounter a child, visit the left subtree. When coming back up check to see if you're the left child of your parent. If so, visit the right subtree. Otherwise, keep going up until you're the left child or until you hit the root of the tree. In this example the size of the stack remains constant, so there's no additional memory consumed. Of course, as Mehrdad pointed out, links to the parents can be considered O(n) space, but this is more of a property of the tree than it is a property of the algorithm. If you don't care about the order in which you traverse the tree, you could assign an integral mapping to the nodes where the root is 1, the children of the root are 2 and 3, the children of those are 4, 5, 6, 7, etc. Then you loop through each row of the tree by incrementing a counter and accessing that node by its numerical value. You can keep track of the highest possible child element and stop the loop when your counter passes it. Time-wise, this is an extremely inefficient algorithm, but I think it takes O(1) space. (I borrowed the idea of numbering from heaps. If you have node N, you can find the children at 2N and 2N+1. You can work backwards from this number to find the parent of a child.) Here's an example of this algorithm in action in C. Notice that there are no malloc's except for the creation of the tree, and that there are no recursive functions which means that the stack takes constant space: #include <stdio.h> #include <stdlib.h> typedef struct tree int value; struct tree *left, *right; } tree; tree *maketree(int value, tree *left, tree *right) tree *ret = malloc(sizeof(tree)); ret->value = value; ret->left = left; ret->right = right; return ret; int nextstep(int current, int desired) while (desired > 2*current+1) desired /= 2; return desired % 2; tree *seek(tree *root, int desired) int currentid; currentid = 1; while (currentid != desired) if (nextstep(currentid, desired)) if (root->right) currentid = 2*currentid+1; root = root->right; return NULL; if (root->left) currentid = 2*currentid; root = root->left; return NULL; return root; void traverse(tree *root) int counter; counter = 1; /* main loop counter */ /* next = maximum id of next child; if we pass this, we're done */ int next; next = 1; tree *current; while (next >= counter) current = seek(root, counter); if (current) if (current->left || current->right) next = 2*counter+1; /* printing to show we've been here */ printf("%i\n", current->value); int main() tree *root1 = maketree(1, maketree(2, maketree(3, NULL, NULL), maketree(4, NULL, NULL)), maketree(5, maketree(6, NULL, NULL), maketree(7, NULL, NULL))); tree *root2 = maketree(1, maketree(2, maketree(3, maketree(4, NULL, NULL), NULL), NULL), NULL); tree *root3 = maketree(1, NULL, maketree(2, NULL, maketree(3, NULL, maketree(4, NULL, NULL)))); printf("doing root1:\n"); printf("\ndoing root2:\n"); printf("\ndoing root3:\n"); I apologize for the quality of code - this is largely a proof of concept. Also, the runtime of this algorithm isn't ideal as it does a lot of work to compensate for not being able to maintain any state information. On the plus side, this does fit the bill of an O(1) space algorithm for accessing, in any order, the elements of the tree without requiring child to parent links or modifying the structure of the tree. share|improve this answer Brian, each bit of the number will show you which direction you'd go. –  LeakyCode Apr 26 '09 at 15:54 But how would you access the node #7 for example without using extra space? To recurse to find such a node would take space, and if you stored all nodes in another data structure that would tkae extra space as well. –  Brian R. Bondy Apr 26 '09 at 15:54 @Brian You can subtract 1 and divide by 2 to see that 3 is 7's parent. Likewise, you can subtract 1 and divide by 2 again to see that 1 is 3's parent. Therefore, all you need is a loop that will compute the next step in the path to the desired node from the current node. –  Kyle Cronin Apr 26 '09 at 15:55 @nobody_: your idea is good but you gotta note that it works only in complete binary trees and from a purely theoretical perspective, you still need "O(height) bit" space to store where you were. –  LeakyCode Apr 26 '09 at 15:57 @Mehrdad: I don't understand exactly what you mean with the bits approach, but even if it does make sense.... O(N) = O(C*N). Even if N is 1 bi you still have O(N) space. –  Brian R. Bondy Apr 26 '09 at 16:04 show 9 more comments You can do it destructively, unlinking every leaf as you go. This may be applicable in certain situations, i.e. when you don't need the tree afterwards anymore. By extension, you could build another binary tree as you destroy the first one. You would need some memory micromanagement to make sure that peak memory never exceeds the size of the original tree plus perhaps a little constant. This would likely have quite some computing overhead, though. EDIT: There is a way! You can use the nodes themselves to light the way back up the tree by temporarily reversing them. As you visit a node, you point its left-child pointer to its parent, its right-child pointer to the last time you took a right turn on your path (which is to be found in the parent's right-child pointer at this moment), and store its real children either in the now-redundant parent's right-child pointer or in your traversal state resp. the next visited children's left-child pointer. You need to keep some pointers to the current node and its vicinity, but nothing "non-local". As you get back up the tree, you reverse the process. I hope I could make this somehow clear; this is just a rough sketch. You'll have to look it up somewhere (I am sure that this is mentioned somewhere in The Art of Computer Programming). share|improve this answer +1, I commented on this method more with a reference to your answer in my answer. –  Brian R. Bondy Apr 26 '09 at 16:27 Ingenious, but appalling. Just have an up pointer in each element. It is so much simpler, less painful and is well-understood and well-recognized. –  user82238 May 21 '09 at 22:16 add comment Pointers from nodes to their ancestors can be had with no (well, two bits per node) additional storage using a structure called a threaded tree. In a threaded tree, null links are represented by a bit of state rather than a null pointer. Then, you can replace the null links with pointers to other nodes: left links point to the successor node in an inorder traversal, and right links to the predecessor. Here is a Unicode-heavy diagram (X represents a header node used to control the tree): ╭─────────────────────────▶┏━━━┯━━━┯━━▼┓│ │ │ ╭─╂─ │ X │ ─╂╯ │ │ ▼ ┗━━━┷━━━┷━━━┛ │ │ ┏━━━┯━━━┯━━━┓ │ │ ╭────╂─ │ A │ ─╂──╮ │ │ ▼ ┗━━━┷━━━┷━━━┛ │ │ │ ┏━━━┯━━━┯━━━┓ ▲ │ ┏━━━┯━━━┯━━━┓ │ │ ╭─╂─ │ B │ ─╂────┤ ├────────╂─ │ C │ ─╂───────╮ │ │ ▼ ┗━━━┷━━━┷━━━┛ │ ▼ ┗━━━┷━━━┷━━━┛ ▼ │ │┏━━━┯━━━┯━━━┓ ▲ │ ┏━━━┯━━━┯━━━┓ ▲ ┏━━━┯━━━┯━━━┓ │ ╰╂─ │ D │ ─╂─╯ ╰───╂ │ E │ ─╂╮ │ ╭╂─ │ F │ ─╂╮ │ ┗━━━┷━━━┷━━━┛ ┗━━━┷━━━┷━━━┛▼ │ ▼┗━━━┷━━━┷━━━┛▼ │ ▲ ┏━━━┯━━━┯━━━┓ │ ┏━━━┯━━━┯━━━┓ ▲ ┏━━━┯━━━┯━━━┓│ ╰─╂─ │ G │ ╂──┴─╂─ │ H │ ─╂─┴─╂─ │ J │ ─╂╯ Once you have the structure, doing an inorder traversal is very, very easy: p points to a node. This routine finds the successor of p in an inorder traversal and returns a pointer to that node If p.rtag = 0 Then While q.ltag = 0 Do End While End If Return q Lots more information on threaded trees can be found in Art of Computer Programming Ch.2 §3.1 or scattered around the Internet. share|improve this answer And it's O(n) aux storage ;) –  LeakyCode Apr 26 '09 at 16:28 add comment You can achieve this if nodes have pointers to their parents. When you walk back up the tree (using the parent pointers) you also pass the node you're coming from. If the node you're coming from is the left child of the node you're now at, then you traverse the right child. Otherwise you walk back up to it's parent. EDIT in response to the edit in the question: If you want to iterate through the whole tree, then no this is not possible. In order to climb back up the tree you need to know where to go. However, if you just want to iterate through a single path down the tree then this can be achieved in O(1) additional space. Just iterate down the tree using a while loop, keeping a single pointer to the current node. Continue down the tree until you either find the node you want or hit a leaf node. EDIT: Here's code for the first algorithm (check the iterate_constant_space() function and compare to the results of the standard iterate() function): #include <cstdio> #include <string> using namespace std; /* Implementation of a binary search tree. Nodes are ordered by key, but also * store some data. struct BinarySearchTree { int key; // they key by which nodes are ordered string data; // the data stored in nodes BinarySearchTree *parent, *left, *right; // parent, left and right subtrees /* Initialise the root BinarySearchTree(int k, string d, BinarySearchTree *p = NULL) : key(k), data(d), parent(p), left(NULL), right(NULL) {}; /* Insert some data void insert(int k, string d); /* Searches for a node with the given key. Returns the corresponding data * if found, otherwise returns None.""" string search(int k); void iterate(); void iterate_constant_space(); void visit(); void BinarySearchTree::insert(int k, string d) { if (k <= key) { // Insert into left subtree if (left == NULL) // Left subtree doesn't exist yet, create it left = new BinarySearchTree(k, d, this); // Left subtree exists, insert into it left->insert(k, d); } else { // Insert into right subtree, similar to above if (right == NULL) right = new BinarySearchTree(k, d, this); right->insert(k, d); string BinarySearchTree::search(int k) { if (k == key) // Key is in this node return data; else if (k < key && left) // Key would be in left subtree, which exists return left->search(k); // Recursive search else if (k > key && right) return right->search(k); return "NULL"; void BinarySearchTree::visit() { printf("Visiting node %d storing data %s\n", key, data.c_str()); void BinarySearchTree::iterate() { if (left) left->iterate(); if (right) right->iterate(); void BinarySearchTree::iterate_constant_space() { BinarySearchTree *current = this, *from = NULL; while (current != this || from == NULL) { while (current->left) { current = current->left; if (current->right) { current = current->right; from = current; current = current->parent; if (from == current->left) { current = current->right; } else { while (from != current->left && current != this) { from = current; current = current->parent; if (current == this && from == current->left && current->right) { current = current->right; int main() { BinarySearchTree tree(5, "five"); tree.insert(7, "seven"); tree.insert(9, "nine"); tree.insert(1, "one"); tree.insert(2, "two"); printf("%s\n", tree.search(3).c_str()); printf("%s\n", tree.search(1).c_str()); printf("%s\n", tree.search(9).c_str()); // Duplicate keys produce unexpected results tree.insert(7, "second seven"); printf("%s\n", tree.search(7).c_str()); printf("Normal iteration:\n"); printf("Constant space iteration:\n"); share|improve this answer "When you walk back up the tree"... how do you get to the bottom of each node in the tree? –  Brian R. Bondy Apr 26 '09 at 16:10 current = root; while current->left exists: current = current->left –  marcog Apr 26 '09 at 16:17 @marcog: Yes you can surely get to a single node.... But I said how do you get to the bottom of each node in the tree? –  Brian R. Bondy Apr 26 '09 at 16:21 Using the condition I mentioned to go down the right child when you've just come up from the left child. –  marcog Apr 26 '09 at 16:29 And once you process that right child, how do you get the the second left most child? and then the left most's right child? ... You need to store which paths you've taken. –  Brian R. Bondy Apr 26 '09 at 16:31 show 4 more comments To preserve the tree and only use O(1) space it's possible if... • Each node is a fixed size. • The whole tree is in a contiguous part of memory (i.e. an array) • You don't iterate over the tree, you simply iterate over the array Or if you destroy the tree as you process it...: • @Svante came up with this idea, but I wanted to expand on how a little, using a destructive approach. • How? You can continue to take the left most leaf node in a tree (for(;;) node = node->left etc... , then process it, then delete it. If the leftmost node in the tree is not a leaf node, then you process and delete the right node's left most leaf node. If a right node has no children, then you process and delete it. Ways that it wouldn't work... If you use recursion you will use a stack implicitly. For some algorithms (not for this problem) tail recursion would allow you to use recursion and have O(1) space, but since any particular node may have several children, and hence there is work to do after the recursive call, O(1) space tail recursion is not possible. You could try to tackle the problem 1 level at a time, but there is no way to access an arbitrary level's nodes without auxiliary (implicit or explicit) space. For example you could recurse to find the node you want, but then that takes implicit stack space. Or you could store all your nodes in another data structure per level, but that takes extra space too. share|improve this answer You are wrong, Knuth TAOCP I.2.3.1 exercise 21 refers to at least three algorithms for tree traversal in O(1) space without destroying the original tree (although they do modify it temporarily in-place). –  Anton Tykhyy Apr 27 '09 at 5:32 @nobody_: I didn't take into account cases where you are allowed to modify the tree. But I did give 2 examples, so surely it has some :) Anyway I modified my answer to take out the invalid parts. –  Brian R. Bondy Apr 27 '09 at 10:57 For those without TAOCP, @AntonTykhyy is referring to the Morris tree traversal algorithms, which run in O(n) time and O(1) auxiliary space. This page might help: stackoverflow.com/questions/5502916/…. Also, someone posted the pre-order Morris algorithm below. –  John Kurlak Feb 7 '13 at 13:44 add comment I think there's no way you could do this, as you should somehow find the nodes where you left off in a path and to identify that you always need O(height) space. share|improve this answer add comment encode your parent node into the leaf pointers share|improve this answer add comment "Datastructures and their algorithms" by Harry Lewis and Larry Denenberg describe link inversion traversal for constant space traversal of a binary tree. For this you do not need parent pointer at each node. The traversal uses the existing pointers in the tree to store path for back tracking. 2-3 additional node references are needed. Plus a bit on each node to keep track of traversal direction (up or down) as we move down. In my implementation of this algorithms from the book, profiling shows that this traversal has far less memory / processor time. An implementation in java is here. share|improve this answer add comment Is it possible to iterate over a binary tree in O(1) auxiliary space. struct node { node * father, * right, * left; int value; }; This structure will make you be able to move 1-step in any direction through the binary tree. But still in iteration you need to keep the path! share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/791052/iterating-over-a-binary-tree-with-o1-auxiliary-space/791062
dclm-gs1-104170001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.028849
<urn:uuid:6b3d916a-08e7-4a79-aeb4-8546eca3c452>
en
0.874613
Take the 2-minute tour × Using SSRS BIDS 2008 to create a Pie Chart in one of my reports. What is the syntax of the statement I need to type into the Expression box to specify which colours I would like each particular field of the pie chart to be. The value i need to specify different colours for is 'value2' and their are a total of 4 possible values. share|improve this question add comment 2 Answers up vote 1 down vote accepted Are you ENTIRELY SURE that the if statement predicate is correct? It looks to me like "1.Proposal" is possibly a series label? share|improve this answer Youve nailed it, my problem was that 1.Proposal should have actually read as 1. Proposal - I was missing a space, thanks all for your help –  SelectDistinct Nov 4 '11 at 14:36 add comment Answered a question on this yesterday! See Reporting services expression using Switch for the Switch syntax. Make sure you give it an even number of arguments. Edit following your sample code - it should be Switch rather than SWITCH. Check the documentation here. share|improve this answer It has an even number of arguments, still not working, this is what I have so far... =SWITCH( Fields!status2.Value="1.Proposal","Green", Fields!status2.Value="2.Live","Red", Fields!status2.Value="3.On Hold","Khaki", Fields!status2.Value="5.Cancelled","Plum") –  SelectDistinct Nov 4 '11 at 14:15 Updated answer following your sample code. If it's still not working, an error message would be useful. –  Sir Crispalot Nov 4 '11 at 14:19 No error message, run the report and it just displays the bog standard colours from before, not my specified ones... –  SelectDistinct Nov 4 '11 at 14:25 What if you add a final catch-all condition with a unique colour like this: ..., True, "Pink") - then you'll at least know that the expression is being evaluated when it all goes pink! –  Sir Crispalot Nov 4 '11 at 14:32 add comment Your Answer
http://stackoverflow.com/questions/8010292/switch-statement-for-multiple-colour-choices-in-pie-chart
dclm-gs1-104180001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.251143
<urn:uuid:07a12e41-55a7-4516-aae1-d217c2ece3f2>
en
0.929717
Take the 2-minute tour × I am going to make an application in which I want to get the user location through sms i.e a person sends an sms to a specific number linked with a web server or to an android app and from that sms I want to find his/her location. This should be done without installing any application as I want to use this feature for old mobiles like nokia 3310 which don't support java. Please give suggestions. Languages I'll be using for my app are php, android, java. share|improve this question Ask them their postal code. No other way to find their location. –  ilhan Nov 11 '11 at 6:21 Who are you working for..:p –  drooooooid Nov 11 '11 at 6:31 FBI, NSA, CIA or any other I dont know name might CBI LOL –  ingsaurabh Nov 11 '11 at 7:36 add comment closed as not a real question by ingsaurabh, bharath, Akshinthala సాయి కళ్యాణ్, VMAtm, Bill the Lizard Nov 11 '11 at 11:35 4 Answers Whichever cellular service provider you are working with will give you an API that you can use to communicate with their database mapping IMEI numbers to specific cell towers. share|improve this answer Example? I didn't know such thing. Very interesting. –  ilhan Nov 11 '11 at 6:24 is that true.?please provide more detaisl –  drooooooid Nov 11 '11 at 6:26 @sarnold will you please elaborate your answer or more specifically provide any example or link –  ingsaurabh Nov 11 '11 at 6:27 add comment AFAIK you can't find the location from sended/receiving SMS on both Android and Java ME application. share|improve this answer add comment If you will not install any application then who will return location on device end ?? Not possible until device support location - based -service and an app is installed which will give location to server . share|improve this answer add comment I was having a project back in the day. It was not the same, but kinda give you ideas of why this is not being done on non-carrier side. In short, cell phone will comunicate to a cell tower(or cell site) constantly via a control channel so the system knows your cell's location. sending an sms is kinda same. But unless you work with a carrier, chances you get an API from them to read the package via a control channel is ZERO. So you are in no hope if you are not one of them. Here is an idea of what you can do: 1. You can have a background service that's running to get a callback when location changed. 2. get the lat and long from location callback to the service. 3. detect and check the target number when user sends out sms here is the link 4. if you detect the target number is your server's number, just add the lat and lon to the sms message body. 5. then do whatever your want with that sms data. I hope This could help. share|improve this answer add comment
http://stackoverflow.com/questions/8090342/how-to-find-location-by-sending-an-sms-to-a-specific-number-linked-with-a-web-se
dclm-gs1-104200001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.250804
<urn:uuid:d28aebec-7324-4ea0-974d-50f1e8c81f0f>
en
0.766098
Take the 2-minute tour × I have a gridview which gets populated in the backend code. I am trying to implement paging now, but when I am trying my way, I am getting nothing. Here is my piece of code: public void generateTable() conn.ConnectionString = connString; SqlCommand comm = new SqlCommand("ViewBusinessInfo", conn); comm.CommandType = CommandType.StoredProcedure; comm.CommandTimeout = 2; SqlDataReader rdr = comm.ExecuteReader(); if (rdr.HasRows) gvAssociation.DataSource = rdr; gvAssociation.AllowPaging = true; gvAssociation.PageSize = 10; lblResult.Text = "No businesses found."; lblResult.Visible = true; Can anyone advice what am I doing wrong and I can't get the paging in the gridview? Thx in advance, Laziale share|improve this question For starters, you can probably change catch to catch(Exception ex) so you can see if you are actually getting an exception. An empty catch block will hide your exception. –  Bryan Crosby Nov 21 '11 at 17:25 add comment 3 Answers up vote 1 down vote accepted You cannot use paging with a DataReader. You should fill your data into a Dataset or a Datatable using a DataAdapter. Something like this: SqlCommand myCommand = new SqlCommand("ViewBusinessInfo", conn); SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand)) DataTable dt = new DataTable(); share|improve this answer add comment The allowPaging and pagesize property of the gridview can be added in the .aspx, where the gridview tag is present. <asp:GridView ID="gridView" OnPageIndexChanging="gridView_PageIndexChanging" AllowPaging="True" pagesize="10" runat="server" /> Additionally, to make the paging links work, you have to add the following code in the gridview_PageIndexChanging event of the gridview: protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e) gridView.PageIndex = e.NewPageIndex; Hope this is helpful. share|improve this answer that was not the problem. The problem was that you cannot use a DataReader to populate a GridView if paging is enabled. –  slfan Nov 22 '11 at 12:51 Yes you are right...it just skipped my mind. With DATAREADER as DATASOURCE, SERVER SIDE PAGING IS NOT ALLOWED. One will have to use DATAADAPTER-DATASET –  Aditya Nov 23 '11 at 10:44 add comment Set the AllowPaging and PageSize declaratively, or do so before you call DataBind(). share|improve this answer I am getting an error: The data source does not support server-side data paging –  Laziale Nov 21 '11 at 17:44 forums.asp.net/p/1320427/2623013.aspx should help. –  drdwilcox Nov 21 '11 at 17:55 add comment Your Answer
http://stackoverflow.com/questions/8215826/gridview-control-and-paging-asp-net
dclm-gs1-104220001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.019079
<urn:uuid:e9358b0b-943c-4941-a6b4-59647cca4883>
en
0.914182
Take the 2-minute tour × In an android application, what is the best method to store primitive data variables (such as a list of 3 integers) on the device so that those integers can be seen and manipulated by the app, but remain on the device after updating the app? also, it would be best if there was a way to tell the difference between the user updating and uninstalling and delete the file upon the latter. Any easy way to do this that i'm unaware of? Any example code of the actual serializing of a piece of data would be very helpful. I'm reading the documentation, but having trouble finding really clear examples. share|improve this question Are you aware of the SharedPreferences? –  user658042 Nov 25 '11 at 21:38 I've been looking at that, but it doesn't specify in the documentation how persistent the data is. Will Shared Preferences persist after updating the app? Internal Storage specifically says that files are deleted at uninstall. I guess my question is more about that. –  cody Nov 25 '11 at 22:03 Yes, the SharedPreferences will persist with every app update, as already answered here. In the early days there used be an issue in combination with forward lock/copy protection, but that was fixed in 1.5. –  MH. Nov 25 '11 at 22:17 add comment 1 Answer up vote 0 down vote accepted Refer here! share|improve this answer I won't downvote this since you are new to StackOverflow, but: Answers that contain only a link are bad. Please give at least a small summary what the answer in the link is and add it for further information. Also please label links with something else than "here", so that interested people have an idea where they go when they click the link. Thanks. –  user658042 Nov 26 '11 at 13:29 And also add that this is your very own blog when you link to it for reasons of transparency. –  user658042 Nov 26 '11 at 13:32 Ok , thanks you your guidance –  Tapan Thaker Nov 27 '11 at 16:50 Also , I will be editing the post when i get time –  Tapan Thaker Nov 27 '11 at 16:57 add comment Your Answer
http://stackoverflow.com/questions/8274377/a-method-to-serialize-simple-data-and-achieve-compatibility
dclm-gs1-104230001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.434136
<urn:uuid:8680d4af-0f32-400b-8d91-0340b52dafb6>
en
0.93664
Take the 2-minute tour × I have just started using AJAX and Javascript and created a web page that loads a div from a text file. Here is the page http://www.1000give100.org/landing-page.html I have a div that gets filled with a text file of names that I need to auto scroll, then stop when user cursors over div. I have tried using JScrollpane but it doesn't really do what I need and I couldn't get it to work. I also tried something called slider but couldn't get it to work either. Can somebody point me to a Jquery scrolling program or something similar. share|improve this question If these plugins "doesn't really do what [you] need", please tell us which behavior you expect. And if you want to use them but didn't succeed, please post the code you tried and tell us where you are stuck. –  JMax Dec 7 '11 at 9:14 Sorry I did figure this out autodivscroll.js worked great. –  user1084383 Dec 16 '11 at 3:27 add comment Your Answer Browse other questions tagged or ask your own question.
http://stackoverflow.com/questions/8407059/auto-scroll-div-that-has-been-filled-with-text-file-using-ajax
dclm-gs1-104240001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.081828
<urn:uuid:8e51709c-b0b2-4375-a2dc-399328b4f901>
en
0.835997
Take the 2-minute tour × I am trying to develop a Qt application for a touchscreen ; this application is running on an ARM system, with Qt Everywhere 4.7.2. In this application, I need to display a specific screen for login ; then the user press an "Ok" button, and I must verify if the informations entered are correct. To do that, I need to send a message to my server and while doing that, I would like to display a waiting screen. I have already a some classes that allow me to switch between screens, and it works. The problem is : when I put some code after the display request, it is executed but the screen doesn't display ! An example : display_->SetScreenId( MTO_Display::WAITING_SCREEN ); It is basically the way I switch between screen ; display_ is a specific object. The method CloseActualScreen() closes the screen being display by deleting its object. Then ChooseScreenToDisplay() creates and display a new widget depending on the screen id. I can put these method's code if needed, but they work if I used them like that. Then, if I do that : display_->SetScreenId( MTO_Display::WAITING_SCREEN ); CallToAnotherFunction() is well executed but here my waiting screen is not displayed at all ; I see no reason for this behavior ! Do you have an idea ? Thanks ! share|improve this question add comment 1 Answer up vote 1 down vote accepted Arg x) I searched on this for two days, and found the solution just after asking here... x) I need to use QApplication::processEvents in order to process all events before executing the rest of the code. share|improve this answer yes, you should read this article about threads and events: developer.qt.nokia.com/wiki/Threads_Events_QObjects especially "Events and the event loop part" –  Maciej Dec 12 '11 at 9:00 add comment Your Answer
http://stackoverflow.com/questions/8471808/how-to-display-a-screen-and-run-some-background-tasks-not-with-thread?answertab=votes
dclm-gs1-104250001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.764992
<urn:uuid:220c2670-c323-4531-8448-cbb866197eb5>
en
0.857552
Take the 2-minute tour × I have a somewhat interesting query.. I may have over simplified the example, but ill do my best to describe my problem. I am building a very simple implementation of a wiki from scratch, everything going well until I realized I need Cycle Detection to prevent endless loops of data populating the page and well Overflowing the stack heap. Database structure is basic, well its more intricate that what is shown but for the purposes of this post the two columns is all we need. The Content field is straight forward, it stores the Content of the Page or WikiPart links i.e [[n]] to link to another part and includes, links are shopwn as [[n]] and includes are {{n}}. | id | Content | | 1 | see {{2}} here | | 2 | {{1}} here [[4]] | | 4 | {{1}} | $html_for_screen = readData($this->Content); function readData($wikipage) { $str = ""; //Convert any wiki links to HTML Links $wikipage = Converter::convertWikink($wikipage); //Get ALL Include Link matches into array $wiki_inc = RegEx::getMatches(wikipage); //Iterate through the Matches foreach($wiki_inc as $wiki) { //traverse through each match. //but I assume here is where I would eventually have the trouble //With infinant loops $str .= readData($wiki); return $str; The Question: How would I prevent Wiki parts endlessly including eachother. i.e WikiPart 1 includes WikiPart2.. but WikiPart 2 includes WikiPart1 The parse or readData() function would just continue looping. share|improve this question so...where is your question here? –  Nick Dec 15 '11 at 16:51 oh yeah, thanks..lol –  IEnumerable Dec 15 '11 at 16:54 add comment 2 Answers up vote 2 down vote accepted Actually if you encounter a cycle, you can't resolve any longer. Example: 1: {{2}} 2: {{1}} This will create an endless loop: 1 -> 2 -> 1 -> 2 -> ... As any computers resources are limited, endless loops will result in a crash. So what can you do? You could detect that and then error out by using a stack: function readData($wikipage) static $stack = array(); if (in_array($wikipage, $stack)) throw new Exception(sprintf('Circular reference detected: %s -> %s', implode(' -> ', $stack), $wikipage)); $stack[] = $wikipage; ... (your existing code) Additionally you can control recursion limit by using count($stack) to determine the nesting level. Actually throwing an exception might not be the proper reaction to the cyclic reference, but it shows how the detection work. You can decide on your own how you'd like to deal with the case, e.g. returning FALSE or not resolving the field any longer etc.. Edit: Getting creative here: If the output is HTML you could make the user resolve the problem as well. If such a cyclic reference is detected, some AJAX marker could be inserted that would request in some form of overlay within the browser that snippet which was unable to obtain on the server side. Such an overlay will then contain the cyclic reference again (being able to overlay again) so that the user would be able to see the cyclic reference interactively. share|improve this answer shouldnt we assign an $n value, $stack[$n] = $wikipage, or does PHP handle by putting it on top of the array ? –  IEnumerable Dec 15 '11 at 17:34 PHP does handle this, $stack[] = $value is like array_push, so no need to take care of it with another variable or $stack[count($stack)] = $value. –  hakre Dec 15 '11 at 17:36 Im loving PHP more every day, thankyou!! –  IEnumerable Dec 15 '11 at 17:39 your edit is very interesting, might even attempt it after this project.. cheers –  IEnumerable Dec 15 '11 at 17:42 add comment You could track your inclusion with a stack (or a set). If you find the Page you are about to include somewhere in the stack you stop. You could also just set a recursion limit like 30 or something, this is not very clean, but works. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/8523582/wikipedia-style-include-cycle-detection-php
dclm-gs1-104260001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.16338
<urn:uuid:ec979130-d618-4ca5-b248-ec6010b77b2c>
en
0.903024
Take the 2-minute tour × If you see the accepted answer in: Aggregating and uglifying javascript in a git pre-commit hook, you'll see that I had to do a chmod +x on my pre-commit hook to get it to work. Why is this not executable by Git by default? share|improve this question add comment 1 Answer up vote 4 down vote accepted Because files are not executable by default; they must be set to be executable. The sample files from a git init are all executable; if it's copied or renamed to a non-sample file, it will retain the original file's x flag. New files will be created with current defaults. In your case, view those defaults with umask: $ umask By default, new files won't be u+x unless explicitly set to be. share|improve this answer I'm running git v1.7.6 on Mac OS X Lion. I'd done git init to reinitialize the repo and that still didn't work. I edited the file in TextMate, which might be the problem, but still doesn't explain why git init wouldn't do the chmod u+x properly. –  Josh Smith Dec 22 '11 at 2:07 @JoshSmith git init only creates sample hooks, not actual ones. I'm running on Lion, and 1.7.0 on Ubuntu--they both create the sample files as u+x--I guess I'm a little skeptical it isn't on yours. –  Dave Newton Dec 22 '11 at 2:10 If nothing else I discovered my Linux box is running an old-ish version of git. –  Dave Newton Dec 22 '11 at 2:11 So am I going to have to chmod every single time I modify the hook? –  Josh Smith Dec 22 '11 at 2:12 @JoshSmith Uh, no, once it's set, you shouldn't need to change it again. –  Dave Newton Dec 22 '11 at 2:13 show 2 more comments Your Answer
http://stackoverflow.com/questions/8598639/why-is-my-git-pre-commit-hook-not-executable-by-default?answertab=active
dclm-gs1-104280001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.021062
<urn:uuid:57a9f809-e1a9-4cd5-b890-96b70d5e922e>
en
0.838652
Take the 2-minute tour × I tried to compile a simple basic c program in ubuntu 11.10 but i got the following error. Here i am providing the error details, pavan@pavan-Aspire-4739:~$ gcc -o simplelq pro.c /tmp/ccR5XApx.o: In function `main': pro.c:(.text+0xf): undefined reference to `Printf' collect2: ld returned 1 exit status Can anyone please tell me if i still need to install any libraries Note: I installed Ubuntu recently. I installed gcc also share|improve this question Maybe you meant printf instead of Printf. Some code to look at wouldn't hurt. –  Michael Foukarakis Jan 3 '12 at 17:09 And compile with -Wall. This will catch many errors like that. –  elmo Jan 3 '12 at 17:11 add comment closed as too localized by Michael Petrotta, Dour High Arch, Vlad Lazarenko, Udo Held, Michael Foukarakis Jan 3 '12 at 19:18 3 Answers The function is called printf, not Printf. And "your test program" is hardly "any C program"... share|improve this answer Oops, Thank u TheifMaster i didn't check that one. –  lovelyguyalone Jan 3 '12 at 17:12 add comment There is no Printf function in standard C. Since C allows implicitly declared functions, you are failing at linking stage. Read warning and error messages carefully. share|improve this answer add comment It's printf not Printf the c programming language is case sensitive. Here is a list of the C standard headers and functions. share|improve this answer add comment
http://stackoverflow.com/questions/8715887/i-am-not-able-to-compile-a-c-program-in-ubuntu-11-10
dclm-gs1-104300001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.299008
<urn:uuid:2c936b1c-26fc-416c-920b-8d05010bedb5>
en
0.664467
Take the 2-minute tour × I have an UINavigationBar added to my UIViewController view. I want to change the fonts properties. Note that I want to change a UINavigationBar not controller. In my app where I use UINavigationController I use self.navigationItem.titleView = label; to display the custom label. How can I accomplish to have a custom title in my UINavigationBar? P.S I use this to set the title text self.navBar.topItem.title = @"Information"; of my UINavigationBar. share|improve this question add comment 4 Answers up vote 31 down vote accepted From iOS 5 onwards we have to set title text color and font of navigation bar using titleTextAttribute Dictionary(predefined dictionary in UInavigation controller class reference). [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor], UITextAttributeTextColor, [UIFont fontWithName:@"ArialMT" size:16.0], UITextAttributeFont,nil]]; The below tutorial is the best tutorial for customization of UIElements like UInavigation bar, UIsegmented control, UITabBar. This may be helpful to you share|improve this answer On iOS 7 the UITextAttributeFont is deprecated –  rolandjitsu Dec 12 '13 at 23:01 @rolandjitsu you just have to use NSFontAttributeName instead of UITextAttributeFont. –  CedricSoubrie Dec 19 '13 at 23:57 @CedricSoubrie ~ yes, that is true, just wanted to inform the author about that so we can have an updated answer :) –  rolandjitsu Dec 20 '13 at 19:08 And UITextAttributeTextColor should be replaced with NSForegroundColorAttributeName –  bobmoff Mar 4 at 8:25 add comment Just put this in your app delegate's From Ray Wenderlich: [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], [UIFont fontWithName:@"STHeitiSC-Light" size:0.0], UITextAttributeFont, nil]]; share|improve this answer Dont set size 0 to your font, that will cause visual errors when you push to a view controller. First when you push the font will have size 0 and then it will size itself appropriately but it still is visible -and annoying. Set it to 18.0 –  matejkramny Aug 9 '12 at 20:45 add comment (This is not possible using the new iOS 5.0 Appearance API). iOS >= 5.0 : Set the Title Text Attributes for the Navigationbar: // Customize the title text for *all* UINavigationBars NSDictionary *settings = @{ UITextAttributeFont : [UIFont fontWithName:@"YOURFONTNAME" size:20.0], UITextAttributeTextColor : [UIColor whiteColor], UITextAttributeTextShadowColor : [UIColor clearColor], UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero]}; [[UINavigationBar appearance] setTitleTextAttributes:settings]; iOS < 5.0 UINavigationItem doesn't have a property called label or something, only a titleView. You are only able to set the font by setting a custom label as this title view You could use the following code: (as suggested here) UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)]; label.font = [UIFont fontWithName:@"YOURFONTNAME" size:20.0]; label.shadowColor = [UIColor clearColor]; label.textColor =[UIColor whiteColor]; label.text = self.title; self.navigationItem.titleView = label; [label release]; share|improve this answer You can actually use [UINavigationBar appearance] to customize the appearance of text on the navBar iOS 5+ You just need to do it in your app delegate, i.e. before your view controller appears. –  stalinkay Jun 24 '12 at 11:45 Indeed, thank you for the comment. I couldn't find it at the time. –  Tieme Dec 28 '12 at 14:48 add comment Don't forget to add the font to your target. I did everything that can be done about a font and I couldn't load it, when , in fact the font wasn't a member of my target. So check Target Membership as well on the custom font added. share|improve this answer add comment Your Answer
http://stackoverflow.com/questions/8774531/change-uinavigationbar-font-properties
dclm-gs1-104310001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false
0.248282
<urn:uuid:4ed6ce0c-f1ba-46f9-af00-90f2d5e93c45>
en
0.823367
Take the 2-minute tour × I am getting a resultset from a query which has users object like this column summap=[[6, gra.Users : 1], [2, gra.Users: 7]] where 1,7 are the ids of the user from Users entity I want to get employeeid from this id how do I do that? I tried Users.get(it[1]).employeeid but it says cannot get property employeeid on null object. How do I get employeeid? Regards Priyank share|improve this question add comment 2 Answers up vote 1 down vote accepted gra.Users : 1 looks like the default toString() output for a domain class, so I'm guessing that the 2nd values in each array are Users instances, not ids. So it'd be something like def results = executeQuery(...) // [[6, gra.Users : 1], [2, gra.Users: 7]] def employeeIds = results.collect { it[1].employeeid } share|improve this answer thats absolutely right Burt..just tried it before and it worked! :) –  pri_dev Jan 18 '12 at 8:49 add comment share|improve this answer This also looks good..thanks.. its just a round about way.. –  pri_dev Jan 18 '12 at 8:53 add comment Your Answer
http://stackoverflow.com/questions/8904924/getting-field-value-from-an-object-in-query-result-list/8905514
dclm-gs1-104320001
false
false
{ "keywords": "" }
false
{ "score": 0, "triggered_passage": -1 }
false