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 0010 VIEWPRODUCTS = 4, // 2^2 // 0000 0100 EDITPRODUCTS = 8, // 2^3 // 0000 1000 VIEWCLIENTS = 16, // 2^4 // 0001 0000 EDITCLIENTS = 32, // 2^5 // 0010 0000 DELETECLIENTS = 64, // 2^6 // 0100 0000 }" Then, you can combine several permissions using the AND bitwise operator. <br /><br /> For example, if a user can view & edit users, the binary result of the operation is 0000 0011 which converted to decimal is 3. <br /> You can then store the permission of one user into a single column of your DataBase (in our case it would be 3).<br /><br /> Inside your application, you just need another bitwise operation (OR) to verify if a user has a particular permission or not.
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 with child windows for each stream.
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 far easier to parse as the functions calls are already identified.
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; if(myList == null) { myList = DAL.ListCustomers(); Cache.Insert(cacheKey, mList, null, SiteConfig.CacheDuration, TimeSpan.Zero); } return myList; } [1]: http://weblogs.asp.net/craigshoemaker/archive/2008/08/28/asp-net-caching-and-performance.aspx
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 = r(t,aggregate); return aggregate; } public static void Transform<T>(this List<T> list, Func<T> f) { foreach(var t in list) f(t,args); }
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 aggregate; } public static void Transform<T>(this IEnumerable<T> list, Func<T> f) { foreach(var t in list) f(t); }
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 all projects, just one particular one, so perhaps there's something I should try to get rebuilt? I have already tried Project -> Clean... and Closing Eclipse, deleting all the built class files and restarting Eclipse to no avail. The only reference I've been able to find on Google for the problem is at [http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx][1], but unfortunately his solution (closing, deleting class files, restarting) did not work for me. If anyone can suggest something to try, or there's any more info I can gather which might help track it's down, I'd greatly appreciate the pointers. Version: 3.4.0 Build id: I20080617-2000 Also just found this thread - [http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html][2] - which indicates the same problem may occur when the project name contains a period. Unfortunately, that's not the case in my setup, so I'm still stuck. Caused by: java.lang.IllegalArgumentException: Class file name must end with .class at org.eclipse.jdt.internal.core.PackageFragment.getClassFile(PackageFragment.java:182) at org.eclipse.jdt.internal.core.util.HandleFactory.createOpenable(HandleFactory.java:109) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1177) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:223) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:506) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:551) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.internalSearch(RefactoringSearchEngine.java:142) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:129) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.initializeReferences(RenameTypeProcessor.java:594) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.doCheckFinalConditions(RenameTypeProcessor.java:522) at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:45) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225) at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:160) at org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$Operation.run(RefactoringExecutionHelper.java:77) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4650) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:92) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Thanks [McDowell][3], closing and opening the project seems to have fixed it (at least for now). [1]: http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx [2]: http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html [3]: #6840
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 be a simpler version of your code: function toggleShowPassword() { var button = $get('PASSWORD_TEXTBOX_ID'); if (button) { alert(button.value); } }
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 be a simpler version of your code: function toggleShowPassword() { var button = $get('PASSWORD_TEXTBOX_ID'); if (button) { alert(button.value); } } edit: actually I just did a quick test, and Firefox has no problem setting the password field's value with code such as `button.value = "blah"`. So it doesn't seem like this would be the case ... I would check if your ASP.NET code is causing a postback as others have suggested.
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 executes the batch update or delete. I generally let entities handle their own inserts atomically.
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 Robson: The Art of SQL [http://oreilly.com/catalog/9780596008949/][2] Another one which I can recommend: Vadim Tropashko: SQL Design Patterns - The Expert Guide to SQL Programming [http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm][3] Systematic text-book about data modelling: Graeme Simsion & Graham Witt, "Data Modeling Essentials" [http://www.elsevierdirect.com/product.jsp?isbn=9780126445510][4] Maybe you are actually looking for a "style guide"?. I that case: Joe Celko: SQL Programming Style [http://www.elsevierdirect.com/product.jsp?isbn=9780120887972][5] [1]: http://www.dorsethouse.com/books/dmp.html [2]: http://oreilly.com/catalog/9780596008949/ [3]: http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm [4]: http://www.elsevierdirect.com/product.jsp?isbn=9780126445510 [5]: http://www.elsevierdirect.com/product.jsp?isbn=9780120887972
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/6373h346(VS.71).aspx][2] [1]: http://msdn.microsoft.com/en-us/library/kxszd0kx(VS.71).aspx [2]: http://msdn.microsoft.com/en-us/library/6373h346(VS.71).aspx
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 system that treats any non-zero as true, then the bitwise or will act in the same way as the logical or, but it's counterpart (bitwise and, "&") will NOT. Also the bitwise or does not perform short circuit evaluation.
|| 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 each bit of each number individually and, if one of the bits is 1 in at least one of the numbers, then the resulting bit will be 1 also. Here are a few examples: A = 01010101 B = 10101010 A | B = 11111111 A = 00000001 B = 00010000 A | B = 00010001 A = 10001011 B = 00101100 A | B = 10101111 Hopefully that makes sense. So to answer the last two questions, I wouldn't say there are any caveats besides "know the difference between the two operators." They're not interchangeable because they do two completely different things.
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 already true. As your conditions can be quite expensive functions, you can get a good performance boost by using them. There is one big caveat, NullReferences or similar problems. For example: if(class != null && class.someVar < 20) If class is null, the if-statement will stop after "class != null" is false. If you only use &, it will try to check class.someVar and you get a nice NullReferenceException. With the Or-Operator that may not be that much of a trap as it's unlikely that you trigger something bad, but it's something to keep in mind. There is a Second use of the | and & operator though: [Bitwise Operations][1]. [1]: http://www.c-sharpcorner.com/UploadFile/chandrahundigam/BitWiserOpsInCS11082005050940AM/BitWiserOpsInCS.aspx
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 could be used to destroy stenographic information emebedded in images by altering least sifnificant bits. Could a similar process be used to enusre that a virus isn't implanted? Does anyone know of any programs that can scrub files?
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 [3]: http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.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 __construct($value) { $this->value = $value; } public function getValue() { return $this->value; } } function swap($x, $y) { $tmp = $x; $x = $y; $y = $tmp; } $a = new Holder('a'); $b = new Holder('b'); swap($a, $b); echo $a->getValue() . ", " . $b->getValue() . "\n"; Outputs: a b To [pass by reference](http://en.wikipedia.org/wiki/Pass_by_reference#Call_by_reference) means we can modify the variables that are seen by the caller. Which clearly the code above does not do. We need to change swap to: <?php function swap(&$x, &$y) { $tmp = $x; $x = $y; $y = $x; } in order to pass by reference.
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 this. I will give somewhat snarky reaction to items mentioned so far, as if I didn't do any research on this. Let's get this started with the creator: > Showing that the design becomes simpler. How can writing more, make things simpler. I would now have to keep tabs on getting more cases, and etc. This makes it more complicated if you ask me. Give me solid details. > Showing it prevents defects. I know that. This is why they are called tests. My code is good, and I checked it for issues, so I don't see where those tests would help. > Making it an ego thing saying only bad programmers don't. Ohh, so you think I am a bad programmer just because I don't do as much used testing. I'm insulted and positively annoyed at you. I would rather have assistance and support than sayings. > @[Justin Standard][1]: On start of new propect pair the junior guy up with yourself or another senior programmer. Ohh, this is so important that resources will be spent making sure I see how things are done, and have some assist me on how things are done. This is helpful, and I might just start doing it more. > @[Justin Standard][2]: Read [Unit Testing 101][3] presentation by Kate Rhodes. Ahh, that was an interesting presentation, and it made me think about testing. It hammered some points in that I should consider, and it might have swayed my views a bit. I would love to see more compelling articles, and other tools to assist me in getting in line with thinking this is the right way to do things. > @[Dominic Cooney][4]: Spend some time and share testing techniques. Ahh, this helps me understand what is expected of me as far as techniques, and it puts more items in my bag of knowledge, that I might use again. > @[Dominic Cooney][5]: Answer questions, examples and books. Having a point person (people) to answer question is helpful, it might make me more likely to try. Good examples are great, and it gives me something to aim for, and something to look for reference. Books that are relevant to this directly are great reference. > @[Adam Hayle][6]: Surprise Review. Say what, you sprung something that I am completely unprepared for. I feel uncomfortable with this, but will do my best. I will now be scared and mildly apprehensive of this coming up again, thank you. However, the scare tactic might have worked, but it does have a cost. However, if nothing else works, this might just be the push that is needed. > @[Rytmis][7]: Items are only considered done when they have test cases. Ohh, interesting. I see I really do have to do this now, otherwise I'm not completing anything. This makes sense. > @[jmorris][8]: Get Rid / Sacrifice. *glares, glares, glares* - There is a chance I might learn, and with support, and assistance, I can become a very important and functional part of the teams. This is one of my handicaps now, but it won't be for long. However, if I just don't get it, I understand that I will go. I think I will get it. ---------- In the end, what I see as a good thing, if I was in the position, would be the support of my team. Having a person take their time to assist, and get me started into good habits is great. Then, afterward having a good support net, and for a few random items have someone come by, and go over the code, not in a review per se, but more in a friendly, let's see what we can improve way. Reasoning, Preparing, Teaching, Follow up, Support. [1]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7274 [2]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7274 [3]: http://www.masukomi.org/talks/unit_testing_talk_2/index.xul?data=slide_data.txt#page1 [4]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7276 [5]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7276 [6]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7265 [7]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7267 [8]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7259
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 this. I will give somewhat snarky reaction to items mentioned so far, as if I didn't do any research on this. Let's get this started with the creator: > Showing that the design becomes simpler. How can writing more, make things simpler. I would now have to keep tabs on getting more cases, and etc. This makes it more complicated if you ask me. Give me solid details. > Showing it prevents defects. I know that. This is why they are called tests. My code is good, and I checked it for issues, so I don't see where those tests would help. > Making it an ego thing saying only bad programmers don't. Ohh, so you think I am a bad programmer just because I don't do as much used testing. I'm insulted and positively annoyed at you. I would rather have assistance and support than sayings. > @[Justin Standard][1]: On start of new propect pair the junior guy up with yourself or another senior programmer. Ohh, this is so important that resources will be spent making sure I see how things are done, and have some assist me on how things are done. This is helpful, and I might just start doing it more. > @[Justin Standard][2]: Read [Unit Testing 101][3] presentation by Kate Rhodes. Ahh, that was an interesting presentation, and it made me think about testing. It hammered some points in that I should consider, and it might have swayed my views a bit. I would love to see more compelling articles, and other tools to assist me in getting in line with thinking this is the right way to do things. > @[Dominic Cooney][4]: Spend some time and share testing techniques. Ahh, this helps me understand what is expected of me as far as techniques, and it puts more items in my bag of knowledge, that I might use again. > @[Dominic Cooney][5]: Answer questions, examples and books. Having a point person (people) to answer question is helpful, it might make me more likely to try. Good examples are great, and it gives me something to aim for, and something to look for reference. Books that are relevant to this directly are great reference. > @[Adam Hayle][6]: Surprise Review. Say what, you sprung something that I am completely unprepared for. I feel uncomfortable with this, but will do my best. I will now be scared and mildly apprehensive of this coming up again, thank you. However, the scare tactic might have worked, but it does have a cost. However, if nothing else works, this might just be the push that is needed. > @[Rytmis][7]: Items are only considered done when they have test cases. Ohh, interesting. I see I really do have to do this now, otherwise I'm not completing anything. This makes sense. > @[jmorris][8]: Get Rid / Sacrifice. *glares, glares, glares* - There is a chance I might learn, and with support, and assistance, I can become a very important and functional part of the teams. This is one of my handicaps now, but it won't be for long. However, if I just don't get it, I understand that I will go. I think I will get it. ---------- In the end, the support of my team with play a large part in all this. Having a person take their time to assist, and get me started into good habits is always welcome. Then, afterward having a good support net would be great. It would always be appreciated to have someone come a few times afterward, and go over some code, to see how everything is flowing, not in a review per se, but more as a friendly visit. Reasoning, Preparing, Teaching, Follow up, Support. [1]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7274 [2]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7274 [3]: http://www.masukomi.org/talks/unit_testing_talk_2/index.xul?data=slide_data.txt#page1 [4]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7276 [5]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7276 [6]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7265 [7]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7267 [8]: http://stackoverflow.com/questions/7252/how-to-make-junior-programmers-write-tests#7259
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 = $x; $x = $y; $y = $tmp; } $a = new Holder('a'); $b = new Holder('b'); swap($a, $b); echo $a->getValue() . ", " . $b->getValue() . "\n"; Outputs: a b However in PHP4 objects were treated like [primitives](http://www.php.net/manual/en/migration5.oop.php). Which means: <?php $myData = new Holder('this should be replaced'); function replaceWithGreeting($holder) { $myData->setValue('hello'); } replaceWithGreeting($myData); echo $myData->getValue(); // Prints out "this should be replaced"
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 factor is RAM. If the indexes of your tables fit into memory and your queries are highly optimized, you can serve a reasonable amount of requests with a average machine. The number of records do matter, depending of how your tables look like. It's a difference to have a lot of varchar fields or only a couple of ints or longs. The physical size of the database matters as well: think of backups, for instance. Depending on your engine, your physical db files on grow, but don't shrink, for instance with innodb. So deleting a lot of rows, doesn't help to shrink your physical files. There's a lot to this issues and as in a lot of cases the devil is in the details. [1]: http://mysqlperformanceblog.com [2]: http://www.amazon.com/High-Performance-MySQL-Optimization-Replication/dp/0596101716/ref=pd_lpo_k2_dp_k2a_1_img?pf_rd_p=304485601&pf_rd_s=lpo-top-stripe-2&pf_rd_t=201&pf_rd_i=0596003064&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=1KVV0S0YC7DEZFDX5BX3
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 control.
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 ASP Menu control.
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 overflow as a bug because of how much of a sore thumb it is to the majority of the world. [1]: http://stackoverflow.com/questions/761/#770
>>> 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 could be used to destroy stenographic information emebedded in images by altering least sifnificant bits. Could a similar process be used to enusre that a virus isn't implanted? Does anyone know of any programs that can scrub files? Update: So the team argued about this a little bit, and one developer found a post about letting the file download to the file system and having the antivirus software that protects the network check the files there. The poster essentially said that it was too difficult to use the API or the command line for a couple of products. This seems a little kludgy to me, because we are planning on storing the files in the db, but I haven't had to scan files for viruses before. Does anyone have any thoughts or expierence with this? http://www.softwarebyrob.com/2008/05/15/virus-scanning-from-code/
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 probably the most straightforward to read.
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 magic number 3 here with arraysize(str_array) -- although I remember there being some special case in which that particular version of arraysize might do Something Bad (sorry I can't remember the details immediately). But it very often works correctly. Also, if you're really gung-ho about the one line thingy, you can define a variadic macro so that a single line such as `DEFINE_STR_VEC(strvector, "hi", "there", "everyone");` works.
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 the Linux Standards Base (LSB). You won't find any positive answer for that question, though, since ... it's not defined ;-). Only thing I can say: Don't put in /bin (neither in /usr/bin). /usr/local/scripts is unusual as well. $HOME/bin seems to be an acceptable place, iff the script is only used by this single user.
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 articly by Joe Celko][1] for more on keys. More general notes: 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][2] Maybe not very pattern-like, but still very good: Stephane Faroult, Peter Robson: The Art of SQL [http://oreilly.com/catalog/9780596008949/][3] Another one which I can recommend: Vadim Tropashko: SQL Design Patterns - The Expert Guide to SQL Programming [http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm][4] Systematic text-book about data modelling: Graeme Simsion & Graham Witt, "Data Modeling Essentials" [http://www.elsevierdirect.com/product.jsp?isbn=9780126445510][5] Maybe you are actually looking for a "style guide"?. I that case: Joe Celko: SQL Programming Style [http://www.elsevierdirect.com/product.jsp?isbn=9780120887972][6] [1]: http://www.intelligententerprise.com/030320/605celko1_1.jhtml [2]: http://www.dorsethouse.com/books/dmp.html [3]: http://oreilly.com/catalog/9780596008949/ [4]: http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm [5]: http://www.elsevierdirect.com/product.jsp?isbn=9780126445510 [6]: http://www.elsevierdirect.com/product.jsp?isbn=9780120887972
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 an external data feed gave me ~17,000 rows of dta that I needed to synchronise with a local table. The solution I chose there was to load the external data into a staging table and call a stored proc that did the synchronisation completely within the database.
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 lib/secondlevel.rb lib/models/thirdlevel.rb lib/models/foo/fourthlevel.rb
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 command, changing the arguments for the parameters to the query during each iteration. This will minimize resource usage. You don't want to re-create the connection and command for each operation.
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 CSS to PDF documents. You can lay out a template just as you would for an HTML page and use standard HTML syntax. You can even include an external CSS file. The library isn't perfect and very complex markup or css sometimes gets mangled, but I haven't found anything else that works as well. [1]: http://www.fpdf.org/ [2]: http://www.digitaljunkies.ca/dompdf/
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 :( [1]: http://stackoverflow.com/questions/17785/default-internet-connection-on-dual-lan-workstation
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 is that you'll need to access your TFS server by IP address (or netbios name) as all DNS requests will be going out over the internet and not through your private LAN.
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 is that you'll need to access your TFS server by IP address (or netbios name) as all DNS requests will be going out over the internet and not through your private LAN. EDIT: If you can't use the phone when the LAN is plugged in, that's because you've got it setup for DHCP and the DHCP server is advertising (incorrectly for you) that it will accept and route internet traffic. As previously mentioned, setup with a static IP and no gateway... if you insist on using DHCP you'll need to learn the ROUTE command in DOS, find the IP address of your phone (assuming it's acting as a router) set that as the default route, and remove whatever default route was assigned from the DHCP server. EDIT2: @dan - you can't use the internet from your phone directly (eg. mobile browser), or you can't make your laptop use your phone for internet when the cable is plugged in? (ie. routing issues) ... if it's the former, then your phone is probably configuring a PAN with your phone and trying to route internet back over the LAN
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 vary from MTA to MTA. Then the failure reason can be tweaked by the site admin making it harder to recognize, and the site admin could modify the failure message template which makes it darn near impossible. See if you can find a .NET mailing list manager and if you can repurpose the bounce handling code. Failing that, see if you can change the tool that's sending the messages to send each email from a unique (and reversible) enveloper sender (VERP I think it's called?). That way you don't need to scan the body of the email, you can tell which recipient failed by examining the recipient address of the failure message. [1]: http://stackoverflow.com/questions/7231/automatically-check-bounced-emails-via-pop3#7249
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 sessions timeout 4. Don't use register globals 5. Store authentication details on the server. That is don't send details such as username in the cookie. 6. Check the $_SERVER['HTTP_USER_AGENT']. This adds a small barrier to session hijacking. You can also check the IP address. But this causes problems for users that have changing IP address due to load balancing on multiple internet connections etc (which is the case in our environment here). 7. Lock down access to the sessions on the file system or use custom session handling 8. For sensitive operations consider requiring the user to provide their authenication details
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 tested, don't let it in, then you won't have to work weekends)
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 tested, don't let it in, then you won't have to work weekends)
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 simply testing the backend is sufficient. I have used NUnit ASP in the past (at my job), and if you insist on unit testing your UI, I would strongly advise you to use ANYTHING but NUnit ASP. It's a pain to work with, and tests tend to be invalidated (needing to be revised) after even the most minor UI changes (even if the subjects of the tests don't actually change).
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_remove = n; vec.erase(std::remove(vec.begin(), vec.end(), int_to_remove);
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_remove = n; vec.erase(std::remove(vec.begin(), vec.end(), int_to_remove), vec.end());
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) { } ***[Example lifted from here](http://bytes.com/forum/thread224970.html)***
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) { } ***[Example lifted from here](http://bytes.com/forum/thread224970.html)*** Edit ***Made the C# example into actual C# (Thanks Blair Conrad)***
**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 existing in the "bad" peak, or vice versa, you may be able to automatically differentiate them that way.
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 existing in the "bad" peak, or vice versa, you may be able to automatically differentiate them that way.
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]: http://code.msdn.microsoft.com/MersenneTwister
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]: http://code.msdn.microsoft.com/MersenneTwister
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 each ID, it ends up seeming to be too verbose.
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 with actual useful outputs instead of a bit stream.
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 the repository itself, I'm not really missing out on anything, and I can now use the --password and --username options gratuitously. Seems obvious now that I think about it.
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, it's a lifesaver. [1]: http://msdn.microsoft.com/en-us/library/2wkebaxa.aspx [2]: http://msdn.microsoft.com/en-us/library/ms186156.aspx
How do I make a GUI?