instruction stringlengths 0 30k ⌀ |
|---|
The humble **for** command has accumulated some interesting capabilities over the years:
D:\> FOR /F "delims=" %i IN ('date /t') DO set today=%i
D:\> echo %today%
Sat 20/09/2008
(note that *delims=* is used to over-write the default space and tab delimiters so that the output of the date command get... |
Presumably your hack was something like this:
q = db.GqlQuery("SELECT * FROM Message WHERE create_date < :1", earliest_date)
results = q.fetch(1000)
while results:
db.delete(results)
results = fetch(1000, len(results))
As you say, if there's sufficient data, you're going to hit t... |
I really like [Propel][1], [here][2] you can get an overview, the [documentation][3] is pretty good, and you can get it through PEAR or SVN.
You only need a working PHP5 install, and [Phing][4] to start generating classes.
[1]: http://propel.phpdb.org/
[2]: http://codepoets.co.uk/propel_php5_framework_quic... |
How verbose should validation output be? |
|database|validation|user-interface|formatting| |
I have an application that reads a database and outputs alerts to any dependencies that are not being met. My thinking on this issue is "Give the minimum information that points the user to the issue." I have been told by a co-worker that I should be as verbose as possible, printing out the values of the database f... |
Like already some users have noted: This is irrelevant for small strings.
And new JavaScript engines in Firefox, Safari or Google Chrome optimize so
"<a href='" + url + "'>click here</a>";
is as fast as
["<a href='", url, "'>click here</a>"].join("");
|
How to access the Server (HttpServerUtility) object in a Thread or Timer ? |
|asp.net|timer|http-context| |
I use a `System.Timers.Timer` in my Asp.Net application and I need to use the `HttpServerUtility.MapPath` method which seems to be only available via `HttpContext.Current.Server.MapPath`.
The problem is that `HttpContext.Current` is `null` when the `Timer.Elapsed` event fires.
Is there another way to get a referenc... |
How to access the HttpServerUtility.MapPath method in a Thread or Timer ? |
A single '_' used only as a visual indicator.
- helps to group members with intellisense.
- easier to spot the member variables when reading the code.
- harder to hide a member variable with a local definition.
|
A single **_** used only as a visual indicator. (C#)
- helps to group members with intellisense.
- easier to spot the member variables when reading the code.
- harder to hide a member variable with a local definition.
|
So far the best I have come up with is:
def my_cool_helper(name, form)
out = capture { link_to name, a_path }
out << capture { form.hidden_field name.tableize, value => 'something' }
end
Is there a better way? |
So far the best I have come up with is:
def my_cool_helper(name, form)
out = capture { link_to name, a_path }
out << capture { form.hidden_field name.tableize, value => 'something' }
end
Is there a better way? |
If you would like to use Wordpress, you can use the [Twitter Tools][1] plugin.
> "Pull your tweets into your blog and create new tweets on blog posts and from within WordPress."
Each tweet/blog post would automatically have comments enabled.
Good luck man,
Brian Gianforcaro
[1]: http://alexking.or... |
I prefer the [PHPMailer][1] tool as it doesn't require PEAR. But either way, you have a misunderstanding: you don't want a PHP-server-wide setting for the SMTP user and password. This should be a per-app (or per-page) setting. If you want to use the same account across different PHP pages, add it to some kind of settin... |
Are you being slowed down by multiple small commits to your db? Sounds like you would be writing to the db almost all the time from your program and making sure you don't commit too often could improve performance. Possibly also preparing your statements and other standard bulk processing tricks could help
Other tha... |
ZX Spectrum AY-3-8912 playback in XNA Game Studio |
|xna|zxspectrum| |
Are there any libraries, pieces of code or suchlike that'll let me play ZX Spectrum .ay files in my XNA Game Studio games? |
I thing not enforcing 80 characters means eventually word wrapping.
IMO, any length chosen for a max-width line is not always appropriate and word wrapping should be a possible answer.
And that is not as easy as it sound.
It is implemented in [jedit][1]![alt text][2] which offers word wrap
But it is [bitter... |
GET should not have side-effects: http://www.w3.org/DesignIssues/Axioms.html#state |
GET should not have side-effects: http://www.w3.org/DesignIssues/Axioms.html#state
POST forms should be used when a submission has side effects.
Neither method has any real implication on security, use SSL if you're concerned about security. |
If you need sound in XNA, and want XBOX 360 support you need to use the supported file formats. You are properbly better of by trying to convert the .ay files to a format that XNA natively support.
If you only want to support Windows, then search for a .NET Library that can play them, it will work in XNA on windows ... |
You are not the only person who is going to maintain your code.
The next person who does might have a 17" screen or might need large fonts to read the text. The limit has to be somewhere and 80 chars is the convention due to previous screen limitations. Can you think of any new standard (120) and why it is a good ... |
It will be thread-safe if the unmodifiable view is safely published, and the modifiable original is never ever modified (including all objects recursively contained in the collection!) after publication of the unmodifiable view.
If you want to keep modifying the original, then you can either create a defensive copy ... |
[http://www.cppreference.com/wiki/operator_precedence] (Found by googling "C++ operator precedence")
That page tells us that &&, in group 13, has higher precedence than || in group 14, so the expression is equivalent to a || (b && c).
Unfortunately, the wikipedia article [http://en.wikipedia.org/wiki/Operators_in... |
For in-place sorting, the fastest way follows. Beware of off-by-one errors in my code. Note that this method gives a reversed sorted list which needs to be unreversed in the final step. If you use a max-heap, this problem goes away.
The general idea is a neat one: swap the smallest element (at index 0) with the las... |
Wouldn't the easiest way just be trying to make a connection at start-up and catching the error?
I mean you might get a few different errors back depending on, for example, the user is online, but they're cases that you should be able to test for. |
Your <b>brain</b> is the best drawing tool.
I prefer to develop a database schema in a simple text file.
At first it contains just the table names, attributes and foreign keys:
<pre>
company:
company_name
...
employee:
name
age
company_name -> company
...
...:
</pre>
The ... |
You should have a look at memcached: http://wiki.rubyonrails.org/rails/pages/MemCached |
Adobe Captivate 3 Typing Sound viewing a recording |
|adobe|captivate|adobe-captivate| |
I am using Adobe Captivate 3 and am having trouble disabling the typing noise when using a recording. Sometimes when I have this 'feature' disabled and make a recording, it doesn't make the typing sound, but when I publish the project, the typing sound returns. Also, I have other projects I am working on where the ty... |
|adobe|adobe-captivate| |
I include the following code in my libraries main entry point (main.php):
/**
* Build current url, depending on protocal (http/https),
* port, server name and path suffix
*/
$site_root = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on")
$site_root .= "s";
$site_root .= "://" . $_... |
can I refactor my mySql queries into one based on number of results? |
|sql|mysql|php| |
I have a table `y` Which has two columns `a` and `b`
Entries are
a b
1 2
1 3
1 4
0 5
0 2
0 4
I want to get 2,3,4 if I search column `a` for 1, and 5,2,4 if I search column `a`.
So, if I search A for something that is in A, (1) I get those rows, and if there are no entries A f... |
The title should say it all, then I can solidify 2 more ticks on the Joel test.
I've implemented build automation using a makefile and a python script already and I understand the basics and the options.
But how can I, the new guy who reads the blogs, convince my cohort of its inherent efficacy? |
|version-control|build-automation|visual-sourcesafe| |
in ColdFusion 8, can you declare a function as private using cfscript? |
|coldfusion|cold|fusion| |
Normally you create a function using cfscript like:
<cfscript>
function foo() { return "bar"; }
</cfscript>
Is there a way to declare this as a private function, available only to other methods inside the same cfc?
I know you can do it with tags:
<cffunction name="foo" access="private"... |
Implement [build lights][1] ... we did something similar with lava lamps and it was a huge hit. For added bonus marks give every developer a red light over their desk and have the right light come on when the build breaks.
[1]: http://alt.pluralsight.com/wiki/default.aspx/Craig/BuildLightsCode.html |
As to the wrist issue, I learned using mouse with both hands some 10 years back.
It's surprisingly easy, and relieves the tension substantially. Currently, I'm using a laptop and pressing the touchpad button is straining my thumb.
Be careful. These problems can last way longer than one would think.
---------... |
As mentioned by others, without additional instruction the compiler will make its own decisions about record layout. The best approach would be to change the original code to write the record using a specific layout. In particular, the [record representation clause](http://adahome.com/rm95/rm9x-13-05-01.html) allows th... |
Your comments imply you chose ArrayList because it was the first component you found.
Assuming you are simply looking for a list of integers, this is probably the best way of doing that.
List<int> list = new List<int>{1,2,3};
And if you are using C# 2.0 (Which has generics, but not collection initializers)... |
I would set up the automated build as a nightly process such that every night it grabs the most recent code revision, builds it, and generates a report. Now you will know first thing every morning whether or not the build is broken, and if it is, you can notify the team. If broken builds are much of a problem on your... |
Your <b>brain</b> is the best drawing tool.
I prefer to develop a database schema in a simple text file.
At first it contains just the table names, attributes and foreign keys:
<pre>
company:
company_name
...
employee:
name
age
company_name -> company
...
...:
</pre>
The ... |
Your <b>brain</b> is the best drawing tool.
I prefer to develop a database schema in a simple text file.
At first it contains just the table names, attributes and foreign keys:
<pre>
company:
company_name
...
employee:
name
age
company_name -> company
...
...:
</pre>
The ... |
If you do go the modal popup route, please please add a delay before input is accepted. There are few things as annoying as typing in some application and seeing the tell-tale flash of dialogue box that implies something popped up, accepted whatever random key you happened to be pressing at the time as its input and go... |
I can see two ways you can dynamically generate lambda's. You could try Reflection.Emit to generate IL (the .Net bytecode) directly and call them as a lambda or you can use the System.CodeDom and Microsoft.CSharp.CSharpCodeProvider to generate the code from higher level constructs. What you want to do depends on how yo... |
You could do the sorting on the server. AJAX would eliminate the necessity of a full refresh, but there'd still be a delay. Sides, databases a generally very fast at sorting. |
That could be tough to do what you want. You can import a git repo into svn via something like this: <http://code.google.com/p/support/wiki/ImportingFromGit>, but I think you will have conflicts. You could just recreate your SVN repo from scratch based on your git repo.
For future reference, it probably would've b... |
SELECT parent, child, parents.description||sys_connect_by_path(childs.description, '/') AS "path"
FROM T1 parents, T1 childs, T2
WHERE T2.parent = parents.id
AND T2.child = childs.id
CONNECT BY PRIOR parent = child |
When key value pairs are not enough I use Configuration Sections as they are not complex to use (unless you need a complex section):
Define your custom section:
public class CustomSection : ConfigurationSection
{
[ConfigurationProperty("LastName", IsRequired = tru... |
What I normally do is to danish-sify (I'm from denmark), or use the danish words for IT terms when talking to business people, or normal non-it people. If it is IT people i just use the english terms. |
I second Peter's recommendation for [Hudson][1]. Continuum and Hudson are both very easy to set-up and use (compared to CruiseControl), but Hudson offers a lot more functionality. If you're interested, I've [previously written][2] about why I would choose Hudson.
TeamCity, with its [pre-tested commit functionality... |
Super-long lines are harder to read. Just because you can get 300 characters across on your monitor doesn't mean you should make the lines that long. 300 characters is also way too complex for a statement unless you have no choice (a call that needs a whole bunch of parameters.)
I use 80 characters as a general ru... |
As others have said, I think it's best for (1) printing and (2) displaying multiple files side by side vertically. |
This is a job for ... **[Wikipedia][1]**!
* [Types of Virtualization][2]
* [Platform Virtualization][3]
* [Comparison of Virtual Machines][4]
Now that the obvious stuff is out of the way...
Linux runs fine as a guest on every VM host I've used, so I'm going to assume that you're referring to Linux as the hos... |
Since you put "generally" in your question, I would say yes. For -most- objects, there isn't going to be a costly ToString overload. There definitely can be, but generally there won't be. |
I tried [Resharper][1] for a while. It was great but too expensive for my taste and I could not get my employer to purchase it when the trial expired. You might take a look.
[1]: http://www.jetbrains.com/resharper/ |
You can use javap (in $JDK_HOME/bin) to decompile java .class files. It will tell you (for example) the class file version among other things |
I would try to avoid getting my stored procs from returning Business Related messages because by definition these kind of messages probably ought to be handled/generated in a Business Logic tier.
Execeptions should be exceptional (infrequent). I would use RAISEERROR only for errors (like hey I tried to import all ... |
Time Synchronization Ubuntu Server Under Parallels |
|ubuntu|vm|parallels| |
I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran fast to the extent that it would gain hours over time. |
If you are looking for API level differences the [javap](http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javap.html) tool can be a big help. It will output the method signatures and those can be output to a plain text files and compared using normal diff tools. |
Look into [getResourceAsStream][1]. It'll keep you from having to extract the files from the jar file. Unless that's your goal.
[1]: http://mindprod.com/jgloss/getresourceasstream.html |
My blasphemous 2 cents:
Text-based messages work really well on the web, like, HTTP for example. It's easy to create, send, debug systems where the messaging is done in human-readable text.
So, maybe the same thing with the messaging between your SQL Server layer and the layer above it. Using text as part o... |
Please please don't use these unholy website projects. Use Web Application projects instead, pack your shared classes into a library project and reference it from all your Web Applications. |
Suggestions for human editable data file format/parsing library |
|data|markup| |
for example, right now I have a roll-my-own solution that uses data files that include blocks like:
PlayerCharacter Fighter
Hitpoints 25
Strength 10
StartPosition (0, 0, 0)
Art
Model BigBuffGuy
Footprint LargeFootprint
end
InventoryItem Sword
Inv... |
Can Mercurial be integrated into VS2008? |
|version-control|visual-studio-2008|mercurial|tortoisehg| |
Does anyone know of a tool to integrate Mercurial into Visual Studio?
Just curious. Mercurial is pretty nice, even with 'just' <a href="http://tortoisehg.sourceforge.net">TortoiseHG</a>, but integration with VS would be better. |
In your development environment, set the Expires header much lower. In your Production environment, set it higher, and then set it low about a week before you do your release. |
If you want to embed the mathematics as images, you may take a look at <a href="http://mathtran.org/">MathTran</a>.
If you'd prefer to have the math inserted into the page primarily as text (using images only when necessary), <a href="http://www.math.union.edu/~dpvc/jsMath/">jsMath</a> may be what you're looking f... |
I don't think there is much point in branching a single file? There is no way to test it with the trunk code?
You could take a patch instead if you want to back out changes and apply them later on. |
The most annoying thing to me are the Import/Export options. Even devs need that. |
In this example, you can simply hand over functions as objects to the methods in `C1`:
>>> class C1(object):
>>> def eval(self, x):
>>> x()
>>>
>>> def f2(): print "go f2"
>>> c = C1()
>>> c.eval(f2)
go f2
In Python, you can pass functions and classes to other meth... |
In this example, you can simply hand over functions as objects to the methods in `C1`:
>>> class C1(object):
>>> def eval(self, x):
>>> x()
>>>
>>> def f2(): print "go f2"
>>> c = C1()
>>> c.eval(f2)
go f2
In Python, you can pass functions and classes to other meth... |
Without optimizations the compiler produces very dumb code - each command is compiled in a very straightforward manner, so that it does the intended thing. The Debug builds have optimizations disabled by default, because without the optimizations the produced executable matches the source code in a straightforward mann... |
Nothing is perfect, but you can make copying a little more difficult = less worthwhile.
* You can watermark preview copies of media.
* You can serial number all copies so they can be tracked.
* You could encrypt the media, only allowing it to be decrypted by software that you control. (e.g. Adobe Acrobat documents... |
You might want to look into the DLR. I havn't done so myself (yet) but the use-case for the DLR (dynamic languages) sounds a lot like what you're trying to do.
Depending on what you want to do the Castle-framework's dynamic proxy object might be a good fit too. |
Right now I can see 12 answers all agreeing that the answer is "No".
If your business relies on your clients' media being published with protection, then your business may already be in trouble. You need to start a conversation with your clients about the content they're generating, why they're generating it and wha... |
From [Paul Vick's][1] blog:
- It removes any NOP instructions that we would otherwise emit to assist in debugging. When optimizations are off (and debugging information is turned on), the compiler will emit NOP instructions for lines that don't have any actual IL associated with them but which you might want to p... |
Can I refactor my MySql queries into one query based on number of results? |
|php|sql|mysql| |
I think the key is to be concise. Put as much detail as is required for the reason for the warning to be communicated and nothing more. |
I would suggest that you should implement both modes. During normal operation you need a useful but short message. But sometimes things could go wrong and in this case a 'dump' mode which gives the user all possible information is a life saver. |
Needless pointer-casts in C |
|c|c++|pointers| |
I got a comment to my answer on this thread:
[http://stackoverflow.com/questions/105477][1]
In short I had code like this:
int * somefunc (void)
{
int * temp = (int*) malloc (sizeof (int));
temp[0] = 0;
return temp;
}
I got this comment:
> Can I just say, please don't c... |
|c++|c|pointers| |
I got a comment to my answer on this thread:
[http://stackoverflow.com/questions/105477][1]
In short I had code like this:
int * somefunc (void)
{
int * temp = (int*) malloc (sizeof (int));
temp[0] = 0;
return temp;
}
I got this comment:
> Can I just say, please don't c... |