instruction
stringlengths
0
30k
May I suggest [Merb](http://merbivore.com)? It is rack-based, modular, ORM-agnostic, built for speed from ground up by Ezra Zygmuntowicz. It is starting to gain some heat now...
If your various user classes inherit from a parent user class, then I recommend you use the same inheritance structure for your test case classes. Consider the following sample classes: class User { public function commonFunctionality() { return 'Something'; } ...
- Create a role in sql server. - Write a script that grants that role permission to use those sprocs. - Add those NT user groups to that role.
Looking for things like sequential scans can be somewhat useful, but the reality is in the numbers... except when the numbers are just estimates! What is usually **far** more useful than looking at a query *plan* is looking at the actual *execution*. In Postgres, this is the difference between EXPLAIN and EXPLAIN ANALY...
There's the **easy** solution, the **hard** solution, and the **use-a-library** solution. **use-a-library** : I prefer always doing the use-a-library solution unless you have a darn good reason otherwise. One possible site which wraps the "hard solution" as a service for you: http://thumbnails.iwebtool.com/demo/ ...
PubSub lib for c#
|c#|python|design-patterns|
Is there a c# library which provides similar functionality to the [Python PubSub][1] library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events. [1]: http://wiki.wxpython.org/PubSub
In C++, can you have a function that modifies a tuple of variable length?
|c++|tuples|
In C++0x I would like to write a function like this: template <typename... Types> void fun(typename std::tuple<Types...> my_tuple) { //Put things into the tuple } I first tried to use a for loop on `int i` and then do: get<i>(my_tuple); And then store some value in the result. How...
Recent versions of git run gc automatically when required, so you shouldn't have to do anything. See the Options section of <a href="http://www.kernel.org/pub/software/scm/git/docs/git-gc.html#_options">man git-gc(1)</a>: "Some git commands run git gc --auto after performing operations that could create many loose obje...
Althout `typeof` is not legal C++ at the moment, you can use template deduction instead. See sample code below: #include <iostream> #include <limits> template <typename T> bool is_signed(const T& t) { return std::numeric_limits<T>::is_signed; } int main() { ...
Depends on the source control system you use. For example, for subversion and cvs your files can reside in a remote location, but you always check out your own copy of them locally. This local copy (often referred to as the `working copy`) are just regular files on the filesystem with some meta-data to let you upload y...
For any size of int with two's complement arithmetic: > #define SIGNBIT ((unsigned int)-1 & ((unsigned int)-1 >> 1)) > if ((x & SIGNBIT) == (y & SIGNBIT)) > // signs are the same
For any size of int with two's complement arithmetic: > #define SIGNBIT (~((unsigned int)-1 >> 1)) > if ((x & SIGNBIT) == (y & SIGNBIT)) > // signs are the same
I am a Prototype person, but I've used jQuery a bit. Honestly I don't there is much between the two that you can use as a 'selling point'. The YUI on the other hand is pretty bloated. I would never use it on any commercial grade application. I found [this page][1] that talks about this exact subject. [1]: htt...
@Twan You don't need a DTD for DOMDocument to parse custom XML. Just use `DOMDocument->load()`, and as long as the XML is well-formed, it can read it. Once you get the files to be well-formed, that's when you can start looking at XML parsers, before that you're S.O.L. Lok Alejo said, you could look at [HTML TIDY](h...
1. Don't edit your code on production. 2. Create a development environment, with the appropriate services (apache w/mod_php). 3. The application directory within your dev environment is where you do your work. 4. Put your current production app in there. 5. Commit this directory to the source control tool. (no...
jQuery: Remove all classes that begin with a certain string
|javascript|css|jquery|
I have a div with id="a" that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to remove all of the ...
I have a div with id="a" that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to remove all of the ...
What's anti-OOP or pro-OOP depends entirely on the functionality of the software and what's needed to make it work.
The subject line doesn't suggest that this question is Mac OS X-specific, so it should be noted that not all 32-bit kernels are capable of running 64-bit processes. Windows certainly doesn't have this property and I've never seen it done on Linux.
Note that not *all* 32-bit kernels are capable of running 64-bit processes. Windows certainly doesn't have this property and I've never seen it done on Linux.
VSTS2005 was quite challenging to install and configure correctly. I have heard 2008 is MUCH better, but have yet to try it yet. Be prepared to spend a fair bit of time on this and read everything before starting. However, don't loose heart, TFS is well worth the effort!!
If every method is just a static call straight to the data source, then the "Posts" class is really a Factory. You could certainly put the static methods in "Posts" into the "Post" class (this is how CSLA works), but they are still factory methods. I would say that a more modern and accurate name for the "Posts" cl...
You mentioned you're using Fogbugz. Try [http://www.fogcreek.com/FogBugz/docs/60/topics/customers/BugzScout.html?isl=59722][1] or [http://www.fogcreek.com/FogBugz/blog/post/C-wrapper-for-the-FogBugz-API.aspx?isl=59722][2] There is some sample code around, I think in your FB install directory. I checked with Mic...
Conditionals are lets you do somethings semaphores won't. For example, suppose you have some code which requires a mutex, called m. It however needs to wait until some other thread has finish their task, so it waits on a semaphore called s. Now any thread which needs m is blocked from running, even though the thread...
Single most useful? http://www.nowdothis.com is AWESOME for focusing on what currrently needs to get done, and has raised my productivity by tons. (Bonus tip: Use Google Chrome to make it its own application and then make the app always be on top of other windows) Biggest distraction? Google Reader.
I like to use this online one: [http://www.cuneytyilmaz.com/prog/jrx/][1] Of course, it'll be javascript regexp, but I've never yet done anything clever enough to notice the difference. [1]: http://www.cuneytyilmaz.com/prog/jrx/
I read this rule somewhere, and I use it every day... - If someone asks you to do something - if it takes less than 2 minutes, do it immediately. If it takes longer, put it on your list and come back to it. This really works for me.
How about: Sub GetLastRow(strSheet, strColum) Dim MyRange As Range Dim lngLastRow As Long Set MyRange = Worksheets(strSheet).Range(strColum & "1") lngLastRow = Cells(65536, MyRange.Column).End(xlUp).Row End Sub
DataGridView column of type DataGridViewCheckBoxCell is constantly readonly/disabled
|datagridview|datagridviewcheckboxcell|
I am using a DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this: column = new DataGridViewColumn(new DataGridViewCheckBoxCell()); You see that I need a CheckBox cell template. The problem I face is that this column is co...
I am using a DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this: column = new DataGridViewColumn(new DataGridViewCheckBoxCell()); You see that I need a CheckBox cell template. The problem I face is that this column is co...
If your various user classes inherit from a parent user class, then I recommend you use the same inheritance structure for your test case classes. Consider the following sample classes: class User { public function commonFunctionality() { return 'Something'; } ...
To read the body of an HTTP request in chunks, you'll need to use `Net::HTTPResponse#read_body` like this: http.request_get('/large_resource') do |response| response.read_body do |segment| print segment end end
If only the CSS equivalent was as expedient in setting up a "table-like" layout, then I would love to use CSS. I find the time that it takes to mimic the things that others have listed here (equal heights on cells, auto-growing rows, etc.) is simply not worth the effort. I don't get a return on my investment as oppos...
It's easy. Think your webpage as a real page on paper. You should use tables on webpage only when you would draw a table on your paper. Another tip is to use table only with border > 0. This way, you use tables only when you **mean** you want a table (and not for layout).
Creating a Silverlight DataTemplate in code
|silverlight|
How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Thanks Nick
How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Edit: Here's the code I'm now using this for, based on the answer from Santiago below. public DataTemplate Create(Type type) { return (DataTemplate)XamlReader.Load( ...
['How to be a Programmer: A Short, Comprehensive, and Personal Summary'][1] by *Robert L Read* Not exactly a book but an essay, but this one was definitely an inspiration for me when I got into coding. Loved the notion of entering a tribe. Worth a read. [1]: http://samizdat.mines.edu/howto/HowToBeAProgrammer....
Is it possible to use .htaccess to send six digit number URLs to a script but handle all other invalid URLs as 404s?
|php|.htaccess|http-redirect|
Is it possible to use .htaccess to process all six digit URLs by sending them to a script, but handle every other invalid URL as an error 404? For example: http://mywebsite.com/132483 would be sent to: http://mywebsite.com/scriptname.php?no=132483 but http://mywebsite.com/132483a or h...
As suggested, you should use seq -f 'frame-%g.jpg' 1 4 number-of-frames to generate the list of filenames since 'ls' will fail on 280k files. So the final solution would be something like: for f in `seq -f 'frame-%g.jpg' 1 4 number-of-frames` ; do mv $f destdir/ done
The problem is that "event based programming" links far too much logic to the events. The way such a system should be designed is that there should be a subsystem that raises events (and you can write tests to ensure that these events are raised in the proper order). And there should be another subsystem that deals on...
I'm using D for my research work in the area of computer graphics. I and others have had papers published in our fields based on work done using D. I think it's definitely ready for use on small to medium sized research projects where performance matters. It's a nice fit for research work because often you're starti...
How do I preview a url using ajax?
|ajax|asp.net|
How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this.
|asp.net|ajax|
How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this. Specifically, I would like to be able to mouse over a link and see the preview of the webpage using ajax.
Groovy (5B): run()
PHP debugging on OS X - hopeless?
|php|macos|debugging|
I have tried: 1. Xdebug and Eclipse. Eclipse launches a web browser, but the browser tries to access a non-existent file in Eclipse's .app bundle. 2. Xdebug and NetBeans. It does a little bit better; a browser opens a page in /tmp which says "Launching. Please wait…" but nothing happens beyond that. 3. Xdebug and ...
There must be some good reason you're not wanting the obvious answer: `SYSTEM "sleep 5"`. If all you're wanting is for the SPL to pause while you check various values etc, here are a couple of thoughts (all of which are utter hacks, of course): 1. Make the TRACE FILE a named pipe (assuming Unix back-end), so it bl...
there's also this other post about this topic: [Best mock framework that can do both WebForms and MVC?][1] [1]: http://stackoverflow.com/questions/10098/best-mock-framework-that-can-do-both-webforms-and-mvc
I think I know what he's driving at. What happens is that he wants a windows to appear on hover over a hyperlink (javascript), and for that windows to display a snapshot image of the website being referenced by the hyperlink. The ajax part connects to the server where you are hosting your site, asynchronously, and h...
Visual Studio creates a copy of all your DLLs and sometimes this copies are not refreshed. Just execute **iisreset** and delete all folders in: > C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary > ASP.NET Files\ Of course change windows installation folder and framework folder to your version!
When you say Castle I assume you mean Castle Active Record? The difference is NHibernate is an OR/M and is aimed at developers who want to focus on the domain rather than the database. With linq to sql, your database is pre-existing and you're relationships and some of programming will be driven by how your database...
You should create a list which contains the countries. Then in the lists where you want to reuse the countries lookup, create a column of type Lookup and select the countries list in the "Get infomation from" dropdown.
You should create a list which contains the countries. Then in the lists where you want to reuse the countries lookup, create a column of type Lookup and select the countries list in the "Get infomation from" dropdown. Here is a link to a more visual guide: http://blog.phase2int.com/?p=101
There are some mistakes in the answers so far (and I have not yet sufficient reputation to comment on them). 1. The ".com" name servers are in no way related with the root name servers. When you change the name servers of stackoverflow.com, through your registrar, the change is made in the ".com" name servers. Root...
For an example of an existing plugin that uses rspec, check out the [restful\_authentication plugin][1]. Maybe it will help. [1]: http://github.com/technoweenie/restful-authentication/tree/master
Not quite sure what you mean. If you are talking about seeing what files need "resolving" (in perforce language) then you can use: p4 resolve -n See the p4 command line manual website here: [http://www.perforce.com/perforce/doc.current/manuals/cmdref/resolve.html#1040665][1] Also P4V has a nice feature t...
I am using a .NET Windows Forms DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this: DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell()); You see that I need a CheckBox cell template. The pr...
A single answer to all of the listed questions is David Ellen's Getting Things Done (GTD) ( "The Art of Stress-Free Productivity" ) A 45-minute presentation of the process [can be found on youtube][1], and you can get the book on [Amazon][2] [1]: http://www.youtube.com/watch?v=Qo7vUdKTlhk [2]: http://www.a...
light-version of a repository/branch in git
|git|branch|
I am using git on a project, that generates lots of data-files (simulation-results). I am "forced" to version and track all those results in the same repository. (This is a hard requirement and can not be changed) However I don't need them. We have about 50 MB for the project and 5 GB results in the repository. ...
That would only work for ManyToOne relations and for them @ManyToOne(fetch=FetchType.EAGER) would probably appropriate. Fetching more than one OneToMany relation eagerly is discouraged and/or does not work as you can read in the link Jeremy posted. Just think about the SQL statement that would be needed to do such a...
At our company we evaluated several different obfuscation technologies, but they all had problems. The biggest problem was that we rely a lot on reflection, e.g. to dynamically create grids based upon property names. So all of the obfuscators rename things, you can disable it of course, but then you lose a lot of t...
As far as I know, there is not a way to do this easily with bazaar. One possibility is to take the original project, branch it, and then remove everything unrelated to the framework. You can then move the files in the subdir to the main dir. It's quite a chore, but it is possible to preserve the history. you wi...
Database functionality with WPF app: SQLite, SQL CE, other?
|wpf|sqlite|sql-server-ce|
I want to extend a WPF application with database functionality. Which database engine would you suggest and why? SQLite, SQL CE, other?
How to identify specific digits of an integer input in C?
|c|
I have a lot of java background and am new to C. If the input integer is 11031, I want to count the number of 1's digits, how would I do this? I know in java I can take the input as a String and use charAt, but I understand there is no implicit String function in C...
|c|homework|
I'm not really sure I'd consider "bitwise trick" and "simplest" to be synonymous. I see a lot of answers that are assuming signed 32-bit integers (though it *would* be silly to ask for unsigned); I'm not certain they'd apply to floating-point values. It seems like the "simplest" check would be to compare how both v...
I still prefer make after having considered a bunch of the alternatives. When you auto-generated dependencies either via the compiler or something like fastdep there is not much left to do. In particular I do not want my build script to be tied to the implementation language, and I do like writing stuff in XML when m...
MySQL does not support the renaming of a database through its command interface at the moment, but you can rename the database if you have access to the directory in which MySQL stores its databases. For default MySQL installations this is usually in the Data directory under the directory where MySQL was installed. Loc...
Well it depends where and how you define your separation of concerns. If you put the code to populate the Post in the Post class, then your Business Layer is interceded with Data Access Code, and vice versa. To me it makes sense to do the data fetching and populating outside the actual domain object, and let the do...
You should be able to do it with fn:replace. You will need to import the tag library into your JSP with the following declaration: <pre><code lang="jsp"> &lt;%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %&gt; </code></pre> Then you can use the following expression to replace occurrences...
Prestaul's answer was helpful, but it didn't quite work for me. The jQuery way to select an object by id didn't work. I had to use document.getElementById("a").className instead of $("#a").className
How to: Pass an ampersand in a lousy filename to a flash object on a webpage
|flash|encoding|character|
Argghh. I have a site that offers audio previews of songs hosted elsewhere. Some file names have an ampersand in them - see below where it passes "soundFile." Anytime there's an ampersand, Flash can't get the file - I think it drops the filename after the ampersand. It doesn't matter if I pass it as an "&" or an HTML e...
OpenFileDialog. How about "Specify Directory Dialog"?
|directory|dialog|open|
On a file path field, I want to capture the directory path like: textbox1.Text = directory path Anyone?
As a general design principle, you should avoid implimenting the same code multiple times. Instead you should lift common code out into a function and execute that (general, well tested, easy to modify) function from multiple places. If (unlike what you infer from your question) you are declaring the internal functi...