instruction stringlengths 0 30k ⌀ |
|---|
For storing passwords you could do a two step encryption routine, first with a hardcoded key in your script itself, and optionally a 2nd time with a key stored in a file (which is set using file permissons to have restricted access).
In a given situation you can then either use a key file (+ key from script), or if... |
QTopia is indeed a good option; others are <a href="http://www.directfb.org/">DirectFB</a>, and of course X11 generally running <a href="http://matchbox-project.org/">Matchbox</a>.
|
You could ignore the decimal when parsing (except for its location). Say the input was:
156.7834e10... This could easily be parsed into the integer 1567834 followed by e10, which you'd then modify to e6, since the decimal was 4 digits from the end of the "numeral" portion of the float.
Precision is an issue. You... |
Every time I come across a file I generally do not want in the repository, I update the pattern. I believe there is no "best" pattern - it always **depends on the language and environment** you develop in.
Moreover, you're not very likely to think of all the possible "ignorable" filetypes - you'll always encounter ... |
In theory the GC shouldn't run if your CPU is under heavy load or unless it really needs to. But if you have to, you may want to just keep all of your objects in memory, perhaps a singleton instance, and never clean them up unless you're ready. That's probably the only way to guarantee when the GC runs. |
Mac users probably want to throw in .DS_Store. In addition, if there are dev's using Emacs or Vim, you probably want to add ~*~ and #*#. |
For a very simple system, create an interface which defines methods like GetSaveText(), etc. and allow assemblies like this to be plugged in to your application. |
I'd have another anectode on test coverage I'd like to share.
We have a huge project wherein, over twitter, I noted that, [with 700 unit tests, we only have 20% code coverage][1].
[Scott Hanselman][2] replied with [words of wisdom][3]:
> Is it the RIGHT 20%? Is it the 20%
> that represents the code your use... |
Enforce unique rows in MySQL |
|mysql|indexing| |
I have a table in MySQL that has 3 fields and I want to enforce uniqueness among two of the fields. Here is the table DDL:
CREATE TABLE `CLIENT_NAMES` (
`ID` int(11) NOT NULL auto_increment,
`CLIENT_NAME` varchar(500) NOT NULL,
`OWNER_ID` int(11) NOT NULL,
PRIMARY KEY (`ID`),
) ENGINE=InnoDB DEFAU... |
Having one .MSI package launch another .MSI package from "within" itself is called a *nested install*, and it's [bad juju][1] (see Rule 20). Windows Installer has some global data that it uses to manage the current install, and it doesn't handle well multiple installs at the same time. For the same reason, if you start... |
first, you forgot your trailing commas in your data array items.
try the following:
<pre><code>var obj_hash = {
"hdrs": ["Make","Model","Year"],
"data" : [
{"Make":"Honda","Model":"Accord","Year":"2008"},
{"Make":"Toyota","Model":"Corolla","Year":"2008"},
{"Make":"Honda","Model":"Pilot","Year":"2008"... |
But why don't you create an object member function? It can certainly not be called on a Null reference, so you're sure the first argument is not Null.
Indeed, you lose the symmetricity of a binary operator, but still...
(note on Purfideas' answer: Null might equal Null if needed as a sentinel value of an array... |
Create one table for lists and one table for list_options.
# Put in the name of the list
insert into lists (id, name) values (1, "Country in North America");
# Put in the values of the list
insert into list_options (id, list_id, value_text) values
(1, 1, "Canada"),
(2, 1, "Un... |
You may want to use XSLT to transfer your XML into SQL statements... ie
<xml type="user">
<data>1</data>
<data>2</data>
<xml>
Then the XSLT would look like
<xsl:template match="xml">
INSERT INTO <xsl:value-of select="@type" /> (data1, data2) VALUES (
'<xsl:va... |
It greatly reduces your level of confidence about security. |
Please help me name my class. |
|naming| |
I'm designing a web site navigation hierarchy. It's a tree of nodes. Nodes represent web pages.
Some nodes on the tree are special. I need a name for them.
There are multiple such nodes. Each is the "root" of a sub-tree with pages that have a distinct logo, style sheet, or layout. Think of different departments... |
|naming|class-naming|class-design| |
This is the simplest code I've got for doing a background HTTP post in ASP
Set objXML = CreateObject("MSXML2.ServerXMLHTTP.6.0")
objXML.open "POST", url, false
objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objXML.send("key="& Server.URLEncode(xmlvalue))
Set respo... |
While not as clever as the Rails unit test framework in one of the other answers here, creating distinct data per test or group of tests is another way of doing it. The level of tediousness with this solution depends on the number of test cases you have and how dependant they are on one another. The tediousness will ... |
This depends what you mean by network - if you're copying on a local network you can just use the file copy operations inside System.IO. If you're wanting to send to remote servers I do this using web services. I compress byte arrays and send them over and decompress on the remote side. The byte array is super easy to ... |
What is 'Currying'? |
|computer-science|terms|functional-programming| |
I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!) |
|computer-science|programming-terms|functional-programming| |
|functional-programming|glossary|computer-science|programming-terms| |
|functional-programming|computer-science|glossary|definition|programming-terms| |
Reflection is not appropriate for this.
You'll have to put up with remembering to get it right.
Fortunately FxCop (or Team System Code Analysis) will help you by pointing out any mismatches.
|
I would try cleaning the bin\ folder.
In any case our shop completely dropped websites in favour of web form applications, which are arguably far better.
|
I would try cleaning the bin\ folder.
In any case our shop completely dropped websites in favour of web form applications, which are arguably far better.
EDIT: [Migration HOW TO here][1]
[1]: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx |
Actually your example outputs:
foo {0}
For you to output foo {1, 2, 3} you have to do something like:
string t = "1, 2, 3";
string v = String.Format(" foo {{{0}}}", t); ;
To put a { you use {{ and to put a } you use }}. |
You have a couple of options:
1. Use a cursor and a recursive user-defined function call (it's quite slow)
1. Create a cache table, update it on INSERT using a trigger (it's the fastest solution but could be problematic if you have lots of updates to the main table)
1. Do a client-side recursive calculation (prefe... |
Do you have the Team Foundation Client installed?
If you have the Team Version it should be residing in the TFC folder on your installation DVD. (I don't know why it isn't an option in the installer)
It is also possible to download the TFC from Microsoft (for free), there is an SP1 version on Microsoft Downloads. |
You might want to try Visual Studio 2008 and its feature to debug javascript.
If the problem is not specific to IE7 but also occurs in Firefox, then another good way to debug javascript is Firefox and the FireBug add-on which has a javascript debugger. Then you can also put console.log statements in the javascript ... |
How to represent date and/or time information in JSON? |
|json|data-formats| |
JSON text ([RFC 4627][1]) has unambigious representation of objects, arrays, strings, numbers, Boolean values (literally `true` or `false`) and `null`. However, it has nothing defined for representing time information like date and time of day, which is very common in applications. What are the current methods in use t... |
I agree that you should normalise as much as possible and only denormalise if absolutely necessary for performance. And with materialised views or caching schemes this is often not necessary.
The thing to bare in mind is that by normalising your model you are giving the database more information on how to constrain ... |
If it is absolutely time critical then you should use a deterministic platform like C/C++. Even calling GC.Collect() will generate CPU cycles.
Your question starts off with the suggestion that you want to save memory but getting rid of objects. This is a space critical optimization. You need to decide what you reall... |
The pattern depends on which operating system you're using.
On Linux, you'll want to block **.o*, **.so*, **.a*, and **.la* to begin with. You may also want to block **~* (backup file from editing) and #*# (emacs backup from a crash).
On Windows, you'll want **.obj*, **.lib*, and **.dll* at the very least.
Any... |
You should have a stack trace pointing to where you NPE is thrown. That should narrow down the number of variables that can be null. Rather than getting the debugger or printf out, I suggest adding appropriate checks and throwing an exception where as soon as the error can be detected. It's a good habit to get into to ... |
Sounds like it happens every time the website spins up (the app gets recycled every time you touch app_code and probably you have IIS configured to shut down the website after X minutes of inactivity).
I bet it has something to do with the asp.net worker process not having the correct access rights on the server. S... |
There is no value to this other than semantic and for scope and garbage collection, none of which is significant in this limited example. If you think it makes the code clearer, for yourself and/or others, then you certainly could use it. However, the more accepted convention for semantic clarification in code genera... |
You can't have **more** colors in the terminal, because there are only ANSI codes for 8 colors (16 if you count bold/light). If you want to customize the colors, you can use the TerminalColours plugin from http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal
Personally, I prefer to use the so-call... |
It's not valuable. It's a by-product of a the parser rule that statement is either a simple statement or a block. i.e. a block can be used wherever a single statement can.
e.g.
if (someCondition)
SimpleStatement();
if (SomeCondition)
{
BlockOfStatements();
}
Others have... |
I am trying to implement a request to an unreliable server. The request is a nice to have, but not 100% required for my perl script to successfully complete. The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is li... |
|perl|perl-lwp|timeout|signals| |
|perl|timeout|signals|perl-lwp| |
I am trying to implement a request to an unreliable server. The request is a nice to have, but not 100% required for my perl script to successfully complete. The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is li... |
I was actually doing something similar a little while back, but I couldn't come up with a way that didn't use a loop.
The best I got was a temp table, and then selecting the dates I wanted to join on into that.
The blog bduke linked to is cute, although I think the temp table solution is perhaps a cleaner solutio... |
Legality of Encryption in Standard Libraries |
|encryption|programming-languages| |
Some programming languages such as Java and C# include encryption packages in their standard libraries. Others such as Python and Ruby make you download third-party modules to do strong encryption. I assume that this is for legal reasons; perhaps Sun Microsystems has enough lawyers that they aren't afraid of getting ... |
|programming-languages|encryption|legal| |
I'm not aware of any published style guide, but I can certainly share my experience. You can use many of the same techniques used in other programming environments, such as making the code modular and splitting it across multiple files. In the environment that I have set up, each project is laid out like so:
"[Project... |
Search for all email-valid-characters before and after the @ sign. Like:
[-A-z0-9._]+@[-A-z0-9._]+
Greedy matching should pull in everything it can, and it'll stop at the commas or colons.
Check which characters are valid in email addresses, though. I've left some out (like +) |
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
should catch most emials |
How do I duplicate a whole line in Emacs? |
|emacs|editor|text|editing|command| |
I saw [this same question for VIM][1] and it has been something that I myself wanted to know how to do for Emacs. In ReSharper I use CTRL-D for this action. What is the least number of commands to perform this in Emacs?
[1]: http://stackoverflow.com/questions/73319/duplicate-a-whole-line-in-vim#73357 |
Telerik makes a great converter. <http://converter.telerik.com/> |
I guess it depends on your standards. For me, buggy code is not production ready and so shouldn't be shipped. Could you have a beta version with a known issues list so users know what to expect under certain conditions? They get the benefit of using the new features but also know that it's not perfect (use that their o... |
On my way to answering my own question. Double-clicking on the Microsoft .net Framework in the Detected dependencies one can choose the version.
Now the question is which is appropriate, **3.5.30729** or **3.5 SP1 Client**? |
On my way to answering my own question. Double-clicking on the Microsoft .net Framework in the Detected dependencies one can choose the version.
Now the question is which is appropriate, **3.5.30729** or **3.5 SP1 Client**?
**EDIT:** 3.5.30729 works. Any ideas of the difference between the two? |
On my way to answering my own question. Double-clicking on the Microsoft .net Framework in the Detected dependencies one can choose the version.
Now the question is which is appropriate, **3.5.30729** or **3.5 SP1 Client**?
**EDIT:** 3.5.30729 works. Any ideas of the difference between the two?
**EDIT:** D... |
This is relative simple but a bit hard to explain since you haven't given us the way you represent your ellipse. There are so many ways to do it..
Anyway, the general principle goes like this: You can't calculate the axis aligned boundary box directly. You can howeve calculate the extrema of the ellipse in x and y ... |
I'd never go down the Silverlight, Flash/Flex or any similar route. It does look nice, but the main problem is that the code of the engine that runs it is completely closed-box and controlled by a single company. Take, for example 64bit versions of both of those. If some new platform emerges, you won't be able to migra... |
Not sure on the exact code (Been a while since I wrote complex Javascript), but you could enumerate through all of the controls on the form and attach an event that outputs something when the event is triggered.
You could even use anonymous functions to wrap the necessary information for identifying which event was ... |
If you are working with trees stored in a relational database, I'd suggest looking at "nested set" or "modified preorder tree traversal". The SQL will be as simple as that:
SELECT id, SUM(value) AS value FROM table WHERE left>left\_value\_of\_your\_node AND right<$right\_value\_of\_your\_node;
... and do this for... |
The obvious way would be to set up some alerts for various events something like:
<pre>element.onclick = function () { alert('Click event'); }</pre>
Otherwise you have a less intrusive option of inserting your alerts into the dom somewhere.
But, seriously consider using a library like [jQuery][1] to implement your... |
I tried this in WebMethods IS Version 6.5 Updates WmPRT_6-5-1_SP1, IS_6-5_SP3.
It worked perfectly first time.
I turned on debugging on the FTP server (Debian's default ftpd). WebMethods' NLST honours the active/passive parameter passed to it.
There's nothing special about the NLST command, nor its correct beh... |
They are essentially doing the same thing, MSIL is Microsoft's version of Java bytecode.
The main differences internally are:
1. Bytecode was developed for both compilation and interpretation, while MSIL was developed explicitly for JIT compilation
2. MSIL was developed to support multiple languages (C# and VB... |
RSS Statistics/Traffic Metrics |
|rss|metrics| |
I want to track how much traffic I'm getting on an RSS feed that is set up using .Net 2.0 & SQL Server.
Is there an industry standard on what metrics I should use, for example, page hits? |
You'll need the cookie plugin, which provides several additional signatures to the cookie function.
$.cookie('cookie_name', 'cookie_value') stores a transient cookie (only exists within this session's scope, while $.cookie('cookie_name', 'cookie_value', 'cookie_expiration") creates a cookie that will last across ses... |
I cannot say _why_ this happens, but for what it's worth, we avoid the problem entirely by having StarTeam delete all of the local files before checking-out. We get _all_ of the files that way. We use the following StarTeam arguments in our NAnt script:
delete-local -q -p "${starteam_project_root}" -is... |
I think I found an easier way to do this:
* right-click on your project in the Package Explorer;
* choose "Build Path...";
* choose "Configure Build Path";
* choose the Libraries tab;
* click the "Add Variable..." button;
* in the list box, choose the "ECLIPSE_HOME" entry, and then click the "Extend" button;
*... |
I would use a [WaitOne][1] event handle.
[1]: http://msdn.microsoft.com/en-us/library/kzy257t0.aspx |
VB.Net: I would use a [WaitOne][1] event handle.
VB 6.0: I've seen a DoEvents Loop.
Do
If isSomeCheckCondition() Then Exit Do
DoEvents
Loop
[1]: http://msdn.microsoft.com/en-us/library/kzy257t0.aspx |
How can I highlight text in Scintilla? |
|c#|python|perl|ide|scintilla| |
I am writing an editor using <a href="http://www.scintilla.org/">Scintilla</a>.
I am already using a lexer to do automatic syntax highlighting but now I'd like to mark search results. If I want to mark only one hit I can set the selection there but I'd like to mark (e.g. with yellow background) all the hits.
I wr... |
The basic principle for lock-free synchronisation is this:
* whenever you are reading the structure, you follow the read with a test to see if the structure was mutated since you started the read, and retry until you succeed in reading without something else coming along and mutating while you are doing so;
* whe... |
The basic principle for lock-free synchronisation is this:
* whenever you are reading the structure, you follow the read with a test to see if the structure was mutated since you started the read, and retry until you succeed in reading without something else coming along and mutating while you are doing so;
* whe... |
Check out the [Stripes Framework][1]. If you are familiar with struts then stripes will make sense to you, but it's so much better. They have a [Stripes vs Struts][2] section on their website. You could check that out and see if it interests you. It allows you to work with any ajax framework you want, and I don't think... |
Did you ever tryed [ANTLR Studio](http://placidsystems.com/screenshots.aspx)? It does not generate the hole AST graph, but for review, its already quite helpful. |
Parsing things with regular expressions works for regular languages. HTML is not a regular language, and the stuff you find on web pages these days is absolute crap. [BeautifulSoup][1] deals with tag-soup HTML with browser-like heuristics so you get parsed HTML that resembles what a browser would display.
The downsi... |
Near the "track changes" stuff there is also an option to compare documents, I believe. |
This does not answer much of your question, but the W3C's [Converting HTML to Other Formats][1] has a section on converting HTML to text. I hope it helps someone develop a full answer to your question!
[1]: http://www.w3.org/Tools/html2things.html |
[Codejacked][1] covers three different methods on how to compare word documents.
[1]: http://www.codejacked.com/comparing-two-versions-of-a-word-document/ "Comparing word documents" |
How to use private assemblies without a manifest file? |
|visual-studio-2008| |
I would like to compile a DLL under Visual Studio 2008 that depends on msvcr90.dll without needing an external manifest file.
I followed the steps outlined in <http://msdn.microsoft.com/en-us/library/ms235291.aspx>
section **"Deploying Visual C++ library DLLs as private assemblies"** but
instead of using an extern... |
How to compile a DLL that does not require an external manifest file? |
I would like to compile a DLL under Visual Studio 2008 that depends on msvcr90.dll as a private assembly (basically I'll dump this DLL into the same directory as my application) without needing an external manifest file.
I followed the steps outlined in <http://msdn.microsoft.com/en-us/library/ms235291.aspx>
sectio... |
How to calculate the sum of values in a tree using SQL |