instruction
stringlengths
0
30k
As Niyaz said, the approach sounds reasonable if you use a quality implementation of strong algorithms, like [SHA-265][1] and [AES][2] for hashing and encryption. Additionally I would recommend using a [Salt][3] to reduce the possibility to create a dictionary of all password hashes. Of course, reading [Bruce Schnei...
There's no way to tell when a user clicks the back button of presses the backspace key to go back in the browser, however there are other events that happen in a certain order which are detectable. This [example javascript][1] has a reasonably good method for detecting back commands: The traditional way, however, i...
See here: [http://msdn.microsoft.com/en-us/library/aa371925.aspx][1] It is not really hard, but a bit tedious as the API involves extensive usage of self-referential, variable-length structures and has to employ some IPC mechanism to obtain the data from the monitored process. [1]: http://msdn.microsoft.co...
One of my favorite frameworks for doing this is [Yahoo!'s Browser History Manager][1]. You register events and it calls you back when the user returns Back to that state. And if you want to learn how it works, [here's a fun blog entry about the decisions Yahoo! made][2] when designing it. [1]: http://developer...
A probably easier approach would be to use Image.FromFile() and then use the RawFormat property, as it already knows about the magic bits in the headers for the most common formats, like this: Image i = Image.FromFile("c:\\foo"); if (System.Drawing.Imaging.ImageFormat.Jpeg.Equals(i.RawFormat)) Mes...
All the image formats set their initial bytes to a particular value: - JPG: [0xFF 0xD8][1] - PNG: [0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A][2] - GIF: ['G' 'I' 'F'][3] Search for "jpg file format" replacing jpg with the other file formats you need to identify. -Adam [1]: http://en.wikipedia.org/wik...
All the image formats set their initial bytes to a particular value: - JPG: [0xFF 0xD8][1] - PNG: [0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A][2] - GIF: ['G' 'I' 'F'][3] Search for "jpg file format" replacing jpg with the other file formats you need to identify. As Garth recommends, there is a [database o...
** Rewritten for clarity ** I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult Archive(int year) { if (!String.IsNullOrEmpty(Request["year"])) { return RedirectToAction("Archive", new { year = year }...
** Rewritten for clarity ** I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult Archive(int year) { if (!String.IsNullOrEmpty(Request["year"])) { return RedirectToAction("Archive", new { year = year }...
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult Archive(int year) { / *** / } } With a route like this: routes.MapRoute( "News-Archive", ...
One thing that you **shouldn't** do is filter the input data as it comes in. People often suggest this, since it's the easiest solution, but it leads to problems. Input data can be sent to multiple places, besides being output as HTML. It might be stored in a database, for example. The rules for filtering data sent ...
TCP sockets to localhost FTW.
Getting started with REST
|.net|rest|
I am looking for some good links with best practices and sample code on creating [REST][1]ful services using .NET. Also, any other input you might have regarding REST would be greatly appreciated. [1]: http://en.wikipedia.org/wiki/Representational_State_Transfer
I am looking for some good links with best practices and sample code on creating [REST][1]ful web services using .NET. Also, any other input you might have regarding REST would be greatly appreciated. [1]: http://en.wikipedia.org/wiki/Representational_State_Transfer
|.net|web-services|rest|
- use structs for small wrapper objects to avoid heap fragmentation - think carefully about object lifetimes, especially for learge objects so they do not end up on the LOH unless you intend them to - think about allocations inside of a loop - make sure dynamically sized array will be of reasonable size, oth...
Not sure where you're at in the project, but if it's a simple and small database you might consider converting it to [SQLite][1]. It's not ideal for Client/Server operations, but if it's low volume/transactions it might work. [1]: http://www.sqlite.org/
Allan Anderson created a custom control to let you do this. You can find it here: http://www.codeproject.com/KB/list/aa_listview.aspx Here's some example code for that control: <pre><code> GlacialList mylist = new GlacialList(); mylist.Columns.Add( "Column1", 100 ); // this can also be added ...
I like the concept of an 'Invisible Captcha'. Phil Haack details one implementation [here][1]. This banks on the fact that bots, spiders, and crawlers don't implement javascript engines. This too could change in the near future. [1]: http://haacked.com/archive/2006/09/26/Lightweight_Invisible_CAPTCHA_Validato...
Here is one way (put this in Page_Load): if (this.IsPostBack) { Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","var isPostBack = true;"); } Then just check that variable in the JS.
Here is one way (put this in Page_Load): if (this.IsPostBack) { Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","<script type='text/javascript'>var isPostBack = true;</script>"); } Then just check that variable in the JS.
The thing you should consider is the decision of platform independence. Do you want to tie your game to Windows, or would you like to release it to Mac OS X or Linux at some point. If you decide that you want to support Linux, OS X in the future, you will need to use OpenGL. There seems to be a lot of goodwill by ...
You could try writing a little script to replace all of the CRs with CRLFs (assuming the direction of trashing was CRLF to CR), swapping them randomly per block until you had the correct crc. Assuming that the data wasn't particularly large, I guess that might not use all of your CPU until the heat death of the univer...
The most fundamental tool to keep people from spambotting a user input site is the "nofollow" tag on links. Most comment-spammers are interested in Google juice rather than actually having their stuff seen, so nofollow removes the incentive.
If they are a real numbers then infinite ... otherwise it is a bit trickier. (OK, for any computer representation of a real number there would be a finite count ... but it would be big!)
I had a similar problem, where the ValidationTextBox met all my needs but it was necessary to disable the validation routines until after the user had first pressed Submit. My solution was to clone this into a ValidationConditionalTextBox with a couple new methods: enableValidator:function() { this.validato...
Image recognition rather than text recognition.
Number of possible combinations
What exactly is Microsoft Expression Studio and how does it integrate with Visual Studio?
|expression-studio|visual-studio|integration|microsoft|
My university is part of MSDNAA, so I downloaded it a while back, but I just got around to installing it. I guess part of it replaces FrontPage for web editing, and there appears to be a video editor and a vector graphics editor, but I don't think I've even scratched the surface of what it is and what it can do. Could ...
|microsoft|visual-studio|integration|expression-studio|
|visual-studio|microsoft|integration|expression-studio|
Visual Studio 2008 Training
|visual-studio|c#|training|
I've been put in charge of coming up with a training itinerary for my team at work for a migration from c++ to Visual Studio 2008 with C#. The actual language switch I'm not too worried about, its the learning curve to Visual Studio. What does everything think would be the best way to set up a training course? ...
|c#|visual-studio|training|
Best practices for debugging linking errors.
|c++|gcc|visual-studio|linker|compilation|
When building projects in C++, I've found debugging linking errors to be tricky, especially when picking up other people's code. What strategies do people use for debugging and fixing linking errors?
|c++|visual-studio|gcc|linker|compilation|
What does ServerVariables["APPL_MD_PATH"] retreives the metabase path for the Application for the ISAPI DLL mean?
|.net|asp.net|.net-2.0|debugging|visual-studio|
I've trying to get an ASP.net (v2) app to work in the debugger and keep running into a problem because the value returned by HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"].ToLower() is an empty string. I have found out that this "Retrieves the metabase path for the Application for the ISAPI DLL". Can a...
|.net|asp.net|.net-2.0|visual-studio|debugging|
|.net|asp.net|visual-studio|.net-2.0|debugging|
How can I point Visual Studio 2008 to a new path for projects?
The best place to start learning C is the book "The C Programming Language" by Kernighan and Ritchie. You will recognise a lot of things from PHP, and you will be surprised how much PHP (and Perl, Python etc) do for you. Oh and you also will need a C compiler, but i guess you knew that.
**Solution** Okay here is the solution, (thanks to Brad for leading me there). 1) Require default value in route: routes.MapRoute( "News-Archive", "News.mvc/Archive/{year}", new { controller = "News...
**Solution** Okay here is the solution, (thanks to Brad for leading me there). 1) Require default value in route: routes.MapRoute( "News-Archive", "News.mvc/Archive/{year}", new { controller = "News...
store everything you'll need to build the project, so you can check it out and build without doing anything. (and, as someone who has experienced the pain - please keep a copy of everything needed to get the controls installed and working on a dev platform. I once got a project that could build - but without an inst...
128 bit data encryption using Java
|java|cryptography|
I need to store some sensitive data by encrypting it with atleast 128 bit key. I investigated into javax.crypto package and found that there are certain Cipher names, like PBEWithMD5AndDES or PBEWithSHA1AndDESede which provides encryption upto 56 bit and 80 bit (http://en.wikipedia.org/wiki/Desede). I referred oth...
The Yahoo User Interface Library, my personal favorite client-side JS library, has an excellent [Browser History Manager](http://developer.yahoo.com/yui/history/) that does exactly what you're asking for.
How do distributed transactions work (eg. MSDTC)?
|transactions|acid|mstdc|
I understand, in a fuzzy sort of way, how regular ACID transactions work. You perform some work on a database in such a way that the work is not confirmed until some kind of commit flag is set. The commit part is based on some underlying assumption (like a single disk block write is atomic). In the event of a catast...
I understand, in a fuzzy sort of way, how regular ACID transactions work. You perform some work on a database in such a way that the work is not confirmed until some kind of commit flag is set. The commit part is based on some underlying assumption (like a single disk block write is atomic). In the event of a catast...
I believe the server variables list only contains the headers sent from the browser to the server.
Maybe [ListView.Checkboxes][1]. [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.checkboxes(VS.80).aspx
I would strongly recommend using PHP 5.2's [DateTime objects][1], rather than using UNIX timestamps, when doing date calculations. When you use the PHP date functions that return UNIX timestamps, you have a very limited range to work with (e.g. nothing before 1970). [1]: http://us2.php.net/datetime
I think you'll want something based on sockets. If you want RPC rather than just IPC I would suggest something like XML-RPC/SOAP which runs over HTTP, and can be used from any language.
I believe this is one of the real limitations of the Visual Studio installation project. You need to be able to modify the last page of the installation UI but VS.NET does not give you a way to do this. You could modify the tables in the .MSI after it has been built but VS.NET would probably overwrite these changes eac...
In Eclipse you can ALT-down or ALT-up to move a line. I find this incredibly useful, as well as ALT-SHIFT-{down, up} to copy a line. In addition, it doesn't wreck your clipboard. It even corrects indentation as the line is moving!
Dan Wahlin has some good Silverlight 2 videos at: <http://weblogs.asp.net/dwahlin/archive/2008/03/07/silverlight-2-0-video-tutorials.aspx> They are quite helpful. rp
From the standard: > Objects with static storage duration (3.7.1) shall be zero-initialized (8.5) before any other initialization takes place. Zero-initialization and initialization with a constant expression are collectively called *static initialization*; all other initialization is *dynamic initialization*. Objec...
You could use a grid view instead, as that gives you more fine control of column contents.
In VIM: - Delete the whole line including the newline: <code>dd<code> - Transpose lines: <code>dd p<code> You can always prefix any command with a number to repeat it, so to delete 10 lines do: 10 dd You can also specify a range of lines to delete. For instance, to delete lines 10-15: :10,1...
|combinations|
How many possible combinations of the variables a,b,c,d,e are possible if I know that: a+b+c+d+e = 500 and that they are all >= 0
|puzzle|
How many possible combinations of the variables a,b,c,d,e are possible if I know that: a+b+c+d+e = 500 and that they are all integers and >= 0, so I know they are finite.
Regex is very handy any time I am trying to replace a value that spans multiple lines. Or when I want to replace a value with something that contains a line break. I also like that you can match things in a regular expression and not replace the full match using the $# syntax to output the portion of the match you ...
In addition to performance benefits, `CHAR` can be used to indicate that all values *should* be the same length, e.g., a column for U.S. state abbreviations.
For now, reputation systems are harder to beat. The community sites of the near future will need to rely on its higher-ranking members to remove the spam. The trend for spam is to become continually more indistinguishable from legitimate content, and for each new generation of mechanical filters to die of innefectiv...
It would be best to find colors maximally distant in a "perceptually uniform" colorspace, e.g. CIELAB (using Euclidean distance between L*, a*, b* coordinates as your distance metric) and then converting to the colorspace of your choice. Perceptually uniformity comes from tweaking the colorspace to approximate the non...
I would strongly consider using [NumPy](http://numpy.scipy.org) to do this. You get efficient N-dimensional arrays that you can quickly and easily process.
Storing multiple arrays in Python
|python|
I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of the ran...
I need to store some sensitive data by encrypting it with atleast 128 bit key. I investigated into javax.crypto package and found that there are certain Cipher names, like PBEWithMD5AndDES or PBEWithSHA1AndDESede which provides encryption upto 56 bit and 80 bit (http://en.wikipedia.org/wiki/DESede). I referred oth...
Another incredibly annoying thing that I just realized is that ctrl-c can't be captured by `event.ctrlKey && event.keyCode = Keyboard.C` (or ...`event.charCode == 67`), instead you have to test for `charCode` or `keyCode` being `3`. It kind of makes sense for `charCode` since ctrl-c is `3` in the ASCII table, but it do...
Another incredibly annoying thing that I just realized is that ctrl-c can't be captured by `event.ctrlKey && event.keyCode = Keyboard.C` (or ...`event.charCode == 67`), instead you have to test for `charCode` or `keyCode` being `3`. It kind of makes sense for `charCode` since ctrl-c is `3` in the ASCII table, but it do...
You need to download and install the unlimited strength JCE policy file for your JDK. For JDK 6, it is on http://java.sun.com/javase/downloads/index.jsp at the very bottom.
A general principle of RESTful web services is to use the features built-in to HTTP, when applicable. In this case, you can indicate the format of your PUT request's content by setting the [Content-Type][1] header to *application/json* or *application/xml*. [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.ht...
Learning any language takes time, I always ensure I have a measurable goal; I set myself an objective, then start learning the language to achieve this objective, as opposed to trying to learn every nook and cranny of the language and syntax. C is not easy, pointers can be hard to comprehend if you’re not coming as...
I'm not a crypto expert by any means (so take this suggestion with a grain of salt), but I have used [Blowfish][1] before, and I think you can use it for what you need. There is also a newer algorithm by the same guy called [Twofish][2]. Here is a [website with a Java implementation][3], but be careful of the licen...
In addition to what John suggested, you should repeatedly flush the output stream. Depending on your web container, it is possible that it caches parts or even all of your output and flushes it at-once (for example, to calculate the Content-Length header). That would burn quite a bit of memory.
Use a good [XSD Schema][1] to create a set of classes with [xsd.exe][2] and use an [XmlSerializer][3] to create a object tree out of your XML and vice versa. If you have few restrictions on your model, you could even try to create a direct mapping between you model classes and the XML with the Xml*Attributes. There ...
If you are using a custom security extention, you will still be able to get all the info you need from the ExecutionLog table. Unless off-course if all your users uses a shared login, in which case you probably need to reconsider your architecture, depending on the importance of the audit log.
Adam's pointing in exactly the right direction. If you want to get gratuitously comprehensive, look at the `file` command on a UNIX, Linux, or Mac OS X machine. To get instructions, enter this command at a shell prompt: man file `file` uses a database of “magic numbers” — those initial bytes Adam listed —...
Adam is pointing in exactly the right direction. If you want to find out how to **sense almost any file**, look at the database behind the `file` command on a UNIX, Linux, or Mac OS X machine. `file` uses a database of “magic numbers” — those initial bytes Adam listed — to sense a file's type. `man file` will t...
As a side note, [connectionstrings.com][1] is a great site so you don't have to remember all that connection string syntax. [1]: http://connectionstrings.com
If you are using Microsoft technologies, the [patterns & practices Summit][1] is a good event -- if you are not working pretty much 100% in the Microsoft .NET space, though, it would be of less use. [1]: http://www.pnpsummit.com/
There's no way to answer this without knowing *what happens when your application goes down*. - If someone dies when your application goes down, uptime is worth spending millions or even billions of dollars on (aerospace, medical devices). - If someone may be injured if your software goes down, uptime is worth ...
There was an app on Downloadsquad.com recently. I dont remember the name of it but it did some fun stiff woth processors and task manager. It may have only been to manage what apps are on what cpu but maybe it would give you this. I will try to look for it this afternoon, and respond back if I find it.
.Net will throw a System.ArgumentException if you try to add an item to a hashtable twice with the same key value, so it doesnt look like there is anything more specific. You may want to write your own exception if you need something more specific.