instruction
stringlengths
0
30k
Maybe this is a silly question, but I've always assumed each number delineated by a period represented a single component of the software. If that's true, do they ever represent something different? I'd like to start assigning versions to the different builds of my software, but I'm not really sure how it should be st...
To concatenate two strings using '+', a new string needs to be allocated with space for both strings, and then the data copied over from both strings. A StringBuffer is optimized for concatenating, and allocates more space than needed initially. When you concatenate a new string, in most cases, the characters can sim...
Well the only way to garuntee the ID is unique, is to make have more id combinations than what your gettings ids from eg for 2 shorts (assuming 16bit), you sohuld use a 32bit int int ID = ((int)short1 << 8) & short2; and for 4 shorts you would need a 64bit int, etc... With basicly anything else collis...
Well the only way to garuntee the ID is unique, is to make have more id combinations than what your gettings ids from eg for 2 shorts (assuming 16bit), you sohuld use a 32bit int int ID = ((int)short1 << 8) | short2; and for 4 shorts you would need a 64bit int, etc... With basicly anything else collis...
Well the only way to garuntee the ID is unique, is to make have more id combinations than what your gettings ids from eg for 2 shorts (assuming 16bit), you sohuld use a 32bit int int ID = ((int)short1 << 16) | short2; and for 4 shorts you would need a 64bit int, etc... With basicly anything else colli...
Silverlight doesn't yet have the market penetration for mission critical stuff. The big deployments of it have been mainly situations where Microsoft is trying to push market penetration by paying NBC to host Olympics content and the like. Flash is the de facto standard for rich media sites. Animated GIFs are extr...
You can try the switch **-q**. -q,--quiet Quiet output - only show errors
This will work OK if the memory being pointed to **and** the pointer you are pointing with are both POD. In this case, no destructor would be called anyhow, and the memory allocator does not know or care about the type stored within the memory. The only case this is OK with non-POD types, is if the pointee is a subt...
Use the -q or --quiet command-line options
Don't. Just don't. Write it into the contract (or revise the contract if you have to), that you are not responsible for changes they make to the software. If they're f-ing up your code and then expecting you to fix it, *you have client problems that aren't going to be solved by obfuscating the code*. And if you obfu...
I've been using screen for over 10 years and probably use less than half the features. So it's definitely not necessary to learn all its features right away (and I wouldn't recommend trying). My day-to-day commands are: ^A ^W - window list, where am I ^A ^C - create new window ^A space - next window ...
I've been using screen for over 10 years and probably use less than half the features. So it's definitely not necessary to learn all its features right away (and I wouldn't recommend trying). My day-to-day commands are: ^A ^W - window list, where am I ^A ^C - create new window ^A space - next window ...
For compression, look at the [System.IO.Compression](http://msdn.microsoft.com/en-us/library/system.io.compression.aspx) namespace and for encryption look at [System.Security.Cryptography](http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx). Skizz
Here is a useful topic: http://stackoverflow.com/questions/71000/help-in-creating-zip-files-from-net-and-reading-them-from-java System.IO.Packaging namespace gives you useful classes to compress data in zip format and [support][1] rights management. [1]: http://msdn.microsoft.com/en-us/library/ms580548....
The [GZipStream][1] class is a native way to handle compression. As for encryption, there are [many][2] [ways][3] to do it, most of them in the System.Security namespace. They can be done chained (encrypt a compressed stream or compress an encrypted stream). [1]: http://blogs.msdn.com/bclteam/archive/2005/06/...
The tilde (~) is the [siblings selector][1]: $('#active ~ img.a').hide(); [1]: http://docs.jquery.com/Selectors/siblings#prevsiblings
use variables in the outer function instead of global variables. This gets you the best of both approaches: you're not mutating global state, and you're not copying a big wad of data. If you have to exit early, just return the partial results. (See the "Scope" section in the R manual: http://cran.r-project.org/doc/m...
If you want a one-dimensional array of libraries returned, with duplicates removed. l.books.map{|b| b.libraries}.flatten.uniq
I wouldn't use floating point at all on a CPU without special hardware for handling it. My advice is to treat ALL numbers as integers scaled to a specific factor. For example, all monetary values are in cents as integers rather than dollars as floats. For example, 0.72 is represented as the integer 72. Addition a...
For shared javascript resources using the Content folder makes sense. The issue was I was specifically trying to solve was aspx page specific javascript that would never be reused. I think what I will just have to do is put the aspx page specific javascript right onto the page itself and keep the shared js resource...
Dealing with Date only dates across timezones in .Net
|.net|date|
Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where *only* the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone is. The ...
How do I import facebook friends from another website
|facebook|
I am looking for a way to connect to facebook by allowing the user to enter in their username and password and have our app connect to their account and get their contacts so that they can invite them to join their group on our site. I have written a facebook app before, but this is not an app as much as it is a conne...
Qt is cross-platform, Delphi not much if we count Kylix. Lazarus is cross-platform, but not quite feature-complete yet.
It's commercial, but <a href="http://www.ej-technologies.com/products/install4j/overview.html">install4j</a> will do this for you, including installing the service.
This approach is actually much better than some others that I have seen. Some functions in C, for example, when they encounter an error they return and seem to succeed. The only way to tell that they failed is to call a function that will get the latest error. I spent hours trying to debug semaphore code on my MacBo...
. . . not totally sure what your trying to do, but you normally control the source of an iframe through javascript
Regular expression solutions tend to be much slower than basic text replacement, so i'd replace double seperators with single seperators, trim the string of any whitespace and then use explode: // assuming $source = '1/2//3/'; $source = str_replace('//', '/', $source); $source = trim($source); $pa...
Alternatively if you want to roll your own and the sites in question are not on the same servers or don't have access to a shared database (in which case see the above responses) then you could place a [web beacon][1] on each of the sites which would refer back to the other site. Place a single pixel image (web bea...
how to remove this kind of symbols from string?
|string|algorithm|unicode|
Imagine I have String in C#: "I Don’t see ya.." I want to remove (replace to nothing or etc...) these "’" symbols. Any ideas how to do this? :)
how to remove this kind of symbols (junk) from string?
|algorithm|string|unicode|
The most direct option is going to be to use the [ToTitleCase][1] function that is available in .NET which should take care of the name most of the time. As [edg][2] pointed out there are some names that it will not work for, but these are fairly rare so unless you are targeting a culture where such names are common it...
I am unable to reproduce the behaviour you are seeing. Here is my code: <pre> package hibtest; import javax.persistence.*; @Entity public class Foo { private Long id; private String name; private Bar bar; public Foo() { } public Foo(String name) { this.name = name; } @Id @GeneratedValue(strategy ...
I am unable to reproduce the behaviour you are seeing. Here is my code: @Entity public class Foo { private Long id; private String name; private Bar bar; public Foo() { } public Foo(String name) { this.name = name; } @Id @GeneratedValue(strategy = GenerationType.A...
I would just put it on a disk for historical sake. Use the [Standard Template Library][1] - one mistake people make is assuming that thier implementation of moderate to complex data structures are the best. I can't tell you how many times I have found a bug in a home grown B-tree implementation. [1]: http://www...
I use kscope, which uses cscope in the background, but provides function lists etc. as well. Seems to handle large projects like the linux kernel well too. The [kscope homepage][1] has a good concise description of what it does and doesn't do. [1]: http://kscope.sourceforge.net/
Comparing names
|string|comparison|
Is there any 'simple' algorithm to determine the likeliness of 2 names representing the same person? I'm not asking for something of the level that Custom department might be using. Just a simple algo that would tell me if 'James T. Clark' is most likely the same name as 'J. Thomas Clark' or 'James Clerk'. If there ...
I like a splash of colour in my prompts: export PS1="\[\033[07;31m\] \h \[\033[47;30m\] \W \[\033[00;31m\] \$ \[\e[m\]" I'm afraid I don't have a screenshot for what that looks like, but it's supposed to be something like (all on one line): [RED BACK WHITE TEXT] Computer name [BLACK BACK WHITE TE...
How do I copy a file to a remote server in python using scp or ssh?
|python|
I have a text file on my local machine that is generated by a python script run daily in cron. I would like to add a bit of code to have that file sent securely to my server over ssh. Help.
|python|automation|scp|
Some useful mencoder commands I found out about when looking for some audio and video editing tools: from .xxx to .avi mencoder movie.wmv -o movie.avi -ovc lavc -oac lavc Dump sound from a video: mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile fileout.mp3 filein.avi
If you expect your app to work for everyone, you'll need a backup for all your javascript functionality. If it's form validation, you should also check the data on the server before saving it. So the answer is Yes, it's okay, but have a backup. Do not rely on it.
<esc>-. Inserts the last arguments from your last bash command. It comes in handy more than you think. cp file /to/some/long/path cd <esc>-.
[Levenshtein][1] is close, although maybe not exactly what you want. [1]: http://en.wikipedia.org/wiki/Levenshtein_distance
rename Example: <pre><code>$ ls this_has_text_to_find_1.txt this_has_text_to_find_2.txt this_has_text_to_find_3.txt this_has_text_to_find_4.txt $ rename 's/text_to_find/been_renamed/' *.txt $ ls this_has_been_renamed_1.txt this_has_been_renamed_2.txt this_has_been_renamed_3.txt this_has_been_renamed_4...
Why are relational set-based queries better than cursors?
|sql|language-agnostic|query|cursor|
When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once. Also, we have the choice of simply pulling a large set of data back into our application and then p...
|sql|language-agnostic|query|cursors|
Convince Firefox to send an If-Modified-Since header over HTTPS
|http|firefox|webdevelopment|
|firefox|http|webdevelopment|
|firefox|http|
|firefox|https|
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL t...
Proceed as usual: <br /> Start by implementing it according to the standard. And then handle the corner cases, i.e. the DBMSes which don't implement the standard. How to handle the corner cases depends on your development environment. I've writte about the standard and the implementations here: [http://troels.arv...
Proceed as usual: <br /> Start by implementing it according to the standard. And then handle the corner cases, i.e. the DBMSes which don't implement the standard. How to handle the corner cases depends on your development environment. You are looking for a "universal" approach. The most universal way to paginate i...
I have no direct experience with JitterBit, but I have heard very good things from coworkers.
I've always gone the OSS way and have never had a problem. I would also highly recommend TeamCity for your CI solution. There is a free licence and I think it blows CC.NET out of the water for ease of configuration and feedback.
I suggest that you follow these steps: 1. Write a set of wrapper functions, e.g MyCreateFile, MyReadFile, etc, that initially just call the corresponding API and pass the same arguments along, unmodified. 2. Use your text editor to search for all calls to the original APIs, and replace these with calls to your ne...
I suggest that you follow these steps: 1. Write a set of wrapper functions, e.g MyCreateFile, MyReadFile, etc, that initially just call the corresponding API and pass the same arguments along, unmodified. 2. Use your text editor to search for all calls to the original APIs, and replace these with calls to your ne...
I suggest that you follow these steps: 1. Write a set of wrapper functions, e.g MyCreateFile, MyReadFile, etc, that initially just call the corresponding API and pass the same arguments along, unmodified. 2. Use your text editor to search for all calls to the original APIs, and replace these with calls to your ne...
I've used [openSTA](http://www.opensta.org/"openSTA"). This allows a session with a web site to be recorded and then played back via a relatively simple script language. You can easily test web services and write your own scripts. It allows you to put scripts together in a test in any way you want and configur...
Though they are (mostly) identical (see below for the one [bug] difference), you definately should care and you should use Int32. - The keyword for a 16 bit integer is Int16, for a 64 bit integer it's Int64, and for a 32 bit integer the intuitive choice is: int or Int32? - The question of the size of a variable o...
Though they are (mostly) identical (see below for the one [bug] difference), you definately should care and you should use Int32. - The name for a 16 bit integer is Int16, for a 64 bit integer it's Int64, and for a 32 bit integer the intuitive choice is: int or Int32? - The question of the size of a variable of t...
I am looking for a way to connect to facebook by allowing the user to enter in their username and password and have our app connect to their account and get their contacts so that they can invite them to join their group on our site. I have written a facebook app before, but this is not an app as much as it is a conne...
If it must really be as small as possible, use plain C and talk to the Windows API directly. However, since you're going to have the CLR loaded anyway because of the .NET dll, I would opt for something less painful and simply use C# for the UI as well.
My vote is KDevelop (I wish I had more points so I can "vote up", so I could just agree with others indirectly than comment). I've been using Eclipse for about couple years now for personal use, convincing myself that "since IBM donated it, it must be good", but then I've discovered KDevelop and never turned back. ...
Third approach: inner function returns a reference to the large array, which the next statement inside the loop then dereferences and stores wherever it's needed (ideally with a single pointer store and not by having to memcopy the entire array). This gets rid of both the side effect and the passing of large datas...
Parsing HTTP Headers
|c|http|post|header|
I've had a new found interest in building a small, efficient web server in C and have had some trouble parsing POST methods from the HTTP Header. Would anyone have any advice as to how to handle retrieving the name/value pairs from the "posted" data? POST /yeah HTTP/1.1 Host: cor.cs.uky.edu:7017 User-A...
It is NOT faster to use explicit field names versus *, if and only if, you need to get the data for all fields. Your client software shouldn't depend on the order of the fields returned, so that's a nonsense too. And it's possible (though unlikely) that you need to get all fields using * because you don't yet k...
Update: The solution I gave is based on the assumption that it is a stored proc. *Will giving a default value of Null to the SQL Stored proc parameters work?* If it is dynamic sql, always pass the correct number of params, whether it is null or the actual value.
Update: The solution I gave is based on the assumption that it is a stored proc. *Will giving a default value of Null to the SQL Stored proc parameters work?* If it is dynamic sql, always pass the correct number of params, whether it is null or the actual value or specify default values.
The holy grail- Ctrl-C, Ctrl-V I kid, I kid! Try the veal!
It's better to use StringBuilder (it's an unsynchronized version; when do you build strings in parallel?) these days, in almost every case, but here's what happens: When you use + with two strings, it compiles code like this: String third = first + second; To something like this: StringBuilder build...
It can be very arbitrary, and differs from product to product. For example, with the Ubuntu distribution, 8.04 refers to 2008.April Typically the left most (major) numbers indicate a major release, and the further you go to the right, the smaller the change involved.
The StringBuffer class maintains an array of characters to hold the contents of the strings you concatenate, whereas the + method creates a new string each time its called and appends the two parameters (param1 + param2). The StringBuffer is faster because 1. it might be able to use its already existing array to con...
:ls for list of open buffers - :bp previous buffer - :bn next buffer - :bn move to nth buffer - :b <filename-part> with tab-key providing auto-completion (awesome !!) or when u are in normal mode ^ to switch to the last file u were working on plus, you can save sessions of vim :mksessio...
I suggest that you follow these steps: 1. Write a set of wrapper functions, e.g MyCreateFile, MyReadFile, etc, that initially just call the corresponding API and pass the same arguments along, unmodified. 2. Use your text editor to search for all calls to the original APIs, and replace these with calls to your ne...
You could just write your new functions in a custom namespace. e.g. namespace Bluetooth { void CreateFile(/*params*/); void etc... } Then in your code, the only thing you would have to change is: if (::CreateFile(...)) { } to if (Bluetooth::CreateFile(...)) ...
I did use urlmon.dll in the end. I thought there would be an easier way but this works. I include the code to help anyone else and allow me to find it again if I need it. using System.Runtime.InteropServices; ... [DllImport(@"urlmon.dll", CharSet = CharSet.Auto)] private extern static System...
Here is what I would do. Let's say I want the following folder hierarchy : /MyWholeApp will containt the files for the whole application. /MyWholeApp/DummyDlg/ will contain the files for the standalone dialogbox which will be eventually part of the whoel application. I would develop the standalone di...
First enable keyword substitution for a file where you wish to have the revision info: svn propset svn:keywords "Rev" file.txt The add to the file where you want the Revision info stored: $Rev$ Further readings: [http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html][1] ...
This has less to do with javascript and more to do with the [CSS coding][1]. Try a few experiments with just HTML and CSS to get the image to clip properly, then add the javascript to move it around. If you can't get it to clip with HTML, or move with the javascript post the simplest demonstration of the problem ...
In the flags for the javac compiler, set the -encoding flag, so in your case you'd mark it as javac -encoding UTF-8 Check [here][1] for a quick explanation from the sun forums. [1]: http://forums.sun.com/thread.jspa?threadID=657056&tstart=74
I found restlet to be a really elegant architecture. I'm working in the .net world so it was not an option for me, but I was able to build my own framework following the same basic principles of restlet. I have found the conversion of our WCF contract-based SOA application to REST based one has significantly simplif...
Think of it this way. SQL Lite will be locked every time someone uses it. So if your serving up a web page or a application that has multiple concurrent users only one could use your app at a time with SQLLite. So right there is a scaling issue. If its a one person application say a Music Library where you hold hundred...
Set up a directory of images. Select seven images and name them 0.jpg, 1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg, 6.jpg, Using mootools Javascript framework with an image tag in HTML with id "rotatingimage": var d=new Date(); var utc = d.getTime() + (d.getTimezoneOffset() * 60000); var offset = -10; // se...