instruction
stringlengths
0
30k
I would say it depends on your specs. I have yet to work anywhere where the specs were good enough to create full unit tests from specifications - the level of detail just wasn't there. My managers always told us that if we specified to that level they could just ship the specs off to India and get it coded on the ch...
As mentioned previously, for(each) is an eager loop, so it wants to evaluate the entire list before starting. For simplicity, I would recommend using an iterator object or closure rather than trying to have a lazily evaluated array. While you *can* use a tie to have a lazily evaluated infinite list, you can run int...
Check out <a href="http://www.liquibase.org/">Liquibase</a>. A database migrations tool, like <a href="http://code.google.com/p/dbmigrate/">dbmigrate</a>, might also be worth a lok.
I generally use reflection for debugging. Reflection can more easily and more accurately display the objects within the system than an assortment of print statements. In many languages that have first-class functions, you can even invoke the functions of the object without writing special code. There is, however, a ...
my experience is that most people use single letters, e.g.: <code>i</code>, <code>j</code>, <code>k</code>, ... or <code>x</code>, <code>y</code>, <code>z</code>, ... or <code>a</code>, <code>b</code>, <code>c</code>, ... but i learned a great alternative a long time ago, and have used it ever since: d...
Using the Lists web service to insert item into a SharePoint list can indeed be tricky. Since this method is of the form: XML in, XML out, it can be hard to get the parameters right. First you should take a look at the list definition. It can be retrieved with the method GetList(), as shown below: XmlNode li...
Using the Lists web service to insert item into a SharePoint list can indeed be tricky. Since this method is of the form: XML in, XML out, it can be hard to get the parameters right. First you should take a look at the list definition. It can be retrieved with the method GetList(), as shown below: XmlNode li...
Thank you, Devin! Here is my C# Code for implementing your suggestion. It works quite good. Turning this into a community owned Wiki post, If someone likes to add some code, feel free to edit this. ![example][1] Image img = Image.FromFile("rss-icon.jpg"); Graphics g = Graphics.FromImage(img); Pen p ...
Thank you, Devin! Here is my C# Code for implementing your suggestion. It works quite good. Turning this into a community owned Wiki post, If someone likes to add some code, feel free to edit this. ![example][1] (Example uses different values for Alpha and exposure than the code below) // Experiment with t...
Thank you, Devin! Here is my C# Code for implementing your suggestion. It works quite good. Turning this into a community owned Wiki post, If someone likes to add some code, feel free to edit this. ![example][1] (Example uses different values for Alpha and exposure than the code below) Image img = Image.Fr...
Decent firewalls allow you to filter access on the loopback interfaces too. So, it's possible to set up a firewall rule that drops icmp ping packets going to localhost (127.0.0.1). Also, as everyone else has already mentioned, even the existence of the localhost or 127.0.0.1 address and the loopback interface isn't gua...
Well, assuming you don't have any prior experience... You need some kind of persistence storage (for example a database) and a client. For the storage you could use almost anything. For example you could create your DB in MS Access and just ship it as a file, using ADO to access it. Other options are MS SQL Expres...
Well, assuming you don't have any prior experience... You need some kind of persistence storage (for example a database) and a client. For the storage you could use almost anything. For example you could create your DB in MS Access and just ship it as a file, using ADO to access it. Other options are MS SQL Expres...
I'll violate the 'one option per post' request - sorry, but which tool to use really depends on what your priorities are. One fairly stable library is [gtkNode][1]. It uses a simple but powerful way to map all GTK widgets to Erlang, and should continue to be stable across releases. It also works well with the Glade ...
It's incredibly redundant and useless is most modern IDEs, where they do a good job of making the type apparent. Plus -- to me -- it's just annoying to see intI, strUserName, etc. :)
I don't think everyone is rabidly against it. In languages without static types, it's pretty useful. I definitely prefer it when it's used to give information that is not already in the type. Like in C, **char * szName** says that the variable will refer to a null terminated string -- that's not implicit in char* --...
In the words of the master: http://www.joelonsoftware.com/articles/Wrong.html An interesting reading, as usual. Extracts: "Somebody, somewhere, read Simonyi’s paper, where he used the word “type,” and thought he meant type, like class, like in a type system, like the type checking that the compiler does. He...
Computers are not smart, they will do whatever you instruct them to do. Compilers can optimize code a bit for you, but they can't optimize algorithms. Human brain works differently and that is why you need to understand the Big O. Consider calculating Fibonacci numbers. We all know F(n) = F(n-1) + F(n-2), and starting ...
> If I feel that useful information is being imparted, why shouldn't I put it right there where it's available? Then who cares what anybody else thinks? If you find it useful, then use the notation.
No, Source Control systems can't be integrated with the VS Express IDEs by design. If you want to continue using your existing VSS, you're best option is to upgrade to Visual Studio Standard. Otherwise, check out TortoiseSVN. Here's a good quick start: http://www.polymorphicpodcast.com/shows/subversion/
Here's why phone interview coding questions don't work: phone screener: how do you find the phone numbers in 50,000 HTML pages? candidate: hang on one second (covers phone) hey (roommate/friend/etc who's super good at programming), how do you find the phone numbers in 50,000 HTML pages? Save the coding quest...
Regular expressions alone are simply not powerful enough to solve your problem. You need something more powerful, such as context-free grammars. See [Chomsky hierarchy][1] at Wikipedia. In other words (as has been said before), don't use regex to parse HTML. [1]: http://en.wikipedia.org/wiki/Chomsky_hierarchy
Report generation
|python|generation|report|
I am writing a web app using TurboGears, and in that app the users must be able to generate different reports. The data the reports need is stored in a database (MySQL). The reports must be returned either as a easily printable html document, or a pdf file. I have previously used jasper and iReport for creating th...
Why use c strings in c++?
|c++|c|string|c-strings|
Is there any good reason to use C-strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string.
|c++|c|stl|string|c-strings|
DAO and unit tests do not get along well ! That does not make sense to mock anything in a component that does not hold any business logic and is focused on database access. You should try instead to write an integration test. Take a look at the spring reference documentation, chapter 8.3 : [http://static.springframew...
How to reduce the bandwith with very high sample frequency on USRP
|gnuradio|usrp|
I am using USRP with DBSRX daughter board. I need a very high sample frequency. Currently, the USRP can give me maximum sample frequency of 64M/8 in I and Q, and the data type is short, which takes 2 bytes. So can I decrease the length of the output data? for example save the data as char which takes 1 bytes, a...
You can put the controllers anywhere; routes do not depend on where a controller is stored. It will be able to find any class that implements IController within your application. I usually keep my controllers in a separate project, f.ex a MyProject.Frontend project, alongisde a MyProject.Frontend.Application projec...
time length of an mp3 file
|music|media|
What is the simplest way to determine the length (in seconds) of a given mp3 file, without using outside libraries? (python source highly appreciated)
What is the simplest way to determine the length (in seconds) of a given mp3 file, **without using outside libraries**? (python source highly appreciated)
|python|mp3|music|media|
Is it possible to create full screen color overlay effects in windows?
|windows|colors|overlay|
I remember my old Radeon graphics drivers which had a number of overlay effects or color filters (whatever they are called) that would render the screen in e.g. sepia tones or negative colors. My current NVIDIA card does not seem to have such a function so I wondered if it is possible to make my own for Vista. I don...
Maybe you can use [highlight: JavaScript text higlighting jQuery plugin][1] [1]: http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
I would not expect file-locking to ever make it as a feature in git. What kind of binary files are you primarily interested in? Are you actually interested in locking the files, or just preventing conflicts caused by not being able to merge them. I seem to remember someone talking (or even implementing) support for ...
**The Easy way** @cos, For the example you have shown, i would say the easiest way to create this system in C++ would be not trouble with the reference counting. All you have to do would be to make sure that the program flow first destroys the objects (views) which holds the direct references to the objects (paragr...
Check you proxy settings in **TortoiseSVN->Settings->Network**. Maybe they are configured differently than in your web browser.
Im my experience, it is bad because: 1 - then you break all the code if you need to change the type of a variable (i.e. if you need to extend a 32 bits integer to a 64 bits integer); 2 - this is useless information as the type is either already in the declaration or you use a dynamic language where the actual...
Try `ftp.nlst(dir)`.
You can start by creating a WPF host. Then you can use the &lt;WindowsFormHost/&gt; control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style for eac...
Dictionaries have a 'get()' method. If you do d['key'] and key isn't there, you get an exception. If you do d.get('key'), you get back None if 'key' isn't there. You can add a second argument to get that item back instead of None, eg: d.get('key', 0). It's great for things like adding up numbers: <code>sum[value]...
I've used to use m_ perfix in C++ but in C# I prefer just using camel case for the field and pascal case for its property. private int fooBar; public int FooBar { get { return fooBar; } set { fooBar = value; } }
You should have a look at the [httplib module](http://docs.python.org/lib/module-httplib.html). It should let you make whatever sort of HTTP request you want.
bounds = self.canvas.bbox(myText) # returns a tuple like (x1, y1, x2, y2) width = bounds[2] - bounds[0] height = bounds[3] - bounds[1] See the [TkInter reference][1]. [1]: http://infohost.nmt.edu/tcc/help/pubs/tkinter/canvas-methods.html
my experience is that most people use single letters, e.g.: <code>i</code>, <code>j</code>, <code>k</code>, ... or <code>x</code>, <code>y</code>, or <code>r</code>, <code>c</code> (for row/column) or <code>w</code>, <code>h</code> (for width/height) , etc. but i learned a great alternative a long time...
You're using the SVN version of the plugin, which is probably unmaintained. [Latest version can be found here][1]. Second thing which you can do is check the production log. Mailings get written to the log, so you'll see if Rails ever even *tried* to send it. If there are no entries, that means things are silently f...
linq equivalent of 'select *' sql for generic function?
|c#|linq|generics|anonymous-types|
I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)? So equivalent to the sql: select *, 'bar' as Foo from items foreach (var item...
I've found the book "Programmer's Guide to nCurses" (Dan Gookin, published by Wiley) invaluable as it includes both tutorial and an impressive reference to the API. There's also the O'Rielly Nutshell guide "Programming with Curses" which isn't too bad.
I've found the book "Programmer's Guide to nCurses" (Dan Gookin, published by Wiley) invaluable as it includes both tutorial and an impressive reference to the API. There's also the O'Reilly Nutshell guide "Programming with Curses" which isn't too bad.
Check your production log, exceptions can be throw in side the exception_notifier plugin, which prevent it from sending mails
My approach is always "minimum effort for maximum effect" (or best bang per buck). If it can be done with cron, why not use cron? I'd consider it wasted effort to re-implement cron just for the fun of it so, unless you really need features that cron doesn't have, stick with it.
As long as the site is the same (i.e. www.example.com) then cookies are platform agnostic. As Todd Kennedy said try the super global $_COOKIE. If you site is different though you won't be able to read the cookies, they are supposed to be site specific and prevent this type of cross site access.
Are the two servers on the machine within the same domain? if so you should set the cookie scope to the domain rather than the FQDN; then both machines will be able to read them; Response.Cookies["domain"].Domain = "contoso.com"; would allow contoso.com, www.contoso.com, hotnakedhamsters.contoso.com etc to acce...
Anyone have sample code for a UserControl with pager controls to be used in a GridView's PagerTemplate?
|asp.net|gridview|user-controls|pagertemplate|
I've got several Gridviews in my application in which I use a custom PagerTemplate. I'd like to turn this custom template into a UserControl so that I don't need to replicate the same logic in multiple pages. I'm pretty sure that such a thing is possible, but I'm unsure of how exactly to wire the UserControl to the Gri...
You want the CASE statement WHERE OrderNumber LIKE CASE WHEN IsNumeric(@OrderNumber)=1 THEN @OrderNumber ELSE '%' + @OrderNumber END
Actually it depends on what shell you use, however must shells have similar bindings. The bindings you are referring to (e.g. CTRL+A and CTRL+E) are bindings you will find in many other programs and they are used for ages, BTW also work in most UI apps. Here's a look of default bindings for Bash: [Most Important ...
Add the `uniq_by` method to Array in your project. It works by analogy with `sort_by`. So `uniq_by` is to `uniq` as `sort_by` is to `sort`. Usage: uniq_array = my_array.uniq_by {|obj| obj.id} The implementation: class Array def uniq_by(&blk) transforms = [] self.select do |...
Try this: var input = document.getElementById('myInputField'); if (input) { input.onmousedown = function(e) { if (!e) e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); } } And if not, have a read of: [http://www.quirksmode.or...
This is probably down to something like trying to execute sudo in a non-interactive shell. If you do a grep for 'sudo' in your apache users mail log you might find things like this > sudo: sorry, you must have a tty to run sudo
A repost from the question text: 1. Create SVN Repository with basic layout (trunk, braches, lib, etc.) 1. Create basic solution structure (core, ui, tests) 1. Create a basic test that fails 1. Copy NAnt scripts, update and tweak, make sure the failing test breaks the build local...
A repost from the question text: 1. Create SVN Repository with basic layout (trunk, braches, lib, etc.) 1. Create basic solution structure (core, ui, tests) 1. Create a basic test that fails 1. Copy NAnt scripts, update and tweak, make sure the failing test breaks the build local...
The problem is not with sudo at the moment, but with [SELinux][1], which is (reasonably) set to deny the HTTPD from gaining root privileges. You will need to either explicitly allow this (you can use [audit2allow][2] for this), or set SELinux to be permissive instead. I'd suggest the former. [1]: http://en.wi...
As a side note, the problem with the Dreaded Diamond is that the base class is present multiple times. So with regular inheritance, you believe you have: A / \ B C \ / D But in the memory layout, you have: A A | | B C \ / D This explain why wh...
I'm with the people that don't use prefixes. IDEs are so good nowadays, it's easy to find the information about a variable at a glance from syntax colouring, mouse-over tooltips and easy navigation to its definition. This is on top of what you can get from the context of the variable and naming conventions (such ...
A simple technique I find handy is to to have a WaitUntilTrue method, which looks something like this: WaitUntilTrue(Func<bool> methodWhichReturnsTrue, int timeoutInMillis, int timeBetweenChecksMillis) { Stopwatch stopwatch = new Stopwatch(); stopwatch...
If you have to test that a background thread does something, a simple technique I find handy is to to have a WaitUntilTrue method, which looks something like this: bool WaitUntilTrue(Func<bool> func, int timeoutInMillis, int timeBetweenChecksMillis) { Stopwatch...
Several reasons: - Any modern IDE will give you the variable type by simply hovering your mouse over the variable. - Most type names are way long (think *HttpClientRequestProvider*) to be reasonably used as prefix. - The type information does not carry the *right* information, it is just paraphrasing the var...
There's no standard for the layout of the `LIST` response. You'd have to write code to handle the most popular layouts. I'd start with Linux `ls` and Windows Server `DIR` formats. There's a lot of variety out there, though. Fall back to the `nlst` method (returning the result of the `NLST` command) if you can't par...
|javascript|dom|browser|client-side|
Try 4.0/100
How do I select the Count(*) of an nHibernate Subquery's results
|nhibernate|query|
I need to do the following for the purposes of paging a query in nHibernate: Select count(*) from (Select e.ID,e.Name from Object as e where...) I have tried the following, select count(*) from Object e where e = (Select e.ID,e.Name from ...) and I get an nHibernate Exception saying I cannot ...
I need to do the following for the purposes of paging a query in nHibernate: Select count(*) from (Select e.ID,e.Name from Object as e where...) I have tried the following, select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...) and I get an nHibernate Exception saying ...
|nhibernate|query|subquery|
A simple route 4 / 100.0 or 4.0 / 100
You need to tell Python to use floating point values, not integers. You can do that simply by using a decimal point yourself in the inputs: >>> 4/100.0 0.040000000000000001
What is PostgreSQL explain telling me exactly?
|postgresql|
MySQL's explain output is pretty straightforward. PostgreSQL's is a little more complicated. I haven't been able to find a good resource that explains it either. Can you describe what exactly explain is saying or at least point me in the direction of a good resource?
I prefer the second one. While your tests may have run fine, [Murphy][1] says that something unexpected will go wrong. So, instead of getting an exception at the actual erroneous method call, you end up tracing out a NullPointerException (or equivalent) 10 stack frames deeper. [1]: http://en.wikipedia.org/wiki/M...
I am an Oracle person, not a SQL*Server person, but it seems to me you should be either:- SELECT CASE WHEN fldField like '%YYY%' THEN 'OTH' ELSE 'XXX' END AS newField FROM tmpTable or ... SELECT CASE WHEN fldField = 'YYY' THEN ...
You don't necessarily need to use SVN to deploy the files to the server. Keep using FTP for that and just use SVN for revision history.
Python and GET or POST data
c strings don't carry the overhead of being a class. c strings generally can result in faster code, as they are closer to the machine level This is not to say, you can't write bad code with them. They can be misused, like every other construct. There is a wealth of libary calls that demand them for historic...
It's not clear that it is tabular data as some others have commented, though it could be. A table would imply a semantic relationship between all the items in the respective columns (other than just "they're all names of database columns"). Anyway, here's how I've done it before: <?xml version="1.0" encoding="...
It's not clear that it is tabular data as some others have commented, though it could be. A table would imply a semantic relationship between all the items in the respective columns (other than just "they're all names of database columns"). Anyway, here's how I've done it before: <?xml version="1.0" encoding="...