instruction
stringlengths
0
30k
Use [Robocopy (Robust File Copy)][1]. [1]: http://en.wikipedia.org/wiki/Robocopy
Use [Robocopy (Robust File Copy)][1]. NOTE: In Windows Vista and Server 2008 when you type: xcopy /? you get: > NOTE: Xcopy is now deprecated, please use Robocopy. So start getting used to robocopy :) [1]: http://en.wikipedia.org/wiki/Robocopy
I agree with John Downey. Personally, I sometimes use a flagged enumeration of permissions. This way you can use AND, OR, NOT and XOR bitwise operations on the enumeration's items. "[Flags] public enum Permission { VIEWUSERS = 1, // 2^0 // 0000 0001 EDITUSERS = 2, // 2^1 // 0000 00...
As far as I can tell Python, up through 2.5, only supports hexadecimal & octal literals. I did find some discussions about adding binary to future versions but nothing definite.
In addition to John Downey and jdecuyper's solutions, I've also added an "Explicit Deny" bit at the end/beginning of the bitfield, so that you can perform additive permissions by group, role membership, and then subtract permissions based upon explicit deny entries, much like NTFS works, permission-wise.
No, it can't. AIR only allows one running instance of any app with the same ID defined in the app.xml file. <application xmlns="http://ns.adobe.com/air/application/1.0"> <id>ApplicationID</id> To work around this you'll either have to create individually ID'd apps for each stream, or create a master app w...
Default arguments are part of C++, but as of C# 3.5 default arguments are still not supported-- you'll have to overload. They've been available in VB.Net since 1.0.
Yes. Or currying. Or abstracting into a class and using default values there.
Last time I checked, an AIR app can only run a single instance. You could open multiple windows, but your app itself would have to support that. I hope they change this soon.
No, AFAIK C# does not support overriding, and yes, that is the recommended way of accomplishing the same effect.
If you set the UpdateMode property to Conditional (default is Always) on both UpdatePanels it should stop the outer UpdatePanel triggering when only the usercontrols updatepanel should have refreshed.
After a bit more searching I decided to let the compiler do the hard work. Get the compiler to produce a [Register Transfer Language (RTL)](http://en.wikipedia.org/wiki/Register_Transfer_Language#RTL_in_GCC) file using the -dr options of gcc. The produced RTL file has the suffix .rtl or .expand. This file is f...
Try [this][1] and [this][2]. The first is a KB article that might have some relavence and the second is a blog post that might give you some insight. Good luck. [1]: http://support.microsoft.com/kb/822668 [2]: http://bisqlserver.blogspot.com/2007/02/issues-transferring-data-back-and-forth.html
I saw one pattern recently called Correct State Bag Access Pattern, which seemed to touch on this. [http://weblogs.asp.net/craigshoemaker/archive/2008/08/28/asp-net-caching-and-performance.aspx][1] public List List() { string cacheKey = "customers"; List myList = Cache[cacheKey] as List; ...
I would use the built in Func delegates instead. Also I took out the parameters on transform. You can pass args via your function pointer. Your code would turn into: public static R Reduce<T,R>(this List<T> list, Func<T,R> r, R initial) { var aggregate = initial; foreach(var t in list) aggregate = ...
I would use the built in Func delegates instead. This same code would work on any IEnumerable<T>. Your code would turn into: public static R Reduce<T,R>(this IEnumerable<T> list, Func<T,R> r, R initial) { var aggregate = initial; foreach(var t in list) aggregate = r(t,aggregate); return aggre...
I was hoping someone could help me out with a problem I'm having using the java search function in Eclipse on a particular project. When using the java search on one particular project, I get an error message saying 'Class file name must end with .class' (see stack trace below). This does not seem to be happening on...
Compressing a TIF file
|c#|tiff|
I'm trying to convert a multipage color tif file to a c# CompressionCCITT3 tif in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online. thanks.
You didn't mention what database you are using, but in SQL Server 2008, you can use table variables to pass complex data like this to a stored procedure. Parse it there and perform your operations. For more info, see Scott Allen's article on [ode to code][1]. [1]: http://www.odetocode.com/articles/365.aspx
I would assume that the browser has some issue with the script attempting to set the value of a password field: button.value = password; This line of code has no real purpose. `password.value` is not affected in the previous lines where you are reading the value and using it in the `alert()`. This should b...
I would assume that the browser has some issue with the script attempting to set the value of a password field: button.value = password; This line of code has no real purpose. `password.value` is not affected in the previous lines where you are reading the value and using it in the `alert()`. This should b...
From a "business entity" design standpoint, if you are doing different operations on each of a set of entities, you should have each entity handle its own persistence. If there are common batch activities (like "delete all older than x date", for instance), I would write a static method on a collection class that ex...
Suggestions for schema designs/data models for different businesses: David C. Hay: Data Model Patterns: Conventions of Thought Rather old, but there is a reason why it's still in print <br />[http://www.dorsethouse.com/books/dmp.html][1] Maybe not very pattern-like, but still very good: Stephane Faroult, Peter R...
The | operator performs a bitwise OR of its two operands (meaning both sides must evaluate to false for it to return false) while the || operator will only evaluate the second operator if it needs to. [http://msdn.microsoft.com/en-us/library/kxszd0kx(VS.71).aspx][1] [http://msdn.microsoft.com/en-us/library/6373h3...
The singe pipe "|" is the "bitwise" or and should only be used when you know what you're doing. The double pipe "||" is a logical or, and can be used in logical statements, like "x == 0 || x == 1". Here's an example of what the bitwise or does: if a=0101 and b=0011, then a|b=0111. If you're dealing with a logic syst...
|| is the logical OR operator. It sounds like you basically know what that is. It's used in conditional statements such as if, while, etc. condition1 || condition2 Evaluates to true if either condition1 OR condition2 is true. | is the bitwise OR operator. Its used to operate on two numbers. You look at eac...
Just like the & and && operator, the double Operator is a "short-circuit" operator. For example: if(condition1 || condition 2 || condition 3) If condition1 is true, condition 2 and 3 will NOT be checked. if(condition1 | condition 2 | condition 3) This will check conditions 2 and 3, even if 1 is a...
ensuring uploaded files are safe
|security|antivirus|
My boss has come to me and asked how to enure a file uploaded through web page is safe. He wants people to be able to upload pdfs and tiff images (and the like) and his real concern is someone embedding a virus in a pdf that is then viewed/altered (and the virus executed). I just read something on a procedure that cou...
For windows [this][3] is a good introduction and guide Here are some good ssh-agents for systems other than linux. - Windows - [pageant][1] - OS X - [SSHKeychain][2] [1]: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html [2]: http://www.askbjoernhansen.com/2005/01/07/sshkeychain_ssh.html [...
It seems a lot of people get confused by the way objects are passed to functions and what pass by reference means. Object variables are still passed by value, its just the value that is passed in PHP5 is a reference handle. As proof: <?php class Holder { private $value; public function _...
The difference in behaviour with `return` is IMHO the most important difference between the 2. I also prefer lambda because it's less typing than Proc.new :-)
Imagine I am a mock programmer, named... Marco. Imagine I have graduated school not that long ago, and never really had to write tests. Imagine I work in a company that doesn't really enforce or asks for this. OK? good! Now imagine, that the company is switching to using tests, and they are trying to get me inline with...
Imagine I am a mock programmer, named... Marco. Imagine I have graduated school not that long ago, and never really had to write tests. Imagine I work in a company that doesn't really enforce or asks for this. OK? good! Now imagine, that the company is switching to using tests, and they are trying to get me inline with...
I find the tutorial videos at [Windows Client .Net][1] equally awesome. Also [Dot Net Rocks TV][2] has also covered it some time ago. [1]: http://windowsclient.net/learn/videos_wpf.aspx [2]: http://www.dnrtv.com/default.aspx?showNum=101
I find the tutorial videos at [Windows Client .Net][1] equally awesome. [Dot Net Rocks TV][2] has also covered it some time ago. [1]: http://windowsclient.net/learn/videos_wpf.aspx [2]: http://www.dnrtv.com/default.aspx?showNum=101
PHP is also pass by value. <?php class Holder { private $value; public function __construct($value) { $this->value = $value; } public function getValue() { return $this->value; } } function swap($x, $y) { $tmp = ...
In general this is a very subtle issue and note trivial whatsoever. I encourage you to read [mysqlperformanceblog.com][1] and [High Performance MySQL][2]. I really think there is no general answer for this. I'm working on a project which has a MySQL database with almost 1TB of data. The most important scalability fa...
While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your local browscap in order to make use of some ASP.Net features. That was the root cause of some headaches we had for a client's site that used the ASP Menu...
While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your application's browscap in order to make use of some ASP.Net features. That was the root cause of some headaches we had for a client's site that used the ...
I have to agree with the OP 'wrong' dates really jar with my DD/MM/YYYY upbringing and I find ISO 8601 dates and times extremely easy to work with. For once the standard got it right and [engtech][1] has the obvious answer that doesn't require localisation. I was going to report the birthday input form on stack ove...
>>> print int('01010101111',2) 687 >>> print int('11111111',2) 255 Another way.
>>> print int('01010101111',2) 687 >>> print int('11111111',2) 255 Another way. *edit: Apparently the only way. Since the other way doesn't actually work.*
Also watch out for complex joins. Transaction complexity can be a big factor in addition to transaction volume. Refactoring heavy queries sometimes offers a big performance boost.
How do I give my web sites an icon for iPhone?
|html|favicon|iphone|
How do I set the icon that appears on the iPhone for the web sites I create?
|html|iphone|favicon|apple-touch-icon|
|security|antivirus|
My boss has come to me and asked how to enure a file uploaded through web page is safe. He wants people to be able to upload pdfs and tiff images (and the like) and his real concern is someone embedding a virus in a pdf that is then viewed/altered (and the virus executed). I just read something on a procedure that cou...
There isn't a tag for that. You would need to use javascript to show the text. Some people already suggested using JS to dynamically set CSS visible. You could also dynamically generate the text with `document.getElementById(id).innerHTML = "My Content"` or dynamically creating the nodes, but the CSS hack is probab...
You can concisely initialize a `vector<string>` from a statically-created `char*` array: char* strarray[] = {"hey", "sup", "dogg"}; vector<string> strvector(strarray, strarray + 3); This copies all the strings, by the way, so you use twice the memory. You can use Will Dean's suggestion to replace the ma...
The problem is, the process didn't just die, it died unexpectedly. Sounds like there's a bug in your SSH client that Vista is pointing out.
For whom it interests, the [Filesystem Hierarchy Standard (FHS)](http://www.pathname.com/fhs/) is a standards document and still a very good read. I describes the foundation for almost any Linux distribution and is officially endorsed e.g. by [Debian](http://www.debian.org/doc/packaging-manuals/fhs/fhs-2.3.html) and th...
Try adding -l to the nm flags in order to get the source of each symbol. If the library is compiled with debugging info (gcc -g) this should be the source file and line number. As Konrad said, the object file / static library is probably unknown at this point.
Specifically, regarding keys: I strongly disagree with the strange idea that keys must be without meaning. In general, I consider a database a collection of facts; as soon as you start adding arbitrary numbers (like generated keys) and other irrelevant information into it, it should be a warning sign. I recommend [this...
The answer depends on the volume of data you're talking about. If you've got a fairly small set of records in memory that you need to synchronise back to disk then multiple queries is probably appropriate. If it's a larger set of data you need to look at other options. I recently had to implement a mechanism where a...
you could attach to the [pageLoading event of the PageRequestManager class](http://msdn.microsoft.com/en-us/library/bb383832.aspx) and go through the panels updating property and remove the DOM elements in each.
Is it possible to craft a glob that matches files in the current directory and all subdirectoies?
|shell|glob|
For this directory structure: . |-- README.txt |-- firstlevel.rb `-- lib |-- models | |-- foo | | `-- fourthlevel.rb | `-- thirdlevel.rb `-- secondlevel.rb 3 directories, 5 files The glob would match: firstlevel.rb li...
It depends on how many you need to do, and how fast the operations need to run. If it's only a few, then doing them one at a time with whatever mechanism you have for doing single operations will work fine. If you need to do thousands or more, and it needs to run quickly, you should re-use the connection and comman...
If you need really simple PDFs, then Zend or [FPDF][1] is fine. However I find them difficult and frustrating to work with. Also, because of the way the API works, there's no good way to separate content from presentation from business logic. For that reason, I use [dompdf][2], which automatically converts HTML and ...
As already mentioned, NetworkX is very good, with another option being [igraph][1]. Both modules will have most (if not all) the analysis tools you're likely to need, and both libraries are routinely used with large networks. [1]: http://cneurocvs.rmki.kfki.hu/igraph/
Most Python programs will use distutils. <a href="http://www.djangoproject.com">Django</a> is a one - see http://code.djangoproject.com/svn/django/trunk/setup.py You should also read <a href="http://docs.python.org/dist/dist.html">the documentation</a>, as it's very comprehensive and has some good examples.
You can actually configure what you want to be the default gateway globally using the "routes" command as described here: [http://stackoverflow.com/questions/17785/default-internet-connection-on-dual-lan-workstation][1] I admit though, on windows it'd finicky at best as sometimes that setup will just disappear :( ...
There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix? The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile. The disadvantage of this method ...
There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix? The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile. The disadvantage of this method ...
as [abfo says][1], the POP3 protocol is super simple, getting the messages is a no brainer. Parsing the messages to get the failures is harder, and reliably parsing out which email caused the failure and why it failed is really hard. The problem is that bounce messages don't have a standard format, the default forms ...
There is a couple of things todo in order to keep your session secure: 1. Use SSL when authenticating users or performing sensitive operations. 2. Regenerate the session id whenever the security level changes (such as logging in). You can even regenerate the session id every request if you wish. 3. Have session...
Have a code review before every commit (even if it's a 1 minute "I've changed this variable name), and as part of the code review, review any unit tests. Don't sign off on the commit until the tests are in place. (Also - If his work wasn't tested - why was it in a production build in the first place? If it's not ...
Have a code review before every commit (even if it's a 1 minute "I've changed this variable name"), and as part of the code review, review any unit tests. Don't sign off on the commit until the tests are in place. (Also - If his work wasn't tested - why was it in a production build in the first place? If it's not...
Well, if you've designed your application properly, you won't have scads of logic inside the UI anyway. It makes much more sense to separate the actual work getting done into units separate from the UI, and then test those. If you do that, then the only code in the UI will be code that invokes the backend, so simpl...
std::remove doesn't actually erase the element from the container, but it does return the new end iterator which can be passed to container_type::erase to do the REAL removal of the extra elements that are now at the end of the container: std::vector<int> vec; // .. put in some values .. int int_to_rem...
std::remove doesn't actually erase the element from the container, but it does return the new end iterator which can be passed to container_type::erase to do the REAL removal of the extra elements that are now at the end of the container: std::vector<int> vec; // .. put in some values .. int int_to_rem...
Is overloading the only way to have default function arguments in C#?
|c#|overloading|
Is it true that the only way to handle default function arguments is through function overloading? For example, in PHP I can do this: function foo($x, $y=0) { } Would the best way to handle it in C# be this? void foo($x) { foo($x, 0); } void foo($x, $y) { ...
Is it true that the only way to handle default function arguments is through function overloading? For example, in PHP I can do this: function foo($x, $y=0) { } Would the best way to handle it in C# be this? void foo(int x) { foo(x, 0); } void foo(int x, int y) ...
**Windows Mobile** It supports C#, and Visual Studio comes with the mobile SDK. So if you know C# you probably already have the tools you need. And in spite of the iPhone/iPodTouch buzz, the Windows Mobile deployment is still 10X greater.
Is there a qualitative difference between the desired peak and the unwanted second peak? If both peaks are "sharp" -- i.e. short in time duration -- when looking at the signal in the frequency domain (by doing FFTs) you'll get energy at most bands. But if the "good" peak reliably has energy present at frequencies not e...
Is there a qualitative difference between the desired peak and the unwanted second peak? If both peaks are "sharp" -- i.e. short in time duration -- when looking at the signal in the frequency domain (by doing FFT) you'll get energy at most bands. But if the "good" peak reliably has energy present at frequencies not ex...
Use the global method std::remove, documented here. http://www.sgi.com/tech/stl/remove.html std::vector<int> v; v.push_back(1); v.push_back(2); //Vector should contain the elements 1, 2 std::remove(v.begin(), v.end(), 1); //Vector should now only contain 2
Actually I have discovered a good way to run DB migrations from an application: > ActiveRecord::Migrator.migrate("db/migrate/")
The only "right" answer is to be consistent. Decide upfront which one you will be using in a project, and stick to it.
In zsh, `**/*.rb` works
How random? If you can deal with pseudo-random then simply: Random randNum = new Random(); randNum.Next(int Max, int Max); If you want a "better" random number, then you probably should look at the Mersenne Twister algorithm. Plenty of people hav [already implemented it][1] for you though [1]: h...
How random? If you can deal with pseudo-random then simply: Random randNum = new Random(); randNum. NextDouble(Min, Max); If you want a "better" random number, then you probably should look at the Mersenne Twister algorithm. Plenty of people hav [already implemented it][1] for you though [1]: ht...
For very common properties like "Name" and "ID", the convention I have used is to not put the entity name in the field. For more unusual properties, I do put the entity name. This is a naming convention decision, but I have not regretted projects where this is the convention, if you put the name of the entity for e...
we do ID on anything that's the primary key. Saying SubCategory.SubCategoryID seems redundant,
For an explaination of why Longhorn has been downmodded so much: <http://msdn.microsoft.com/en-us/magazine/cc163367.aspx> Look for the implementation of NextDouble and the explanation of what is a random double. That link is also a goo example of how to use cryptographic random numbers (like Sameer mentioned) only w...
Is there a way to generate WMI code/classes?
|c#|code-generation|wmi|
How do you generate C# classes for accessing WMI?
The problem was that the working copy was checked out via svn+ssh (thanks, [Thomas](#38386)). Instead of setting up ssh keys as was suggested, I just checked out a new working copy using svn://domain.com/path/to/repo rather than svn+ssh://domain.com/path/to/repo. Because this working copy is on the same machine as th...
To generate strongly typed WMI classes, use the Management Strongly typed class generator (MgmtClassGen.exe). It's usually in C:\Program Files\Microsoft Visual Studio X\SDK\vX\Bin\. The parameters are [at MSDN][1] and they even have [a page][2] describing the code generated. If you have to do a lot of work with WMI,...
How do I make a GUI?