instruction
stringlengths
0
30k
When you bind your ServerSocket, specifying localhost should make the TCP/IP stack reject the connection. Even if this isn't working on your system, localhost can't (okay, maybe if someone hacked your TCP/IP stack and the default gateway router) be spoofed, since that address isn't routed through the physical interfac...
Well nobody answer... at the end I end up modifying my original script(the one that created the sqlite2 database in the first place) to create the database directly in sqlite3. I think that a big string processing script(big because mi databases are 800mb and 200mb each) can do the job, but generating the database d...
The EE's here just discovered that a>>-2 is a bit fraught. I nodded and told them it was not natural.
We've been running an application using Hibernate talking to multiple remote MSQL Server instances for a few years now and we also switched to the jTDS driver early on after a few issues with the M$ driver. Since the switch we haven't had any issues at all. However, it's not a complicated application so it doesn't use ...
Checkout CLISP [wiki-link][1] that ie. was used by Paul Graham Direct [link][2] [1]: http://en.wikipedia.org/wiki/CLISP [2]: http://clisp.cons.org/
Playing wave file ends immediatly (C++, Windows)
|c++|windows|waveout|
I've got a following situation. On a machine there is a Fritz ISDN card. There is a process that is responsible for playing a certain wave file on this device's wave out (ISDN connection is made at startup and made persistent). The scenario is easy, whenever needed the process calls waveOutWrite() on the previously ope...
I've got a following situation. On a machine there is a Fritz ISDN card. There is a process that is responsible for playing a certain wave file on this device's wave out (ISDN connection is made at startup and made persistent). The scenario is easy, whenever needed the process calls waveOutWrite() on the previously ope...
Did you try Allegro CL from <http://www.franz.com/>?
The best method I've used for debugging JavaScript in Internet Explorer is through the **Microsoft Script Editor**. The debugger is full featured and very easy to use. The article above teaches how to install the **Microsoft Script Editor** and configure it. [HOW-TO: Debug JavaScript in Internet Explorer][1] f...
Custom Tab Completion (compgen and complete bash builtins) Tab Completion is nice, but being able to apply it to more than just filenames is great. I have used it to create custom functions to expand arguments to commands I use all the time. For example, lets say you often need to add the FQDN as an argument to a ...
If you have java 1.4: I assume the connection timeout (`URLConnection.setConnectTimeout(int timeout)` ) is of no use because you are doing some kind of streaming. ---**Do not kill the thread**--- It may cause unknown problems, open descriptors, etc. Spawn a java.util.TimerTask where you will check if you h...
Is FileStream lazy-loaded in .NET?
|.net|performance|
I have a question about using streams in .NET to load files from disk. I am trying to pinpoint a performance problem and want to be sure it's where I think it is. Dim provider1 As New MD5CryptoServiceProvider Dim stream1 As FileStream stream1 = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare....
I have used [Apache Commons JXPath][1] in a production application. It allows you to apply XPath expressions to graphs of objects in Java. [1]: http://commons.apache.org/jxpath/
SELECT DATABASEPROPERTYEX ('master', 'STATUS') AS 'Status'; Replace 'master' with your database name
Do you generate code? If so, what do you use and what do you generate?
|.net|java|database|code-generation|
I've used MyGeneration, and I love it for generating code that uses Data Access Applicaiton Blocks from Microsoft for my Data Access Layer, and keeping my database concepts in sync with the domain I am modeling. Although, it took a steeper than expected learning curve one weekend to make it productive. I'm wonderin...
Visual Studio Intellisense, c#, no code behind.
|visual-studio|intellisense|c#|
If I open a file in Design View (web form), I get intellisense for my display code, but not my <script> code.. If I open with source code editor I, occasionally, get intellisense within the <script> tags. Anyone know how to get intellisense working all of the time for all of my code? Been living with this one...
|c#|visual-studio|intellisense|
If I open a file in Design View (web form), I get intellisense for my display code, but not my script code.. If I open with source code editor I, occasionally, get intellisense within the script tags. Anyone know how to get intellisense working all of the time for all of my code? Been living with this one for...
Here's an equivalent expression. for(Iterator<String> sit = someList.iterator(); sit.hasNext(); ) { System.out.println(sit.next()); }
It would look something like this. Very crufty. for (Iterator<String> i = someList.iterator(); i.hasNext(); ) System.out.println(i.next()); There is a good writeup on for each in the [Sun documentation.][1] [1]: http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html
How to manually parse a floating point number from a string
|parsing|floating-point|precision|
Of course most languages have library functions for this, but suppose I want to do it myself. Suppose that the float is given like in a C or Java program (except for the 'f' or 'd' suffix), for example "<code>4.2e1</code>", "<code>.42e2</code>" or simply "<code>42</code>". In general, we have the "integer part" befo...
SQL Enterprise manager or SQL Server Management studio have wizard based approaches, and the latter will generate the scripts so you can see how its done. You could also use the BACKUP and RESTORE commands. More detail here: http://msdn.microsoft.com/en-us/library/ms189826.aspx
Remoting in .NET Framework 2.0 provides the **IPC channel** for inter-process communication within the same machine.
If you can get DTS or Integration Services to connect to both servers, you can use the wizards to 'copy objects' from one server to another. 'Copy Database' requires that the two servers can authenticate with each other, which typically means being on the same domain and that the service runs under a domain logon. O...
Out-of-the-box, without special modifiers, most regex implementations don't go beyond the end-of-line to match text. You probably should look in the documentation of the regex engine you're using for such modifier. I have one other advice: beware of greed! Traditionally, regex **are** greedy which means that your re...
**Second edit.** Wait, how do you want to catch `<div>`s if your regex string specifies `<span>`s? Is it a typo? Out-of-the-box, without special modifiers, most regex implementations don't go beyond the end-of-line to match text. You probably should look in the documentation of the regex engine you're using for such...
Out-of-the-box, without special modifiers, most regex implementations don't go beyond the end-of-line to match text. You probably should look in the documentation of the regex engine you're using for such modifier. I have one other advice: beware of greed! Traditionally, regex **are** greedy which means that your re...
You can also check out how [DotNetNuke](http://www.dotnetnuke.com/) does this
You can build MFC apps if you download the libraires in the platform SDK. But there is no built in support for designing dialogs
How to properly handle exceptions when performing file io
|c#|.net|file-io|exception-handling|
|sql|linq|linq-to-sql|code-reuse|
Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following: var people = from p in Person where p.age < 18 select p var otherPeople = from p in people where p.firstName equals "Daniel" ...
i've only heard of it as short circuit. in a pipeline doesnt the next op that goes in depend on the outcome of the if statement? if that is the case this would more optimized so it wouldnt have to test two values every time.
Short-circuit, or minimal evaluation is just syntactic sugar for nested ifs. To assume it is inefficient, or causes stalls is a case of premature optimization. At this point, most compilers are intelligent enough to correctly interpret and optimize these statements. Using these statements can greatly reduce nesting, ...
I have no experience with python, but an algorithm would be to sort the list, then remove duplicates (by comparing to previous items in the list), and finally find the position in the new list by comparing with the old list. Longer answer: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript that will allow you do to that without just looping in "wait" until the time has passed. You could certainly do that but you risk seriously degrading the browser performance and if your timeout is l...
You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript that will allow you do to that without just looping in "wait" until the time has passed. You could certainly do that but you risk seriously degrading the browser performance and if your timeout is l...
The message-level encryption is needed when you do not control an intermediary. Intermediary services need to be able to modify the soap headers and could peek at your sensitive data for malicious purposes. But if you control everything from initial sender to ultimate receiver, then you do not need encryption at that l...
I need to dig up the link, but if the user is using IE, with common software titles installed, determining which ones are installed is possible.
The earliest implementation of interfaces that I know of in computing came from CORBA. My understanding is that the concept came out of electrical and electronic engineering where a power outlet in a wall for instance can be used (and implemented) by anyone who knows the specification. Interfaces then provide the...
In general terms, as long as you're dealing with point to point connections, and certificates are being validated on both sides (particularly if you're using mutual authentication), then yes, transport level security might be enough. Checking the certificates is useful to ensure that someone doesn't supplant the server...
Having trouble achieving 1Gbit UDP throughput
|sockets|networking|udp|
For UDP packets with a payload less then 1470, is it possible to achieve 1Gbit throughput? Due to the small packet size, there should be some bottlenecks in achieving such throughput (I/O, OS, network, etc.). I imagine drivers and hardware might have to be tuned to small packet/high throughput. Has anybody attempted su...
This registry key should tell you: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA 1 enabled / 0 or missing disabled But that assumes you have the rights to read it. Programmatically you can try to read the user's token and guess if it's an admin running with UAC enabled (see [he...
This registry key should tell you: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System Value EnableLUA (DWORD) 1 enabled / 0 or missing disabled But that assumes you have the rights to read it. Programmatically you can try to read the user's token and guess if it's an admin running with UAC e...
Use an existing implementation, as this area of work is the realm of domain experts and PhDs (if you want it done right!) For example there is a library of code here: http://www.cl.cam.ac.uk/research/srg/netos/lock-free/
Usually CFGs are computed on a lower-level representation (e.g. JVM bytecode). Someone did [a thesis][1] on such things a few years ago. There might be a helpful way described in there for how to get at that representation. Since your source and target languages are the same, there's no code generation step -- you...
I have used CodeSmith. Was pretty helpful.
By default, yes. However, it can be changed via the pack() #pragma. I don't believe the C++ Standard make any requirement in this regard, and leaves it up to the implementation.
I've done work with CSLA and used codesmith to generate my code using the CSLA templates. codesmithtools.com
Unfortunately, this is one of the many misnomers in the framework, or at best a violation of SRP. <br> To use the DateTimePicker for times, set the Format property to either Time or Custom (Use Custom if you want to control the format of the time using the CustomFormat property). Then set the ShowUpDown property t...
It is common to compress data before encrypting. Compressing it afterwards doesn't work, because AES encrypted data appears random (as for any good cipher, apart from any headers and whatnot). However, compression can introduce side-channel attacks in some contexts, so you must analyse your own use. Such attacks hav...
Often I find myself interacting with files in some way but after writing the code I'm always uncertain how rubust it actually is. The problem is that I'm not entirely sure how file related operations can fail and, therefore, the best way to handle expections. The simple solution would seem to be just to catch any IO...
How do I protect my file data from disk corruption?
|filesystems|storage|data|
Recently, I read an article entitled ["SATA vs. SCSI reliability"][1]. It mostly discusses the very high rate bit flipping in consumer SATA drives and concludes "A 56% chance that you can't read all the data from a particular disk now". Even Raid-5 can't save us as it must be constantly scanned for problems and if a di...
|filesystems|data|storage|
Recently, I read an article entitled ["SATA vs. SCSI reliability"][1]. It mostly discusses the very high rate bit flipping in consumer SATA drives and concludes "A 56% chance that you can't read all the data from a particular disk now". Even Raid-5 can't save us as it must be constantly scanned for problems and if a di...
You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript that will allow you do to that without just looping in "wait" until the time has passed. You could certainly do that but you risk seriously degrading the browser performance and if your timeout is l...
Taken from [http://www.peterbe.com/plog/uniqifiers-benchmark][1] def f5(seq, idfun=None): # order preserving if idfun is None: def idfun(x): return x seen = {} result = [] for item in seq: marker = idfun(item) # in old P...
Difference between Convert.ToDecimal(string) & Decimal.Parse(string)
|c#|.net|
What is the difference in C# between Convert.ToDecimal(string) & Decimal.Parse(string)? In what scenarios would you use one over the other? What impact does it have on performance? What other factors should I be taking into consideration when choosing between the two?
A single thread is sequential so if you have two ifs the first will of course be evaluated before the second, so I can't see a difference on that. I use the conditional-AND operator (which is what && is called afaik) much more than nested ifs. If I want to check something that may take a while to evaluate, I do the sim...
Here's what i do: 1. Only maintain in source control your ant build script and associated classpath. Classpath could either be explicit in the ant script, a property file or managed by ivy. 2. write an ant target to generate the Eclipse .classpath file from the ant classpath 3. Netbeans will use your build scri...
One other thing to note, if you updated a legacy app that had structs to use classes you might run into the following issue: Old code has structs, code was cleaned up and these changed to classes. A virtual function or two was then added to the new updated class. When virtual functions are in classes then inter...
Views are essentially logical table-like structures populated on the fly by a given query. The results of a view query are not stored anywhere on disk and the view is recreated every time the query is executed. Materialized views are actual structures stored within the database and written to disk. They are updated ...
You can use the program Caffeine [caffiene][1] to keep your workstation awake. You could run the program via the open command in os X. [1]: http://lightheadsw.com/caffeine/
Have a look at [Net::Stomp::Receipt][1]. It's a subclass of Net::Stomp that implements "return receipts" from the Stomp protocol, and allow you to make sure the correct reception of your message, and abort the transaction otherwise. [1]: http://search.cpan.org/~huguei/Net-Stomp-Receipt-0.34/lib/Net/Stomp/Receipt...
Well, you can certainly set the Format to Custom and then specify the format by doing something such as: dateTimePicker1.CustomFormat = "MM dd yyyy hh mm ss"; or however you want to lay it out. You could then type in directly the date/time. If you use MMM, you'll need to use the numeric value for the month for ...
I have used LLBLGen and nHibernate successfully to generate Entity and DAL layers.
Control-Shift-Space (and the completion is based on type, not name) For more goodness: Help -> Default Keymap Reference
If your database is your model, [SubSonic][1] has an excellent code generator that as of v2.1, no longer requires ActiveRecord (you can use the Repository Pattern instead). It's less flexible than others, but there are customizations that can be made in the stock templates. [1]: http://subsonicproject.com
I love to use [SubSonic][1]. Open source is the way to go with code generation I think because it is very easy to modify the templates and the core as they always tend to have bugs or one or two things you want to do that is not built in. [1]: http://www.codeplex.com/subsonic
I've used code generation for swizzle functions in a vector math library. I used a custom PERL script for it. None of the FLOSS generators I looked at seemed well-suited to creating swizzle functions I generally use C++ templates, rather than code generation.
Yes, all types are always aligned to at least their alignment requirements. How could it be otherwise? But note that the sizeof() a type is not the same as it's alignment.
I'm using this application to test the regex: http://www.regular-expressions.info/dotnetexample.html I have tested it against some fairly good data and it seems to be pulling out only the commented section.
Maybe inserting Logging in a transparent way would rather belong in the Aspect Oriented Programming idiom. But we're talking OO design here... The Singleton pattern may be the most useful, in my opinion: you can access the Logging service from any context through a public, static method of a LoggingService class. ...
If you are doing anything in Unix/Linux/MacOS etc, you must read Advanced Programming in the Unix Environment (also known by the acronym APUE), by the late W Richard Stevens. If you don't know how file descriptors work or what sessions are, or all the things you should do when you daemonize yourself (admit it, you don'...
It is a possible security risk, it has a different scope of execution, and is quite inefficient, as it creates an entirely new scripting environment for the execution of the code. See here for some more info: http://userjs.org/help/tutorials/efficient-code#evalevil It is quite useful, though, and used with moderatio...
Use an interface `IPerson` and a nested class: public class Creator { private class Person : IPerson { public string Name { get; set; } } public IPerson Create(...) ... public void Modify(IPerson person, ...) { Per...
Sometimes it can make your code more tightly coupled with the singleton class being refrerenced directly by name from different parts of your codebase. So, for example, when you need to test some part of your code and it references a singleton from a diferent part of code you cannot easily fake that dependency with a m...
Sometimes it can make your code more tightly coupled with the singleton class being refrerenced directly by name from different parts of your codebase. So, for example, when you need to test some part of your code and it references a singleton from a diferent part of the code you cannot easily fake that dependency with...
What are the strengths of the various database searching mechanisms with Lucene?
>>> def unique(list): ... y = [] ... for x in list: ... if x not in y: ... y.append(x) ... return y
From [bytes.com][1]: > The Convert class is designed to > convert a wide range of Types, so you > can convert more types to Decimal than > you can with Decimal.Parse, which can > only deal with String. On the other > hand Decimal.Parse allows you to > specify a NumberStyle. > > Decimal and decimal are alias...
the issue is the combination of Expectation usage and that Matchers does not support primitive type. The Matchers code rely on Generic which basically does not support primitive type. Typically the usage of Matchers is more for matching value; with the auto-boxing/unboxing feater in Java 5, this is usually not a pro...
Java jdb remote debugging command line tool