instruction
stringlengths
0
30k
I wrote a utility for dumping all of the relevant parts of my db into a directory structure that I use SVN on. I never got around to trying to incorporate it into the Manager but, if you're interested, it's here: http://www.reluctantdba.com/dbas-and-programmers/sqltools/svnforsql2005.aspx It's free and, since I regu...
Anything you do to provide "encryption" that isn't using SSL/TLS is likely to be vulnerable. Now you have to ask yourself, is it worth burning dev hours you could be spending on features on a rubber-chicken security measure? Maybe it is. .NET APIs like DPAPI and the Win32 crypt32 API make it easy to encrypt blobs of...
Yep, in .NET namespaces doesn't depend on file system or anything else. It's a great advantage in my opinion. For example you can distribute your code across different assemblies which allows flexible distribution. When working in Visual Studio, IDE tends to introduce new namespace when you add new folder to project...
Yep, in .NET namespace doesn't depend on file system or anything else. It's a great advantage in my opinion. For example you can distribute your code across different assemblies which allows flexible distribution. When working in Visual Studio, IDE tends to introduce new namespace when you add new folder to project ...
Yep, in .NET namespace doesn't depend on file system or anything else. It's a great advantage in my opinion. For example you can split your code across different assemblies which allows flexible distribution. When working in Visual Studio, IDE tends to introduce new namespace when you add new folder to project tree....
I would recommend using a recognized algorithm such as PBKDF2 defined in [PKCS #5 version 2.0][1] to generate a key from your password. It's similar to the algorithm you outline, but is capable of generating longer symmetric keys for use with AES. You should be able to find an open-source library that implements PBE ke...
### Key Generation ### I would recommend using a recognized algorithm such as PBKDF2 defined in [PKCS #5 version 2.0][1] to generate a key from your password. It's similar to the algorithm you outline, but is capable of generating longer symmetric keys for use with AES. You should be able to find an open-source libr...
From my reading, there are a number of things that can cause this. The fix for my particular situation, however, was to "unblock" the DLL file. Because I had downloaded the zip from the Internet, XP had put a block on the file. Right-clicking the file and clicking "Unblock" did the trick.
Wix has out-of-the-box support for creating event log sources. Assuming you use Wix 3, you first need to add a reference to WixUtilExtension to either your Votive project or the command line. You can then add an EventSource element under a component : <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" ...
Thanks Timbo. I got satisfactory results. To create a standard size button we have to do this then: LONG units = GetDialogBaseUnits(); m_hButton = CreateWindow(TEXT("BUTTON"), TEXT("Close"), WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 0, 0, MulDiv(LOWORD(units)...
[neo4j][1] is: > an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables I haven't had a chance to try it yet - but it looks very promising. Note this is not an SQL database - your object graph is persisted for you - so it might not be app...
How do I HTML Encode all the output in a web application?
|asp.net|php|jsp|
I want to prevent XSS attacks in my web application. I found that HTML Encoding the output can really prevent XSS attacks. Now the problem is that how do I HTML encode every single output in my application? I there a way to automate this? I appreciate answers for JSP, ASP.net and PHP.
Or you may want to give this script a try... [http://www.vim.org/scripts/script.php?script_id=23][1] [1]: http://www.vim.org/scripts/script.php?script_id=23
Alternatives to XCopy for copying lots of files?
|xcopy|
The situation: I have a pieceofcrapuous laptop. One of the things that make it pieceofcrapuous is that the battery is dead, and the power cable pulls out of the back with little effort. I recently received a non-pieceofcrapuous laptop, and I am in the process of copying everything from old to new. I'm trying to xcop...
Are you talking about doing this? >>> a = [ ['a', 'b'], ['c', 'd'] ] >>> a[1] ['c', 'd'] >>> a[1][1] 'd'
Detecting appilcation hangs with ActiveX controls in .Net
|.net|activex|hangs|
I am working on upgrades to a screen scraping application. We are using an ActiveX control to scrape screens out of an IBM mainframe. The mainframe program often hangs and crashes the ActiveX control causing our application to crash. We don't have access to the mainframe or the ActiveX source code. We are not going to ...
|.net|activex|hangs|
There are "disk repair" type applications and services that can still read data off a hard drive even after it's been formatted, so simply overwriting with random 1s and 0s one time isn't sufficient if you really need to securely erase something. I would say that for the average user, this is more than sufficient, b...
How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC?
|string|gcc|warnings|const-char|
So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning: warning: deprecated conversion from string constant to ‘char*’ Obviously, the correct way to fix this is to find every declaration like char *s = "constant string"; or function call like ...
Char is a little bit faster, so if you have a column that you KNOW will be a certain length, use char. For example, storing (M)ale/(F)emale/(U)nknown for gender, or 2 characters for a US state.
There is some small processing overhead in calculating the actual needed size for a column value and allocating the space for a Varchar, so if you are definitely sure how long the value will always be, it is better to use Char and avoid the hit.
WSDualHttpBinding for duplex callbacks
|wcf|callback|duplex|
Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a .NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks?
The [getID3()][1] library is a quick and easy works-most-of-the-time option. Originally named for a project to obtain MP3 ID3 data, the library does two hecks of a lot more than that and is quite convenient for all sorts of common or odd file meta data tasks. I've used it to get the MIME types of files for online im...
How do I automate finding unused #include directives?
|c|
Typically when writing new code you discover that you are missing a #include because the file doesn't compile. Simple enough, you add the required #include. But later you refactor the code somehow and now a couple of #include directives are no longer needed. How do I discover which ones are no longer needed? Of cou...
If you're allergic to angle brackets, then JSON, [HDF][1] (ClearSilver), and [OGDL][2] are the only ones I know offhand. After a bit of googling, I also found a list of alternatives here:<br/> [http://web.archive.org/web/20060325012720/www.pault.com/xmlalternatives.html][3] [1]: http://www.clearsilver.net/do...
How do you treat legacy code (and data)?
|svn|version-control|legacy|project-management|
I am currently in the process of restructuring my local Subversion repository by adding some new projects and merging legacy code and data from a couple of older repositories into it. When I have done this in the past I have usually put the legacy code in a dedicated "legacy" folder, as not to "disturb" the new and...
I learned the art of add-ons primarily by looking at the code of Blizzard's UI. You can see that code by [extracting the default UI][1] or [finding a copy of the default UI online][2]. Add-on developers sometimes like to over-engineer their pet projects (who doesn't?), while Blizzard's code is usually pretty no-nonsens...
You can include Ruby on Rails by freezing it to the version of Rails you want to use in your project. They call this Freezing. The user will not have to install Rails to use your application. You can do this with any library you use in your project. If the project uses a library, just place it under the Vendor fold...
I'm using two different approaches in my `models.py`. The first is the `permalink` decorator: from django.db.models import permalink def get_absolute_url(self): """Construct the absolute URL for this Item.""" return ('project.app.views.view_name', [str(self.id)]) get_absolute_u...
For an inheritance-friendly implementation, check out Tal Cohen's solution: [http://www.ddj.com/java/184405053][1] Summary: In his book Effective Java Programming Language Guide (Addison-Wesley, 2001), Joshua Bloch claims that "There is simply no way to extend an instantiable class and add an aspect while preserv...
I think you have a typo in your second example (extra ')'). I'd edit it but I don't have the rep :-). In the first example, cvalue as passed parameter is in really just a pointer to a character array and when you take the sizeof() of it, you get the size of the pointer. In the second case, where you've declared it...
Another, very pragmatic reason, to prefer composition over inheritance has to do with your domain model, and mapping it to a relational database. It's really hard to map inheritance to the SQL model (you end up with all sorts of hacky workarounds, like creating columns that aren't always used, using views, etc). Some O...
Have you tried running process monitor and when it hangs and see what the underlying error is? Using process moniter you should be able to tell whick file/resource it waiting for/erroring on.
Adding command recall to a Unix command line application
|java|unix|command-line|commandprompt|
I'm working on a command line application for Solaris, written in Java6. I'd like to be able to scroll through a history of previous commands using the up and down arrows like many Unix tools allow (shells, VIM command mode prompt, etc). Is there any standard way of achieving this, or do I have to roll my own?
This is not an answer, just a side comment. It is **highly** recommended to declare variables and constants <code>const</code> as much as possible. 1. This communicates your intent to users of your class (even/especially yourself). 1. The compiler will keep you honest to those intentions. -- i.e., it's like comp...
Yes, use the [GNU readline][1] library. [1]: http://tiswww.case.edu/php/chet/readline/rltop.html
I've used Emacs for 20 years. It's great and it works everywhere. I also have TextMate, which I use for some things on the Mac (HTML mode is great). If you want to do Ruby development, Netbeans supports Ruby and it also runs on all platforms. http://www.netbeans.org/features/ruby/index.html I've seen some blog...
Is the code trying to find a specific needle or just any needle? It sounds like a stupid question, but it changes the problem. Looking for a specific needle the code in the question makes sense. Looking for any needle it would be more like needle = haystack.findNeedle() or needle = searcher.findNee...
Don't store in images in the database unless you absolutely have to. I understand that this is not a web application, but if there isn't a shared file location that you can point to save the location of the file in the database. //linuxserver/images/imagexxx.jpg then perhaps you can quickly set up a webserve...
There simply is no reliable way to do this. You cannot guarantee that 100% of the time you can stop the user from doing this. With that in mind, is it worth going to extremely exotic solutions to disable "most" of the time? That's for you to decide. Good luck.
Because of the security isolation of javascript in the browser, you cannot change what the back button does. Perhaps you could store something in the user's session that indicates that a comment is needed, and have any page in the app that the user tries to load redirect to the comment page? What if the user clos...
How do I get InputVerifier to work with an editable JComboBox
|java|swing|
I've got an JComboBox with a custom inputVerifyer set to limit MaxLength when it's set to editable. The verify method never seems to get called. The same verifyer gets invoked on a JTextField fine. What might I be doing wrong? Thanks.
Compare the environment variables in your shell and from within the script.
I've seen this before: window.onBack = history.forward(); It is most definitely a dirty hack and, if at all possible, I would attempt to not disable the back button. And the user can probably still get around it quite easily. And depending on caching, there is no telling if the server code will be processed o...
It means that $objPage is not an instance of an object. Can we see the code you used to initialize the variable?
Don't do this, just don't. It's bad interface design and forces the user's browser to behave in a way that they don't expect. I would regard any script that successfully stopped my back button from working to be a hack, and I would expect the IE team to release a security-fix for it. The back button is part of th...
|svn|version-control|project-management|legacy|
I am currently in the process of restructuring my local Subversion repository by adding some new projects and merging legacy code and data from a couple of older repositories into it. When I have done this in the past I have usually put the legacy code in a dedicated "legacy" folder, as not to "disturb" the new and...
Saving emails
|email|
If you have a site which sends out emails to the customer, and you want to save a copy of the mail, what is an effective strategy? If you save it to a table in your database (eg create a table called Mail), it gets very large very quickly. Some strategies I've seen are: 1. Save it to the file system 2. Run a ...
|backup|email|
A static source code analysis tool like lint might do the job. They will tell you if a piece of code will never be called.
@Vinko Vrsalovic Your example may be simplified. import urllib import BeautifulSoup soup = BeautifulSoup.BeautifulSoup(urllib.urlopen("https://www.google.com")) print soup.title.string
@Vinko Vrsalovic Your example may be simplified. import urllib import BeautifulSoup soup = BeautifulSoup.BeautifulSoup(urllib.urlopen("https://www.google.com")) print soup.title.string NOTE: * _soup.title_ finds the first _title_ element **anywhere** in the html document * _title...
Rather than focusing on making your existing structures more readable, you should focus on making more logical structures. Make smaller blocks, try not to nest blocks excessively, make smaller functions, and try to think through your code flow more. If you come to a point where you can't quickly determine the struc...
Example of modern text editor architecutre
|architecture|text-editor|
I'm looking for design\architectual guidance for modern text editors. *Modern* text editor means that: - It has support for syntax highlighting - It has auto-completion (something like IntelliSense) - It has advanced navigation capabilities (incremental search, etc.) Following properties will be a pl...
I'm looking for design\architectual guidance for modern text editors. *Modern* text editor means that: - It has support for syntax highlighting - It has auto-completion (something like IntelliSense) - It has advanced navigation capabilities (incremental search, etc.) Following properties will be a pl...
Eric, you're biting off more than you can chew on this topic. Ted Neward was not being flippant when he called it the "Vietnam of Computer Science". Well done for asking this question first though, as I'm sure it will generate much action/interest/reputation for you. One thing I can absolutely guarantee you, it ...
Eric, you're biting off more than you can chew on this topic. Ted Neward was not being flippant when he called it the "[Vietnam of Computer Science][1]". Well done for asking this question first though, as I'm sure it will generate much action/interest/reputation for you. One thing I can absolutely guarantee you...
The apotheosis of the Module Pattern: [The Revealing Module Pattern][1] A neat little extension to a very robust pattern. [1]: http://www.wait-till-i.com/2007/08/22/again-with-the-module-pattern-reveal-something-to-the-world/ "from Chris Heilemann, naturally"
You can define PHP's **__toString** magic method inside your class. For example class cat { private $name; public function __contruct($catname) { $this->name = $catname; } public function __toString() { return "My name is " . $this->name . "\n";...
You can define PHP's **__toString** magic method inside your class. For example class cat { private $name; public function __contruct($catname) { $this->name = $catname; } public function __toString() { return "My name is " . $this->name . "\n";...
Do users ever touch your code? If you're not doing solely back-end work, I recommend [About Face: The Essentials of User Interface Design][1] — now in its third edition (linked). I used to think my users were stupid because they didn't "get" my interfaces. I was, of course, wrong. About Face turned me around. [1]...
George: You may have already seen this but it may help: <http://usphp.com/manual/en/language.oop5.object-comparison.php> >When using the comparison operator (==), object variables are compared in a simple manner, namely: Two object instances are equal if they have the same attributes and values, and are instances of...
It is possible to log in using HTTP authentication by setting the "Authorization" HTTP header, with the value of this header set to the string "basic username:password", but with the "username:password" portion of the string Base 64 encoded. [http://frontier.userland.com/stories/storyReader$2159][1] A bit of re...
*Guideline: Don't test code that you haven't written.* You shouldn't be concerned with WinAPI implementation not working (most probably it works as expected). Your concern should be testing is the 'Wiring' i.e. if your code makes the right WinAPI call. In which case, all you need is to mock out the interface and ...
*Guideline: Don't test code that you haven't written.* You shouldn't be concerned with WinAPI implementation not working (most probably it works as expected). Your concern should be testing the 'Wiring' i.e. if your code makes the right WinAPI call. In which case, all you need is to mock out the interface and let...
You can also use [pygooglechart][1], which uses the [Google Chart API][2]. This isn't something you'd always want to use, but if you want a small number of good, simple, charts, and are always online, and especially if you're displaying in a browser anyway, it's a good choice. [1]: http://pygooglechart.slowchop...
It is a perfectly valid desire to have the signature an overriding method have a return type that is a subtype of the return type in the overridden method (*phew*). After all, they are run-time type compatible. But C# does not yet support "covariant return types" in overridden methods (unlike C++ [1998] & Java [200...
It is a perfectly valid desire to have the signature an overriding method have a return type that is a subtype of the return type in the overridden method (*phew*). After all, they are run-time type compatible. But C# does not yet support "covariant return types" in overridden methods (unlike C++ [1998] & Java [200...
How to capture output of "pnputil.exe -e"
|windows|
How do I capture the output of "%windir%/system32/pnputil.exe -e"? (assume windows vista 32-bit) Bonus for technical explanation of why the app normally writes output to the cmd shell, but when stdout and/or stderr are redirected then the app writes nothing to the console or to stdout/stderr? <pre> C:\Windows\S...
Call to a member function on a non-object
|oop|
So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes. class PageAtrributes { private $db_connection; private $page_title; public function __construct($db_connection) { $this->db_connection = $db_connection; $this->page_title = ''; } public f...
So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes. class PageAtrributes { private $db_connection; private $page_title; public function __construct($db_connection) { $this->db_connection = $db_connection; $this->page_title = ''; } public f...
I realized that I wasn't passing **$objPage** into **page_properties()**. It works fine now.
It is not easy on the server [side][1].. For client side, you can use [ChannelFactory][2] [1]: http://blogs.msdn.com/drnick/archive/2006/12/04/overriding-the-default-configuration-file.aspx [2]: http://msdn.microsoft.com/en-us/library/ms734681.aspx