instruction
stringlengths
0
30k
⌀
it's a list of public objects of that module -- it overrides the default of hiding everything that begins with an underscore
There are several other answers already, but I'd like to show you the approach I took to solve it: First, let's check out how Stack Overflow handles normal cases and edge cases. Each of my pages displays 10 results, so to find out what it does for 1 page, find a tag that has less than 11 entries: [usability][1] works...
Are you executing the programs directly or going through the shell? If you always launch an external program by giving the full path name to the executable and leaving the shell out of the equation, then you aren't really susceptible to any kind of command line injection.
The rule of thumb is to use the function most suited to your needs. If you just want the keys and do not plan to ever *read* any of the values, use keys(): foreach my $key (keys %hash) { ... } If you just want the values, use values(): foreach my $val (values %hash) { ... } If you need the keys *...
Or, using a little jQuery: $('#fieldID').css('background-color', '#FF6600');
Big O gives the upper bound for time complexity of an algorithm. It is usually used in conjunction with processing data sets (lists) but can be used elsewhere. A few examples of how it's used in C code. Say we have an array of n elements int array[n]; If we wanted to access the first element of the a...
Instead of learning APIs to each map service provider ( like Gmaps, Ymaps api) Its good to learn [Mapstraction][1] "Mapstraction is a library that provides a common API for various javascript mapping APIs" I would suggest you go to the URL and learn a general API. There is good amount of How-Tos too. [1]: ht...
The previous answer is fine, but I'm one of those guys that's firmly against mixing behavior with presentation (putting JavaScript in my HTML) so I prefer to put my event handling logic in my JavaScript files. Additionally, not all browsers implement event (or e) the same way. You may want to do a check prior to runnin...
It may be easier to serialise the classes to/from xml, you can then simply pass the XmlReader (which is reading your config file) to the deserializer and it will do the rest for you.. [This is a pretty good article on serialization](http://www.diranieh.com/NETSerialization/XMLSerialization.htm)
It may be easier to serialise the classes to/from xml, you can then simply pass the XmlReader (which is reading your config file) to the deserializer and it will do the rest for you.. [This is a pretty good article on serialization](http://www.diranieh.com/NETSerialization/XMLSerialization.htm) ##Edit One thin...
I have experimented a little with the BDD approach and my premature conclusion is that BDD is well suited to use case implementation, but not on the underlying details. TDD still rock on that level. BDD is also used as a communication tool. The goal is to write executable specifications which can be understood by th...
hmm, if you've serialized an object with the `StudentId` property then I think that it will be: var studentId; function(json) { if (json.length > 0) studentId = json[0].StudentId; } But if you're just returning the `StudentId` itself maybe it's: var studentId; fun...
hmm, if you've serialized an object with the `StudentId` property then I think that it will be: var studentId; function(json) { if (json.length > 0) studentId = json[0].StudentId; } But if you're just returning the `StudentId` itself maybe it's: var studentId; fun...
RoR is actually one of the things the GWT is made to work well with, as long as you're using REST properly. It's in the Google Web Toolkit Applications book, and you can see a demo from the book using this kind of idea [here][1]. That's not to say that you won't have any problems, but I think the support is definitel...
Using Guids as primary keys is acceptable and is considered a fairly standard practice for the same reasons that you are considering them. They can be overused which can make things a bit tedious to debug and manage, so try to keep them out of code tables and other reference data if at all possible. The thing that ...
Using Guids as primary keys is acceptable and is considered a fairly standard practice for the same reasons that you are considering them. They can be overused which can make things a bit tedious to debug and manage, so try to keep them out of code tables and other reference data if at all possible. The thing that ...
Eric Lippert did a series of articles on creating a [C# implemention of A*][1], which might be more efficient. [1]: http://blogs.msdn.com/ericlippert/archive/tags/AStar/default.aspx
You should post more information. For instance, is this C#? It looks like it, but I might be wrong. Also, you say you get an exception, what is the exception type and message? In any case, you can't redirect to a page for POST, you need to submit it from the browser, not from the server redirect, so if you wan...
sql missing rows when grouped by DAY, MONTH, YEAR
|t-sql|date|grouping|
RoR is actually one of the things the GWT is made to work well with, as long as you're using REST properly. It's in the Google Web Toolkit Applications book, and you can see a demo from the book using this kind of idea [here][1]. That's not to say that you won't have any problems, but I think the support is definitel...
Don't forget refactoring support. ReSharper on .NET provides automatic refactoring and quick fixes for missing code. That means if you write a call to something that does not exist, ReSharper will ask if you want to create the missing piece.
VMWare Tools for Ubuntu Hardy
|vmware-tools|ubuntu|hardy|vmware|virtualization|
I've been having a very tough time with VMWare tools for Ubuntu Hardy. For some reason, vmware-install.pl finds fault with my linux headers. Saying the "address space size" doesn't match. I have resorted to vmware-any-any-update117 and here is the error I am getting now: <pre> In file included from include/asm...
|vmware|ubuntu|virtualization|vmware-tools|
You're on the right track. Cocoa's collection classes — which all have mutable an immutable variants — are: - NSArray: ordered, can contain an object multiple times - NSDictionary: unordered, mapping from keys to values, keys are copied - NSSet: unordered, can contain an object only once - NSCountedSet: unorde...
A short list might be: - Avoid memory leaks through use shared pointers to manage memory allocation and cleanup - Use the Resource Acquisition is Initialization (RAII) idiom to manage resource cleanup - especially in the presence of exceptions - Avoid calling virtual functions in constructors - Employ minimal...
Try IE7.js. Should fix your problem without having to make any modifications. Link: [IE7.js][1] [1]: http://code.google.com/p/ie7-js/
There is a very rough percentage of browsers with *some* JRE available at [The Counter][1], though I wouldn't trust it. Sun has a few useful [stats from 2007][2], but their [stats from 2008][3] are much less detailed. They suggest that in 2007 "92%...of JRE installs...are now Java SE 6", but who knows what highly techn...
The most important pitfalls for beginning developers is to avoid confusion between C and C++. C++ should never be treated as a mere better C or C with classes because this prunes its power and can make it even dangerous (especially when using memory as in C).
I would go with a 1 GB for /boot, 100 GB for /, and the rest for /home. 1 GB is probably too high for /boot, but it's not like you'll miss it. 100 GB might seem like a lot for everything outside home, until you start messing around with Databases and realize that MySQL keeps databases in /var. Best to leave some roo...
yes, vs2008 can "[target](http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx)" a framework, but i think by default, if converting from vs2005 - vs2008 it just keeps it at framework 2.0
There's also Exchange Web Services in newer versions of Exchange. If you need to use Outlook Express and talk to an Exchange server which doesn't support IMAP/POP3, you're stuck, sadly.
A magic number is a sequence of characters at the start of a file format, or protocol exchange. This number serves as a sanity check. Example: Open up any GIF file, you will see at the very start: GIF89. "GIF89" being the magic number. Other programs can read the first few characters of a file and properly i...
SEO Superstitions: Are <script> tags really bad?
|seo|
We have an SEO team at my office, and one of their dictums is that having lots of &lt;script&gt; blocks inline with the HTML is apocalypticly bad. As a developer that makes no sense to me at all. Surely the Google search engineers, who are the smartest people on the planet, know how to skip over such blocks? <br /> My...
@kronoz I would say YES. The neat thing about MSBuild is that if you modify your csproj files to include custom build steps then those steps will happen from within VS or from MSBuild. Also if you ever have a build server you will not need to install full VS, only the SDK to build your projects.
Have you taken a look at the wikipedia entry for [magic number?][1] It goes into a bit of detail about all of the ways the magic number reference is made. Here's a quote about magic number as a bad programming practice > The term magic number also refers to the bad programming practice of using numbers directly...
I assume this is a response to my [answer][1] to your earlier question. In programming, a magic number is an embedded numerical constant that appears without explanation. If it appears in two distinct locations, it can lead to circumstances where one instance is changed and not another. For both these reasons, it's imp...
A Magic Number is a hardcoded value that may change at a later stage, but that can be therefore hard to update. For example, let's say you have a Page that displays the last 50 Orders in a "Your Orders" Overview Page. 50 is the Magic Number here, because it's not set through standard or convention, it's a number tha...
Are you executing the programs directly or going through the shell? If you always launch an external program by giving the full path name to the executable and leaving the shell out of the equation, then you aren't really susceptible to any kind of command line injection. EDIT: DrFloyd, the shell is responsible for...
Substitution Control at the User Control Level?
|asp.net|caching|user-controls|
I am trying to create some cached user controls. Basically Header and Footer are static. Except the footer has one link that reads in the url of the page and puts it into the javascript for sending a link to a friend. So I need that link to be dynamic. I set up a substitution control and had the static method ...
@Orion Edwards I take your point about an exception being thrown in the finally block. However, I think there is a way - using yet another thread - of using this exception-as-interrupt idea. Thread A: At some random time, throw an exception on thread C: Thread B: try { Signal thread C...
Yes, you can. The boost.ptr_container library provides polymorphic value semantic versions of the standard containers. You only have to pass in a pointer to a heap-allocated object, and the container will take ownership and all further operations will provide value semantics , except for reclaiming ownership, which ...
If you have a mix of unix and Windows users working with the repository, I urge you to use the *[case-insensitive.py][1]* pre-commit hook-script as a precautionary measure. It prevents hard-to-sort-out situations where svn [updates fail for Windows users because of a file rename which only changed the case of the file ...
@[Domenic][1], I've considered, but I'd prefer to stay legal, and I'm fairly sure the information would have to be embedded into the framework anyway. [1]: http://stackoverflow.com/questions/44795/how-can-i-determine-whether-a-given-date-is-in-daylight-saving-time-for-a-given#44819
I'm late to this party, so my first choices are already taken. But I didn't see anyone mention this gem yet: [Parallel Extensions to the .Net Framework][1] It has things like replace with Parallel.For or foreach with Parallel.ForEach [1]: http://msdn.microsoft.com/en-us/concurrency/default.aspx
Fast SQL Server 2005 script generation
|sql-server|scripting|
It seems like the generation of SQL scripts from the SQL Server Management Studio is terribly slow. I think that the old Enterprise Manager could run laps around the newer script generation tool. I've seen a few posts here and there with other folks complaining about the speed, but I haven't seen much offered in the wa...
Cannot access a webservice from mobile device
|mobile|
I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service and exe...
If I select from a table group by the month, day, year, it only returns rows with records and leaves out combinations without any records, making it appear at a glance that every day or month has activity, you have to look at the date column actively for gaps. How can I get a row for every day/month/year, even when n...
@pek - That won't work, as your array keys are 0 and 1, not 'home' and 'page'. This code should do the trick, I believe: <?php $whitelist = array( 'home', 'page', ); if(in_array($_GET['page'], $whitelist)) { include($_GET['page'] . '.php'); } else { incl...
First thought that comes to mind: Hasn't MS designed the DataSet and DataAdapter model to support scenarios like this? I believe I read that MS changed their ADO recordset model to the current DataSet model so it works great offline too. And there's also this [Sync Services for ADO.NET][1] I believe I have seen c...
Create a calendar table and outer join on that table
Google Chrome looks promising. It is of course in an early beta so it's missing a lot of the things people would need or at least feel they need, like plugins, cross-machine synchronization of data (could be done with plugins), cross-platform support (ie. Linux and Mac versions). So far it renders Gmail like a bat o...
I've had luck just copying `signons2.txt` and `key3.db` over from one profile to another. See also [the documentation on MozillaZine][1]. [1]: http://kb.mozillazine.org/Signons.txt
I think they mean they don't want you to use URL parameters (GET). If you use http headers, it's not really querying through POST any more.
What language/framework? Using Python and httplib2, you should be able to do something like: http = httplib2.Http() http.request(url, 'POST', headers={'key': 'value'}, body=urllib.urlencode(''))
By default (i.e. out of the box) net.tcp services are unsecured and don't perform any authentication at all. So you won't need (and in fact can't) set a service principal name. If you need to authenticate, then check the [net.tcp security][1] modes on MSDN. The best way to understand the different combinations is t...
I believe that the Request object would only accept a certain set of predefined headers. There's an enumeration that lists all the supported HTTP Headers too. But I can't remember it at the moment... I'll look it up in a sec...
[Hotwire](http://hotwire-shell.org) is an attempt to combine the power of the traditional command line interface with GUI elements. So it has a GUI side, and tries to be helpful in suggesting commands, and in showing you possible matches from your history. (While there are keyboard shortcuts to do this in bash and ot...
It is possible to have a 2.0 project in VS 2008. You would just target .NET Framework 2.0 under the project properties. Your solution will have to be converted to a VS9 solution however.
The best way to learn anything is to start with the basic. You can find any good text book to explain what programming is, memory, algorithms. The next step select the language which it just depends on what the teacher knows or why the student wants to learn. Then it is just code, code, code. Code every exa...
Yes you can run 2.0 with VS2008. Be sure to select that when you convert, however. When converting a project, I mistakenly left in the ASP.NET 3.5 conversion, and then all new files contained references to Linq, so it was a little bit of a pain to switch back to 2.0 when I realized the mistake.
tesseract interface
|c#|tesseract|
How do you OCR an tiff file using tesseract's interface in c#? Currently only know how to do it using the executable.
OCR with the Tesseract interface
|c#|ocr|tesseract|
To summarize: This behavior will be going away in version 1.9, in which the character itself is returned, but in previous versions, trying to reference a single character of a string by it's character posision will return its character value (so "ABC"[2] returns 67) There are a number of methods that return a ra...
Note that the performance of Enum.Parse() is awful, because it is implemented via reflection. (The same is true of Enum.ToString, which goes the other way.) If you need to convert strings to Enums in performance-sensitive code, your best bet is to create a `Dictionary<String,YourEnum>` at startup and use that to do...
I've had success with running a wget and sending the result to /dev/null on a shared server.
@SCdF is correct. From [the horse's mouth][1]: > A Macromedia Flash movie cannot > communicate directly with a database. > However, Macromedia Flash movies can > "talk" to server-side applications > (also referred to as "middleware"). > Middleware can query a database and > relay data back and forth. There are...
[@SCdF][1] is correct. From [the horse's mouth][2]: > A Macromedia Flash movie cannot > communicate directly with a database. > However, Macromedia Flash movies can > "talk" to server-side applications > (also referred to as "middleware"). > Middleware can query a database and > relay data back and forth. Ther...
LINQ to SQL doesn't really have a n-tier story that I've seen, since the objects that it creates are created in the class with the rest of it, you don't really have an assembly that you can nicely reference through something like Web Services, etc. The only way I'd really consider it is using the datacontext to fetc...
Batch (NT): @echo off set n=%1 set result=1 for /l %%i in (%n%, -1, 1) do ( set /a result=result * %%i ) echo %result% Usage: C:\>factorial.bat 15
You have four options that I can think of, three of which have already been named by others: 1. Go the factory route, as suggested by several others here. One disadvantage to this is that you can't have consistent naming via overloading (or else you'd have the same problem), so it's superficially less clean. Anoth...
Ok, I've solved my own problem. To get that "authdata" string, you need to configure your client to how you need to authenticate. Then navigate to c:\[users directory]\[username]\Local Settings\Application Data\plastic. Pick up the client.conf and extract the string from the SecurityConfig element in the ...
I don't know what is "terribly slow" for you, but I have a decent performance with SQL 2005 Management Studio. In either case, [RedGate][1] products are very cool. Unfortunately it's not free. [1]: http://www.red-gate.com/
I guess you have considered the reads of Scott Ambler? http://www.agiledata.org/essays/databaseRefactoring.html
I used the draggable search in Spy++ (installed with VS) to look at the split open button on the file-open dialog of VS. This revealed that it's an ordinary windows button with a style which includes BS_DEFSPLITBUTTON. That's a magic keyword which gets you to some interesting places, including http://www.codepl...
I used the draggable search in Spy++ (installed with VS) to look at the split open button on the file-open dialog of VS. This revealed that it's an ordinary windows button with a style which includes BS_DEFSPLITBUTTON. That's a magic keyword which gets you to some interesting places, including http://www.codepl...
These articles may help: - [Git vs. Mercurial: Please Relax][1] (Git is MacGyver and Mercurial is James Bond) - [The Differences Between Mercurial and Git][2] [1]: http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/ [2]: http://www.rockstarprogrammer.org/post/2008/apr/06/differences-betwe...
At work we use friends extensively for out testing code. It means we can provide proper encapsulation and information hiding for the main application code. But also we can have seperate test code that uses friends to inspect internal state and data for testing. Suffice to say I wouldn't use the friend keyword as an ...
What logging is good logging for your app?
|.net|logging|client-applications|
So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches? Typically our scenario is, no logging really at all, and mostly .NET apps, winforms/WPF clients talking through web services or direct to a db. So, the real question ...
I think the VB6 units are not the same with the VB.Net one. So you have to do a conversion.
Sometime last year I evaluated both git and hg for my own use, and decided to go with hg. I felt it looked like a cleaner solution, and worked better on more platforms at the time. It was mostly a toss-up, though. More recently, I started using git because of git-svn and the ability to act as a Subversion client. Th...
This is what I use: def shellquote(s): return "'" + s.replace("'", "'\\''") + "'" The shell will always accept a quoted filename and remove the surrounding quotes before passing it to the program in question. Notably, this avoids problems with filenames that contain spaces or any other kind of nasty ...
Perhaps you have a specific reason for using os.system(). But if not you should probably be using the subprocess [module][1]. You can specify the pipes directly and avoid using the shell. The following is from [PEP324][2] > Replacing shell pipe line > ------------------------- > > output=`dmesg | ...
@[Domenic][1], I've considered, but I'd prefer to stay legal, and I'm fairly sure the information would have to be embedded into the framework anyway, or grabbed from the registry in some sneaky way that doesn't throw exceptions... [1]: http://stackoverflow.com/questions/44795/how-can-i-determine-whether-a-given...
@[Domenic][1], I've considered, but I'd prefer to stay legal, and I'm fairly sure the information would have to be embedded into the framework anyway, or grabbed from the registry in some sneaky way that doesn't require permissions... [1]: http://stackoverflow.com/questions/44795/how-can-i-determine-whether-a-gi...