instruction
stringlengths
0
30k
Though I agree with scubabbl, here is a version without an inner while. int year = 2008; for (int m = Calendar.JANUARY; m <= Calendar.DECEMBER; m++) { Calendar cal = new GregorianCalendar(year, m, 1); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); int...
@ScArcher2 Making a second call is *extremely* dangerous. The process of `INSERT`ing and selecting the resultant auto-generated keys must be atomic, otherwise you may receive inconsistent results on the key select. Consider two asynchronous `INSERT`s where they both complete before either has a chance to select th...
As far as I know, GTK TextView doesn't include an undo function. So while I am not familiar with Python's GTK library, I would think it doesn't have one. The Ruby-GNOME2 project has a [sample text editor][1] that has undo/redo functionality. Basically they are connecting to the insert_text and delete_range signals o...
Ilkka: I was looking at Wireshark, but from what I could tell, that didn't handle the interception aspect -- only the sniffing and logging. The thing the professor's looking for is to prevent the spams from getting out onto the network. Adam: I'll definitely look into Winsock. I haven't checked that out yet. Only th...
Iterate over and check the byte value of every character in a string - VBA
|string|vba|loops|for-loop|
Iterate over and check the byte value of every character in a string - VBA Code I have: cell_val = CStr(Nz(fld.value, "")) Dim iter As Long For iter = 0 To Len(cell_val) - 1 Step 1 If Asc(Mid(cell_val, iter, 1)) > 127 Then addlog "Export contains...
Simply override any span styles. Set layout properties back to browser defaults and set formating to inherit from the parent: span#yourSpan { /* defaults */ position: static; display: inline; margin: 0; padding: 0; background: transparent; border: none; ...
Simply override any span styles. Set layout properties back to browser defaults and set formating to inherit from the parent: span#yourSpan { /* defaults */ position: static; display: inline; margin: 0; padding: 0; background: transparent; border: none; ...
Thanks, CDV. I'll look into that as well. Good call about the legality check. I've actually been trying to use gnu public license projects so far.
I think one aspect that defines real-time is that the process is *deterministic* - that is, the application's response time is totally predictable based on the inputs. Thus, painting with very broad brush-strokes, any app sitting on top of Windows can only be "near-real-time", at best. Doubly so if your app is runni...
Handling and storing elapsed time
|c#|database|datetime|timespan|
I'm having problems deciding on what is the best way is to handle and store time measurements. I have an app that has a textbox that allows the users to input time in either hh:mm:ss or mm:ss format. So I was planning on parsing this string, tokenizing it on the colons and creating TimeSpan (or using TimeSpan.Pa...
I think the simplest is to just convert user input into a integer number of seconds. So 54:12 == 3252 seconds, so store the 3252 in your database or wherever. Then when you need to display it to the user, you can convert it back again.
Here's what I've used in past projects: var myDate = new Date(); var tzo = (myDate.getTimezoneOffset()/60)*(-1); //get server date value here, the parseInvariant is from MS Ajax, you would need to do something similar on your own myDate = new Date.parseInvariant('<%=DataCurrentDate%>', 'yyyyMM...
Doing your own flush()ing sounds right to me - you want to be in control, not leave it to the vagaries of the generic buffer layer. This may be obvious, but make sure you're not calling write() too often - make sure every write() has enough data to be written to make the syscall overhead worth it. Also, in the othe...
The Voronoi diagram is just the dual of the Delaunay triangulation. So, the edges of the Voronoi diagram are along the perpendicular bisectors of the edges of the Delaunay triangulation, so compute those lines. Then, compute the vertices of the Voronoi diagram by finding the intersections of adjacent edges. Finally,...
For that you have to understand the standard IEEE 754 in order for proper binary representation. After that you can use **Float.intBitsToFloat** or **Double.longBitsToDouble**. http://en.wikipedia.org/wiki/IEEE_754
Even if it was actually useful for any reason (e.g. variable scope control), I would discourage you from such construct from the standpoint of good old code readibility.
Consider the following setup: A windows PC with a LAN interface and a WiFi interface (the standard for any new laptop). Each of the interfaces might be connected or disconnected from a network. I need a way to determine which one of the adapters is the one connected to the internet - specifically, in case they are bot...
Consider the following setup: A windows PC with a LAN interface and a WiFi interface (the standard for any new laptop). Each of the interfaces might be connected or disconnected from a network. I need a way to determine which one of the adapters is the one connected to the internet - specifically, in case they are bot...
Option 2 is the correct answer, unless you have a really good reason to add a surrogate numeric key (which you have done in option 1). Surrogate numeric key columns are not 'primary keys'. Primary keys are technically one of the combination of columns that uniquely identify a record within a table. Anyone buildi...
Your company appears not to be defining requirements clearly before starting a project, and this will only end in tears. My policy is to get a clear breakdown of all requirements in advance and have all parties know the implications of intruding these requirements. 1. Progressively Delayed Release times 2. ...
Additionally, `os.access()`.
Adobe has two products: Livecycle Data Services ES (LCDS) and BlazeDS. BlazeDS contains a subset of LCDS features and was made open source. Unfortunately NIO channels (RTMP NIO/HTTP) and the DataManagement features are implemented only in LCDS, not BlazeDS. BlazeDS can be used only to integrate Flex with Java backen...
It's nice for aggregating feeds, yes, but the other handy thing to do is filtering the feeds. A while back, I created a feed for Digg (before Digg fell into the Fark pit of dispair). I didn't care about the overwhelming Apple and Ubuntu news, so I filtered those keywords out of Technology, which I then combined with Sc...
For managers: - the sooner the product is released to the market (assuming it's shrink-wrap), the sooner the company can make money and the better the cashflow. - don't rule out the new feature outright, but balance it against the value you can derive from doing alternative work; explain the opportunity cost. ...
Lock-in feature set for a short time frame (Scrum/iteration/agile). As the user starts seeing things working, the necessity or lack thereof of features will become more apparent. Also, it is helpful to have a person through which all changes come (in Scrum, a really good Product Owner).
Have you tried setting the "margin" property? Not sure if that directly applies to your question.
They should be saying what they achieved not what they worked on, and if they achieved nothing then what stopped them achieving.
Hardware's generally pretty OS-agnostic (at least in terms of Windows flavors) these days. Your only concern is getting drivers for other devices (scanners, printers, IR remotes) that won't work on 64bit and/or won't work on "Server" OSes. Online backup software like Mozy generally won't even install on a Server OS, so...
Running DB Migrations from application
|ruby-on-rails|
I have a rails application where each user has a separate database (taking Joel Spolsky's advice on this). I want to run DB migrations from the rails application to create a new database and tables for this user. What is the easiest way to do this? Maybe db migrations is not the best for this type of thing. Thanks!
Sessions are tied to the server **AND** the domain. Using frameset across domain will cause all kind of breakage because that's just not how it was designed to do. Try using apache mod rewrite to create a "passthrough redirection", the "**proxy**" flag ([P]) in the rule is the magic flag that you need Documentat...
*Inside OLE* from Craig Brockschmidt probably has the best coverage on monikers. If you want to dig a little deeper into this topic, I'd recommend getting this book. It is also contained on the MSDN disk that came along with VS 6.0, in case you still have that.
I use: CTRL-F2 toggle bookmark F2 next bookmark SHIFT-F2 previous bookmark CTRL-SHIFT-F2 clear all bookmarks BTW, after using Visual Studio for years I just found about a couple of months ago that you can press ALT and drag mouse to mark a column or a square.
We use seperate configuration files for each user. So in the config/ dir we would have roo.database.yml which would connect to my personal database, and I would copy that over the database.yml file that is used by rails. We were thinking of expanding the rails Rakefile so we could specify the developer as a environ...
What sort of constraints? I'm guessing foreign key constraints, since you imply that deleting a row might violate the constraint. If that's the case, it seems like you don't really need a constraint per se, since you're not concerned with referential integrity. Without knowing more about your specific situation, I...
For quite some time I've been using [ProFont][1], mainly because it allows a lot of lines fit into a given height (a lot more than say Consolas or others). Consolas is not bad either, though... [1]: http://www.tobias-jung.de/seekingprofont/
Set up a post-build event under Project Properties: ilmerge /out:$(TargetDir)foo.exe $(TargetPath) $(TargetDir)bar.dll
Do you have a specific need in mind which makes you consider them? Stored procedures are much less portable than "plain" SQL, that's usually why people don't want to use them. Also, having written a fair share of PL/SQL, I must say that the procedural way of writing code is just not very modern or testable.
Do you have a specific need in mind which makes you consider them? Stored procedures are much less portable than "plain" SQL, that's usually why people don't want to use them. Also, having written a fair share of PL/SQL, I must say that the procedural way of writing code adds complexity and it's just not very modern or...
jQuery doesn't offer that. But [Prototype](http://www.prototypejs.org) does, via [Class.create](http://www.prototypejs.org/api/class/create).
I have done something similar, by decomposing images into signatures using [wavelet transform](http://en.wikipedia.org/wiki/Wavelet). My approach was to pick the most significant _n_ coefficients from each transformed channel, and recording their location. This was done by sorting the list of (power,location) tuple...
I have done something similar, by decomposing images into signatures using [wavelet transform](http://en.wikipedia.org/wiki/Wavelet). My approach was to pick the most significant _n_ coefficients from each transformed channel, and recording their location. This was done by sorting the list of (power,location) tuple...
Real-time = Guaranteed maximum time for resolution. It could be picoseconds or minutes depending on the application's requirements This is StackOverflow's biggest problem: unqualified people answer LOTS of questions with answers that "sound right" and get voted up, people who care whether the answer is actually cor...
Virtual functions in constructors, why do languages differ?
|c++|.net|java|language-agnostic|
In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered for the first time was surprised but on second thought it makes sense, if the derived constructor hasn't yet run the object is **not** yet a *derived* so how can a derived funct...
|.net|java|c++|language-agnostic|
In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered for the first time was surprised but on second thought it makes sense, if the derived constructor hasn't yet run the object is **not** yet a *derived* so how can a derived funct...
In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered for the first time was surprised but on second thought it makes sense, if the derived constructor hasn't yet run the object is **not** yet a *derived* so how can a derived funct...
They should be saying what they achieved not what they worked on, and if they achieved nothing then what stopped them achieving. The questions that are asked could be phrased differently 1. What have I completed since thelast meeting? 2. What will I complete before the next meeting? 3. What is in my way (i...
They should be saying what they achieved not what they worked on, and if they achieved nothing then what stopped them achieving. The questions that are asked could be phrased differently 1. What have I completed since thelast meeting? 2. What will I complete before the next meeting? 3. What is in my way (i...
Re: Ruby on Rails vs. PHP - whichever you're currently competent in. If neither, whichever you'd *like* to become competent in. Both can do what you want.
How to read commandline parameters in console application
|parameters|
Below are two ways of reading in the commandline parameters. The first is the way that I'm accustom to seeing using the parameter in the main. The second I stumbled on when reviewing code. I noticed that the second assigns the first item in the array to the path and application but the first skips this. Is it j...
|parameters|.net|command-line|
|parameters|.net|
|parameters|.net|command-line|vb.net|
|parameters|.net|command-line|
Below are two ways of reading in the commandline parameters. The first is the way that I'm accustom to seeing using the parameter in the main. The second I stumbled on when reviewing code. I noticed that the second assigns the first item in the array to the path and application but the first skips this. Is it j...
How important is a database in managing information?
|database|
I have been hired to help write an application that manages certain information for the end user. It is intended to manage a few megabytes of information, but also manage scanned images in full resolution. Should this project use a database, and why or why not?
ulimit -c unlimited is a system variable, wich will create a core dump after your application crashes. look for a file called core.dump or equal in the very same directory regards
ulimit -c unlimited is a system variable, wich will allow to create a core dump after your application crashes. In this case an unlimited amount. Look for a file called core in the very same directory. Make sure you compiled your code with debugging informations enabled! regards
You did not specify your operating system, so this is difficult to answer. If you are using a system based on gnu libc, you might be able to use the libc function backtrace(). GCC also has two builtins that can assist you, but which may or may not be implemented fully on your architecture, and those are __builtin_fr...
My advice is to lazily evaluate your own dependency tree. Study something you think is interesting -- when you hit something you don't know, go learn about it. I always find it easier to learn something new when I already have a context in which I want to use it.
This may sound stupid, but just hear me out. Check all the indexes and primary keys involved in your query. Do they exist? Are they fragmented? I've had a problem where, so some reason, running the script outright worked just find, but then when I did it through the application, it was slow as dirt. The reader's b...
You could use CSS to attain this. By specifying the list in the color and style of your choice, you can then also specify the text as a different color. Follow the example at [http://www.echoecho.com/csslists.htm][1]. [1]: http://www.echoecho.com/csslists.htm
Given a html page like this: `<body>`<br/> ` <table id="my-table">`<br/> ` <tr>`<br/> ` <td><div>This is the contents of Column One</div></td>`<br/> ` <td><div>This is the contents of Column Two</div></td>`<br/> ` <td><div>This is the contents of Column Three</div></td...
Used for my Visual Studio projects */bin */obj *.user *.suo You can expand more file types from there.
Most databases have some sort of time interval type. The answer depends on which database you're talking about. For Oracle, it's just a floating point NUMBER that represents the number of days (including fractional days). You can add/subtract that to/from any DATE type and you get the right answer.
Floor a date in SQL server
|sql-server|t-sql|
In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year? Let's say that I have a date of **2008-09-17 12:56:53.430**, then the output of flooring should be: * Year: 2008-01-01 00:00:00.000 * Month: 2008-09-01 00:00:00.000 * Day: 2008-09-17 00:00:00.000 * Hour: 2008-09-17 12:00:00.000 * ...
As an integer count of seconds (or Milliseconds as appropriate)
I'll add my own two cents to this question: I use the following SVN ignore pattern with TortoiseSVN and Subversion CLI for native C++, C#/VB.NET, and PERL projects on both Windows and Linux platforms. It works well for me! *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store thumbs.db Thumbs.db *.bak *.class *.ex...
I don't believe anything other than those 2 parameters are available to report subscription emails (at least in SSRS 2005). You may be able to do something via a data-driven subscription, but the values you want to use need to be in the data source used for the subscription data - SSRS is still not able to collect...
The key is to use [DATEADD](http://msdn.microsoft.com/en-us/library/ms186819.aspx) and [DATEDIFF](http://msdn.microsoft.com/en-us/library/ms189794.aspx) along with the appropriate SQL timespan enumeration. declare @datetime datetime; set @datetime = getdate(); select @datetime; select dateadd(year...
Forms auth is implemented on the web site instance. Its not going to work that way.
TimeSpan has an Int64 [Ticks][1] property that you can store instead, and a [constructor][2] that takes a Ticks value. [1]: http://msdn.microsoft.com/en-us/library/system.timespan.ticks.aspx [2]: http://msdn.microsoft.com/en-us/library/zz841zbz.aspx
CTRL-D then type ">of " then file name. If the standard toolbar is up crtl-d put you in find combobox and there is now a dropdown with files in your solution that match the start of the filename you typed. Pick one and it will open it. This alternative to the open filedialog is awesome for big solutions with lots of ...
How to take screenshot in Mac OS X using Cocoa or C++
|c++|macos|cocoa|
How to take screenshot programmically of desktop area in Mac OS X ?
C# Lookup: Nothing to calculate really, just look it up. To extend it,add another 8 numbers to the table and 64 bit integers are at at their limit. Beyond that, a BigNum class is called for. public static int Factorial(int f) { if (f<0 || f>12) { throw new ArgumentExcepti...
As you say, there's no Adobe-created way to do this, but you might have better luck with [Zinc][1], it is similar to AIR but provides real OS integration of Flash-based applications. Look though the [API docs][2], there should be something there. [1]: http://www.multidmedia.com/ [2]: http://www.multidmedia.co...
I believe that 6 of the 9 licenses on the OSI's list of "Licenses that are popular and widely used or with strong communities" meet your criterion: Apache, BSD, MIT, Mozilla, CPL, and Eclipse. Both the Mozilla license and CPL (the Common Public License) have language concerning patents might make them more attractive t...
I believe that 6 of the 9 licenses on the OSI's list of "Licenses that are popular and widely used or with strong communities" meet your criterion: Apache, BSD, MIT, Mozilla, CPL, and Eclipse. The Mozilla license and CPL (the Common Public License) have language concerning patents that might make them more attractive t...
Here's an old blog article on some of the [hidden debugger features in the expression evaluators][1]. [1]: http://blogs.msdn.com/stevejs/default.aspx?p=2
SELECT Field1, Field2, 'Value' Field3 FROM Table or for clarity SELECT Field1, Field2, 'Value' AS Field3 FROM Table
Yes - it's very possible, in fact you almost had it! Try: SELECT Field1, Field2, 'Value' AS `Field3` FROM Table
I prefer a mix of the techinques used by Josh and Mark Harrison: Two tables, one with the data of the Person and other with the hierarchichal info (person_id, parent_id [, mother_id]) if the PK of this table is person_id, you have a simple tree with only one parent by node (which makes sense in this case, but not in...
Pretty simple: list( $h, $m, $s) = explode(':', $hms); echo ($h ? "$h hours, " : "").($m ? "$m minutes, " : "").(($h || $m) ? "and " : "")."$s seconds"; This will only display the hours or minutes if there are any, and inserts an "and" before the seconds if there are hours, minutes, or both to display. I...
Read the file line by line and only write those lines to a new file that don't match the regex. You cannot just remove a line.