instruction
stringlengths
0
30k
[Boost signals][1] is another commonly used library you might come across to do Observer Pattern (aka Publish-Subscribe). Buyer beware here, I've heard its performance is terrible. [1]: http://www.boost.org/doc/libs/1_36_0/doc/html/signals.html
I'm not sure you need separate controllers based on header; this structure sounds perfectly reasonable. If your controller is massive as you say, consider whether it's dealing with multiple resources, and if it is, perhaps it should be split into multiple controllers based on resource?
There's no way to stop Google from holding my gmail inbox hostage until I pay them $n. It's a trust thing, I guess.
Experimenting with Excel 2007 from Visual Basic, I discovered that the page break isn't known unless it has been displayed on the screen at least once. The best workaround I could find was to page down, from the top of the sheet to the last row containing data. Then you can enumerate all the page breaks. Here's t...
> because it loads all the environement, loads fixtures and all that jazz. The real culprit is if you run it using `rake spec`, [it runs the `db:test:prepare` task](http://github.com/dchelimsky/rspec-rails/tree/master/generators/rspec/templates/rspec.rake#L11). This task drops your entire test database and re-cr...
The date is stored in the <a href="http://en.wikipedia.org/wiki/Exif">EXIF</a> data in the jpeg. There's a <a href="http://www.drewnoakes.com/code/exif/">java library</a> and a <a href="http://sourceforge.net/projects/jexifviewer/">viewer in java</a> that might be helpful.
I have a simple strategy that works every time. First, I develop the site using commonly accepted CSS to look good in Safari and Firefox 3. See [w3schools.com][1] for details on browser support. Then, I go into IE6 and IE7 and alter the CSS using [conditional includes][2]. This is hack free and lets you handle...
If you're using JDK 6 (you really should), the Desktop API is now part of the JRE. See <http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/> for more information.
create table A ( At datetime not null, State varchar(20) not null ) go insert into A(At,State) select '2008-08-01T13:30:00','Initial' union all select '2008-08-02T13:30:00','Work' union all select '2008-08-03T13:30:00','Review' union all select '2008-08-04T13:30:00','W...
create table A ( At datetime not null, State varchar(20) not null ) go insert into A(At,State) select '2008-08-01T13:30:00','Initial' union all select '2008-08-02T13:30:00','Work' union all select '2008-08-03T13:30:00','Review' union all select '2008-08-04T13:30:00','W...
How to convert GMT to LocalTime in Win32 C
|c|winapi|timezone|
I want to convert various location/date/times in history from GMT to local time. It seems that `SystemTimeToTzSpecificLocalTime` is better than `FileTimeToLocalFileTime`. When the date/time pairs also include various locations, the conversion gets hairy. I've found a data set at [ftp://elsie.nci.nih.gov/pub/][1] that ...
I want to convert various location/date/times in history from GMT to local time. It seems that `SystemTimeToTzSpecificLocalTime` is better than `FileTimeToLocalFileTime`. When the date/time pairs also include various locations, the conversion gets hairy. I've found a data set at [ftp://elsie.nci.nih.gov/pub/][1] that ...
How do I convert GMT to LocalTime in Win32 C?
I tend to do all of my testing in another environment (not the live one!). This allows me to push the updates to the live site knowing that the code should be working ok, and I just do sanity testing on the live data - make sure I didn't forget a file somewhere, or had something weird go wrong. So proper testing in...
Also check [this article][1]. Supposedly Microsoft released their [Enterprise Library (v4.0)][2] from their patterns and practices where they cover the validation subject but god knows why they didn't included validation for WPF, so the blog post I'm directing you to, explains what the author did to adapt it. Hope this...
We migrated from VSS to SVN very easily. TortoiseSVN, in the Win32 environment, integrates well with Explorer. To setup your server. I would recommend a mirrored raid setup with Ubuntu Server installed. Once you have this running, set up apache and svn to host the repository from the raid. For a small team like your...
[Assembla][1] and [BeanStalk][2] are nice, both have things like; wiki, discussion, alerts, chat, ticketing, Trac, Git and Subversion [1]: http://www.assembla.com/ [2]: http://beanstalkapp.com/
what is the difference between adobe true type font and type one font?
|fonts|truetype|
what is the difference between adobe true type font and type one font?
OK, maybe cheating a bit :). My answer for C: a b{a c=b; d c;} Of course you have to compile it like this: gcc -D"a=int" -D"b=main()" -D"d=return" so.c
OK, maybe cheating a bit :). My answer for C: a b{a c=b*b; d c;} Of course you have to compile it like this: gcc -D"a=int" -D"b=main()" -D"d=return" so.c Note, this works with gcc -O3, whereas the two version below don't: a b{a c=b; d c;} a b{a c=b+1; d c;}
EDIT: shorter answer: a{return a*a}; Still works(i.e. crashes) with gcc -O3. Expands to: main() { return main()*main(); } Compile with: gcc -O3 -D"a=main()" so.c *** OK, maybe cheating a bit :). My answer for C: a b{a c=b*b; d c;} Of course you have to compile ...
a{return a*a;}; Compile with: gcc -D"a=main()" so.c Expands to: main() { return main()*main(); }
I always use them, but then I make databases for financial systems. The database is the critical part of the application. If the data in a financial database isn't totally accurate then it really doesn't matter how much effort you put into your code/front-end design. You're just wasting your time. There's also th...
If you haven't already checked out [A List Apart][1] you should, as it contains some excellent tutorials and guidelines for website design. [This article][2] in particular should help you out. [1]: http://www.alistapart.com/ [2]: http://alistapart.com/articles/holygrail
If you choose to rewrite new/delete, I have done this and have simple source code at: <a href="http://gandolf.homelinux.org/~smhanov/blog/?id=10">http://gandolf.homelinux.org/~smhanov/blog/?id=10</a> This catches memory leaks and also inserts guard data before and after the memory block to capture heap corruption...
The [Beagle Project][1] for Linux is written in c# (mono) and is a google-desktop like search tool. It may have some code in there for these kind of string matching. If I recall correctly, it uses the [Lucene][2] library for searching and retrieving data. Maybe that can be useful for your project too. [1]: ht...
I use it all the time. Why look at potentially flawed documentation when you can see the actual source?
Just manipulate your order and group clauses as necessary. Excel is fast because all the data is in memory, and it can be sorted fast and efficiently.
I faced the same problem with my college project a few years ago. I responded (in a rather weasel way) by splitting the year and the date(MM:DD) in two separate columns. And before that, my project mate was simply getting all the dates and programatically going through them. We changed that because it was too inefficie...
How to access custom fields from the global class in a webhandler?
|asp.net|c#|
I added some custom fields (public booleans) to the global class in global.asax.cs which are initialized during the Application_Start event. How do I access them in a webhandler (ashx)?
|c#|asp.net|
I added some custom fields (public booleans) to the global class in global.asax.cs which are initialized during the Application_Start event. How do I access them in a webhandler (ashx)? Or is it better to save them in the Application state object?
I think that your steps (each record of your trip can be seen as a step) can be somewhere grouped together as part of the same activity. It is then possible to group your data on it, as, for example: SELECT Min(Tbl_Step.dateTimeStep) as tripBegin, _ Max(Tbl_Step.dateTimeStep) as tripEnd _ FRO...
Using IIF(RowNumber...) can lead to some issues when rows are being grouped and another alternative is to use a simple VBScript function to determine the color. It's a little more effort but when the basic solution does not suffice, it's a nice alternative. Basically, you add code to the Report as follows... ...
I don't know Python, but your question seems very general. Ignore me if it's specific to Python. Class nesting is all about scope. If you think that one class will only make sense in the context of another one, then the former is probably a good candidate to become a nested class. It is a common pattern make help...
Java Code Signing Certificates...same as SSL Certificate?
|java|ssl|certificate|code-signing|
I'm looking around for a Java Code Signing certificate so my Java applets don't throw up such scary security warnings. However all the places I've found offering them charge (in my opinion) way too much, like over $200 per year. While doing research, a code signing certificate seems almost exactly the same as a SSL cer...
Source: [this link][1] - Open the database db = sqlite3.open("filename") -- Ten attempts are made to proceed, if the database is locked function my_busy_handler(attempts_made) if attempts_made < 10 then return true else return false end end ...
When should XML be used for data persistence instead of a database? Almost never. XML is a data transport language. It is slow to parse and awkward to query. Parse the XML (don't shred it!) and convert the resulting data into domain objects. Then persist the domain objects. A major advantage of a database for persisten...
Not sure if it is possible, but it seems like this would be something like the AcceptVerbs attribute that was [added in Preview 5][1]. I'd take a look at how that was implemented (get the MVC source) to see if you can add something similar based on content type. [1]: http://weblogs.asp.net/scottgu/archive/2008/...
how to embed a true type font within a postscript file
|fonts|true|types|cups|postscript|
I have a cross platform app and for my Linux and Mac versions it generates a postscript file for printing reports and then prints them with CUPS. It works for simple characters and images but I would like to have the ability to embed a true type font directly into the postscript file. Does anyone know how to do this?? ...
CL-WHO can generate XML pretty easily.
What table is being accessed when the lock is encountered? Do you have long-running transactions? Can you figure out which requests were still being processed when the lock was encountered?
I don't think that, if you specify a doctype, there is any reason not to adhere to this doctype. Using XHTML makes automated error detection easy, every change can be automatically checked for invalid markup. This prevents errors, especially when using automatically generated content. It is really easy for a web dev...
How can I control checkboxes in a .Net Forms.TreeView?
|.net|treeview|
I have a .Net desktop application with a TreeView as one of the UI elements. I want to be able to multi-select that TreeView, only that isn't supported at all. So I'm adding check-boxes to the tree, My problem is that only some items are selectable, and those that aren't can't consistently cascade selections. ...
|.net|treeview|winforms|
|.net|treeview|winforms|treenode|
|.net|winforms|treeview|treenode|
Generally I don't like "loop through the record" solutions as they tend to be slow and you end up writing a lot of custom code. So... Depending on how many records are in your staging table, you could post process the data with a series of SQL statements that test the columns for correctness and mark any records ...
I've been a on-again, off-again user of vim throughout the years (doing the occasional sys admin job). I just recently started spending more time doing my programming work in it. I'd suggest starting with gvim too. It integrates well with most OS environments, and (even better), you can fall back to the mouse when y...
I've always used `<table width="100%">`
Google is your friend. Keep a window or tab handy and when you have something that you need to do several times, say indent code or search with a regex, look it up. The best hints sites will become familar, bookmark some and perhaps print out a cheat sheet.
The image dimensions being multiples of 8 or 16 is not going to affect the size on disk very much, but you can get dramatic savings if you can line up the visual contents to the 8x8 pixel grid, such as if there is a repeating pattern or texture in the image.
If there are no other variables that reference the items in the collection then those objects should be handed to the Garbage Collector to be cleaned up the next time the GC is run. If you, for example do this where sObj is a static variable somewhere then the when the GC is invoked next by the system, the first obj...
Password strength checkers, and if you have time+resources (its justified only if you are checking for more than a few passwords) use Rainbow Tables.
With a series of checks to ensure it meets minimum criteria:<ul> <li>at least 8 characters long</li> <li>contains at least one non-alphanumeric symbol</li> <li>does not match or contain username/email/etc.</li> <li>etc</li> </ul> Here's a jQuery plugin that reports password strength (not tried it myself): http...
Using network services when disconnected in Mac OS X
|macos|networking|
From time to time am I working in a completely disconnected environment with a Macbook Pro. For testing purposes I need to run a local DNS server in a VMWare session. I've configured the lookup system to use the DNS server (/etc/resolve.conf), and commands like "dig" and "nslookup" work. For example, my DNS server is c...
I've used the print style sheet here's and article [http://alistapart.com/stories/goingtoprint/][1] that will go through the way to set that up. Rather than setting up a special page that would need to be maintained as well. [1]: http://alistapart.com/stories/goingtoprint/
To find out how people do these kinds of things in CSS and/or Javascript the tool Firebug is just outstanding: [Firebug addon for Firefox][1] [1]: https://addons.mozilla.org/en-US/firefox/addon/1843
SourceForge Enterprise Edition 4.4 is available for free for up to 15 users. We use it for our development team and another development team where I work. It's been working great for us. It has subversion and cvs built in (whichever you wish to use). If you plan on accessing it over the internet you might want to...
For a div, you can add in the cSS <pre> overflow: auto </pre> For example, <pre> &lt;div style="overflow:auto; height: 500px"&gt;Some really long text&lt;/div&gt; </pre> Edit: After looking at the site you posted, you probably don't want this. What he does in his website is make the layout as fixed (posit...
For a div, you can add in the cSS <pre> overflow: auto </pre> For example, <pre> &lt;div style="overflow:auto; height: 500px"&gt;Some really long text&lt;/div&gt; </pre> Edit: After looking at the site you posted, you probably don't want this. What he does in his website is make the layout as fixed (pos...
You could try removing all the markers, or even removing the map from the DOM using the "onbeforeunload" event.
You have to try your application and see how it performs. for example, I used to always run IDEA out of the box until I've got this new job where I work on this huge monolithic project. IDEA was running very slow and regularly throwing out of memory errors when compiling the full project. first thing I did is to ra...
My limited understanding of the issue is that currently reporting is very difficult to do with DB4O, due to some missing functionality such as Count, Aggregate, etc. As it stands, you have to implement these yourself with all the poor performance that implies (e.g. activating all records, then doing a Count operation o...
Here is a function I use to execute sql commands. You just have to change $sqlCommand.CommandText to the name of your sproc and $SqlCommand.CommandType to CommandType.StoredProcedure. function execute-Sql{ param($server, $db, $sql ) $sqlConnection = new-object System.Data.SqlClient.SqlConnection $sqlConnec...
Codeplex/Sourceforge for internal use
|version-control|codeplex|open-source|
I'm looking for a free/open source collaborative project manager that can be deployed internally in my workplace that would act similar to Codeplex or Sourceforge. Does anyone know of something like this, and if so do you have experience with it. **Requirements:** - Open Source *or* Free - Locally Deployable...
|open-source|version-control|codeplex|
I'm looking for a free/open source collaborative project manager that can be deployed internally in my workplace that would act similar to Codeplex or Sourceforge. Does anyone know of something like this, and if so do you have experience with it. **Requirements:** - Open Source *or* Free - Locally Deployable...
You might want to do this when the "inner" class is a one-off, which will never be used outside the *definition* of the outer class. For example to define a metaclass, it's sometimes handy to do class Foo(object): class __metaclass__(type): .... instead of defining a metaclass separat...
You might want to do this when the "inner" class is a one-off, which will never be used outside the *definition* of the outer class. For example to use a metaclass, it's sometimes handy to do class Foo(object): class __metaclass__(type): .... instead of defining a metaclass separately...
There comes a point where refactoring is a waste of time. You just have to start again from scratch. If you keep your design fairly flexible, and you recognise that you don't know everything just yet, you won't have to throw anything away. A class might become redundant, of course, but you wont throw away a whole syste...
How do I format text in between xsl:text tags?
|xslt|formatting|
I have an xslt sheet with some text similar to below: <code> &lt;xsl:text&gt;I am some text, and I want to be bold&lt;xsl:text&gt; </code> I would like some text to be bold, but this doesn't work. <code> &lt;xsl:text&gt;I am some text, and I want to be &lt;strong&gt;bold&lt;strong&gt; &lt;/xs...
**Multicast is specified by IP Address** It's the same in erlang as for all languages. The IP addresses 224.0.0.0 through 239.255.255.255 are multicast addresses. Pick an address in that range, check that you're not overlapping an already assigned address, and you are good to go. <http://www.iana.org/assignme...
If you have 1000+ developers working on a single piece of software, you have the resources to invest in a lot of tooling of your own. Whatever you choose, you'll probably do plenty of work to adapt it to your situation. Microsoft's Team Foundation Server is used within Microsoft on some very large teams, and the ...
I'd use [IOUtils][1] from the commons io project. IOUtils.copy(zipStream, byteArrayOutputStream); [1]: http://commons.apache.org/io/api-release/org/apache/commons/io/IOUtils.html
How do I quickly rename a mysql database (change schema name)?
|mysql|
Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently RENAME {DATABASE | SCHEMA} db_name TO new_db_name; <a href="http://dev.mysql.com/doc/refman/5.1/en/rename-database.html">does bad things, exist only in a handful of versions, and is a bad idea over...
Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently RENAME {DATABASE | SCHEMA} db_name TO new_db_name; <a href="http://dev.mysql.com/doc/refman/5.1/en/rename-database.html">does bad things, exist only in a handful of versions, and is a bad idea over...
Why isn't there a Team Foundation Server Express Edition?
|visual-studio|version-control|tfs|
Why isn't there a Team Foundation Server Express Edition?