instruction
stringlengths
0
30k
If you've never done any CGI programming before I think it would be worth doing one project - perhaps just a sample play site just for yourself - using the DIY approach. You'll learn a lot more about how all the various parts work than you would by using a framework. This will help in you design and debug and so on all your future web applications however you write them. Personally I now use Django. The real benefit is very fast application deployment. The object relational mapping gets things moving fast and the template library is a joy to use. Also the admin interface gives you basic CRUD screens for all your objects so you don't need to write any of the "boring" stuff. The downside of using an ORM based solution is that if you do want to handcraft some SQL, say for performance reasons, it much harder than it would have been otherwise, although still very possible.
If you've never done any CGI programming before I think it would be worth doing one project - perhaps just a sample play site just for yourself - using the DIY approach. You'll learn a lot more about how all the various parts work than you would by using a framework. This will help in you design and debug and so on all your future web applications however you write them. Personally I now use [Django][1]. The real benefit is very fast application deployment. The object relational mapping gets things moving fast and the template library is a joy to use. Also the admin interface gives you basic CRUD screens for all your objects so you don't need to write any of the "boring" stuff. The downside of using an ORM based solution is that if you do want to handcraft some SQL, say for performance reasons, it much harder than it would have been otherwise, although still very possible. [1]: http://www.djangoproject.com/
Erland Sommarskog has maintained the authoritative answer to this question for the last 12 years: [http://www.sommarskog.se/arrays-in-sql.html](http://www.sommarskog.se/arrays-in-sql.html) It's not worth reproducing all of the options here on StackOverflow, just visit his page and you will learn all you ever wanted to know.
could you redo that link in something like tinyurl.com? I need this info too but can get that mega-link to work.
Visual Studio is not needed, but for C++ you need the Platform SDK as well: [http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en][1] Edit: There is also one for Windows 2008/Vista, not sure which is the correct one: [http://www.microsoft.com/downloads/details.aspx?familyid=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en][2] [1]: http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en [2]: http://www.microsoft.com/downloads/details.aspx?familyid=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en
How do I make the jquery dialog work with the themeroller themes?
|javascript|jquery|dialog|
I am trying out the dialog from jquery ui. All the online [demos][1] use flora.css. I can't the dialog to display correctly with the css file generated by the [themeroller][2] application. Am I missing something? shouldn't these things work out of the box? [1]: http://dev.jquery.com/view/trunk/ui/demos/functional/#ui.dialog [2]: http://ui.jquery.com/themeroller
Have you looked at connecting to the server using [unixODBC][1]? If I remember correctly it has support for IBM DB2 and compiles on OpenBSD. Check out [http://www.php.net/odbc][2] for more information regarding the PHP side. If you can't get that to work the option to setup a web service on a Linux server may be all you can do. [1]: http://www.unixodbc.org/ [2]: http://www.php.net/odbc
Embedded Database for .net that can run off a network
|.net|database|embedded|
I was (and still am) looking for an embedded database to be used in a .net (c#) application. The caveat: The Application (or at least the database) is stored on a Network drive, but only used by 1 user at a time. Now, my first idea was [SQL Server Compact edition][1]. That is really nicely integreated, but it can not run off a network. [Firebird][2] seems to have the same issue, but the .net Integration seems to be not really first-class and is largely undocumented. [Blackfish SQL][3] looks interesting, but there is no trial of the .net Version. Pricing is also OK. Any other suggestions of something that works well with .net **and** runs off a network without the need of actually installing a server software? [1]: http://www.microsoft.com/sql/editions/compact/default.mspx [2]: http://www.firebirdsql.org/dotnetfirebird/ [3]: http://www.codegear.com/products/blackfish
[SQLite][1] came to my mind while reading your question, and I'm quite sure that it's possible to access it from a network drive *if* you keep yourself to the constraint of 1 user at a time. [edit:] added some more links to get you started with using SQLite with .NET: [http://www.mikeduncan.com/sqlite-on-dotnet-in-3-mins/][2] [1]: http://www.sqlite.org/ [2]: http://www.mikeduncan.com/sqlite-on-dotnet-in-3-mins/
Check out [VistaDB][1]. They have a very good product, the server version (3.4) is in Beta and is very close to release. [1]: http://www.vistadb.net
Scott Hanselman had a good Podcast about this, entitled "The Past, Present and Future of .NET Unit Testing Frameworks": [Hanselminutes #112][1] [1]: http://www.hanselminutes.com/default.aspx?showID=130
I think NUnit **is** your best bet. With TestDriven.NET, you get great integration within VS.NET. (Resharper also has a unit test runner if you're using it). NUnit it simple to use and follows an established paradigm. You'll also find plenty of projects/tutorials/guides using it which always helps. Your other main choice is probably MBUnit, which is more and more position itself as the BDD framework of choice (in conjunction with Gallio <http://www.gallio.org>).
VFP .NET OLEdb provider does not work in Win 64-Bits. Help
|.net|database|legacy|oledb|provider|visual-foxpro|
I wrote a windows service using VB that read some legacy data from Visual Foxpro Databases to be inserted in SQL 2005. The problem is this use to run fine in Windows server 2003 32-Bits, but the client recently moved to Windows 2003 64-Bits and now the service won't work. I'm getting a message the the VFP .NET OLEdb provider is not found. I researched and everything seems to point out that there is no solution. Any Help, please...
All you'll ever need to know (and then some): <http://msdn.microsoft.com/en-us/library/ms978498.aspx> Oh, and GC.Collect() forces a collect.
Depending on which sub directory of All Users you want, there's a couple different options [defined here][1]. For "All Users/Application Data" you would use System.Environment.GetEnvironmentVariable("%16419%") [1]: http://msdn.microsoft.com/en-us/library/ms933062.aspx
[Major Edit] You'll want to use the system.environment variables. Most of the predefined ones are [shown here][1]. For the "All Users" you would use System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE") [1]: http://msdn.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx
[Major Edit] You'll want to use the system.environment variables. Most of the predefined ones are [shown here][1]. For the "All Users" you would use System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE") I know I got a lot of upmods and a correct answer for my other stuff, but this actually works. where as the other [environment variables][2] I linked to previously don't seem to work with that function call. [1]: http://msdn.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx [2]: http://msdn.microsoft.com/en-us/library/ms933062.aspx
Summary of differences in Regular Expression syntax for various tools and languages?
|regex|grep|
I can never remember the differences in regular expression syntax used by tools like `grep` and `awk`, or languages like Python and PHP. Generally, Perl has the most expansive syntax, but I'm often hamstrung by the limitations of even `egrep` ("extended" `grep`). Anyone know of a site that lists the differences in a concise and easy-to-read fashion?
Try and break your own site before someone else does. Your web site is basically a publicly accessible API that allows access to a database and other backend systems. Test the URLs as if they were any other API. I like to start by cataloging all URLs that have some sort of permenant affect on the state of the system - this is easy if you are doing Ruby on Rails development or trying to follow a RESTful design pattern. For each of those URLs, try running a GET, POST, PUT or DELETE HTTP methods with different parameters so that you can ensure that you're only giving access to what you want to give access to. This of course is in addition to obvious: Functional testing, Load Testing, SQL Injection, XSS etc.
Probably nothing in your example. My understanding is that "javascript:" is for anchor tags (in place of an actual href). You'd use it so that your script can execute when the user clicks the link, but without initiating a navigation back to the page (which a blank href coupled with an onclick will do). For example: <a href="javascript:someFunction();">Blah</a> Rather than: <a href="" onclick="someFunction();">Blah</a>
I find this site helpful: <http://www.regular-expressions.info/> Other than that, I use the corresponding documentation extensively and I believe, all said and done, there's no way around that.
You can use the one built in, `hg view`. I believe you just have to enable it in your `.hgrc`. You'll also need tcl installed. I find it sometimes lags for a few seconds, but overall it's pretty decent.
You can use the one "built in", [`hg view`][1]. You'll need `TCL` installed though. >From the documentation: >>The hgk Tcl script is a direct port of the gitk tool used with git. The hgk.py extension allows hgk to interact with mercurial in a git-like manner. [1]: http://www.selenic.com/mercurial/wiki/index.cgi/HgkExtension
You can use the one "built in", [`hg view`][1]. You'll need `TCL` installed though. >From the documentation: >>The hgk Tcl script is a direct port of the gitk tool used with git. The hgk.py extension allows hgk to interact with mercurial in a git-like manner. _edit_ @ [Matthew][2]: yeah, that's why I linked to the documentation that explains it. You need to enable it in your .hgrc (like the `fetch` command), and TCL --as mentioned. [1]: http://www.selenic.com/mercurial/wiki/index.cgi/HgkExtension [2]: http://stackoverflow.com/questions/30903/good-mercurial-repository-viewer-for-mac#31434
list.sort() It really is that simple :)
How do you unsubscribe from a ubiquity command
|ubiquity|
I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something?
I'm not clear exactly what you're asking, but variables will maintain their value for each iteration of a loop, as long as they're declared outside of the loop itself. For example: int a = 0; while(a < 10) { int b = 0; cout << "a: " << a << " b: " << b << "\n"; a++; b++; } In the above, the value output for b will always be 0, as it's declared inside the loop and is being reinitialized each time, whereas a will maintain its value and get incremented each iteration. If b were an object, rather than an int, its constructor and destructor would get called each iteration.
rix0rrr's answer is correct. However, if you find yourself wanting to do something slightly more complicated, you can pass a function to the sort method telling it how to sort. For example, mylist = ["b", "C", "A"] mylist.sort() print mylist # prints ['A', 'C', 'b'] mylist.sort(key=lambda x: x.lower()) print mylist # prints ['A', 'b', 'C'] The second sorting example shows how to sort a list of strings in alphabetical order, ignoring case.
Jeff Atwood himself described how StackOverflow.com sanitizes user input (in non-language-specific terms) on the Stack Overflow blog: <http://blog.stackoverflow.com/2008/06/safe-html-and-xss/> However, as Justin points out, if you use Django templates or something similar then they probably sanitize your HTML output anyway. SQL injection also shouldn't be a concern. All of Python's database libraries (MySQLdb, cx_Oracle, etc) always sanitize the parameters you pass. These libraries are used by all of Python's object-relational mappers (such as Django models), so you don't need to worry about sanitized there either.
|asp.net|asp.net-mvc|mvc|forms|routing|
> GUI-based command shell seems like an oxymoron to me. Not really? A command shell is just an encapsulated environment in which to execute commands. Why can't they have GUI extensions? We are in the 21st century! :) > Check out http://hotwire-shell.org/ This is along the lines of what I was thinking. It's a shame it uses PyGTK, I'd have preferred PyQT (perhaps a licensing issue?). There look to be some interesting related links from the project as well. > If the idea of piping file sizes into a pie chart interests you, you might try PowerGUI, a GUI layer on [...] PowerGUI looks like a hobby project I've been working on that organises regularly used tasks. It looks like it organises frequent jobs and formats the output for you. The formatting I see as the end result of the data flow. But it would be nice to be able to tinker with data and then continue to use it. > PowerShell as a command shell is very forgiving for new users and is easy to learn. There is an add-on product (it is a commercial product) called PowerGadgets that would let you pipe file sizes into a pie chart or other types of displays PowerGadgets looks very interesting. It would be interesting to have things like system monitors so that you could say, read the CPU usage per second and pipe it into a graph. > Is this for Python in particular, or are you just interested in any command shell that has a GUI interface? Any really, currently, but I like the idea of cross platform, easy to edit, no compiler setup. I use Windows at work and Windows/Linux (Ubuntu)/OSX at home. Python is just an easy solution, and for writing stuff like this is has a lot of libraries already. Thanks for all the links. Keep them coming. :)
All standard ASP.NET postbacks work by calling a __doPostBack javascript method on the page. That function submits the form (ASP.NET only really likes one form per page) which includes some hidden input field in which all the viewstate and other goodness lives. On the face of it I can't see anything in SimpalModal that would screw up your page's form or any of the standard hidden inputs, unless the contents of that modal happened to come from a HTTP GET to an ASP.NET page. That would result in two ASP.NET forms being rendered into one DOM and would would almost certainly screw up the __doPostBack function. Have you considered using the [ASP.NET AJAX ModalPopup control][1]? [1]: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
Use a normalised colour histogram. (Read the section on applications [here](http://en.wikipedia.org/wiki/Color_histogram)), they are commonly used in image retrieval/matching systems and are a standard way of matching images that is very reliable and relatively fast. Essentially a colour histogram will capture the colour distribution of the image. This can then be compared with another image to see if the colour distributions match. This type of matching is pretty resiliant to scaling (once the histogram is normalised), and rotation/shifting/movement etc. Avoid pixel-by-pixel comparisons as if the image is rotated/shifted slightly it may lead to a large difference being reported. The [OpenCV](http://en.wikipedia.org/wiki/OpenCV) library is a great resource for doing this kind of stuff. [Here](http://vast.uccs.edu/~tboult/CS330/NOTES/OpenCVTutorial_II.ppt) is a powerpoint presentation that shows you how to create a histogram using OpenCV.
I am trying out the dialog from jquery ui. All the online [demos][1] use flora.css. I can't the dialog to display correctly with the css file generated by the [themeroller][2] application. Am I missing something? shouldn't these things work out of the box? [1]: http://dev.jquery.com/view/trunk/ui/demos/functional/#ui.dialog [2]: http://ui.jquery.com/themeroller Update: Thanks, Brock. When I cleaned up my code to make a sample, I realized that the HTML in demo.html (that comes with the themeroller.zip) is a little too verbose. All I needed to do was give the dialog div the attribute class="ui-dialog" like this: <div id="SERVICE03_DLG" class="ui-dialog">please enter something<br><br> <label for="something">somthing:</label>&nbsp;<input name="something" id="something" type="text" maxlength="20" size="24"> </div> I'll accept your answer. Thanks for your time.
Tool called Perforator will help you. See following article for details: [Performance Profiling Tools for WPF][1] [1]: http://msdn.microsoft.com/en-us/library/aa969767.aspx
No, you have to install the windows platform SDK. You'll need to download this: http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en **Edit:** @[Michael Stum][1] You need the Server 2008 / Vista / .NET 3.5 SDK version. [1]: http://stackoverflow.com/questions/43766/vsnet-2005-required-on-build-box-with-net-20-c-projects#43770
WPF control performance
|.net|wpf|performance|unit-testing|testing|
What is a good (and preferably simple) way to test the rendering performance of WPF custom controls? I have several complex controls in which rendering performance is highly crucial. I want to be able to make sure that I can have lots of them drawwing out in a designer with a minimal impact on performance.
|.net|performance|wpf|
CGI is great for low-traffic websites, but it has some performance problems for anything else. This is because every time a request comes in, the server starts the CGI application in its own process. This is bad for two reasons: 1) Starting and stopping a process can take time and 2) you can't cache anything in memory. You can go with FastCGI, but I would argue that you'd be better off just writing a straight [WSGI][1] app if you're going to go that route (the way WSGI works really isn't a whole heck of a lot different from CGI). Other than that, your choices are for the most part how much you want the framework to do. You can go with an all singing, all dancing framework like Django or Pylons. Or you can go with a mix-and-match approach (use something like CherryPy for the HTTP stuff, SQLAlchemy for the database stuff, paste for deployment, etc). I should also point out that most frameworks will also let you switch different components out for others, so these two approaches aren't necessarily mutually exclusive. Personally, I dislike frameworks that do too much magic for me and prefer the mix-and-match technique, but I've been told that I'm also completely insane. :) How much web programming experience do you have? If you're a beginner, I say go with Django. If you're more experienced, I say to play around with the different approaches and techniques until you find the right one. [1]: http://www.python.org/dev/peps/pep-0333/
<pre><code>object Enum.Parse(System.Type enumType, string value, bool ignoreCase); </code></pre> So if you had an enum named mood it would look like this: <pre><code> enum Mood { Angry, Happy, Sad } // ... Mood m = (Mood) Enum.Parse(typeof(Mood), "Happy", true); Console.WriteLine("My mood is: {0}", m.ToString());</code></pre>
C# Include Derived Control in Toolbox
|c#|visual-studio|winforms|textbox|
This is in reference to my other question [Auto Clearing Textbox][1]. If I choose to derive a new TextBox control from TextBox instead of implement a user control just containing my Textbox, how would I include that in the toolbox. [1]: http://stackoverflow.com/questions/16110/c-auto-clearing-winform-textbox
Right-click the toolbox, click "Choose Items" from the context menu, browse to your DLL, and select it.
OK, are you sure that is wise? I am picturing two scenarios here: 1. There is a default button on the form, which is "clicked" when enter is pushed". 2. There is no default button, and you want the user to have to press enter, regardless. Both of these raise the same questions: * Is there any validation that is taking place on the text? * Why not create a user control to encapsulate this logic? * If you know the enter button is being pushed and consumed fine, how are you having problems with _TextBoxName.Text = string.Empty_ ? Also, as a polite note, can you please try and break up your question a bit? One big block is a bit of a pain to read..
I use [Analog][1] because it's free, but it is rather dated now (wow, last release was 4 years ago!) and I'm sure it doesn't have as many fancy features as newer ones. [1]: http://analog.cx
If you do take the rsync/filecopy approach with CVS, it is important to only sync the files at a time when there is not an active commit. Otherwise, the repository's lock file will get copied over and you will be unable to checkout/update on the target side until the next sync. This reason alone may make CVS a bad choice. The migration path from CVS to Subversion is pretty smooth and there are tools to import a full CVS repo, with history, into Subversion. Consider Git or Mercurial if you want to get into true distributed versioning, but it sounds like that would be overkill for your "read only" needs.
The Best (and perhaps costliest) way is [Clearcase Multisite](http://www-01.ibm.com/software/awdtools/clearcase/multisite/) But if you are looking for opensource, [Git](http://git.or.cz/) is becoming quickly replacing svn everywhere..
> On the other hand, if there's a way to > move an existing window from one > X-server to another, that might solve > the problem. I think you can use <a href="http://ubuntuforums.org/showthread.php?t=202589">xmove</a> to move windows between two separate x-servers. So if it works, this should at least give you a way to do what you want albeit not as easily as changing the resolution.
C# Auto Clearing Winform Textbox
Visual Studio 2008 has a built in test project type that works in a similar way to NUnit, but obviously has much tighter integration with Visual Studio (can run on every build and shows the results in a similar way to the conversion results page when upgrading solution files), but it is obviously not as mature as NUnit as it's pretty new and I'm not sure about how it handles mocking. But it would be worth looking into when your team moves to VS2008
Another important but subtle difference is in the way procs created with `lambda` and procs created with `Proc.new` handle the `return` statement: - In a `lambda`-created proc, the `return` statement returns only from the proc itself - In a `Proc.new`-created proc, the `return` statement is a little more surprising: it returns control not just from the proc, **but also from the method enclosing the proc!** Here's `lambda`-created proc's `return` in action. It behaves in a way that you probably expect: def whowouldwin mylambda = lambda {return "Freddy"} mylambda.call # mylambda gets called and returns "Freddy", and execution # continues on the next line return "Jason" end whowouldwin => "Jason" Now here's a `Proc.new`-created proc's `return` doing the same thing. You're about to see one of those cases where Ruby breaks the much-vaunted Principle of Least Surprise: def whowouldwin2 myproc = Proc.new {return "Freddy"} myproc.call # myproc gets called and returns "Freddy", # but also returns control from whowhouldwin2! # The line below *never* gets executed. return "Jason" end whowouldwin2 => "Freddy" Thanks to this surprising behaviour (as well as less typing), I tend to favour using `lambda` over `Proc.new` when making procs.
It sounds like you've covered all the server-side bases--maybe it's a client issue? I assume your users have integrated authentication enabled in IE7? (Tools -> Internet Options -> Advanced -> Security). This is enabled by default. Also, is your site correctly recognized by IE7 as being in the Local Intranet zone? The IE7 default is to allow automatic logon only in that zone, so users would be prompted if IE thinks your site is on the internet. I believe using a hostname with a dot in it causes IE to place the site into the Internet zone.
Why not use [SQL Server 2005 Express edition](http://www.microsoft.com/sql/editions/express/default.mspx)? It really depends on what you mean by "embedded" - but you can redistribute SQLServer2005E with your applications and the user never has to know it's there. <http://msdn.microsoft.com/en-us/library/ms165660.aspx> <http://msdn.microsoft.com/en-us/library/bb264562.aspx>
I think: #!/bin/python bar in dict(Foo) Is what you are thinking of. When trying to see if a certain key exists within a dictionary in python (python's version of a hash table) there are two ways to check. First is the **<code>has_key()</code>** method attached to the dictionary and second is the example given above. It will return a boolean value. That should answer your question. And now a little off topic to tie this in to the _list comprehension_ answer previously given (for a bit more clarity). _List Comprehensions_ construct a list from a basic _for loop_ with modifiers. As an example (to clarify slightly), a way to use the <code>in dict</code> language construct in a _list comprehension_: Say you have a two dimensional dictionary **<code>foo</code>** and you only want the second dimension dictionaries which contain the key **<code>bar</code>**. A relatively straightforward way to do so would be to use a _list comprehension_ with a conditional as follows: #!/bin/python baz = dict([(key, value) for key, value in foo if bar in value]) Note the **<code>if bar in value</code>** at the end of the statement**, this is a modifying clause which tells the _list comprehension_ to only keep those key-value pairs which meet the conditional.** In this case **<code>baz</code>** is a new dictionary which contains only the dictionaries from foo which contain bar (Hopefully I didn't miss anything in that code example... you may have to take a look at the list comprehension documentation found in [docs.python.org tutorials](http://docs.python.org/tut/node7.html#SECTION007140000000000000000) and at [secnetix.de](http://www.secnetix.de/olli/Python/list_comprehensions.hawk), both sites are good references if you have questions in the future.).
I beg to differ, there is ALWAYS another way.. And if you really _cannot_ refactor, then you need to break the problem down into smaller parts.. Like I said, establish which dimensions you need to sum, then hit them one at a time.. Also, stop changing the edits, they are correcting your spelling errors, they are trying to help you ;)
When you say you don't know how many dimensions there are, how exactly are you defining the data structures? At some point, someone needs to create this array, and to do that, they need to know the dimensions of the array. You can force the creator to pass in this data along with the array. Unless the question is to define such a data structure... MSN
First off, I think you need to be clearer in your question - what technology are you using and where is this process that is timing out - server-side or client-side? If you want to have the server-side code take a long time and you are using .NET, place this line in the method you call server-side: System.Threading.Thread.Sleep(timeoutMilliseconds); As long as you use a number sufficient so that your client-side code assumes the server has timed out, you should be good.
Find out which process has an exclusive lock on a USB device handle
|c++|winapi|usb|device|
I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver. Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my library (and anything that consumes it) from working with the device. I suppose that's the rub with being an HID-compatible device -- other driver software (mice, controllers, PHIDGETS, etc) can be uncooperative. Anyway, the device file path is of the form: > "\\?\hid#hpqremhiddevice&col01#5&21ff20e7&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". > > "\\?\hid#vid_045e&pid_0023#7&34aa9ece&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". > > "\?\hid#vid_056a&pid_00b0&col01#6&5b05f29&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". And I'm trying to open it using code, like: // First, open it with minimum permissions, this device may not be ours. // we'll re-open it later in read/write hid_device_ref = CreateFile( device_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); I've considered a tool like FileMon or Process Monitor from SysInternals. But I can't seem to get it to report usage on device file handles like the one listed above.
I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver. Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my library (and anything that consumes it) from working with the device. I suppose that's the rub with being an HID-compatible device -- other driver software (mice, controllers, PHIDGETS, etc) can be uncooperative. Anyway, the device file path is of the form: <pre> 1: "\\?\hid#hpqremhiddevice&col01#5&21ff20e7&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 2: "\\?\hid#vid_045e&pid_0023#7&34aa9ece&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 3: "\?\hid#vid_056a&pid_00b0&col01#6&5b05f29&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". </pre> And I'm trying to open it using code, like: // First, open it with minimum permissions, this device may not be ours. // we'll re-open it later in read/write hid_device_ref = CreateFile( device_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); I've considered a tool like FileMon or Process Monitor from SysInternals. But I can't seem to get it to report usage on device file handles like the one listed above.
Jeff Atwood himself described how StackOverflow.com sanitizes user input (in non-language-specific terms) on the Stack Overflow blog: <http://blog.stackoverflow.com/2008/06/safe-html-and-xss/> However, as Justin points out, if you use Django templates or something similar then they probably sanitize your HTML output anyway. SQL injection also shouldn't be a concern. All of Python's database libraries (MySQLdb, cx_Oracle, etc) always sanitize the parameters you pass. These libraries are used by all of Python's object-relational mappers (such as Django models), so you don't need to worry about sanitation there either.
Have you tried using an HTML control instead of the server control? Does it also cause a compilation error? <input type="text" id="TextBox4" runat="server" value="<%=TextFromString%>" />
What are some real life examples of Design Patterns used in software
|design-patterns|
I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world. If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look :) then please list it below.
|design-patterns|
Go to about:ubiquity in Firefox. Under the section "subscribed feeds" there should be an option to unsubscribe to command feeds you no longer desire. Also, if you clear your entire browser history, it will delete all command feeds (this will be fixed by 0.2)
The way to delete commands is to find them in the Subscribed Feeds section of the main help page: 1. ubiq help | about:ubiquity 2. Scroll down to "Subscribed Feeds" in the right hand column 3. Click '[unsubscribe]' for the one you want to delete. 4. Profit!
An ah-ha moment for me for the observer pattern was to realize how closely associated it is with events. Consider a Windows program that needs to acheive loosely communications between two forms. That can easily be accomplished with the observer pattern. The code below shows how Form2 fires an event and any other class registered as an observer get its data. See this link for a great patterns resource: http://sourcemaking.com/design-patterns-and-tips Form1's code: namespace PublishSubscribe { public partial class Form1 : Form { Form2 f2 = new Form2(); public Form1() { InitializeComponent(); f2.PublishData += new PublishDataEventHander( DataReceived ); f2.Show(); } private void DataReceived( object sender, Form2EventArgs e ) { MessageBox.Show( e.OtherData ); } } } Form2's code namespace PublishSubscribe { public delegate void PublishDataEventHander( object sender, Form2EventArgs e ); public partial class Form2 : Form { public event PublishDataEventHander PublishData; public Form2() { InitializeComponent(); } private void button1_Click( object sender, EventArgs e ) { PublishData( this, new Form2EventArgs( "data from form2" ) ); } } public class Form2EventArgs : System.EventArgs { public string OtherData; public Form2EventArgs( string OtherData ) { this.OtherData = OtherData; } } }
DefaultValue for System.Drawing.SystemColors
|c#|user-controls|.net|
I have a line color property in my custom grid control. I want it to default to Drawing.SystemColors.InactiveBorder. I tried: [DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")] public Color LineColor { get; set; } But it doesn't seem to work. How do I do that with the default value attribute?
|c#|.net|winforms|user-controls|
I have implemented Access reports which were 'pretty' enough. The downside is that it takes a **lot** of time and effort, and trial and error to produce the desired output. You can definitely get there, but it requires the patience of a saint.
'method' vs. 'message' vs. 'function' vs. '???'
|language-agnostic|terminology|
I recently asked a question about what I called "method calls". The answer referred to "messages". As a self-taught hobby programmer trying to phrase questions that don't make me look like an idiot, I'm realizing that the terminology that I use reveals a lot about how I learned to program. Is there a distinction between the various terms for methods/messages/etc. in OO programming? Is this a difference that comes from different programming languages using different terminology to describe similar concepts? I seem to remember that in pre-OO languages, a distinction would sometimes be made between "subroutines" and "functions" based on whether a return value was expected, but even then, was this a language-by-language distinction?
What is the replacement of Controller.ReadFromRequest in ASP.NET MVC?
|asp.net-mvc|
I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form?
|asp.net-mvc|.net-3.5|beta|entity-framework-ctp5|
Short answer: draw your system architecture in terms of modules, drawn side-by-side, with each module sliced vertically into layers (e.g. view, model, persistence). Then use a structure like *com.mycompany.myapp.somemodule.somelayer*, e.g. *com.mycompany.myapp.client.view* or *com.mycompany.myapp.server.model*. Using the top level of packages for application *modules*, in the old-fashioned computer-science sense of [modular programming][1], ought to be obvious. However, on most of the projects I have worked on we end up forgetting to do that, and end up with a mess of packages without that top-level structure. This anti-pattern usually shows itself as a package for something like 'listeners' or 'actions' that groups otherwise unrelated classes simply because they happen to implement the same interface. Within a module, or in a small application, use packages for the application layers. Likely packages include things like the following, depending on the architecture: - *com.mycompany.myapp.view* - *com.mycompany.myapp.model* - *com.mycompany.myapp.services* - *com.mycompany.myapp.rules* - *com.mycompany.myapp.persistence* (or 'dao' for data access layer) - *com.mycompany.myapp.util* (beware of this being used as if it were 'misc') Within each of these layers, it is natural to group classes by type if there are a lot. A common anti-pattern here is to unnecessarily introduce too many packages and levels of sub-package so that there are only a few classes in each package. [1]: http://en.wikipedia.org/wiki/Modular*programming
Are you looking to get a list of objects that have a certain attribute? If so, a [list comprehension](http://docs.python.org/tut/node7.html#SECTION007140000000000000000) is the right way to do this. result = [obj for obj in listOfObjs if hasattr(obj, 'attributeName')]
Format string to title case
|language-agnostic|string|format|title-case|
How do I format a string to title case?