instruction
stringlengths
0
30k
Are you using the re.match() or re.search() method? My understanding is that re.match() assumes a "^" at the begining of your expression and will only search at the beginning of the text, while re.search() acts more like the Perl regular expressions and will only match the beginning of the text if you include a "^" at ...
C++ Standard [2.1.1.2] declares: > ... If a source file that is not empty does not end in a new-line character, or ends in a new-line character immediately preceded by a backslash character before any such splicing takes place, the behavior is undefined.
If you are using .Net, I would recommend going with one or more resource files (.resx). There is plenty of documentation on this on MSDN.
I can only repeat what others have said. Parametrized SQL is the way to go. Sure, it is a bit of a pain in the butt coding it - but once you have done it once, then it isn't difficult to cut and paste that code, and making the modifications you need. We have a lot of .Net applications that allow web site visitors sp...
Sometimes, the compiler will optimize a field and use a register to store it. If thread 1 does a write to the field and another thread accesses it, since the update was stored in a register (and not memory), the 2nd thread would get stale data. You can think of the volatile keyword as saying to the compiler "I want ...
You need to enable warning 4365 to catch the assignment. That might be tricky - you need to enable ALL warnings - use /Wall which enables lots of warnings, so you may have some trouble seeing the warning occur, but it does.
In Visual Studio add the Width and Height attribute to your UserControl XAML, but in the code-behind insert this public UserControl1() { InitializeComponent(); if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { this.Width = double.NaN; ; this....
Serializing SQL CE data to XML
|.net|xml|.net-2.0|sql-server-ce|
I'm working on a product feature that will allow the user to export data from a SQL CE database on one copy of my application and re-import it into SQL CE on the other end. This data is not whole tables, but the result of queries. I had hoped to take advantage of .net's built-in XML-based serialization like in DataT...
I recommend [A-prompt][1] for testing of Accessibility. It is free and it can really help. I also recommend Mark Pilgrim's online text - [Dive into Accessibility][2]. [1]: http://aprompt.snow.utoronto.ca/ [2]: http://diveintoaccessibility.org/
Well, obviously the law in different countries varies vastly. In the UK, for example, we don't have any specific web-accessibility laws, but no service is allowed to discriminate against someone with a sight or hearing impediment, insofar as it relates to functionality. In light of this, a simplistic way to design ...
It's also worth noting that depending on your need defining your own bean may not be the best bet for you. <util:constant static-field="org.example.Constants.FOO"/> is a good way to access a constant value stored in a class and default binders also work very well for conversions e.g. <bean class="Foo"...
Use <code>[ReferenceEquals][1]</code>. From the [MSDN forums][2]: public static bool operator ==(Foo foo1, Foo foo2) { if (ReferenceEquals(foo1, null)) return ReferenceEquals(foo2, null); if (ReferenceEquals(foo2, null)) return false; return foo1.field1 == foo2.field2; } [1...
Here's how to do this. I ended up finding reference to a sproc in the MSDN docs. I pulled this from the sproc and wrapped it in a loop of all the databases known to the instance. select DbRole = g.name, MemberName = u.name from @NAME.sys.database_principals u, @NAME.sys.database_principals g, @NAME.sys....
It usually does this by default for you, but if it isn't you need to look into file properties and propset. Frank Wiles, Revolution Systems, <a href="http://www.revsys.com">www.revsys.com</a>
fix line endings in vi: `:set fileformat=unix` `:w`
From page 367 of the [Subversion book][1] > In the most general sense, Subversion handles binary files more gracefully than CVS does. Because CVS uses RCS, it can only store successive full copies of a changing binary file. Subversion, however, expresses differences between files using a binary differencing algori...
With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007). One of the main issues with testing forms is that only a few controls have a hwnd handle and other controls only get one they have foc...
You can't modify existing XML tree. You can create new tree from existing xml tree. If you include mentioned element in the new tree it will be in the same namespace
If you include mentioned element in the new xml tree it will be in the same namespace. var xml1 = XElement.Parse("<a xmlns:foo=\"abc\"><foo:b></foo:b></a>"); var xml2 = XElement.Parse("<a xmlns:boo=\"efg\"></a>"); XNamespace ns = "abc"; var elem = xml1.Element(ns + "b"); elem.Remove(); x...
This is one of those perfectly reasonable, simple things that CSS can't do. Faux Columns, as suggested by Silviu, is a hacky but functional workaround. It would be lovely if someday there was a way to say <pre> div.foo { height: $(div.blah.height); } </pre>
I would design the application to have as much work as possible done in queries and in vba subroutines so that your testing could be made up of populating test databases, running sets of the production queries and vba against those databases and then looking at the output and comparing to make sure the output is good. ...
I have not tried this, but you could attempt to [publish your access forms as data access web pages to something like sharepoint][1] or [just as web pages][2] and then use an tool such as [selenium][3] to drive the browser with a suite of tests. [1]: http://office.microsoft.com/en-us/access/HA101314691033.aspx ...
I am not a Ruby programmer but I have been pretty tightly involved in a JRuby deployment lately and can thus draw some conclusions. Do not expect to much from JRuby's performance. In interpreted mode, it seems to be somewhere in the range of C Ruby. JIT mode *might* be faster, but only in theory. In practice, we tried ...
Eclipse is by-far the best I've used. Couple JUnit with a [code coverage](http://www.eclemma.org/) plug-in and Eclipse will probably be the best unit-tester.
I just submitted a solution [over here][1] that also applies to this question. Basically, I just keep a single list (a stack really) of visited nodes. Add a node to the list just before recursing or saving a solution. Always remove from the list directly after. [1]: http://stackoverflow.com/questions/58306/gr...
You can't, you need to go back to the drawing board and re-engineer your solution.
The Alt attribute is to be used as an alternative to the image, in the case of the image missing, or in a text only browser. IE got it wrong, when they made alt appear as a tooltip. It was never meant to be that. The correct attribute for this is title, which of course doesn't do a tooltip in IE. So, to do hav...
How about: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING COUNT(*) > 1; To answer the example above, it would look like: SELECT job_number, count(*) FROM jobs GROUP BY job_number HAVING COUNT(*) > 1;
In C# 3.0 you can use LINQ to accomplish this easily: <pre><code>int[] front = { 1, 2, 3, 4 }; int[] back = { 5, 6, 7, 8 }; int[] combined = front.Concat(back).ToArray();</code></pre> In C# 2.0 you don't have such a direct way, but Array.Copy is probably the best solution: <pre><code>int[] front = { 1, 2, 3,...
Can you explain why TortoiseSVN doesn't work for you? That would help us figure out what you really need in an application. Combine TortoiseSVN with Windows Explorer and you've got a great tool, and then pickup VisualSVN if you want something to integrate with Visual Studio.
There is an old saying about programmers pretending to be cryptographers :) Jeff Atwood has a good post on the subject: [You're Probably Storing Passwords Incorrectly][1] To reply more extensively, I agree with all of the above, the hash makes it easier *in theory* to get the user's password since multiple passwo...
HTML.Button in ASP.NET MVC
|html|asp.net-mvc|
Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are no longer supported. The question is, what is the equivalent for them? I've an app that was built using Preview 2, now I have to make it compatible with the latest CTP releases.
Using Lock pages in memory without being Administrator on Windows Vista and 2008 Server
|windows|
The following question answers how you get large memory pages on Windows "[how do i run my app with large pages in windows][1]". The problem I'm trying to solve is how do I configure it on Vista and 2008 Server. Normally you just allow a specific user to lock pages in memory and you are done. However on Vista and...
You might be better off going to #mplayer or #ffmpeg on Freenode IRC for specific help with those programs.
How to use form values from an unbound form
|python|django|
I have a web report that uses a Django form (new forms) for fields that control the query used to generate the report (start date, end date, ...). The issue I'm having is that the page should work using the form's initial values (unbound), but I can't access the cleaned_data field unless I call is_valid(). But is_valid...
What are the key components of web accessibility?
|accessibility|
I understand that some countries have laws regarding website accessibility. In general, what are the minimum requirements that a website must meet to be accessible, regardless of country?
|sql-server|version-control|build-automation|starteam|
I'm looking for some "Best Practices" for automating the deployment of Stored Procedures/Views/Functions/Table changes from source control. I'm using StarTeam & ANT so the labeling is taken care of; what I am looking for is how some of you have approached automating the pull of these objects from source - not necessari...
You can surround the textbox with a `<div>` and give that `<div>` `padding: 0 20px`. Your problem is that the 100% width does not include any padding or margin values; these values are added on top of the 100% width, thus the overflow.
GridView will not update underlying data source
|asp.net|linq-to-sql|data-binding|
So I'm been pounding on this problem all day. I've got a LinqDataSource that points to my model and a GridView that consumes it. When I attempt to do an update on the GridView, it does not update the underlying data source. I thought it might have to do with the LinqDataSource, so I added a SqlDataSource and the same t...
Then what's the point in the Bind method (as opposed to the Eval method) if I have to bind everything back up manually on postback?
There is a [limit of 10 inbound connections][1] on XP professional, and 5 on XP Home. So it would only be practicable for a very small company. [1]: http://support.microsoft.com/default.aspx?kbid=314882
I prefer to separate views, procedures, and triggers (objects that can be re-created at will) from tables. For views, procedures, and triggers, just write a job that will check them out and re-create the latest. For tables, I prefer to have a database version table with one row. Use that table to determine what ne...
MS-Access design pattern for last value for a grouping
|ms-access|
It's common to have a table where for example the the fields are account, value, and time. What's the best design pattern for retrieving the last value for each account? Unfortunately the last keyword in a grouping gives you the last physical record in the database, not the last record by any sorting. Which means IM...
Standard way to merge Entities in LlblGenPro
|c#|orm|llblgenpro|
I start with an entity A with primary key A1, it has child collections B and C, but they are empty, because I haven't prefetched them. I now get a new occurrence of A (A prime) with primary key A1 with the child collections B and C filled. What is a good way to get the A and A prime to be the same object and to get...
In pseudo code: reverse input string reverse each word (you will need to find word boundaries)
Mark - I would like to be able to easily synchronize two database schemas. Specifically, [this demo][1] looks like heaven to me. [1]: http://www.red-gate.com/products/SQL_Compare/video_sql_compare_standard_compare_synchronize.htm
Solution found! With the introduction of the ActionNameAttribute, it's now necessary to filter manually which method to call depending on the request. This is done by the ActionSelectionAttribute. Full explanation here: [http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx][1] [1]: htt...
Push each word onto a stack. Pop all the words off the stack.
How can I break on exception using ddbg
|d|
I'm using the d programing language to write a program, and I'm trying to use ddbg to debug it. When there is an exception, I want to have the program break whenever there is an exception thrown so that I can inspect the stack. Alternatively, is there another debugger that works with d? Is there another way to get...
<a href="http://selenium-grid.openqa.org/">Selenium Grid</a> can run your web tests across multiple machines in parallel, which can speed up the web testing process
In C: (C99) #include <stdio.h> #include <string.h> void reverseString(char* string, int length) { char swap; for (int i = 0; i < length/2; i++) { swap = string[length - 1 - i]; string[length - 1 - i] = string[i]; string[i] = swap; } } ...
If using tortoise svn in Windows, right click on the file and go to properties. Click on new and add a new property of type svn:mime-type. For the value put: application/octet-stream
I am looking into Codesite as well. I built my own in the past but I really like the featrues in Codesite. The Raize componenets are very well written and always quality stuff.
Also look for ptkdb on CPAN: http://search.cpan.org/search?query=ptkdb&mode=all
The [Domain Driven Design Yahoo Group][1] may be a better place to find an answer to your question. [1]: http://tech.groups.yahoo.com/group/domaindrivendesign/
I think you'd be surprised how reasonably priced online storage is these days. Amazon S3 (simple storage solution) is $0.10 per gigabyte per month, with upload costs of $0.10 per GB and download costing $0.17 per GB maximum. Therefore, if you stored 20GB for a month, uploaded 20GB and downloaded 20GB it would cost y...
You could use Javascript to traverse and pass the DOM than make a call into your WCF service from the Javascript when all the Ajax calls are complete. If you are after the data that is stored on the page after all the Ajax calls I would re-think your implementation... Petar
We're I'm working right now, we're using Maven 2 and we have a pretty nice archetype for our projects. The goal was to obtain a good separation of concerns, thus we defined a project structure using multiple modules (one for each application 'layer'): - common: common code used by the other layers (e.g., i18n) - ...
In perl you could do something like this, leaving out all the my local variable declarations and ... or die "failmessage" error handling for brevity. use DBI; use DBD::Oracle; $dbh = DBI->connect( "dbi:Oracle:host=127.0.0.1;sid=XE", "username", "password" ); # some settings that you usual...
I believe theoretically you are unable to do such a thing while being behind a router (e.g. using invalid ip ranges) without using an external "help".
Write your own, tailored to your needs. For instance, if all your exponents are of the power of two, you can use bit-shifting. If you work with a limited range or set of values, you can use look-up tables. If you don't need pin-point precision, you use an imprecise, but faster, algorithm.
Unless executiontime is really important, I would consider refactoring the business logic that (so often) tends to find its way down to the datalayer and into gazillion-long stored procs. In terms of maintainabillity, editabillity and appendabillity I always try to (as the C# programmer I am) lift code up to the busine...
How to get name associated with open HANDLE
|windows|c|winapi|
What's the easiest way to get the filename associated with an open HANDLE in Win32?
|windows|python|c|winapi|
|windows|c|winapi|
You may want to use a schema where the message body and attachment records can be shared between multiple recipients on the message. It's not uncommon to see email servers where fully 50% of the disk storage is used by duplicate emails. A simple hash of the body/attachment would be enough to see if that record was ...
Try specifying both a wrapper and a label container in your options. I also added display:none; to the style of error-container to let jquery decide when to show it. Html: <div class="error-container"> <ul> </ul> </div> <form id="CreateLog" action="Create" method="post" /> <label>U...
[TortoiseSVN][1] is the best standalone system. It integrates itself into Windows Explorer so it works extremely well and gives you the full power of SVN. [Ankhsvn][2] is a good solution that integrates into Visual Studios (Except Express Editions). [SVN Notifier][3] monitors your repositories and will notify yo...
For total stand alone [Synchro SVN][1] is a powerful and cross platform solutions. [TortoiseSVN][2] is the best general use system [An integrated system is not standalone - Thanks Martin Kenny]. It integrates itself into Windows Explorer (You can use it in explorer or any shell dialog) so it works extremely well an...
**Standalone Clients** For total stand alone [Synchro SVN][1] is a powerful and cross platform solution. It looks like the most native application on each of the platforms. The [Subversion website][2] includes a listing of other **standalone SVN Clients** (most are cross platform). [Copied list below from http:...
O(N) in space and O(N) in time solution in Python: def reverse_words_nosplit(str_): """ >>> f = reverse_words_nosplit >>> f("this is a string") 'string a is this' """ iend = len(str_) s = "" while True: ispace = str_.rfind(" ", 0, iend) if...
I'd second the recommendation of the use of Passenger - it makes deployment and management of Rails applications trivial
I avoid it since a coworker/manager will undoubtedly question its use either in a code review or when they stumble across it. While I think it has uses (the error handling example for example) - you'll run afoul of some other developer who will have some type of problem with it. It’s not worth it.
I avoid it since a coworker/manager will undoubtedly question its use either in a code review or when they stumble across it. While I think it has uses (the error handling case for example) - you'll run afoul of some other developer who will have some type of problem with it. It’s not worth it.
The slugs make the URL more user-friendly and you know what to expect when you click a link. Search engines such as Google, rank the pages higher if the searchword is in the URL.
Usability is one reason, if you receive that link in your e-mail, you know what to expect. SEO (search engine optimization) is another reason. Search engines such as google will rank your page higher for the keywords contained in the url
I mostly use [CubicTest][1], which is an eclipse plugin that lets you define tests graphically. It can export/run tests through several libraries, including watir and selenium. Most people just use the Selenium runner though. Full disclosure: I'm one of the developers, so I'm kind of biased :) Take a closer look ...
The subquery option sounds best to me, something like the following psuedo-sql. It may be possible/necessary to optimize it via a join, that will depend on the capabilities of the SQL engine. select * from table where account+time in (select account+max(time) from table ...
Would you recommend using "The C5 Generic Collection Library for C# and CLI" based on your experience with it ?