instruction stringlengths 0 30k ⌀ |
|---|
It's the process ID of the bash process. No concurrent processes will ever have the same PID. |
Easy:
use python instead of shell scripts.
You get a near 100 fold increase in readablility, without having to complicate anything you don't need, and preserving the ability to evolve parts of your script into functions, objects, persistent objects (zodb), distributed objects (pyro) nearly without any extra code. |
Create a type-safe utility class which will load enums by code:
The interface comes down to:
public interface CodeableEnum {
String getCode();
}
The utility class is:
import java.lang.reflect.InvocationTargetException;
public class CodeableEnumUtils {
@SuppressWar... |
I have found sessions to be very useful, but a few things to note:
1) That PHP may store your sessions in a tmp folder or other directory that may be accessible to other users on your server. You can change the directory were sessions are stored by going to the php.ini file.
2) If you are setting up a high value ... |
<< command >> | tee < file >>
This will also show the output. |
You need to know two things - the number of days in the month, and the weekday the first of the month falls on.
If the first day of the month is a
- Sunday, then the last Friday is *always* the 27th.
- Monday, then the last Friday is *always* the 26th.
- Tuesday, then the last Friday is *always* the 25th.... |
That is the generally accepted way of branching your source code in SourceSafe. The only other way to do it, if merging and retaining the history are not an issue, is to copy the files to a new folder, remove the read-only attribute, remove the .vssscc and .scc files, and then add that new project to SourceSafe. At t... |
A/B testing on a news site to improve relevance |
|algorithm|testing| |
If you were running a news site that created a list of 10 top news stories, and you wanted to make tweaks to your algorithm and see if people liked the new top story mix better, how would you approach this?
Simple Click logging in the DB associated with the post entry?
A/B testing where you would show one versi... |
[Doxygen](http://www.stack.nl/~dimitri/doxygen/) can generate an set of web pages that include a source browser. Not quite as fancy as an IDE, but all it needs is a web browser. |
What is the best way to build an index to get the fastest read response? |
|indexing| |
I need to index up to 500,000 entries for fastest read. The index needs to be rebuilt periodically , on disk. |
I need to index up to 500,000 entries for fastest read. The index needs to be rebuilt periodically , on disk. I am trying to decide between a simple file like a hash on disk or a single table in an embedded database. I have no need for an RDBMS engine. |
> Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it into an char* pointer and casting it as a function and executing?
Yes, if you were doing it in C or C++ (or something similar), that's exactly what you'd do.
It appears hacky, but that's actually an artifact of the langua... |
You might want to read this rather well written essay on parsing Python, [Python: Myths about Indentation][1].
While I haven't tried to write a context free parser using something like yacc, I think it may be possible using a conditional lexer to return the indentation change tokens as described in the url.
By th... |
I think the nearest in the .NET Framework is
<pre>
string.Split()
</pre> |
Ummm... an inner class IS a nested class... do you mean anonymous class and inner class?
Edit: If you actually meant inner vs anonymous... an inner class is just a class defined within a class such as:
public class A {
public class B {
}
}
Whereas an anonymous class is an extension ... |
Ummm... an inner class IS a nested class... do you mean anonymous class and inner class?
Edit: If you actually meant inner vs anonymous... an inner class is just a class defined within a class such as:
public class A {
public class B {
}
}
Whereas an anonymous class is an extension ... |
Actually, QuickSort is O(n^2). Its *average case* running time is O(nlog(n)), but its *worst-case* is O(n^2), which occurs when you run it on a list that is reverse-sorted. This can be avoided by randomizing the list before sorting, making such a case unlikely. Randomization takes O(n). Of course, this doesn't chan... |
It would depend on how the custom controls are being used - A commercial, re-distributable control should be compliant with the VS IDE, and behave the way users expect it to when they implement the control.
On the other hand there is no point in wasting a lot of time to get styling to work if you or your team are th... |
Quicksort is the fastest sorting algorithm in practice but has a number of pathological cases that can make it perform as badly as O(n2).
Heapsort is guaranteed to run in O(n*ln(n)) and requires only finite additional storage. But there are many citations of real world tests which show that heapsort is significantly... |
I've done this many times and I will speak from experience: Never ever touch the onet.xml files within the 12 hive under any circumstance. Any error that you make in there, and to make the CAML even more complex the file is largely whitespace sensitive, will have an impact on every part of SharePoint.
You should als... |
Select is equally efficient (in terms of velocity) if you use * or columns.
The difference is about memory, not velocity. When you select several columns SQL Server must allocate memory space to serve you the query, including all data for all the columns that you've requested, even if you're only using one of them.
... |
use a long long so you can store all 4 possibilities, then bitshift each short:
((long long)shortNumberX) << 0, 4, 8, or 12
make sure you cast before shifting, or your data could drop off the end.
Edit: forgot to add, you should OR them together. |
It depends on the version of your DB server, but modern versions of SQL can cache the plan either way. I'd say go with whatever is most maintainable with your data access code. |
Absolutely define the columns you want to SELECT every time. There is no reason not to and the performance improvement is well worth it.
They should never have given the option to "SELECT *" |
A simple google search offered up: [Differ][1]. I've never used it so I can't vouch for the quality of that :-)
[1]: http://www.codeproject.com/KB/cs/differ.aspx |
How about this:
if (object.Equals(myArgument, default(T)))
{
//...
}
HTH,
Kent |
How about this:
if (object.Equals(myArgument, default(T)))
{
//...
}
Using the `static object.Equals()` method avoids the need for you to do the `null` check yourself. Explicitly qualifying the call with `object.` probably isn't necessary depending on your context, but I normally prefix `st... |
Having worked at a few companies with 1000+ workers, I've found that by-and-large, they all use Perforce.
I've asked "Why don't you use something else? SVN? Git? Mercurial? Darcs?"- and they've said that (this is the same for all of the companies) - when they made the decision to go with Perforce, it was either th... |
You can try to use an object property and catch the resulting NullReferenceException. If the property you try is inherited or overridden from Object, then this works for any class.
public static bool operator ==(Foo foo1, Foo foo2)
{
// check if the left parameter is null
bool LeftNull = ... |
You can try to use an object property and catch the resulting NullReferenceException. If the property you try is inherited or overridden from Object, then this works for any class.
public static bool operator ==(Foo foo1, Foo foo2)
{
// check if the left parameter is null
bool LeftNull = ... |
Is there a way to productively do Silverlight development without buying VS2008? |
|silverlight|visual-studio-express| |
It seems that Microsoft wants Silverlight to take off, yet I cannot find an easy way to develop in it without buying Visual Studio 2008. Has anyone out there found a way to get the silverlight development environment in the express editions of Visual Studio? Any other tools? |
Did you check the whitepaper on the website?
http://www.microsoft.com/sqlserver/2008/en/us/overview.aspx
I cannot recall off the top of my head, but it atleast has a nice database to object linking functionality. They have geospatial types too, if you need to use those. |
Did you check the whitepaper on the website?
<a href="http://www.microsoft.com/sqlserver/2008/en/us/overview.aspx"> SQL Server 2008 Overview. </a>
I cannot recall off the top of my head, but it atleast has a nice database to object linking functionality. They have geospatial types too, if you need to use those. |
Two ways. Symbols (:foo notation) or constants (FOO notation).
Symbols are appropriate when you want to enhance readability without littering code with literal strings.
postal_code[:minnesota] = "MN"
postal_code[:new_york] = "NY"
Constants are appropriate when you have an underlying value that is impo... |
You need to know two things - the number of days in the month, and the weekday the first of the month falls on.
If the first day of the month is a
- Sunday, then the last Friday is *always* the 27th.
- Monday, then the last Friday is *always* the 26th.
- Tuesday, then the last Friday is *always* the 25th.... |
Using C/Pthreads: do shared variables need to be volatile? |
|c|pthreads|multithreading| |
In the C programming language and Pthreads as the threading library; do variables/structures that are shared between threads need to be declared as volatile? Assuming that they might be protected by a lock or not (barriers perhaps).
Does the pthread POSIX standard have any say about this, is this compiler-dependent ... |
|c|multithreading|pthreads| |
In the C programming language and Pthreads as the threading library; do variables/structures that are shared between threads need to be declared as volatile? Assuming that they might be protected by a lock or not (barriers perhaps).
Does the pthread POSIX standard have any say about this, is this compiler-dependent ... |
code for Adam Davis's algorithm
public static int getLastFriday(int month, int year)
{
Calendar cal = Calendar.getInstance();
cal.set(year, month, 1, 0, 0, 0); // set to first day of the month
cal.set(Calendar.MILLISECOND, 0);
int firstDay = cal.get(Calendar.DAY_OF_WEEK);
int days... |
replace 'foo' with 'bar' everywhere in the file
:%s/foo/bar/gc |
The split method of a string is what you need. In fact the tokenizer class in Java is depreciated in favor of Java's string split method as well. |
Can't you just put two identical bound columns one after the other? |
From [the Wikipedia entry on Quicksort][1]:
> Quicksort also competes with
> mergesort, another recursive sort
> algorithm but with the benefit of
> worst-case Θ(nlogn) running time.
> Mergesort is a stable sort, unlike
> quicksort and heapsort, and can be
> easily adapted to operate on linked
> lists and ver... |
I found the Spoffard book not very helpful. MDX is such an oddity compared to other languages you'll learn, it's so hard to grasp from a dry book. I really would recommend a training course, otherwise you will flounder for ages. A course will really jump-start you, and it provides access to an expert when you have ques... |
Wikipedia's explanation is:
> Typically, quicksort is significantly faster in practice than other Θ(nlogn) algorithms, because its inner loop can be efficiently implemented on most architectures, and in most real-world data it is possible to make design choices which minimize the probability of requiring quadratic t... |
`mod_jk`, or simply just use `mod_proxy` even though it's not really a Tomcat connector. |
You can get good firefox addons to test multiple flaws and vulnerabilities like xss and sql injections from [Security Compass][1]. Too bad they doesn't work on firefox 3.0. I hope that those will be updated soon.
[1]: http://securitycompass.com/exploitme.shtml |
What I find irreplaceable (because it works in vi also, unlike vim's visual mode) are marks. You can mark various spots with `m` (lower case) and then a letter of your choice (eg x). Then you go elsewhere, and can go back with "backquote x" (I don't know how to enter a literal backquote here) to the exact spot, or with... |
How do I get TextMate style quotes in Emacs? |
|emacs| |
In textmate, when there's a current selection, I hit the " key and the selection gets surrounded by quotes. The same thing happens with other balanced characters like (, {, [ and '.
Am I missing something obvious in Emacs configuration that would enable similar behaviour when using transient mark mode, or do I need ... |
It looks like you set the calendar to the first day of the next month, so you need one more line to subtract one day, to get the last day of the month that *sampleDay* is in:
cal.add(Calendar.DAY_OF_MONTH, -1);
In general, it's much easier to do this kind of thing using [Joda Time][1].
[1]: http://joda... |
It looks like you set the calendar to the first day of the next month, so you need one more line to subtract one day, to get the last day of the month that *sampleDay* is in:
cal.add(Calendar.DAY_OF_MONTH, -1);
In general, it's much easier to do this kind of thing using [Joda Time][1], eg:
DateTime dat... |
It looks like you set the calendar to the first day of the next month, so you need one more line to subtract one day, to get the last day of the month that *sampleDay* is in:
Calendar cal = Calendar.getInstance();
cal.setTime(sampleDay.getTime());
cal.roll(Calendar.MONTH, true);
cal.set(Calendar.D... |
In developing embedded systems, where you need to read or write a memory-mapped hardware device. The contents of a particular device register could change at any time, so you need the `volatile` keyword to ensure that such accesses aren't optimised away by the compiler. |
In developing embedded systems or device drivers, where you need to read or write a memory-mapped hardware device. The contents of a particular device register could change at any time, so you need the `volatile` keyword to ensure that such accesses aren't optimised away by the compiler. |
You can embed your CSS within the page, sprinkled with some server tags to overcome the problem. At runtime the code blocks will be replaced with the ASP.NET generated IDs.
For example:
[style type="text/css"]
#<%= AspNetId.ClientID %> {
... styles go here...
}
[/style]
[script type="text/javascr... |
If you need every column then just use SELECT * but remember that the order could potentially change so when you are consuming the results access them by name and not by index.
I would ignore comments about how * needs to go get the list - chances are parsing and validating named columns is equal to the processing t... |
VS 2008 is not the point. The latest .Net package is the point. You can use Linq and all the other new Features with notepad and the commandline compiler but i guess that is more theoretical. So my statement is yes, .net 3.5 is the recommendation but using it without VS 2008 isn't a good idea. |
One reason it's better practice to spell out exactly which columns you want is because of possible future changes in the table structure.
If you are reading in data manually using an index based approach to populate a data structure with the results of your query, then in the future when you add/remove a column you ... |
If you want to do "real" TDD, then you also have to start using Mock/Stubs, when you want to test integration points.
When you start using Mock's then after a while, you will want to start using Dependency Injection (DI) and a Inversion of Control (IoC) container. To do that you need to use Interfaces for every thin... |
If you want to do "real" TDD (read: Test First with Red, Green, Refactor), then you also have to start using Mock/Stubs, when you want to test integration points.
When you start using Mock's then after a while, you will want to start using Dependency Injection (DI) and a Inversion of Control (IoC) container. To do t... |
What are you trying to accomplish? `Map` already exposes its keys as a `Set` via its [keySet()](http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet(\)) method. If you want a reliable iteratior order, there's [LinkedHashMap](http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html) and [TreeMap... |
What are you trying to accomplish? `Map` already exposes its keys as a `Set` via its [keySet()](http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet(\)) method. If you want a reliable iteratior order, there's [LinkedHashMap](http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html) and [TreeMap... |
Yes.
ThisWorkbook.RefreshAll
Or, if your Excel version is old enough,
dim w as worksheet, p as pivottable
for each w in thisworkbook.worksheets
for each p in w.pivottables
p.refreshtable
p.update
next
next |
mp4box if you want a dedicated tool; its probably the easiest way to go. ffmpeg can do the job too. |
Hibernate mapping a composite key with null values |
|hibernate|java| |
With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values? |
|java|hibernate| |
With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values?
This is to deal with a legacy table that has a unique key which can have null values but no primary key.
I realise that I could just add a new primary key column to the table, but I'm wondering i... |
I don't think that your choice of Virtual Disk type in VMWare matters for performance. What matters is the following: How much memory you have (the more the better), How many CPU cores you have (the more the better), and more specifically about disks, what matters most is the speed of the physical drive (a 15K RPM SCSI... |
I think you should consider your "target market" for the custom control, e.g., the people who will use it.
If it's an internal custom control, you can pretty much mandate the use of one or the other: if it's internal to the company you will have the ability to enforce its consistency.
If it's meant for commercial... |
While they're both in the same complexity class, that doesn't mean they both have the same runtime. Quicksort is usually faster than mergesort, just because it's easier to code a tight implementation and the operations it does can go faster. It's because that quicksort is generally faster that people use it instead o... |
Perhaps there is some kind of pre-commit check on your repository, see [here][1]
[1]: http://ximbiot.com/cvs/manual/cvs-1.12.13/cvs_18.html#SEC188 |
I think it would be inefficient to store binary files in any form of version control system.
The better idea would be to store meta-data textfiles in the repository that reference the binary objects. |
I'm not going to go in depth on SSL in general, gregmac did a great job on that, see below ;-).
However, some of the most common (and critical) mistakes made (not specifically PHP) with regards to use of SSL/TLS:
1. Allowing HTTP when you should be enforcing HTTPS
2. Retrieving some resources over HTTP from ... |
In terms of execution efficiency I am not aware of any significant difference. But for programmers efficiency I would write the names of the fields because
- You know the order if you need to index by number, or if your driver behaves funny on blob-values, and you need a definite order
- You only read the fields yo... |
How to find broken links on a website |
|html| |
What techniques or tools are recommended for finding broken links on a website?
I have access to the logfiles, so could conceivably parse these looking for 404 errors, but would like something automated which will follow (or attempt to follow) all links on a site.
Thanks. |
What techniques or tools are recommended for finding broken links on a website?
I have access to the logfiles, so could conceivably parse these looking for 404 errors, but would like something automated which will follow (or attempt to follow) all links on a site. |
the first line would consist of 3 DIVs. One outer that contains two inner divs. The first inner div would have float:left which would make sure it stays to the left, the second would have float:right, which would stick it to the right.
< div style="width:500;height:50"><br>
< div style="float:left" >stuff < /div... |
We have used ASP.NET Ajax, JQuery and Telerik components on a large project for quite a while and haven't had any issues
I would definitely recommend using JQuery |
This is what my code looks like. It seems to work fine.
Are you using a service locator or just creating your service?
SomeServiceLocator locator = new SomeServiceLocator();
SomeService service = null;
try
{
service = locator.getSomeServiceImplPort();
}
catch (ServiceException e)
... |
Thanks a lot for the quick responses!
Here's a summary of the options, for posterity:
var input = 'foo bar "lorem ipsum" baz';
output = input.match(/("[^"]+"|[^"\s]+)/g);
output = input.match(/"[^"]*"|\w+/g);
output = input.match(/("[^"]*")|([^\s"]+)/g)
output = /(".+?"|\w+)/g.exec(input... |
code for [Adam Davis's algorithm][1]
public static int getLastFriday(int month, int year)
{
Calendar cal = Calendar.getInstance();
cal.set(year, month, 1, 0, 0, 0); // set to first day of the month
cal.set(Calendar.MILLISECOND, 0);
int firstDay = cal.get(Calendar.DAY_OF_WEEK);
int... |
Did you set ScreenUpdating to True, as mentioned in the KB article?
You may want to actually toggle it to True to force a screen repaint. It sounds like the calculation of page breaks is a side-effect of actually rendering the page, rather than something Excel does on demand, so you have to trigger a page rendering ... |
I just had the same issue, and found the answer [here][1]:
> When the user navigates away from the
> row, the control commits all row
> changes. The user can also press
> CTRL+ENTER to commit row changes
> without leaving the row. To commit row
> changes programmatically, call the
> form's Validate method. If ... |
use set -e so you don't plow forward after errors. Try making it sh compatible without relying on bash if you want it to run on not-linux. |
Every process in a UNIX like operating system has a (temporarily) unique identifier, the PID. No two processes running at the same time can have the same PID, and $$ refers to the PID of the bash instance running the script.
This is very much *not* a unique idenifier in the sense that it will never be reused (indee... |
The $$ is the process id of the shell in which your script is running. For more details, see the man page for sh or bash. The man pages can be found be either using a command line "man sh", or by searching the web for "shell manpage" |