instruction
stringlengths
0
30k
Try this: def adamsplit(s): result = [] inquotes = False for substring in s.split('"'): if not inquotes: result.append(substring.split()) else: result.append(substring) inquotes = not inquotes return result
What wfarr is describing would be [single table inheritance][1], which is what I currently do in this situation. I have one table for Assets which contains all the necessary attachment_fu columns, plus an extra column called type, which will hold the actual model name. I have a model for assets and additional models fo...
Given a stream of bytes, you have to know what encoding it is to begin with - email use mime headers to specify the encoding, http uses http headers to specify the encoding. Also, you can specify the encoding in a meta tag in a web page, but it is not always honored. Anyway, once you know what encoding you want t...
It can refer to any code executed by a virtual machine rather than directly by the CPU. I think this enables things like garbage collection and array bounds checking.
The term _managed_ is generally applied only to .NET because Microsoft uses the term. Microsoft generally doesn't use the term "virtual machine" in reference to a .NET managed execution environment. .NET's "bytecode" (IL) is somewhat different from Java bytecode in that it was explicitly designed to be compiled int...
The term _managed_ is generally applied only to .NET because Microsoft uses the term. Microsoft generally doesn't use the term "virtual machine" in reference to a .NET managed execution environment. .NET's "bytecode" (IL) is somewhat different from Java bytecode in that it was explicitly designed to be compiled int...
You might also want to check out the 3rd party [aspNetEmail][1] library, which has a lot of useful features to offer above what System.Net.Mail gives you. [1]: http://www.aspnetemail.com/
_In a controlled environment,_ using SmtpClient would be the answer. But on a user's machine you would need an SMTP server to send through. You could prompt the user for their SMTP credentials, but I think that would be impractical for your case. As a user, I would not want to provide my SMTP credentials to a rand...
I think your confusion comes from the fact that it looks like your first example is a home-brewed library, not part of .NET. The configurationmanager example is an example of built-in functionality.
When to use HtmlControls vs WebControls
|asp.net|
I like HtmlControls because there is no HTML magic going on... the asp source looks similar to what the client sees. I can't argue with the utility of GridView, Repeater, CheckBoxLists, etc, so I use them when I need that functionality. Also, it looks weird to have code that mixes and matches: <asp:Butto...
After a brief amount of Googling, I found nothing that looks like a wrapper for this API, but I'm not quite sure if a wrapper is what is necessary for GeoPlanet. According to Yahoo's [documentation][1] for GeoPlanet, requests are made in the form of an HTTP GET messages which can very easily be made using Python's...
Assuming 32 bit ints: bool same = ((x ^ y) & >> 31) != 1; Slightly more terse: bool same = !((x ^ y) & >> 31);
Thinking back to my university days, in most machine representations, isn't the left-most bit of a integer a 1 when the number is negative, and 0 when it's positive? I imagine this is rather machine-dependent, though.
You don't mention which version of .NET you're using, but something that's worked for me in using Visual Studio .NET 2003 is to provide a thin C# wrapper around the pimpled implementation of the real C++ class: public __gc class MyClass_Net { public: MyClass_Net() :native_ptr_(new MyClass...
(integer1 * integer2) > 0 Because when two integers share a sign, the result of multiplication will always be positive. You can also make it >= 0 if you want to treat 0 as being the same sign no matter what.
wget is probably the most complete method. If you don't have access to that, and you have a template based layout, you may want to look into using Savant 3. I recommend Savant 3 highly over other template systems like Smarty. Savant is very light weight and uses PHP as the template language, not some proprietary su...
While this does not answer your initial question, you could perhaps eliminate the hassle of going through java.util.Calendar by doing this: // Date d given d.setTime(d.getTime()+86400000);
You need to set AutoPostBack to true (so that the \_\_doPostBack javascript function will get rendered in the page output) and then manually override the onchange attribute with a confirm() and a manual call to __doPostBack: <asp:DropDownList ID="TheDropDown" runat="server" AutoPostBack="true" onchange=...
You can utilize the the CustomValidator control to "validate" dropdown by calling a javascript function in which you do the confirm(): <asp:DropDownList ID="TestDropDown" runat="server" AutoPostBack="true" CausesValidation="true" ValidationGroup="Group1" OnSelected...
If you can't get xinclude to work and you're using Ant, I'd recommend [XMLTask][1], which is a plugin task for Ant. It'll do lots of clever stuff, including the one thing you're interested in - constructing a XML file out of fragments. e.g. <xmltask source="templatefile.xml" dest="finalfile.xml"> <inse...
[ITextSharp][1] is the way to go [1]: http://itextsharp.sourceforge.net/
**Why is rspec so slow?** because it loads all the environement, loads fixtures and all that jazz. **Is there a way to speed up Rails' initial load** you could try using mocks instead of relying on the database, this is actually correct for unit testing and will definitly speed up your unit tests. Additionnaly usin...
Is it me, or is Eclipse horribly unpredictable?
|java|eclipse|ide|editor|
I recently started using Eclipse at work for my Java servlet projects. I've been using jEdit for years, which is a uber-powerful text editor. It has syntax highlighting, but it doesn't have any language-specific features like code completion and intelligent refactoring. I'm finding that's hindering my productivity. ...
http://github.com/claco/csvdatareader/ updated using TextFieldParser suggested by cfeduke. Just a few props away from exposing separators/trimspaces/type ig you just need code to steal.
Business Logic should be handled outside of the proc. The procs jobs should be to save the data passed to it. If the requirment is to only store Date and not time, then the BL/DL should pass in DateTime.Now**.Date** (or the equiv...basically the Date part of your DateTime object). If you can't control the code for...
**If you are writing your tests after you've written your code and making them pass, you are not doing TDD** (nor are you getting any benefits of Test-First or Test-Driven development.. check out SO questions for definitive books on TDD) > One of the things I've noticed with > using mocker is that it's easier to >...
See the excellent MSDN article [here][1] as your first stop. [1]: http://msdn.microsoft.com/en-us/magazine/cc302121.aspx
What is the best way to extract a version string from a file?
|perl|bash|scripting|
I want to use a file to store the current version number for a piece of customer software which can be used by a start-up script to run the binary in the correct directory. For Example, if the run directory looks like this: . .. 1.2.1 1.2.2 1.3.0 run.sh current_version And cur...
All formal methods exist to sell books and training courses, and for no other reason. That's why there's so many of them. Once you realise this, you are free :-)
Apps that support both DirectX 9 and 10
|graphics|compatibility|directx|
I have a noobish question for any graphics programmer. I am confused how some games (like Crysis) can support both DirectX 9 (in XP) and 10 (in Vista)? What I understand so far is that if you write a DX10 app, then it can only runs in Vista. Maybe they have 2 code bases -- one written in DX9 and another in DX1...
Form controls are treated specially by browsers, so a lot of things don't necessarily work as they should. One of these things is generated content - it doesn't work for form controls. Instead, wrap the labels in `<label>` and use `label:before { content: '\a' ; white-space: pre; }`. You can also do it by floating e...
[GhostDoc][1] helps by creating a stub comment for your method/class. [1]: http://www.roland-weigelt.de/ghostdoc/
Auto-updating in Corporate Environments (C#)
|c#|.net|update|
I have a three-tier application which is installed in corporate environments. With every server version update, all clients have to be updated, too. Currently, I provide an MSI package which is automatically deployed via Active Directory, however my customers (mostly with 20-300 users each) seem to hate the MSI solutio...
You can create an ActionFilter that modifies the view data. That way, you can decorate every action that returns the partial with the action filter. Take a look at my post: http://weblogs.asp.net/stephenwalther/archive/2008/08/12/asp-net-mvc-tip-31-passing-data-to-master-pages-and-user-controls.aspx
It's not quite that easy. The only general rule of thumb is that you should look for another solution when the current one can't keep up anymore. That could include using different software (not necessarily in any globally fixed order), hardware or architecture. You will probably get a lot more benefit out of cachin...
Public Function LastData(rCol As Range) As Range Set LastData = rCol.Find("*", rCol.Cells(1), , , , xlPrevious) End Function Usage: ?lastdata(activecell.EntireColumn).Address
A delegate is a reference to a method with a particular parameter list and return type. It may or may not include an object. A lambda-expression is a form of anonymous function.
If the problem is just LazyInitializationExceptions, you can avoid that by adding an OpenSessionInViewFilter. This will allow the objects to be loaded in the view, but will not help with the speed issue. <filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework....
do you want to insert extraction in existing table? if it does not matter they you can try the following query: SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 INTO T1 FROM Table1 GROUP BY LongIntColumn1); It will create a new table -> T1 with the extracted information
I'm not sure if this will work, but try using [.Net Reflector][1] along with [ReflectionEmitLanguage][2] plug-in. The RelelectionEmitLanguage plug-in claims to convert your assembly to c# code. [1]: http://www.red-gate.com/products/reflector/ [2]: http://www.codeplex.com/reflectoraddins/Wiki/View.aspx?title=R...
[DotNetNuke][1] is quick to set up and get running. It is the best ASP.NET CMS that I have used. It comes with many modules, and can be extended with numerous commercial and free 3rd party modules. It is very easy to change to look of a DNN site by simply changing the assigned skin, and many 3rd party skins ar...
Currently, you're always returning the result of the `confirm()`, so even if it returns `true`, you'll still stop execution of the event before the postback can fire. Your `onchange` should `return false;` only when the `confirm()` does, too, like this: if (!confirm('Please click OK to change. Otherwise click CA...
The generally excellent [C5 Generic Collection Library][1] has several different tree-based data structures, including sets, bags and dictionaries. Source code is available if you want to study their implementation details. (I have used C5 collections in production code with good results, although I haven't used any of...
How do you place a textbox object over a specific Cell when automating Excel?
|excel|automation|
We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable reports. We can do this if we add textbox objects, and set the print object setting to false. (If you have another way, please direct me) The cod...
Subversion is easy to scale and split up. Perforce costs thousands of dollars for only a handful of employees, way to expensive, and besides, it offers nothing that subversion does not offer. Subversion is really easy, better than cvs. I would have recommended git if only their windows support was better
The question, as posed, seems quite odd to me: I can't see why anyone would want to do that. It is possible that you are misunderstanding just what a "classmethod" is in Python (it's a bit different from, say, a static method in Java). A normal method is more-or-less just a function which takes as its first argument...
I'm not sure if you are asking the correct question here. Are you after a simplified make? In which case, you need to get someone who is very familiar with make to create a series of (M|m)akefiles that will simplify your problem. Or are you wanting to look at the underlying technology? Are we wanting to enforce a...
Writing a solution in VBA would be my first choice, especially if the rules have the possibility of becoming more complex.
well... i wouldn't use an html control if you don't need to do anything on it on the server. i would do <input id='btnCancel' type='button' value='Cancel' /> fin.
I think what you're probably looking for is the Flush function of the RegistryKey class. This is normally not necessary (the registry is lazily-flushed by default), but if the power is turned off on the device before the system has a chance to do this, changes will be discarded: http://msdn.microsoft.com/en-us/libra...
To answer the question specifically for MSSQL, full-text indexing will **NOT** help in your scenario. In order to improve that query you could do one of the following: 1. Configure a full-text catalog on the column and use the CONTAINS() function. 2. If you were primarily searching with a prefix (i.e. matching f...
In my experience, there's very little difference. As Darren said, if you don't need server-side functionality, HTML controls are probably lower-impact. And don't forget, you can bolt server-side functionality onto almost any HTML control just by adding a runat="server" directive and an ID to it.
We used Sun Fire T2000s for my last system. The boxes themselves were far exceeded our capacity requirements in terms of processing power. For us the decision was based on the lower power consumption and space requirement. We successfully ran WebSphere 6, Oracle 10g and SunONE Directory server on the same box.
A workaround is to use an ImageList that is as tall as you want the items to be. Just fill a blank image with the background color. You can even make the image 1 wide so as to not take much space horizontally.
Use a pivot table which will act as a database query on the data you have. Pivot so that the teams go down the columns and scores go across the pivot table. I'm not sure for 2003, but Excel 2007 lets you then sort so the highest scores appear to the left. Then your sum can simply take the first four scores for the e...
Use a pivot table which will act as a database query on the data you have. Pivot so that the teams go down the columns and team members along with their status type go across the pivot table. I'm not sure for 2003, but Excel 2007 lets you then sort so the highest scores appear to the left. Then your first sum can si...
I'm not sure ASCIIEncoding.GetBytes is going to do it, because it only supports the [range 0x0000 to 0x007F][1]. You tell the string contains only bytes. But a .NET string is an array of chars, and 1 char is 2 bytes (because a .NET stores strings as UTF16). So you can either have two situations for storing the byte...
I'm not sure ASCIIEncoding.GetBytes is going to do it, because it only supports the [range 0x0000 to 0x007F][1]. You tell the string contains only bytes. But a .NET string is an array of chars, and 1 char is 2 bytes (because a .NET stores strings as UTF16). So you can either have two situations for storing the byte...
**The Stack** When you call a function the arguments to that function plus some other overhead is put on the stack. Some info (such as where to go on return) is also stored there. When you declare a variable inside your function, that variable is also allocated on the stack. Deallocating the stack is pretty simpl...
**The Stack** When you call a function the arguments to that function plus some other overhead is put on the stack. Some info (such as where to go on return) is also stored there. When you declare a variable inside your function, that variable is also allocated on the stack. Deallocating the stack is pretty simpl...
I think your list is subjective but I will play your game. Flat Files BDB SQLite MySQL PostgreSQL SQL Server Oracle Teradata
You can get conditional compile, but not very nicely - javac will ignore unreachable code. Thus if you structured your code properly, you can get the compiler to ignore parts of your code. To use this properly, you would also need to pass the correct arguments to javac so it doesn't report unreachable code as errors, a...
It's a little primitive, but I've been using tiddlywiki (self-contained, single-file wiki) http://www.tiddlywiki.com/ which works good for basic text and markup. I combine it with a plugin to sync it with Outlook's notes (http://syncoutlooknotes.tiddlyspot.com/#SyncOutlookNotes) so that I can then sync it to my blackbe...
If you think you are going to ever need one of the heavyweights (SqlServer, Oracle), you should start with one of those at the beginning. Data migrations are extremely difficult. In the long run it will cost you less to just start at the top and stay there.
Instead of trying to create the column in code, click on the tiny arrow in a box at the top right of the DataGridView control, and select "Edit Columns..." from the menu that appears. In the dialog box, click the Add button, then choose the "Databound column" option and pick the boolean column you're binding to.
Can you post a code snippet so we can assist you with your code?
Here is a very simple example to show you one of the ways it could be done. $Content = "This is your content`n" Get-ChildItem *.cs | foreach-object { $FileContents = Get-Content -Path $_ Set-Content -Path $_ -Value ($Content + $FileContents) }
Typically, I go with what is commonly accepted by whichever framework I am using. So, if I'm doing .NET => SQL Server, Python (via Django or Pylons) => MySQL or SQLite. I almost never use flat files though.
The built-in RTTI based system for serializing published properties is vulnerable to changes in the components. Going forwards is manageable as long as old properties are kept in new objects. I.e. you leave the property interface as is, but can toss away the contents if you like. Going backwards is worse - as a newer...
This may seem counter-intuitive, but turn edit and continue off. There might be another "allow me to edit read-only files" or "allow me to edit even when I am debugging...no really!" setting somewhere, but I don't have 2005 to look at to check. In 2008, turn off edit and continue and you can edit while it's run...
Memory management in C++
|c++|memory|memory-management|
What are some general tips to make sure I don't leak memory in C++ programs ? How do I figure out who should free memory that has been dynamically allocated ?
I have tried Quantify an AQTime, and Quantify won because of its invaluable 'focus on sub tree' and 'delete sub tree' features.
select id from tbl where date in (select date from tbl group by date having count(*)>1)
Storing the session data in a shared db works, but can be slow. If it's a really big site, [memcache](http://en.wikipedia.org/wiki/Memcached) is probably a better option.
The array operator is associative. A[8] is a synonym for *(A + 8). Since addition is associative, that can be rewritten as *(8 + A), which is a synonym for..... 8[A] You didn't say useful... :-)
A friend of mine found the source code from a university for the camera matching in PhotoSynth. I'd Google around for it, if I were you.
As suggested [here][1]: Get-Content tmp.log | Out-File -Encoding UTF8 new.log [1]: http://stackoverflow.com/questions/64860/best-way-to-convert-text-files-between-character-sets#64937
Every one of these tools provides differing layers of abstraction, along with differing points to override behavior. These are architecture choices, and all architectural choices depend on trade-offs between technology, control, and organization, both of the application itself and the environment where it will be depl...
If you use the settings tab in VS 2005+, you can add strongly typed settings and get intellisense, such as in your first example. string phoneNum = Properties.Settings.Default.EmergencyPhoneNumber; This is physically stored in App.Config. You could still use the config file's appSettings element, or even r...
I don't think that this can be done unless the table is sorted in some way. Most of Excel's lookup functions require ordered lists. This could certainly be done with a VBA function.
IIRC The coolthreads technology is referring to the fact that rather than just ramping up the clock speed ever higher to improve performance they are now looking at multiple core processors with hyperthreading effectively giving you loads of processors on one chip. Overall the processing capacity available is higher bu...
IIRC The coolthreads technology is referring to the fact that rather than just ramping up the clock speed ever higher to improve performance they are now looking at multiple core processors with hyperthreading effectively giving you loads of processors on one chip. Overall the processing capacity available is higher bu...
I've done this before. It wasn't pretty, but it worked, especially since vendor perl's are usually 2-3 years old. I started with making my own perl RPM that installed perl into a different location, like `/opt/`. This was pretty straight forward. I mostly started with this because I didn't want the system utilities ...
Qt concurrent offers an implementation of MapReduce for multicore which is really easy to use. It is multiOS.
Locking into stored procedures seems to be a waning way of thought these days, at least that have been my current observations. That way of thinking does lend itself to the ORM world since they are typically more affective going against tables directly but any ORM worth their salt will also allow the use of procs – som...
> All of them need to be vertically aligned within the div Aligned *how*? Tops of the images aligned with the top of the text? > One of the images needs to be absolute positioned within the div. Absolutely positioned relative to the DIV? Perhaps you could sketch out what you're looking for...? [fd has desc...