instruction
stringlengths
0
30k
I'd use http and start with understanding what the Python [library](http://docs.python.org/lib/asyncore-example.html) offers. Then I'd move onto the more industrial strength [Twisted](http://wiki.python.org/moin/Twisted-Examples) library.
Windows Home Server. My dev box has two drives with about 750GB of data between them (C: is a 300GB SAS 15K RPM drive with apps and system on it, D: is a mirrored 1TB set with all my enlistments). I use Windows Home Server to back this machine up and have successfully restored it several times after horking it.
Be careful when dealing with a merge table however. It has been my experience that although a single join can be good in most situations, when merge tables are involved you can run into strange situations.
I've always liked doing it this way result = { 'a': lambda x: x * 5, 'b': lambda x: x + 7, 'c': lambda x: x - 2 }[value](x) [From here](http://simonwillison.net/2004/May/7/switch/)
"By default, your pages should be placed in the "C:\Program Files\Apache Group\Apache2\htdocs" folder for Apache 2.0 and the "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" folder for Apache 2.2. When your site is ready, simply delete the existing files in the folder and replace them with those you want ...
The languages of choice of Firefox is Javascript. Unless you have a specific requirement that requires Python, I would advice you to use that.
You could try [selenium][1]. [1]: http://selenium.openqa.org/
I'm not aware of a tool, but you could write a Visual Studio extension to list the contents without too much work. If you download the [Visual Studio SDK](http://msdn.microsoft.com/en-us/vsx/default.aspx), it has some straightforward examples that you can use. Find one that looks appropriate (like maybe the Toolwin...
How to animate the command line?
|command-line|
I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this: > [======>                 &...
From MSDN forum [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120476&SiteID=1][1] [1]: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120476&SiteID=1
If you are really just returning a predetermined, fixed value, you could create a dictionary with all possible input indexes and the keys, along with their corresponding values. Also, you might not really want a function to do this - unless you're computing the return value somehow. Oh, and if you feel like doing so...
This has already been covered but I'm unsure how to link to it. Here is the code snippit: public static string Ordinal(this int number) { var ones = number % 10; var tens = Math.Floor (number / 10f) % 10; if (tens == 1) { return number + "th"; } switch (number % 10) { ...
Let's assume a list with the structure A -> B -> C -> D If you only had a pointer to B and wanted to delete it, you could do something like tempList = B->next; *B = *tempList; free(tempList); The list would then look like A -> B -> D but B would hold the old contents of C, effectively de...
I would recommend either NHibernate or Entity Framework. For large sites, I'd use ADO.NET Data Services. I wouldn't do anything large with LINQ to SQL. I think Stack Overflow might end up with some interesting scale problems being 2-tier rather than 3-tier, and they'll also have some trouble refactoring as the physical...
How do I query the CrystalReports CMS database?
|encryption|crystal-reports|business-objects|
Is it possible to query the Crystal CMS database and get meaningful data back? The data appears to be encrypted. I am running Business Objects Crystal Report Server version 11.5
While it shouldn't be necessary, you could try bas64 encoding data in and decoding it out. That means the db will just have ascii characters. It will take a bit more space and time, but any issue to do with the binary data will be eliminated
Another crucial difference between debug and release is how local variables are stored. Conceptually local variables are allocated storage in a functions stack frame. The symbol file generated by the compiler tells the debugger the offset of the variable in the stack frame, so the debugger can show it to you. The de...
There are a couple of things you can look at to optimize your query performance. 1. Ensure that you just have the minimum of data. Make sure you select only the columns you need. Reduce field sizes to a minimum. 2. Consider de-normalising your database to reduce joins 3. Avoid loops (i.e. fetch cursors), stick...
There are a couple of things you can look at to optimize your query performance. 1. Ensure that you just have the minimum of data. Make sure you select only the columns you need. Reduce field sizes to a minimum. 2. Consider de-normalising your database to reduce joins 3. Avoid loops (i.e. fetch cursors), st...
There are a couple of things you can look at to optimize your query performance. 1. Ensure that you just have the minimum of data. Make sure you select only the columns you need. Reduce field sizes to a minimum. 2. Consider de-normalising your database to reduce joins 3. Avoid loops (i.e. fetch cu...
I'll assume you know the difference between a List, Set and Map. Why you would choose between their implementing classes is another thing. For example: **List**: 1. **ArrayList** is quick on retrieving, but slow on inserting. It's good for an implementation that reads a lot but doesn't insert a lot. It keeps its...
I'll assume you know the difference between a List, Set and Map. Why you would choose between their implementing classes is another thing. For example: **List**: 1. **ArrayList** is quick on retrieving, but slow on inserting. It's good for an implementation that reads a lot but doesn't insert a lot. It keeps its...
I'll assume you know the difference between a List, Set and Map from the above answers. Why you would choose between their implementing classes is another thing. For example: **List**: 1. **ArrayList** is quick on retrieving, but slow on inserting. It's good for an implementation that reads a lot but doesn't ins...
James Bennett has a wonderful [set of slides][1] on how to organized reusable apps. [1]: http://www.b-list.org/weblog/2008/mar/15/slides/
You should have the native wrapper written in Objective C. This wrapper could contain really few lines of code (like, 10) necessary to create a WebView and navigate it to the given address in the internet (where your application resides). But in this case your application should be a full-featured web application (I me...
VBA is messy. I'm not sure there is an easy way to do fake overloads: In the past I've either used lots of Optionals, or used varied functions. For instance Foo_DescriptiveName1() Foo_DescriptiveName2() I'd say go with Optional arguments that have sensible defaults unless the argument list is g...
I think auto-generating empty Javadoc is an anti-pattern and should be discouraged; it gives code the appearance of being documented, but just adds noise to the codebase. I would recommend instead that you configure your code editor to assist on a per-method and per-class basis to use when you actually write the j...
I ran into this same problem. I already have a game written entirely in Javascript. I would love to make an iPhone friendly version, but Obj-C is an overkill. What I ended up doing was using the WebView to point to a special url of the iphone app. After thinking about it, I suppose I could just move those files to the ...
How about opening a file based on ARGV[0]? readfile.rb: $<.each_line{|l| puts l} ruby readfile.rb testfile.txt It's a great shortcut for writing one-off scripts. There's a whole mess of pre-defined variables that most people don't know about. Use them wisely (read: don't litter a code base you plan to mai...
I often write lisp shell scripts which start with this line: \#!/usr/bin/clisp Then you don't even need to type "lispinterpret" on the command-line. Just mark the script executable and run it directly.
There is a C# tutorial for reading posts using NNTP [here][1]. It should be enough to get you started but if you wish to start getting into processing binary posts, you're probably going to have to deal with some mime-type content too. I don't think this article covers that. [1]: http://www.geekpedia.com/tutor...
What is the best way to make a .net client consume service from a Java server ?
|java|c#|interop|
I have a user interface in .net which needs to receive data from a server, on a request/reply/update model. The only constraint is to use Java only on the server box. What is the best approach to achieve this ? Is it by creating a Webservice in Java and then accessing it in .net, or should I create Java proxies and ...
For Qt on Windows you can create DLLs for every subproject you want. No problem with using them from the main project (exe) after that. You'll have to take care of dependencies but it's not very difficult.
There seems to be some sort of bug in Delphi. Read this post, the last comment links to other bug-reports that may be the one that you have got: <http://qc.codegear.com/wc/qcmain.aspx?d=8144>
Are you sure you have done everything to solve the warning? Maybe you could post the code for us to look at? You can turn off the warning locally this way: {$WARN NO_RETVAL OFF} function func(...): string; begin ... end; {$WARN NO_RETVAL ON}
Yes, you can edit your main project (.pro) file to include your sub project's project file. [See here](http://doc.trolltech.com/4.1/qmake-project-files.html)
Never assume that a trivial 2 line method will work. Writing a quick unit test is the only way to prevent the missing null test, misplaced minus sign and/or subtle scoping error from biting you, inevitably when you have even less time to deal with it than now.
"Vision impaired" includes colour-blindness. I used to work with someone who couldn't distinguish red from green too well, so any applications that used a traffic-light style interface was very difficult for him to use. In the industry we were working in, alerts in rows were colour-coded, so another form of display w...
The code for many web pages is structured as: 1. Header 2. Top Navigation 3. Left Navigation 4. Content 5. Footer When structured this way, then the hidden link for "Skip to Main Content" is beneficial. However, with CSS layout, you may be able to reorder this so that you have: 1. Content 2. Header...
Try using a BindingSource object in between the datasource and the datasource property of the listbox. Then refresh that.
Use the datasource property and a BindingSource object in between the datasource and the datasource property of the listbox. Then refresh that. **update** added example. Like so: Public Class Form1 Private datasource As New List(Of NumberInfo) Private bindingSource As New BindingSou...
It is difficult to provide a good answer without knowing anything about your product and customers. For enterprise software sold to technical people you can use a fairly complex licensing system and they'll figure it out. For consumer software sold to the barely computer-literate, you need a much simpler system. In ...
You can try to use [clock()][1] which will provide the number of "ticks" between two points. A "tick" is the smallest unit of time a processor can measure. As a side note, you can't use clock() to determine the actual time - only the number of ticks between two points in your program. [1]: http://www.cplusplu...
We keep it simple: store every license data to an XML (easy to read and manage), create a hash of the whole XML and then crypt it with a utility (also own and simple). This is also far from perfect, but it can hold for some time.
Shouldn't the onmouseover event be on the image div and the onmouseout event be on the text div?
select * from myTable limit 10
Blatantly changing my answer. "Limit 10" works for MySql and others, Ingres uses Select First 10 * from myTable [Ref][1] [1]: http://docs.ingres.com/sqlref/Selectinteractive
*Programming Windows Security* by Keith Brown includes a thorough discussion of DCOM security. I can highly recommend this book.
GetLocalTime() API time resolution
|profile|
I need to find out time taken by a function in my application. Application is a MS VIsual Studio 2005 solution, all C code. I used thw windows API GetLocalTime(SYSTEMTIME *) to get the current system time before and after the function call which i want to measure time of. But this has shortcoming that it lowest re...
|c|profile|
I need to find out time taken by a function in my application. Application is a MS VIsual Studio 2005 solution, all C code. I used thw windows API GetLocalTime(SYSTEMTIME *) to get the current system time before and after the function call which I want to measure time of. But this has shortcoming that it lowest re...
I have an MVC controller with RequestMapping annotations. One method has a parameter of type UUID. Thanks toolkit, after reading about [WebDataBinder][1], I figured that I need a method like this in my controller: @InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEdit...
You could always implement IXmlSerializer and perform the serialization manually. See http://www.codeproject.com/KB/cs/IXmlSerializable.aspx for an example.
Biggest differences of Thrift vs Protocol Buffers?
|google|erlang|buffers|protocol|thrift|
What are the biggest pro/con's of both
personaly, i'm using exceptions to handle validation. it requires following steps: 1. in your data binding expression, you need to add "ValidatesOnException=True" 2. in you data object you are binding to, you need to add DependencyPropertyChanged handler where you check if new value fulfills your conditions - if not ...
The expectation is for the debug version to be - debugged! Setting breakpoints, single-stepping while watching variables, stack traces, and everything else you do in a debugger (IDE or otherwise) make sense if every line of non-empty, non-comment source code matches some machine code instruction. Most optimizati...
You have the head of the list, right? You just traverse it. Let's say that your list is pointed to by "head" and the node to delete it "del". C style pseudo-code (dots would be -> in C): prev = head next = prev.link while(next != null) { if(next == del) { prev.l...
I don't have a complete answer at this time, but look into Bindings. It's generally possible to do all sorts of things with Cocoa Bindings. There's no Visibility binding for NSTableColumn, but you may be able to set the width to 0. Then you can bind it to the Null Placeholder, and set this value to 0 - but don't...
|.net|java|interop|
Sending mail from Python using SMTP
|python|smtp|
I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ? from smtplib import SMTP import datetime debuglevel = 0 smtp = SMTP() smtp.set_debuglevel(debuglevel) smtp.connect('YOUR.MAIL.SERVER', 26) smtp.lo...
There not way to do this with the current apple API's. Your closest bet is to write a simple native iPhone app that embeds the webkit browser. That will let you browse your xhtml/js application locally. If you want to store data, you'll need to take it a step further and include a light weight http server that serve...
I think the biggest problem for me is the HUGE loss of time it takes "getting in to it". I am still very much at the beginning of my journey with TDD (See my [blog][1] for updates my testing adventures if you are interested) and I have literally spent **hours** getting started. It takes a long time to get your brain...
I think the biggest problem for me is the HUGE loss of time it takes "getting in to it". I am still very much at the beginning of my journey with TDD (See my [blog][1] for updates my testing adventures if you are interested) and I have literally spent **hours** getting started. It takes a long time to get your brain...
Scheduled Task Cmdlet
|powershell|schedule|
Does anyone know of a powershell cmdlet out there for automating task scheduler?
Does anyone know of a powershell cmdlet out there for automating task scheduler in XP/2003? If you've ever tried to work w/ schtasks you know it's pretty painful.
Windows 2003 Scheduled Task Cmdlet (v 1.0)
I've used something like this to preload an image and then automatically call back to my javascript when the image is finished loading. You want to check complete before you setup the callback because the image may already be cached and it may not call your callback. function PreloadImage(imgSrc, callback){ ...
What does the PDB get me while debugging and how do I know it's working?
|.net|debugging|pdb|
I have to use a third-party component without source code. I have the release DLL and release PDB file. Let's call it 'CorporateComponent.dll'. My own code creates objects from this DLL and calls methods on these objects. CorpObject o = new CorpObject(); Int32 result = o.DoSomethingLousy(); While debuggi...
Apple defines the user agent [here][1]. [1]: http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/chapter_3_section_3.html
Apple defines the user agent [here][1]. This field is transmitted in the HTTP headers under the key "User-Agent" [1]: http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/chapter_3_section_3.html
You could show a static image that gives the [optical illusion of a spinny-wheel, like these][1]. [1]: http://www.ritsumei.ac.jp/~akitaoka/saishin-e.html
The PDB is a database file that maps the instructions to their line numbers in the original code so when you get a stack trace you'll get the line numbers for the code. If it's an unmanaged DLL then the PDB file will also give you the names of the functions in the stack trace, whereas that information is usually only a...
You can use one of the builtin validators with a regex that counts the words. I'm a little rusty with regex so go easy on me: (\b.*\b){0,10}
And if you can't use source level debugging with the .Net framework source code Microsoft supplied, you could try a different debugger. Like mdbg or even windbg.
And if you can't use source level debugging with the .Net framework source code Microsoft supplied, you could try a different debugger. Like mdbg or even windbg. **edit** [This][1] explains getting the released parts of .Net framework and how to set breakpoints in great detail. The NetMassDownloader will give you...
If you know which block threw the exceptioon, can you put more specific handlers in the catch block to try and isolate it that way? Are you throwing an exception that you rolled yourself? Edit: I forgot to point you towards [this article][1] on Visual C++ exceptions which I've found to be quite useful. Rob ...
Several of the extension methods got moved to Microsoft.Web.Mvc, which is the MVC Futures DLL. You might want to look there for things that have gone missing.
Because you're reviewing a crash dump I'll assume it came in from a customer and you cannot easily reproduce the fault with more instrumentation. I don't have much help to offer save to note that the exception code 0x64487347 is ASCII "dShG", and developers often use the initials of the routine or fault condition wh...
How to disable a warning in Delphi about "return value ... might be undefined"?
|delphi|warning|directive|
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is: Result := ''; and there is ...
|delphi|warnings|directive|
All the answers saying to use floats (with explicit widths) are correct. But to answer the original question, what is the best way to position a `<div>`? It depends. CSS is highly contextual, and the flow of a page is dependent on the structure of your HTML. Normal flow is how elements, and their children, will layo...
If you are really just returning a predetermined, fixed value, you could create a dictionary with all possible input indexes as the keys, along with their corresponding values. Also, you might not really want a function to do this - unless you're computing the return value somehow. Oh, and if you feel like doing som...