instruction
stringlengths
0
30k
⌀
Sounds to me like you're trying to combine things that shouldn't be combined. If you need to do different processing in your view depending on if it's a User or Group object you're trying to look at then you should use two different view functions. On the other hand there can be common idioms you'd want to extract ...
Is a GUID unique 100% of the time?
|.net|guid|
Is a GUID unique 100% of the time? Will it stay unique over multiple threads?
|language-agnostic|guid|
What do you call the tags in Subversion and CVS that add automatic content?
|cvs|svn|tags|
Things like <code>@log</code> and <code>@version</code> which add data upon check-in to the file. I'm interested in seeing the other ones and what information they can provide, but I can't get much info unless I know what they are called. Thanks.
|svn|cvs|tags|
Things like <code>$log$</code> and <code>$version$</code> which add data upon check-in to the file. I'm interested in seeing the other ones and what information they can provide, but I can't get much info unless I know what they are called. Thanks.
I've been able to debug some control designer issues by running a second instance of VS, then from your first VS instance do a "Debug -> Attach to Process" and pick "devenv". The first VS instance is where you'll set your breakpoints. Use the second instance to load up the designer to cause the "designer" code to ru...
How do I do multiple updates in a single SQL query?
|php|sql|
Okay, here's the case: I have an SQL query like this: UPDATE foo SET flag=true WHERE id=? Now, I have a PHP array, which has a list of IDs. Is there a neat way of doing this, outside parsing something like: foreach($list as $item){ $querycondition = $querycondition . " OR " . $it...
Assuming you're joining on columns with no duplicates, which is by far the most common case: - An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection. - An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union. ...
> Because the Format method has nothing to do with a string's current value. That's true for *all* string methods because .NET strings are immutable. > If it was non-static, you would need a string to begin with. It does: the format string. I believe this is just another example of the many design flaws in ...
I use it every time I refer to an instance variable, even if I don't need to. I think it makes the code more clear.
I use it anywhere there might be ambiguity (obviously). Not just compiler ambiguity (it would be required in that case), but also ambiguity for someone looking at the code.
I tend to underscore fields with _ so don't really ever need to use this. Also R# tends to refactor them away anyway...
You should always use it, I use it to diferantiate private fields and parameters (because our naming conventions state that we don't use prefixes for member and parameter names (and they are based on information found on the internet, so I consider that a best practice))
I only use it when absolutely necessary, ie, when another variable is shadowing another. Such as here: class Vector3 { float x; float y; float z; public Vector3(float x, float y, float z) { this.x = x; this.y = y; thi...
Any time you need a reference to the current object. One particularly handy scenario is when your object is calling a function and wants to pass itself into it. Example: void onChange() { screen.draw(this); }
Since there are a bunch of different functional programming languages, it's hard to recommend books. But if you're interested in Common Lisp, recently I've been reading ["Practical Common Lisp"][1] by Peter Seibel, which you can [check out online for free][2] before dropping your hard earned cash on it. It's a pretty g...
Is Visual Studio prompting you for the path to the source file? If it isn't then it doesn't think it has symbols for the callstack. Setting the source path should work without having to map the exact original location. You can tell if symbols are loaded by looking at the 'modules' window in Visual Studio. Assumi...
replace the last line from $CMD to just wine '$EXEC' $ARGS You'll note that the error is ''/home/chris/.wine/drive_c/Program' and not '/home/chris/.wine/drive_c/Program' The single quotes are not being interpolated properly, and the string is being split by spaces.
You can try preceeding the spaces with \ like so: /home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe You can also do the same with your \t problem - replace it with \\t.
You can try preceeding the spaces with \ like so: /home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe You can also do the same with your \t problem - replace it with \\\t.
I use passive view, a flavor of the [Model View Presenter][1] pattern, with any web forms like development (.NET) to increase testability/maintainability/etc For example, your code-behind file might look something like this Partial Public Class _Default Inherits System.Web.UI.Page Implements...
I'm not really sure what 'tag' is, but branch is a fairly common source control concept. Basically, a branch is a way to work on changes to the code without affecting trunk. Say you want to add a new feature that's fairly complicated. You want to be able to check in changes as you make them, but don't want it to a...
If having the revision numbers change based on other projects bothers you, then put the projects in separate repositories. That is the only way to make the revision numbers independent. To me, the big reason to use different repositories is to provide separate access control for users and/or using different hook scr...
Hmm, not sure I agree with Nick re tag being similar to a branch. A tag is just a marker - **Trunk** would be the main body of development, originating from the the start of the project until the present. - **Branch** will be a copy of code derived from a certain point in the trunk that is used for applying maj...
How can I find the full path to a font from its display name on a Mac?
|python|macos|font|photoshop|
I am using the Photoshop's javascript API to find the fonts in a given PSD. Given a font name returned by the API, I want to find the actual physical font file that that corresponds to on the disc. This is all happening in a python program running on OSX so I guess I'm looking for one of: * Some Photoshop java...
Python and MySQL
|python|mysql|postgresql|
I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as Django or PySQL, I generally fail when installing them on my computer so maybe it's good I can't install on the host. I fo...
You can print from the command line using the following: > rundll32.exe > %WINDIR%\System32\mshtml.dll,PrintHTML > "%1" Where %1 is the file path of the html file to be printed. If you don't need to print from memory (or can afford to write to the disk in a temp file) you can use: using (Process printPr...
Just use ISO-8601. It's an international standard. <http://en.wikipedia.org/wiki/ISO_8601>
How do I use Python's itertools.groupby()?
|python|iteration|
I haven't been able to find an understandable explanation of how to actually use Python's itertools.groupby() function. What I'm trying to do is this: take a list - in this case, the children of an objectified lxml element - divide it into groups based on some criteria, and then later iterate over each of these group...
Are you looking for a software package that'll do the work or actually doing the matrix operations and such and do each step? The the first, a coworker of mine just used [Ocaml GLPK][1]. It is just a wrapper for the [GLPK][2], but it removes a lot of the steps of setting things up. It looks like you're going to have...
Can you show us your code? The example on the Python docs is quite straight forward: groups = [] uniquekeys = [] for k, g in groupby(data, keyfunc): groups.append(list(g)) # Store group iterator as a list uniquekeys.append(k) So in your case, data is a list of nodes, keyfu...
Turn off javascript and make sure your site can still be navigated. Even if you want to ignore the small but significant number of people who have it disabled, this will impact search engines as well.
I learned from Jeffrey Ullman's <em>Elements of ML Programming</em>, which is pretty good. It loses points for being about Standard ML, when OCaml, F#, and Haskell are (seemingly) more popular.
Netbeans is good becasue you can use it on Windows and OSX.
You're doing this in c/c++... so you have an array of array of array... you don't have to visualize 20 dimensions since that isn't how the data is laid out in memory, for a 2 dimensional: [1] --> [1,2,3,4,5,6,...] [2] --> [1,2,3,4,5,6,...] [3] --> [1,2,3,4,5,6,...] [4] --> [1,2,3,4,5,6,...] [...
Not sure what the confusion is. Sites on your intranet are in the intranet zone, web sites are in the internet zone, and sites on your computer are in the local zone, unless you've specifically overridden something in the browser's preferences.
I pretty much only use **this** when referencing a type property from inside the same type. As another user mentioned, I also underscore local fields so they are noticeable without needing **this**.
It depends on the coding standard I'm working under. If we are using _ to denote an instance variable then "this" becomes redundant. If we are not using _ then I tend to use this to denote instance variable.
I tend to use it everywhere as well, just to make sure that it is clear that it is instance members that we are dealing with.
Behaviour is the same when a window finishes flashing for as long as it's supposed to: the taskbar button stays coloured. I don't think this is a bug. If you think about it, when you use FLASHW_STOP, the flashing does in fact stop, but the point of the flashing is to get the user's attention. The button stays coloured ...
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast with the procedural programming style that emphasizes changes in state.
|python|macos|fonts|photoshop|
The **trunk** is the development line that holds the latest source code and features. It should have the latest bug fixes in it as well as the latest features added to the project. The **branches** are usually used to do something away from the trunk (or other development line) that would otherwise *break* the build...
I have seen RSS used to syndicate gas prices from a service for a specific zip code.
[Tomcat Documentation][1] DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons components: * Jakarta-Commons DBCP * Jakarta-Commons Collections * Jakarta-Commons Pool This attribute may help you out. removeAbandonedTimeout="60" I'm using the ...
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for ...
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for ...
Passing multidimensional arrays as function arguments in C
|c|
In C can I pass a multidimensional array to a function as a single argument ?
In C can I pass a multidimensional array to a function as a single argument when I don't know what the dimensions of the array are going to be ?
In C can I pass a multidimensional array to a function as a single argument when I don't know what the dimensions of the array are going to be ? In addition my multidimensional array may contain types other than strings.
Caching
|language-agnostic|caching|
Currently I know of only two ways to cache data (I use PHP but I assume that the same will apply to most languages). 1. Save the cache to a file 2. Save the cache to a large DB field Are there any other (perhaps better) ways of caching or is it really just this simple?
You can also cache in memory which is much more efficient. Try [memcached][1]. [1]: http://www.danga.com/memcached/
I've used WiX a little bit before, and generally I found that it's great once you figure out what to do but there is a steep learning curve. If you spend a solid day going over the WiX tutorial you should be be able to get 80% of your setup working. [link text][1] [1]: http://wix.sourceforge.net/tutorial.html
I don't have it entirely implemented yet, but this web site seems to give a [good walkthrough][1] of setting up the certificates and the code. [1]: http://developers.de/blogs/damir_dobric/archive/2006/08/01/897.aspx
Hanselminutes .NET Rocks, StackOverflow, SoftwareEngeneeringRadio Are my favorites. TWiT and CrankyGeeks I listen to if i want a laugh or get mad, they are horrible.
Sybase Anywhere has a OLEDB provider for VFP tables. It states in the page that the server supports 64 bit Windows, don't know about the OLEDB provider: > Support 64-bit Windows and Linux Servers > In order to further enhance scalability, support for the x86_64 architecture was added to the Advantage Database Ser...
There's a [good explanation here](http://codebetter.com/blogs/karlseguin/archive/2008/04/27/foundations-of-programming-pt-7-back-to-basics-memory.aspx) for .NET. A lot of people are surprise that reference objects are actually passed by value (in both C# and Java). It's a copy of a stack address. This prevents a met...
We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index: // Add market_local to index contactDocument.add( new Field( "m...
I believe *message* is used in smalltalk. Java, C# etc. tend to use *method* or *instance method*.
I've found this to be a language and programming-paradigm thing. One paradigm — OOP — refers to objects with member methods, which conceptually are how you send messages to those objects (this view is reflected in UML, for example). Another paradigm — functional — may or may not involve classes of objects, but func...
By the way: most programming languages would disagree with Python and give the result `-2`. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of *a* and *b* is the (strictly positive) rest *r* of the division of *a* / *b*. More prec...
I am pretty sure (but a quick [Wikipedia][1] check seems to confirm this) that the `message passing' terminology comes from the Smalltalk community. I think it is more or less equivalent to a method call. [1]: http://en.wikipedia.org/wiki/Smalltalk#Messages
Here's some simplified definitions: <strong>methods/subroutines/voids:</strong> perform an action <strong>functions:</strong> perform an action and return a value <strong>events:</strong> are called when an object is acted upon <strong>handlers:</strong> are the functions/methods that handle the events ...
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for ...
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for ...
http://www.immobilienscout24.com/ they use RSS feeds for updates on your search.
I mainly code ColdFusion or PHP (and JS/CSS/xHTML), but have dabbled in a bit of RoR. RadRails/Apatana has been great for me, because it's built on Eclipse, which I was already using for my other work. It also integrates with Subversion via the Subclipse plugin. The Eclipse platform is so extensible that it's worth...
[Cramer's Rule](http://en.wikipedia.org/wiki/Cramers_rule) and [Gaussian Elimination](http://en.wikipedia.org/wiki/Gaussian_elimination) are two good, general-purpose algorithms (also see [Simultaneous Linear Equations](http://en.wikipedia.org/wiki/Simultaneous_linear_equations)). If you're looking for code, check o...
[Cramer's Rule](http://en.wikipedia.org/wiki/Cramers_rule) and [Gaussian Elimination](http://en.wikipedia.org/wiki/Gaussian_elimination) are two good, general-purpose algorithms (also see [Simultaneous Linear Equations](http://en.wikipedia.org/wiki/Simultaneous_linear_equations)). If you're looking for code, check o...
What source control system are you using? Almost all of them have some form of $ Id $ tag that gets expanded when the file is checked in. I usually use some form of hackery to display this as the version number. The other alternative is use to use the date as the build number: 080803-1448
Not efficient at all, but you can use a regular expression to test for prime numbers. ^1?$|^(11+?)\1+$/
Absolutely, especially dealing with lots of these permutations/combinations I can definitely see that the first pass would be an issue. Interesting implementation in python, though I wrote a nice one in C and Ocaml based on "Algorithm 515" (see below). He wrote his in Fortran as it was common back then for all the "...
I would be wary of automatically upcasing all whitespace-preceded-words in scenarios where I would run the risk of attracting the fury of nitpickers. I would at least consider implementing a dictionary for exception cases like articles and conjunctions. Behold: > "Beauty and the Beast" And when it comes to proper n...
A functional language (ideally) allows you to write a mathematical function, i.e. a function that takes *n* arguments and returns a value. If the program is executed, this function is evaluated. A procedural language, on the other hand, performs a series of *sequential* steps, where the functional program would be n...
I wouldn't bother looking for ASP.NET stuff specifically (probably won't find any anyways). Finding a good CSS theme easily can be used in ASP.NET. Here's some sites that I love for CSS goodness: <http://www.freecsstemplates.org/> <http://www.oswd.org/> <http://www.openwebdesign.org/> <http://www.st...
I have used [Open source Web Design][1] in the past. They have quite a view css themes, don't know about ASP.Net [1]: http://www.oswd.org/
We are heavily using [EasyMock][1] and EasyMock Class Extension at work and are pretty happy with it. It basically gives you everything you need. Take a look at the documentation, there's a very nice example which shows you all the features of EasyMock. [1]: http://easymock.org
While I obviously cannot speak to the specifics of your application, in most instances you should not tie your caching implementation to some perceived expectation for how the GC will work. As Stu mentions, calling GC.Collect() will force a collection (with overloads for a specific generation) but more often than not ...
I would use [Stax][1] to parse XML, it's fast and easy to use. I've been using it on my last project to parse XML files up to 24MB. There's a nice introduction on [java.net][2], which tells you everything you need to know to get started. [1]: http://jcp.org/en/jsr/detail?id=173 [2]: http://today.java.net/pub/...
I've been using the [Data Transfer Objects][1] pattern (originally from the Java world, I believe), with a SqDataReader to populate collections of DTOs from the data layer for use in other layers of the application. The DTOs themselves are very lightweight and simple classes composed of properties with gets/sets. They...
This is what I use to read from a Magtek card reader: //Open file on the device deviceHandle = CreateFile (deviceDetail->DevicePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); Try those options and see if you can at least read from the d...
Assuming you're joining on columns with no duplicates, which is by far the most common case: - An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection. - An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union. ...
Assuming you're joining on columns with no duplicates, which is by far the most common case: - An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection. - An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union. ...