instruction
stringlengths
0
30k
It really depends on your data, and how you intend to use it. At one of my previous positions, we used Postgres due to the native geo-location and timezone extensions which existed because it allowed us to manage our data using polygonal datatypes. For us, we needed to do that, and we also wanted to use stored procedur...
Python 2.5.2 (r252:60911, Jun 16 2008, 18:27:58) [GCC 3.3.4 (pre 3.3.5 20040809)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> random.seed() >>> dir(random) ['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'Random', 'SG_MAGICCONST'...
|c#|generics|primitive|type-safety|
OK, here we go again! Following on from my [previous question](http://stackoverflow.com/questions/8625/generic-type-conversion-from-string) on Converting to a Generic Type from String, I thought I would ask another Generics-related question! This time, **is there a way to enforce/limit the types that are passed to P...
My approach is similar to a few others here, using regions to organize code blocks into constructors, properties, events, etc. There's an excellent set of VS.NET macros by Roland Weigelt available from his blog entry, [Better Keyboard Support for #region ... #endregion](http://weblogs.asp.net/rweigelt/archive/2003/0...
last | grep reboot Works for me :)
Kate Rhodes has a great essay on the differences at http://weblog.masukomi.org/writings/xml-rpc_vs_soap.htm
I wanted to adjust David B's "Life Lesson". I think it should be "never use char for variable length string values" -> There are valid uses for the char data type, just not as many as some people think :)
@none The DatagramSocket classes sure need a polish up, DatagramChannel is slightly better for clients, but confusing for server programming. For example: <pre> import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.DatagramChannel; public clas...
There were a great session at OSCON this year on just this topic: http://assets.en.oreilly.com/1/event/12/Shell%20Scripting%20Craftsmanship%20Presentation%201.pdf
storing revision changes of a message
|algorithm|stackoverflow|version-control|
What algorithms and processes are involved in storing revision changes like stackoverflow and wikipedia do? Is only one copy of the message kept? And if so is it only the latest copy? Then only changes to go back to the previous version(s) are stored from there? (This would make for a faster display of the main m...
I think many other people have given you mostly correct answers on this matter. One detail that has been missed, however, is that the "heap" should in fact probably be called the "free store". The reason for this distinction is that the original free store was implemented with a data structure known as a "binomial ...
I used SQL Compact Edition with my WPF app and I'm happy with my decision. Everything just works (since WPF and SQLCE are both MS they play nicely together), and the installation of the runtime is small enough and smooth enough for my needs. I created and modified the database through visual studio.
dbr said: > def hash_password(password): > """Returns the hashed version of a string > """ > return hasher.new( str(password) ).hexdigest() This is a really insecure way to hash passwords. You *don't* want to do this. If you want to know why read the [Bycrypt Paper][1] by the guys w...
I have often come across the need to have a Generic parameter-object persisted into the viewstate in a base class. public abstract class BaseListControl<ListType,KeyType,ParameterType> : UserControl where ListType : BaseListType && ParameterType ...
WinForms DataGrid: How to programmatically iterate rows?
|winforms|
I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an ArrayList of business objects bound to a Windows Forms DataGrid. I'd like the user to be able to edit the cells, and when finished, press a Save button. At that point I'd like to itera...
How to programmatically iterate rows?
I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an ArrayList of business objects bound to a Windows Forms DataGrid. I'd like the user to be able to edit the cells, and when finished, press a Save button. At that point I'd like to it...
What about FireBird? Where would that fit into that list?
Scalable Moebius strip in WPF
|c#|wpf|math|xaml|topology|
A [moebius strip][1] is a surface with one side. How would one define such an object in XAML/WPF? How could such an object be manipulated in 3D, scaled up and down and rotated using C#? [1]: http://en.wikipedia.org/wiki/M%C3%B6bius_strip
Scott, as you guessed: truncating the log is a bad move if you care about your data. The following, free, videos will help you see exactly what's going on and will show you how to fix the problem without truncating the logs. (These videos also explain why that's such a dangerous hack and why you are right to look fo...
invalidateDisplayList() merely sets a flag so that updateDisplayList() can be called later during a screen update. invalidateList() is what you want. [http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponent.html#invalidateDisplayList()][1] [1]: http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponen...
aliased generics: using ASimpleName = Dictionary<string, Dictionary<string, List<string>>>; allows you to use `ASimpleName`, instead of `Dictionary<string, Dictionary<string, List<string>>>` use it when you would use the same generic big long complex thing in a lot of places
Full disclosure: I'm one of the guys who invented Kid's Programming Language, which is now <http://www.Phrogram.com>, which others have recommended here. Let me add some programmer-oriented info about it. It's a code IDE, rather than drag-and-drop, or designer-based. This was intentional on our part - we wanted to...
I suggest using either a [Unix socket](http://en.wikipedia.org/wiki/Unix_domain_socket) or [D-Bus](http://en.wikipedia.org/wiki/D-Bus). Using a socket might be faster if you're familiar with Unix sockets programming and only want a few operations, whereas D-Bus might make it easier to concentrate on implementing the fu...
How do I call a Flex SWF from a remote domain using Flash (AS3) ?
|flash|apache-flex|security|
I have a Flex swf hosted at http://www.a.com/a.swf. I have a flash code on another doamin that tries loading the SWF: _loader = new Loader(); var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf"); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish); _loader.load(req); ...
|security|apache-flex|flash|actionscript-3|
The cause of this error is an older version of NVIDIA's **glext.h**, which still has this definition. Whereas the most recent versions of [GLEW][1] don't. This leads to compilation errors in code that you had written previously or got from the web. The **GL\_FRAMEBUFFER\_INCOMPLETE\_DUPLICATE\_ATTACHMENT\_EXT** defi...
We have used [Telerik's RadChart][1] and MSSQL Reporting Services. [1]: http://demos.telerik.com/aspnet/prometheus/Chart/Examples/Overview/DefaultCS.aspx
Keep in mind regexp are greedy, so if you are just searching within the version number string and not within a bigger text, use ^ and $ to mark start and end of your string. The regexp from Greg seems to work fine (just gave it a quick try in my editor), but depending on your library/language the first part can still ...
Keep in mind regexp are greedy, so if you are just searching within the version number string and not within a bigger text, use ^ and $ to mark start and end of your string. The regexp from Greg seems to work fine (just gave it a quick try in my editor), but depending on your library/language the first part can still ...
There's a bit of a tutorial (with - presumably - working code you can leverage) over at [CodeProject][1]. The only thing you have to be a little careful of is that it's perfectly "normal" for a WAV file to be composed of multiple chunks - so you have to scoot over the entire file to ensure that all chunks are accoun...
Smooth ProgressBar in WPF
|c#|wpf|progress-bar|
I'm using the ProgressBar control in a WPF application and I'm getting this old, Windows 3.1 Progress*Blocks* thing. In VB6, there was a property to show a *smooth* ProgressBar. Is there such a thing for WPF?
ZedGraph works superbly in ASP .NET, and is a superb charting package. Really flexible, and makes attractive graphs. The graphs are generated as static images (PNG by default) and it automatically deletes old ones. Also, it is widely supported, has a great wiki, and a decent code-project tutorial (http://www.codepro...
I like [google charts][1], but check the license before using. [1]: http://code.google.com/apis/chart/
#Bash: Recursive In bash and recursive, but with the added advantage that it deals with each iteration in a new process. The max it can calculate is !20 before overflowing, but you can still run it for big numbers if you don't care about the answer and want your system to fall over ;) <pre><code>#!/bin/bash echo $...
There is **generally** nothing to be gained by divorcing object initialization from construction. RAII is correct, a successful call to the constructor should either result in a fully initialized live object or it should fail, and **ALL** failures at any point in any code path should always throw an exception. You gain...
Why should I care about compacting an MS Access .mdb file?
|ms-access|
We distribute an application that uses an MS Access .mdb file. Somebody has noticed that after opening the file in MS Access the file size shrinks a lot. That suggests that the file is a good candidate for compacting, but we don't supply the means for our users to do that. So, my question is, does it matter? Do...
Seems to work fine for me. Check out the methods in the [official python documentation][1] for random: >>> import random >>> random.random() 0.69130806168332215 >>> random.uniform(1, 10) 8.8384170917436293 >>> random.randint(1, 10) 4 [1]: http://docs.python.org/lib/module-rando...
While it won't reveal unneeded include files, Visual studio has a setting "/showIncludes" (right click on a .cpp file, Properties->C/C++->Advanced) that will output a tree of all included files at compile time. This can help in identifying files that shouldn't need to be included. You can also take a look at the pi...
Either Cast or Convert: Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) http://msdn.microsoft.com/en-us/library/ms187928.aspx
Either Cast or Convert: Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) http://msdn.microsoft.com/en-us/library/ms187928.aspx Actually since you asked for a specific format: REPLACE(CONVERT(varchar(10), D...
If your interested in testing your Access application at a more granular level specifically the VBA code itself then [VB Lite Unit][1] is a great unit testing framework for that purpose. [1]: http://vb-lite-unit.sourceforge.net/
Limit dev environment to e-mail only certain domains for testing (XP smtp IIS)
|testing|iis|smtp|windows-xp|
I'm developing a website on an XP virtual machine and have an SMTP virtual server set up in IIS -- it delivers mail just fine. What I would *like* is to confirm that any emails the site sends are only going to a specific domain. The XP firewall seems to only involve incoming connections, I can't block outgoing TCP...
It almost looks like the CStatic doesn't know that it needs to repaint itself, so the background color of the draggable object is left behind. Maybe try to invalidate the CStatic, and see if that helps at all?
If you are calling another batch file, you must use CALL batchfile.cmd
Can I add maven repositories in teh command line?
|maven-2|java|build-process|
I'm aware I can add maven repositories for fetching dependencies in ~/.m2/settings.xml. But is it possible to add a repository using command line, something like: mvn install -Dmaven.repository=http://example.com/maven2 The reason I want to do this is because I'm using a continuous integration tool where I ha...
Can I add maven repositories in the command line?
|java|build-process|maven-2|
JS error for JQuery in IE 8.0
|jquery|internet-explorer|
I have developed a simple page using JQuery. It works fine in almost all browsers (i.e. Firefox, IE, Chrome) but whenever the page is opened in IE, it prompts Javascript error like, **'guid' is null or not an object** on line **1834** Do you have any idea ?
You can generalize it, but there's no join in Java, as you well say. [This][1] might work better. public static String join(AbstractCollection<String> s, String delimiter) { if (s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuffer buffer = new StringBuffer(ite...
You can generalize it, but there's no join in Java, as you well say. [This][1] might work better. public static String join(Iterable<? extends Charsequence> s, String delimiter) { if (s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuffer buffer = new StringBuff...
To add to what Brad and squadette have said, the self-closing XML syntax is correct, but only if your web server sends your documents as properly formed XML with an XML mimetype like `application/html+xml` (and *not* `text/html`). However, this will cause them not to be parsed by IE7. From [w3][1]: > In summary, 'a...
dbr said: > def hash_password(password): > """Returns the hashed version of a string > """ > return hasher.new( str(password) ).hexdigest() This is a really insecure way to hash passwords. You *don't* want to do this. If you want to know why read the [Bycrypt Paper][1] by the guys w...
How to robustly, but minimally, distribute items across a peer-to-peer system
|p2p|machinelearning|language-agnostic|distributed|fault-tolerance|
If one has a peer-to-peer system that can be queried, one would like to - reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) - avoid excess storage at each node - assure good availability to even moderately rare items in the face of c...
If I need to do some XPath, I just tweak one of these examples. - **child::node()** selects all the children of the context node, whatever their node type - **attribute::name** selects the name attribute of the context node - **attribute::*** selects all the attributes of the context node - **descendant::...
A JSON value is a string, number, object, array, true, false or null. So this is just a string. There is no official way to represent dates in JSON. This syntax is from the asp.net ajax implementation. Others use the ISO 8601 format. You can parse it like this: var s = "\/Date(1221644506800-0700)\/"; var...
If one has a peer-to-peer system that can be queried, one would like to - reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) - avoid excess storage at each node - assure good availability to even moderately rare items in the face of c...
|language-agnostic|distributed|fault-tolerance|machinelearning|p2p|
If one has a peer-to-peer system that can be queried, one would like to - reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) - avoid excess storage at each node - assure good availability to even moderately rare items in the face of c...
If one has a peer-to-peer system that can be queried, one would like to - reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) - avoid excess storage at each node - assure good availability to even moderately rare items in the face of c...
You say it's Unicode, so why not use File.ReadAllText(**Encoding.Unicode**) then?
What exactly is your application doing with compressed WAVs? Compressed WAV files are always tricky - I always try and use an alternative container format in this case such as OGG or WMA files. The XNA libraries tend to be designed to work with specific formats - although it is possible that within XACT you'll find a...
I prefer a website. A website is a collection of files in a directory. It becomes more portable and deployable. A web application clouds the issue with a project file.
You could send a message to all observers informing them the data source is terminating and let the observers remove themselves from the list. Skizz
You could send a message to all observers informing them the data source is terminating and let the observers remove themselves from the list. Skizz In response to the comment, the implementation of the subject-observer pattern should allow for dynamic addition / removal of observers. In C#, the event system is a...
Take a look at [Terracotta][1], I think it can address your scaling issues without a major application redesign. [1]: http://www.terracotta.org/
I used <a href="http://www.advsofteng.com/">Chart Director</a> for a medium sized project, and loved it. It's incredibly feature-rich, has pretty good documentation, and an amazingly good support forum -- it's one of those ones where you ask a question, and a guy who works for the company that produces the software alm...
If you do not mind using Flash to display your graphs, [Open Flash Charts][1] supports a lot of languages. This was also the choice used for the Stackoverflow reputation tracker piece as [mentioned in this question][2] [1]: http://teethgrinder.co.uk/open-flash-chart/ [2]: http://stackoverflow.com/questions/69...
[This][1] KB article seems to explain what you are looking for... there is a link to a VB version of the article too. [1]: http://support.microsoft.com/kb/323116
There definitely is a way. Though I'd strongly vote for sticky sessions - saves so much load for your servers/database (unless something fails)... http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html has information about SessionManager configuration and setup for Tomcat. Depending on your exact requirements ...
In the .net framework there is a mediaplayer class: http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer_members.aspx Here is an example: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2667714&SiteID=1&pageid=0#2685871
|language-agnostic|distributed|p2p|fault-tolerance|machine-learning|
Seconding comments made by others: Catalyst (which more or less forked from Maypole) is by far and away the most complete and robust of them. There is a book by Jonathan Rockway that will certainly help you come to grips with it. In addition to the 'Chained' dispatch type, the :Regex (and :LocalRegex) dispatch metho...
The best answer depends on the platform. For deployment on Windows, I have had good results using a combination of <a href="http://one-jar.sourceforge.net/">one-jar</a> and <a href="http://launch4j.sourceforge.net/">launch4j</a>. It did take a little while to set up my build environment properly (ant scripts, mostly)...
Yes OOP did not solve all our problems, sorry about that. We are, however working on SOA which will solve all those problems.
I would use the preg_match function to do this, as what you want is a pretty simple expression. $matches = array(); $result = preg_match("/^(.{1,199})[\s]/i", $text, $matches); The expression means "match any substring starting from the beginning of length 1-200 that ends with a space." The result is in ...
I would use the preg_match function to do this, as what you want is a pretty simple expression. $matches = array(); $result = preg_match("/^(.{1,199})[\s]/i", $text, $matches); The expression means "match any substring starting from the beginning of length 1-200 that ends with a space." The result is in ...
This appears to be that you're not mixing the Module into your class. If I run the test in irb then the require throws a LoadError. So I assume you've put two files together, if not dump it. Normally you'd write the functionality in the module, then mix that into the class. so you may modify your code like this: ...
The cause of this error is an older version of NVIDIA's **glext.h**, which still has this definition. Whereas the most recent versions of [GLEW][1] don't. This leads to compilation errors in code that you had written previously or got from the web. The **GL\_FRAMEBUFFER\_INCOMPLETE\_DUPLICATE\_ATTACHMENT\_EXT** defi...