instruction
stringlengths
0
30k
I'm not a beginner at C# but I really need to increase my understanding, so I've picked a classic deadlock problem to code to help teach myself some of the more advanced concepts of C#. The [Dining Philosophers Problem][1] seems like a good one, but I need a little help to get started. I know I need to approach the "...
Yes, you can add the `/x` [Pattern Modifier](http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php). > This modifier turns on additional > functionality of PCRE that is > incompatible with Perl. Any backslash > in a pattern that is followed by a > letter that has no special meaning > causes an error,...
In PHP the comment syntax looks like this:<pre>(?# Your comment here)</pre> preg_match(' ^J[0-9]{7}:\s+ (.*?) (?#Extract the Transaction Start Date msg) \s+J[0-9]{7}:\s+Project\sname:\s+ (.*?) (?#Extract the Project Name)...
In PHP the comment syntax looks like this:<pre>(?# Your comment here)</pre> preg_match(' ^J[0-9]{7}:\s+ (.*?) (?#Extract the Transaction Start Date msg) \s+J[0-9]{7}:\s+Project\sname:\s+ (.*?) (?#Extract the Project Name)...
I run XCode on a current-gen Macbook with only ONE GB of RAM and it runs fine, so long as I limit the amount of total applications running.
Answering to the original question: - ASCII is bad : I had to squint to find "WOW". Is this even correct? It could be "VVOVV" or whatever; - Very simple arithmetic is good. Blind people will be able to answer. (But as Jarod said, beware of operator precedence.) I gather someone could write a parser, but it make...
It depends on the size of your development effort. Multiple teams working in parallel won't be able to work effectively all on the same code (trunk). If you have just a small group of people working and your main concern is cutting a branch so you can continue to work while going back to the branch for making bug-fix...
Where do you live that you can get free bear!? Subversion is complicated to set up -- if you have no experience with version control at all, I'd recommend using a distributed VCS because they don't require any server configuration. [Bazaar in five minutes](http://doc.bazaar-vcs.org/bzr.dev/en/mini-tutorial/index.htm...
Eric Sink has an [excellent series][1] on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the [Subversion book][2] is a great resource, and includes a section with examples of a typical session with Subversion (checkout, commit, merging and updating bas...
Eric Sink has an [excellent series][1] on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the [Subversion book][2] is a great resource, and includes a section with examples of a typical session with Subversion (checkout, commit, merging and updating bas...
What I would do for the particular case is: 1. Define the <body> tag in the masterpage as: <body runat="server" id="masterpageBody"> 2. In your content aspx page, register the MasterPage with the register: <% MasterPageFile="..." %> 3. In the Content Page, you can now simply use `MasterPage.FindC...
What I would do for the particular case is: 1. Define the body as a server side control `<body runat="server" id="masterpageBody>` 2. In your content aspx page, register the MasterPage with the register: <% MasterPageFile="..." %> 3. In the Content Page, you can now simply use `MasterPage.FindControl` an...
What I would do for the particular case is: i. Define the body as a server side control `<body runat="server" id="masterpageBody>` ii. In your content aspx page, register the MasterPage with the register: `<% MasterPageFile="..." %>` iii. In the Content Page, you can now simply use `MasterPa...
What I would do for the particular case is: i. Define the body as a server side control <body runat="server" id="masterpageBody"> ii. In your content aspx page, register the MasterPage with the register: <% MasterPageFile="..." %> iii. In the Content Page, you can now simply use ...
Personally I use [MediaWiki][1] for this purpose. I've tried a number of other free and paid wikis (including [Confluence][2]) and have always been impressed with MediaWiki's simplicity and ease of use. I have MediaWiki installed on a thumb drive (using [XAMPP][3] from [PortableApps][4]), which I use mostly as a ...
I am not aware of any plugin that does it natively, especially since Mono users seem to prefer [MonoDevelop][1]. However, it should be possible to use Cygwin and a custom MSBuild Task or Batch file in order to achieve that by using the native .deb creation tools. [1]: http://www.monodevelop.com/Main_Page
[Resharper][1] does this with the Ctrl-N keyword. Unfortunately it doesn't come for free. Visual Studio doesn't have anything like this feature beyond Find. [1]: http://www.jetbrains.com/resharper/
I think the "wisdom of crowds" work here. How did most people learn how to program? Many claim that they did so by copying programs of others, usually games they wanted to play in BASIC. Maybe that route will work with him too?
Answering the original question: - ASCII is bad : I had to squint to find "WOW". Is this even correct? It could be "VVOVV" or whatever; - Very simple arithmetic is good. Blind people will be able to answer. (But as Jarod said, beware of operator precedence.) I gather someone could write a parser, but it makes t...
OK, here's a solution: preg_match( '/(?x)^J[0-9]{7}:\s+ (.*?) #Extract the Transaction Start Date msg \s+J[0-9]{7}:\s+Project\sname:\s+ (.*?) #Extract the Project Name \s+J[0-9]{7}:\s+...
OK, here's a solution: preg_match( '/(?x)^J[0-9]{7}:\s+ (.*?) #Extract the Transaction Start Date msg \s+J[0-9]{7}:\s+Project\sname:\s+ (.*?) #Extract the Project Name \s+J[0-9]{7}:\s+...
What is the best architecture to bridge to XMPP?
|architecture|xmpp|bridge|
If I have a separate system with its own concept of users and presence, what is the most appropriate architecture for creating a bridge to an XMPP server network? As far as I can tell there are three primary ways: 1. Act as a server. This creates one touchpoint, but I fear it has implications for compatibility, an...
While nifty, the revision keyword trick only updates the file when it's changed in that revision - if you don't change the file, then it will continue to reflect the old revision. If you want the software to always reflect the overall revision number, then you'll have to delve into the [relevant SVN entries file][1]...
You could add the DB2 database as a linked server in sql server and just join the two tables in a view/sproc in sql. I've done it, it's not hard and you'll get data in realtime.
Another benefit of storing the images in the file system is that you don't have to do anything special to have the client cache them... ...unless of course the image isn't accessible via the document root (e.g. authentication barrier), in which case you'll need to check the cache-control headers your code is sending...
http://blog.clickablebliss.com/2006/04/26/introduction-to-subversion-screencast/ explains how to use SVN very well.
The solution really depends on what your needs are, and can be pretty complex (Thanks fully to Windows Vista). This is probably going to be beyond your need, but this will help others that find this page via search. 1. If you do not need the process to run with a GUI and you do not require elevation 2. If the ...
The best explanation of how the garbage collector works is in Jeff Richters [CLR via C#][1] book, (Ch. 20). Reading this gives a great grounding for understanding how objects persist. One of the most common causes of rooting objects accidentally is by hooking up events outisde a class. If you hook up an external e...
The MAC address is as unique as a serial number printed on a manual/sticker. Microsoft does hashing to prevent MAC address spoofing, and to allow a bit more privacy. With the only MAC approach, you can easily match a device to a customer by only being in the same subnet. The hash prevents that, by being opaque t...
The following adds -1 years to the current date: SELECT ... From ... WHERE date > DATEADD(year,-1,GETDATE())
This [MSDN article][1] has some example Date strings that are parse-able is that what you're looking for? string dateString = "5/1/2008 8:30:52 AM"; DateTime date1 = DateTime.Parse(dateString, CultureInfo.InvariantCulture); [1]: http://msdn.microsoft.com/en-us/library/ey1cdcx8.aspx
Look up dateadd in BOL dateadd(yy,-1,getdate())
Stripes is a great framework. We converted a major project from a home grown framework to stripes and it took less than one week. The book referenced above is a great resources, as is the mailing list. There's also an active irc channel \#stripes on freenode. It's a very powerful framework that doesn't get in yo...
Original form (The Right Hungarian Notation :) ) where prefix means type (i.e. length, quantity) of value stored by variable is OK, but not necessary in all type of applications. The popular form (The Wrong Hungarian Notation) where prefix means type (String, int) is useless in most of modern programming languages. ...
Ethernet MAC address as activation code for an appliance?
|ethernet|drm|activation|licensing|
This is much more concise: where datediff(day, date1, date2) = 0
In our scenario, we have a separate file server that both of our front end app servers write to, that way you either server has access to the same sets of files.
While the question touches on a couple of very debatable issues (OOP, User authentication) I'll skip by those and second Konrad's comment about __autoload. Anyone who knows C/C++ knows how much of a pain including files can be. With autoload, a PHP5 addition, if you choose to use OOP (which I do almost exclusively) y...
How will the user upload the photos? If you are writing an ASP page to accept the uploaded files then only the user that IIS runs as will need write permission to the folder, since IIS will be doing the file I/O. Your ASP page should check the file size and have some form of authentication to prevent hackers from filli...
The best solution for this is usually to provide the shared area on some form of SAN, which will be accessible from all servers and contain failover. This also has the benefit that you don't have to provide sticky load balancing, the upload can be handled by one server, and the edit by another.
ASP.NET Tutorials
|asp.net|asp.net-mvc|
can you recommend some good ASP.NET tutorials or a good book? Should I jump right to ASP.NET MVC/html/javascript or learn web forms first? Thanks
this will remove time component from a date for you: select dateadd(d, datediff(d, 0, current_timestamp), 0)
It can be done without RegExp as function IsNumeric(data){ return parseFloat(data)==data; }
MVC www.asp.net/mvc great videos Asp.net www.asp.net
Virtual Mac?
|macos|iphone|virtualization|
I’m thinking about trying some development for the iPhone, is it possible to install Leopard inside VMWare? I already have a pretty high spec PC with a comfy setup that I’d like to use, or do I need to buy a real Mac?
Legally, you need to buy a Mac. It is "possible" to run (at least Tiger) in VMWare -- the experience is not optimal, but you can do it. It's also possible to run OS X on PC hardware; however, it's an exercise in illegal software and hacks.
If you're going to use ASP.NET MVC, then go straight to it. But it's a fairly new technology, not even in beta yet, so have that in mind. However, the application model is totally different compared to ASP.NET, so it is not in fact a replacement. For tutorials, you can surely check out <http://www.asp.net> and <http://...
How can I reformat XAML efficiently?
|.net|wpf|formatting|xaml|
Visual Studio 2008's XAML editor (SP1) cannot reformat the XML into a consistent style. Which tools can I use to get a nicely formatted XAML file? Studio integration preferred.
How can I reformat XAML nicely in VS 2008?
How does google make make those awesome PDF reports in Analytics and when you print a Google Doc etc?
|pdf|google|pdf-generation|
When you print from Google Docs (using the "print" link, not File/Print) you end up printing a nicely formated PDF file instead of relying on the print engine of the browser. Same is true for some of the reports in Google Analytics . . . the printed reports as PDF's are beautiful. How do they do that? I can't imag...
You should be using `IllegalArgumentException` (IAE), not `NullPointerException` (NPE) for the following reasons: First, the [NPE JavaDoc][1] explicitly lists the cases where NPE is appropriate. Notice that all of them are thrown <i>by the runtime</i> when `null` is used inappropriately. In contrast, the [IAE Java...
iTextSharp and iText are opensource and free PDF generation libraries for .NET and Java respectively. I've used them to generate report PDF's before and was quite happy with the results. http://itextsharp.sourceforge.net/ http://www.lowagie.com/iText/
I used to do that with FTP on windows (create a file of commands and shell out FTP.exe) Xetius I tried to upvote yours and accept your answer too and I received an warning that I needed 25 rep to do that. Sorry.
Well, one way is to compile it as x64 with VS2008 This runs as you would expect: int normalInt = 5; unsigned long long int num=285212672l; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); return 0; Outp...
Well, one way is to compile it as x64 with VS2008 This runs as you would expect: int normalInt = 5; unsigned long long int num=285212672l; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); For 32 bit code...
Well, one way is to compile it as x64 with VS2008 This runs as you would expect: int normalInt = 5; unsigned long long int num=2852126721; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); For 32 bit code...
Well, one way is to compile it as x64 with VS2008 This runs as you would expect: int normalInt = 5; unsigned long long int num=285212672; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); For 32 bit code,...
SQL Server 2008 has a new *date* datetype and this simplifies this problem to: SELECT CAST(CAST(GETDATE() AS date) AS datetime)
im not sure there's any other way than: > $result = [ $result ] if ref($result) ne 'ARRAY'; > foreach .....
If you want to teach the basics of programming, without being language specific, there is an application called [Scratch][1] that was created in MIT. It's designed to help people develop programming skills. As users create Scratch projects, they learn to create conditions, loops, etc. There is a also a community of sc...
Let's suppose you deploy a network-attached appliances (small form factor PCs) in the field. You want to allow these to call home after being powered on, then be identified and activated by end users. Our current plan involves the user entering the MAC address into an activation page on our web site. Later our softw...
|licensing|drm|activation|ethernet|
Let's suppose you deploy a network-attached appliances (small form factor PCs) in the field. You want to allow these to call home after being powered on, then be identified and activated by end users. Our current plan involves the user entering the MAC address into an activation page on our web site. Later our softw...
In addition to the other answers: The C++ language actually has the `auto` keyword to explicitly declare the storage class of an object. Of course, it's completely needless because this is the implied storage class for local variables and cannot be used anywhere. The opposite of `auto` is `static` (both locally and ...
WPF setting a MenuItem.Icon in code
|wpf|
I have an images folder with a png in it. I would like to set a MenuItem's icon to that png. How do I write this in procedural code?
I used to get these all the time on Apache1/fastcgi. I think it's caused by fastcgi hanging up before Ruby is done. Switching to mongrel is a good first step, but there's more to do. It's a bad idea to cull from web services on live pages, particularly from Rails. Rails is not thread-safe. The number of concurrent ...
Chris, They're different beasts. WHS backup is pretty much automatic and uses deltas - Vista's is manual and I don't believe offers incremental updates. While your solution (Vista + network copy) would preserve your data it has two problems I an see; 1. Your documents will only have the latest revision. If y...
"Multi-agent computing" in simple terms
|multi-agent|
I've encountered the term "multi-agent computing" as of late, and I don't quite get what it is. I've read a book about it, but that didn't answer the fundamental question of what an agent was. Does someone out there have a pointer to some reference which is clear and concise and answers the question without a load o...
On a two-column page, how can I grow the left div to the same height of the right div using CSS or Javascript?
|javascript|html|css|
I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one. My right div typically has a lot of content. Here's is a paired down example of my template to illustrate the problem. <div style="float:left; width...
I am not sure what you are looking for this application to accomplish. If it is just to try some code without having to create a project and all the overhead to just test an idea, then [SnippetCompiler][1] could be a good fit. I just wanted to give you another option. [1]: http://www.sliver.com/dotnet/Snippe...
Have you tried CTRL K, D?
The shunting yard algorithm is the right tool for this. Wikipedia is really confusing about this, but basically the algorithm works like this: Say, you want to evaluate 1 + 2 * 3 + 4. Intuitively, you "know" you have to do the 2 * 3 first, but how do you get this result? The key is to realize that when you're scanni...
How do you determine how far to normalize a database?
|database-design|language-agnostic|
When creating a database structure, what are good guidelines to follow or good ways to determine how far a database should be normalized? Should you create an un-normalized database and split it apart as the project progresses? Should you create it fully normalized and combine tables as needed for performance?
|language-agnostic|database-design|normalizing|
Make a Java Swing application. That will not require Internet and it runs on Mac, Windows, and Linux. You can write to the file system for the lock. [System.getProperty("user.home")][1] gives you the home equivalent for the platform. You might have to include a jre in your CD. [1]: http://java.sun.com/j2se/1.4.2/d...
When you do crontab -e, try this: 59 23 * * * /usr/sbin/myscript > /dev/null That means: At 59 Minutes and 23 Hours on every day (*) on every month on every weekday, execute myscript. See **man crontab** for some more info and examples.
I used to teach programming and your brother has one main advantage over most of my students he wants to learn :) If you decide to go with C [a friend has a site][1] that has the sort of programs those of use from older generations remember as basic type-ins. The more complex of them use ncurses which sort of negat...
I used to teach programming and your brother has one main advantage over most of my students he wants to learn :) If you decide to go with C [a friend has a site][1] that has the sort of programs those of use from older generations remember as basic type-ins. The more complex of them use ncurses which sort of negat...
'Best' Diff Algorithm
|vb.net|diff|
I need to implement a Diff algorithm in VB.NET to find the changes between two different versions of a piece of text. I've had a scout around the web and have found a couple of different algorithms. Does anybody here know of a 'best' algorithm that I could implement? Thanks, - Chris