instruction
stringlengths
0
30k
- I start up my application which uses a Jetty server, using port 9000. - I then shut down my application with Ctrl-C - I check with "netstat -a" and see that the port 9000 is no longer being used. - I restart my application and get: > [ERROR,9/19 15:31:08] java.net.BindException: Only one usage of ea...
This would make me feel much safer as it should work even if there is a `vtable` (or the compiler will scream). memset(static_cast<MY_STRUCT*>(this), 0, sizeof(MY_STRUCT)); I'm sure your solution will work, but I doubt there are any guarantees to be made when mixing `memset` and classes.
Javascript interpreter to replace Python
|javascript|shell|scripting|
In terms of quick dynamically typed languages, I'm really starting to like Javascript, as I use it a lot for web projects, especially because it uses the same syntax as Actionscript (flash). It would be an ideal language for shell scripting, making it easier to move code from the front and back end of a site, and le...
Would something like this work? .selected { display: block; width: 100%; background: #BEBEBE; }
Put the selected class on the `<li>` and not the `<a>`
My opinion is no. I'm not sure what it gains either. As your definition of CMyStruct changes and you add/delete members, this can lead to bugs. Easily. Create a constructor for CMyStruct that takes a MyStruct has a parameter. CMyStruct::CMyStruct(MyStruct &) Or something of that sought. You can then ...
In my years I've found most Javascript developers find it quite easy to transfer over to PHP and vice versa - it isn't a direct answer to your question, although if you're working in ActionScript and JavaScript then you're best to stick with something like PHP (if you're not willing to move to Java, and stick with the ...
Google's [V8][1] can be used as a standalone interpreter. Configuring with `scons sample=shell` will build an executable named `shell`, that can be called like so: `./shell file.js`. [1]: http://code.google.com/apis/v8/build.html
I think too that the O'Reilly book is going to be the only one, there isn't much about XSL-FO out there... Frankly I think it's a dead technology, it's just too complex for the average programmer to learn, it takes weeks - plus the good formatters out there are expensive as hell. This is not an answer to your questi...
There are four big javascript interpreters currently. V8, Squirrelfish, Spidermonkey and Rhino. I think more important than performance is how well it integrates into existing infrastructure, and I guess Rhino with its bridge to Java wins here.
The event keyword in c# modifies the declaration of the delegate. It prevents direct assignment to the delegate (you can only use += and -= on an event), and it prevents invocation of the delegate from outside the class. So you could alter your code to look like this: public class CustomGUIElement { ...
- I start up my application which uses a Jetty server, using port 9000. - I then shut down my application with Ctrl-C - I check with "netstat -a" and see that the port 9000 is no longer being used. - I restart my application and get: > [ERROR,9/19 15:31:08] java.net.BindException: Only one usage of ea...
Virtual member call in a constructor
|c#|resharper|
I'm getting a warning from ReSharper about a call to a virtual member from my objects constructor. Why would this be something not to do?
*The problem*: A media player does not automatically load subtitles due to they are names differ from corresponding video files. *Solution*: Rename all *.srt (files with subtitles) to match the *.avi (files with video). perl -e'while(<*.avi>) { s/avi$/srt/; rename <*.srt>, $_ }' CAVEAT: Sorting order of or...
*The problem*: A media player does not automatically load subtitles due to their names differ from corresponding video files. *Solution*: Rename all *.srt (files with subtitles) to match the *.avi (files with video). perl -e'while(<*.avi>) { s/avi$/srt/; rename <*.srt>, $_ }' CAVEAT: Sorting order of origi...
You might want to look into using svn:externals: http://svnbook.red-bean.com/en/1.0/ch07s03.html
If this is important enough to spend a lot of time on, I'd consider using Venn diagrams. The visualisation will represent the result sets rather than the query terms. So to demonstrate AND you would show two circles representing the results, and highlight the overlap between them (intersection). To demonstrate OR yo...
How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?
|python|macos|gtk|pygtk|
I have read that it is possible to [build GTK+ on MacOS X][1]. I know that it's possible to create a [bundle of a GTK+ application on MacOS][2]. I also know that it's possible to create widgets [that look sort of native][3]. However, searching around I am not really clear on how to create a bundle that includes the ...
Start with Master Pages on day #1 - its a pain coming back to retrofit.
Can css be used to set style when using javascript?
|javascript|css|
I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet.
Can an element's CSS class be set via JavaScript?
I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet.
What's the most efficient way to select the last n rows in a table without changing the table's structure?
|sql|mysql|database-query|
What's the most efficient way to select the last n number of rows in a table using mySQL? The table contains millions of rows, and at any given time I don't know how large the table is (it is constantly growing). The table does have a column that is automatically incremented and used as a unique identifier for each row...
I like Spring MVC, using 2.5 features there is very little XML involved.
Template metaprogramming is essentially abuse of the template mechanism. What I mean is that you get basically what you'd expect from a feature that was an unplanned side-effect --- it's a mess, and (although tools are getting better) a real pain in the ass because the language doesn't support you in doing it. Mes...
Template metaprogramming is essentially abuse of the template mechanism. What I mean is that you get basically what you'd expect from a feature that was an unplanned side-effect --- it's a mess, and (although tools are getting better) a real pain in the ass because the language doesn't support you in doing it (I shou...
All the consts in your examples have no purpose. C++ is pass-by-value by default, so the function gets copies of those ints and booleans. Even if the function does modify them, the caller's copy is not effected. So I'd avoid extra consts because - They're redudant - They clutter up the text - Th...
*The problem*: A media player does not automatically load subtitles due to their names differ from corresponding video files. *Solution*: Rename all *.srt (files with subtitles) to match the *.avi (files with video). perl -e'while(<*.avi>) { s/avi$/srt/; rename <*.srt>, $_ }' CAVEAT: Sorting order of origi...
*The problem*: A media player does not automatically load subtitles due to their names differ from corresponding video files. *Solution*: Rename all *.srt (files with subtitles) to match the *.avi (files with video). perl -e'while(<*.avi>) { s/avi$/srt/; rename <*.srt>, $_ }' CAVEAT: Sorting order of origi...
Jar file naming converntions
|java|jar|naming-conventions|
Are there any industry standard conventions for naming jar files?
Jar file naming conventions
You could try setting up your own handler for the [onerror event][1] and use XMLHttpRequest to tell the server what went wrong, however since it's not part of any specification, [support is somewhat flaky][2]. Here's an example: [Using XMLHttpRequest to log JavaScript errors][3] [1]: http://developer.mozilla.or...
[Somasegar][1] has some notes in this [blog post][2]. Mainly about [incremental build improvements][3] and [multi core improvements][4]. [1]: http://blogs.msdn.com/somasegar [2]: http://blogs.msdn.com/somasegar/archive/2007/09/27/vs-2008-performance-improvements.aspx [3]: http://blogs.msdn.com/vcblog/arch...
It works fine so long as everyone on the project has agreed to use the same whitespace style (spaces or tabs). But I've seen cases where a developer has converted an entire file from spaces to tabs (I think Eclipse had that as a feature, bound to Ctrl+Tab!), which makes spotting diffs near impossible.
Have you looked [here][1], [here][2] or [here][3] ? If yes, and no information was there you could start by checking first the compiler version (cl.exe) the linker version(link.exe) and then make some performance (optimization tests) and see who is the winner. Usually a newer version of cl.exe will be better. Not...
You _could_ use goto, but it's still messy. I've actually wanted a sort of single statement try-catch for a while. It would be helpful in certain cases, like adding logging code or something that you don't want to interrupt the main program flow if it fails. I suspect something could be done with some of the f...
Check out [WaveMaker](www.wavemaker.com) for building a quick, simple webapp. They have a browser based drag-and-drop designer for Dojo/JavaScript widgets, and the backend is 100% Java.
Here is a draft of how I do it: Query: public IList GetOrders(int pageindex, int pagesize) { IList results = session.CreateMultiQuery() .Add(session.CreateQuery("from Orders o").SetFirstResult(pageindex).SetMaxResults(pagesize)) .Add(session.CreateQuery("select count(*)...
Can I unshelve to a different branch in tfs 2008?
|tfs|branch|shelve|unshelve|
Let's assume that some developer in my team shelved his changes that he did in branch A. And I am working on branch B. Can I unshelve his changes into branch B? (By GUI or command prompt)
as first, give an ID to Search button. Then,on textbox, you could intercept client event **onkeydown**, with a (javascript) function like this: function KeyDownHandler(event) { // process only the Enter key if (event.keyCode == 13) { // cancel ...
There's really no reason to make a value-parameter "const" as the function can only modify a copy of the variable anyway. The reason to use "const" is if you're passing something bigger (e.g. a struct with lots of members) by reference, in which case it ensures that the function can't modify it; or rather, the compi...
Also. be mindful that with the A-Star algorithm, at least, you will need to figure out a admissible heuristic to determine whether a possible next step is closer to the finished route than another step.
This is a great tool for such purposes.: http://sourceforge.net/projects/duplo/
Much better than a memset, you can use this little trick instead: MY_STRUCT foo = { 0 }; This will initialize all members to 0 (or their default value iirc), no need to specifiy a value for each.
Of course, in Windows, the JavaScript interpreter is shipped with the OS. Just run `cscript` or `wscript` against any .js file.
You'll need some server-side JavaScript interpreter. Check out the following [blog post][1]. Something such as [Rhino][2] might be useful for you. [1]: http://peter.michaux.ca/article/3001 [2]: http://www.mozilla.org/rhino/
Depending of how much you want to integrate, you can check Google single sign-on (SSO) api. I'm studing how to use it and the best way to integrate it http://code.google.com/apis/apps/sso/saml_reference_implementation.html Victor UPDATED: As a better option, you should check this link as well http://esoepro...
Try [jslibs][1], a scripting-focused standalone JS runtime and set of libraries that uses SpiderMonkey (the Gecko JS engine). [1]: http://code.google.com/p/jslibs/
You might try toying around with [SquirrelFish][1] or [v8][2], both should be runnable on the command line. [1]: http://trac.webkit.org/wiki/SquirrelFish [2]: http://code.google.com/p/v8/
If you want to programmatically access the content of a GMail account, I would strongly suggest to use the [IMAP access provided by Google](http://mail.google.com/support/bin/answer.py?hl=en&answer=75725). Looking at the question the other way around, you can setup an [OpenID](http://openid-provider.appspot.com/) au...
Using Python's ftplib to get a directory listing, portably
|python|ftp|portability|
You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is: # File: ftplib-example-1.py import ftplib ftp = ftplib.FTP("www.python.org") ftp.login("anonymous", "ftplib-example-1") data = [] ftp.dir(data.append) ...
Attribute & Reflection libraries for C++?
|c++|reflection|attributes|
Most mature C++ projects seem to have an own **reflection and attribute system**, i.e for defining attributes which can be accessed by string and are automatically serializable. At least many C++ projects I participated in seemed to **reinvent the wheel**. Do you know any **good open source libraries** for C++ which...
I have found some C++ compilers (I.e. SunStudio) complain if the inline is omitted as in int AnotherFunc() { return 42; } So I would recommend always using the inline keyword in this case. And don't forget to remove the inline keyword if you later implement the method as an actual function call, this will re...
endian-ness of new macs - are all pc platforms the same now?
|macos|endian|
Does the change of macs over to intel chips mean we're done with the bit twiddling on numbers in binary resources for cross platform data distributions? Is that the last of this problem or are there some other platforms I'm not aware of?
I have had good experiences with Compass. It has really good integration with hibernate and can mirror data changes made through hibernate and jdbc directly to the Lucene indexes though its GPS devices http://www.compass-project.org/docs/1.2.2/reference/html/gps-jdbc.html. Maintaining the Lucene indexes on all your ...
Maybe this will help: http://jdbc.postgresql.org/documentation/83/callproc.html#callproc-resultset-setof I haven't really messed with that before :P
This might help you. It uses YUI, but you can probably port some of that functionality over to another library or custom code it. It should get you started though. [http://www.codeproject.com/KB/aspnet/aspnet-yahoouicalendar.aspx][1] [1]: http://www.codeproject.com/KB/aspnet/aspnet-yahoouicalendar.aspx
@Mike B - Thanks for the tip on ildasm - I didn't know about that tool. It appears that I misread/misunderstood Nish - the __clrcall modifier and the double-thunking problem it eliminates only apply to methods of NATIVE classes. All methods of Managed classes are __clrcall by default - which seems obvious in retrosp...
Wait until any of Future<T> is done or .wait() on few objects
|java|concurrency|multithreading|
Wait until any of Future<T> is done
|java|concurrency|multithreading|
I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished). Currently they are presented as Future<T>, so I need something like /** * Blocks current thread until one of specified futures is d...
I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished). Currently they are presented as Future<T>, so I need something like /** * Blocks current thread until one of specified futures is d...
The problem with this is that you are not guaranteed the process still being alive. IIS will reclaim the process basically whenever it feels like it, so you run the risk of it not being performed. If you need this work done then you need to either code it into a web call, or have a service running in the background ...
For my projects, I usually have a repo. On my laptop is a working copy, and the live website is a working copy. I make my changes on the local copy, using my local webserver. When everything is tested and ready to go, I commit the changes, then I ssh into the remote server and svn update. I also keep a folder in thi...
What I do at work, is use FTP to upload changes to a test server. Then when I am finished with the section of the site that I was working on, I commit the changes and update both. Sometimes, if I am working on something and I change a lot of files in different directories, I commit it and update the test server. But I ...
C++ timing, milliseconds since last whole second
|c++|timing|accurate|millisecond|
I'm working on a C++ application that needs detailed timing information, down to the millisecond level. We intend to gather the time to second accuracy using the standard time() function in <ctime>. We would like to additionally gather the milliseconds elapsed since the last second given by time(). Does anyo...
I would create a supertype / subtype relationship. THINGS ------ PK ThingId ALPHAS ------ FK ThingId AlphaCol1 AlphaCol2 AlphaCol3 BRAVOS ------ FK ThingId BravoCol1 BravoCol2 BravoCol3 ...
I would create a supertype / subtype relationship. THINGS ------ PK ThingId ALPHAS ------ FK ThingId (not null, identifying, exported from THINGS) AlphaCol1 AlphaCol2 AlphaCol3 BRAVOS ------ FK ThingId (not null, i...
You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is: # File: ftplib-example-1.py import ftplib ftp = ftplib.FTP("www.python.org") ftp.login("anonymous", "ftplib-example-1") data = [] ftp.dir(data.append) ...
**Get**. And then provide a way of calling them asynchronously to emphasize that they may be out to lunch for a while...
"Cocoa Touch Application" Template from XCode 3.1.1
|iphone|cocoa|xcode|iphone-sdk|
Just installed the latest SDK for iPhone 2.1. When I go to File -> New Project in XCode, under the iPhone OS Application selection, I don't see a template icon for "Cocoa Touch Application". Am I missing something? Anything else I need to download other than the iPhone SDK?
Just installed the latest SDK for iPhone 2.1. When I go to File -> New Project in XCode, under the iPhone OS Application selection, I don't see a template icon for "Cocoa Touch Application". Am I missing something? Anything else I need to download other than the iPhone SDK? If not, how do I add it to the "iPhone OS App...
|iphone|xcode|cocoa-touch|
FYI, there is a built-in one already on modern windows platforms. You need to use JScript, but it's close enough. Same environment also allows for VBScript. To run a program you can execute something like: cscript foo.js The windows system API is a bit weird and frustrating if you expect the same flexibility as ...