instruction stringlengths 0 30k ⌀ |
|---|
|schema|normalizing|microformats|hcard|vcf-vcard| |
I need to store contact information for users. I want to present this data on the page as an [hCard][1] and downloadable as a [vCard][2]. I'd also like to be able to search the database by phone number, email, etc.
What do you think is the best way to store this data? Since users could have multiple addresses, etc complete normalization would be a mess. I'm thinking about using XML, but I'm not familiar with querying XML db fields. Would I still be able to search for users by contact info?
I'm using SQL Server 2005, if that matters.
[1]: http://en.wikipedia.org/wiki/Hcard
[2]: http://en.wikipedia.org/wiki/VCard |
Best version control system for managing home directories |
|linux|version-control| |
I have 3 Linux machines, and want some way to keep the dotfiles in their home directories in sync. Some files, like .vimrc, are the same across all 3 machines, and some are unique to each machine.
I've used SVN before, but all the buzz about DVCSs makes me think I should try one - is there a particular one that would work best with this? Or should I stick with SVN? |
The [List::MoreUtils][1] module has a zip/mesh function that should do the trick.
Here is the source of the mesh function:
sub mesh (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) {
my $max = -1;
$max < $#$_ && ($max = $#$_) for @_;
map { my $ix = $_; map $_->[$ix], @_; } 0..$max;
}
[1]: http://search.cpan.org/~vparseval/List-MoreUtils-0.22/lib/List/MoreUtils.pm
|
Just to clarify: You are looking for names of fonts that will make your website-design look similar to Windows and Mac OS X when viewed under Linux, you are not looking to design new fonts, correct?
(I read your question in the same way that Jason Navarrete did, so at least two people misunderstood your question.)
The font names you are looking for might be something like [the Liberation fonts that RedHat has released][1]?
Incidently, 'sans-serif' doesn't give the user "any sans-serif", it gives the user his/her *preferred* sans-serif - which may arguably be better than one you pick.
[1]: https://www.redhat.com/promo/fonts/ |
The most important thing is to always be consistent in when you escape. Accidental double sanitizing is lame and not sanitizing is dangerous.
For SQL, just make sure your database access library supports bind variables which automatically escapes values. Anyone who manually concatenates user input onto SQL strings should know better.
For HTML, I prefer to escape at the last possible moment. If you destroy user input, you can never get it back, and if they make a mistake they can edit and fix later. If you destroy their original input, it's gone forever. |
The result of `M-x describe function RET frame-parameter` is
> frame-parameter is a built-in
> function.
>
> (frame-parameter FRAME PARAMETER)
>
> Return FRAME's value for parameter
> PARAMETER. If FRAME is nil, describe
> the currently selected frame.
Also, have a look in the Elisp info manual for the node called 'Frame/Frame Parameters". There isn't a specific reference to 'buried-buffer-list that I could find.
You might be able to get the same thing by doing
(cdr (frame-parameter FRAME 'buffer-list))
since a "buried buffer" is just a buffer in the list that isn't at the top. |
>Without her input, I started the Scrum practices (daily scrums, burndown charts and other things I've found that worked for me and my previous teams (ala H. Kniberg's cool wall chart). During out daily stand up she slinks by and ignores us as if we actually weren't standing right outside her door (we are actually). It's pretty amazing. I've never seen such resistance.
>Question... how do I get her onboard? Peer pressure is not working.
Yikes! Who would ever want to work in such an oppressive environment? If you're lucky, she's sending around her resume and you'll be able to hire someone who is on board with your development process.
Assuming you want to hang on to her, I'd turn down (or off) the rhetoric and work on being a friend and co-worker first. If the project is a year late, she can't be feeling good about herself and it sounds like you aren't afraid to trumpet your success. That can be intimidating.
I know nothing about Scrum, however. I'm just imagining what it would be like to walk around in your co-worker's shoes. |
How about **covariant return types** which have been in place since JDK 1.5? They are pretty poorly publicised, as it is a rather unsexy addition, but as I understand it were absolutely necessary for generics to work.
Essentially, the compiler now allows a subclass to narrow the return type of an overridden method to be a subclass of the original method's return type. So this is allowed:
class Souper {
Collection<String> values() {
...
}
}
class ThreadSafeSortedSub extends Souper {
@Override
ConcurrentSkipListSet<String> values() {
...
}
}
You can call the subclass's `values` method and obtain a sorted thread safe `Set` of `String`s without having to down cast to the `ConcurrentSkipListSet`. |
How about **covariant return types** which have been in place since JDK 1.5? It is pretty poorly publicised, as it is an unsexy addition, but as I understand it, is absolutely necessary for generics to work.
Essentially, the compiler now allows a subclass to narrow the return type of an overridden method to be a subclass of the original method's return type. So this is allowed:
class Souper {
Collection<String> values() {
...
}
}
class ThreadSafeSortedSub extends Souper {
@Override
ConcurrentSkipListSet<String> values() {
...
}
}
You can call the subclass's `values` method and obtain a sorted thread safe `Set` of `String`s **without having to down cast** to the `ConcurrentSkipListSet`. |
Use...
System.IO.Path.GetDirectoryName(saveDialog.FileName)
(and the corresponding System.IO.Path.GetFileName). The Path class is really rather useful. |
You can only make DNS name pont to a different IP address, so if You you are using virtual hosts redirecting with DNS won't work.
When you enter subdomain.hostone.com in your browser it will use DNS to get it's IP address (if it's a CNAME it will continue trying until it gets IP from A record) then it will connect to that IP and send a http request with
<pre>Host: subdomain.hostone.com </pre>
somewhere in the http headers. |
You can do this a number of non-DNS ways. The landing page at subdomain.hostone.com can have an [HTTP redirect](http://www.activejump.com/o-6.shtml). The webserver at hostone.com can be configured to redirect (easy in Apache, not sure about IIS), etc. |
There is a book called *Code*. I can't remember who wrote it, but it goes through the basics of a lot of stuff that we (programmers) know and take for granted that people we talk to know also. Everything from how do you count binary to how processors work. It doesn't have anything dealing with programming languages in it (well from what I remember), but it is a pretty good primer. I will admit that I am also of the school that believes you have to know how the computer works to be able to effectively program things for it. |
Another interesting find is the presence of assemblies here:
> C:\Program Files\Reference
> Assemblies\Microsoft\Framework\v3.5
You'd think Microsoft would build a check for "latest version" into the framework. |
Another good resource I found:
<http://www.walkernews.net/2008/05/16/how-to-check-net-framework-version-installed/> |
A good resource I found:
<http://www.walkernews.net/2008/05/16/how-to-check-net-framework-version-installed/> |
Burn it to a DVD and install it from there. Also remove any development software that you don't need from Visual Studio, such as C++, VB.NET, Crystal Reports, etc. |
I find Geany ([http://geany.uvena.de/][1]) quite good.
[1]: http://geany.uvena.de/ |
Plugin Capability |
|plugins|extensibility| |
Is there a general procedure for programming extensibility capability into your code?
I am wondering what the general procedure is for adding extension-type capability to a system you are writing so that functionality can be extended through some kind of plugin API rather than having to modify the core code of a system.
Do such things tend to be dependent on the language the system was written in, or is there a general method for allowing for this? |
Adding Plugin Capability? |
Where I work we use [RedGate Data Generator][1] to generate test data.
Since we work in the banking domain. When we have to work with nominative data (Credit card numbers, personnal ID, phone numbers) we developped an application who can *mask* these database fields so we can work with them as real data.
I can say with Redgate you can get close to what your real data can look like on a production server since you can customize every field of every table in your BD.
[1]: http://www.red-gate.com/products/SQL_Data_Generator/index.htm |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as
> far as I know) was brought to Amazon
> by Ron Braunstein. The question is
> quite a rich one, as it manages to
> probe a wide variety of important
> skills: OOP design, recursion, binary
> trees, polymorphism and runtime
> typing, general coding skills, and (if
> you want to make it extra hard)
> parsing theory.
>
> At some point, the candidate hopefully
> realizes that you can represent an
> arithmetic expression as a binary
> tree, assuming you're only using
> binary operators such as "+", "-",
> "*", "/". The leaf nodes are all
> numbers, and the internal nodes are
> all operators. Evaluating the
> expression means walking the tree. If
> the candidate doesn't realize this,
> you can gently lead them to it, or if
> necessary, just tell them.
>
> Even if you tell them, it's still an
> interesting problem.
>
> The first half of the question, which
> some people (whose names I will
> protect to my dying breath, but their
> initials are Willie Lewis) feel is a
> Job Requirement If You Want To Call
> Yourself A Developer And Work At
> Amazon, is actually kinda hard. The
> question is: how do you go from an
> arithmetic expression (e.g. in a
> string) such as "2 + (2)" to an
> expression tree. We may have an ADJ
> challenge on this question at some
> point.
>
> The second half is: let's say this is
> a 2-person project, and your partner,
> who we'll call "Willie", is
> responsible for transforming the
> string expression into a tree. You get
> the easy part: you need to decide what
> classes Willie is to construct the
> tree with. You can do it in any
> language, but make sure you pick one,
> or Willie will hand you assembly
> language. If he's feeling ornery, it
> will be for a processor that is no
> longer manufactured in production.
>
> You'd be amazed at how many candidates
> boff this one.
>
> I won't give away the answer, but a
> Standard Bad Solution involves the use
> of a switch or case statment (or just
> good old-fashioned cascaded-ifs). A
> Slightly Better Solution involves
> using a table of function pointers,
> and the Probably Best Solution
> involves using polymorphism. I
> encourage you to work through it
> sometime. Fun stuff!
So, let's try to tackle the problem all three ways. How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using cascaded-if's, a table of function pointers, and/or polymorphism?
Feel free to tackle one, two, or all three.
[update: title modified to better match what most of the answers have been.]
[1]: http://steve.yegge.googlepages.com/when-polymorphism-fails |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as
> far as I know) was brought to Amazon
> by Ron Braunstein. The question is
> quite a rich one, as it manages to
> probe a wide variety of important
> skills: OOP design, recursion, binary
> trees, polymorphism and runtime
> typing, general coding skills, and (if
> you want to make it extra hard)
> parsing theory.
>
> At some point, the candidate hopefully
> realizes that you can represent an
> arithmetic expression as a binary
> tree, assuming you're only using
> binary operators such as "+", "-",
> "*", "/". The leaf nodes are all
> numbers, and the internal nodes are
> all operators. Evaluating the
> expression means walking the tree. If
> the candidate doesn't realize this,
> you can gently lead them to it, or if
> necessary, just tell them.
>
> Even if you tell them, it's still an
> interesting problem.
>
> The first half of the question, which
> some people (whose names I will
> protect to my dying breath, but their
> initials are Willie Lewis) feel is a
> Job Requirement If You Want To Call
> Yourself A Developer And Work At
> Amazon, is actually kinda hard. The
> question is: how do you go from an
> arithmetic expression (e.g. in a
> string) such as "2 + (2)" to an
> expression tree. We may have an ADJ
> challenge on this question at some
> point.
>
> The second half is: let's say this is
> a 2-person project, and your partner,
> who we'll call "Willie", is
> responsible for transforming the
> string expression into a tree. You get
> the easy part: you need to decide what
> classes Willie is to construct the
> tree with. You can do it in any
> language, but make sure you pick one,
> or Willie will hand you assembly
> language. If he's feeling ornery, it
> will be for a processor that is no
> longer manufactured in production.
>
> You'd be amazed at how many candidates
> boff this one.
>
> I won't give away the answer, but a
> Standard Bad Solution involves the use
> of a switch or case statment (or just
> good old-fashioned cascaded-ifs). A
> Slightly Better Solution involves
> using a table of function pointers,
> and the Probably Best Solution
> involves using polymorphism. I
> encourage you to work through it
> sometime. Fun stuff!
So, let's try to tackle the problem all three ways. How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using cascaded-if's, a table of function pointers, and/or polymorphism?
Feel free to tackle one, two, or all three.
[update: title modified to better match what most of the answers have been.]
[1]: http://steve.yegge.googlepages.com/when-polymorphism-fails |
It looks like you can't embed `<object>` tags in a richtext field. I'm getting nothing when I do it. But thanks anyway Jason. Any other ideas? |
One workaround might be, throw a new list of KeyValuePair from the Dictionary to keep the original unmodified.
var dict = new Dictionary<string, string>();
dict.Add("Hello", "World");
dict.Add("The", "Quick");
dict.Add("Brown", "Fox");
var dictCopy = dict.Select(
item => new KeyValuePair<string, string>(item.Key, item.Value));
// returns dictCopy;
This way the original dictionary won't get modified. |
How do I store information in my executable in .Net |
|c#|.net| |
I'd like to bind a configuration file to my executable. I'd like to do this by storing an MD5 hash of the file inside the executable. This should keep anyone but the executable from modifying the file.
Essentially if someone modifies this file outside of the program the program should fail to load it again. |
I'd like to bind a configuration file to my executable. I'd like to do this by storing an MD5 hash of the file inside the executable. This should keep anyone but the executable from modifying the file.
Essentially if someone modifies this file outside of the program the program should fail to load it again.
EDIT: The program processes credit card information so being able to change the configuration in any way could be a potential security risk. This software will be distributed to a large number of clients. Ideally client should have a configuration that is tied directly to the executable. This will hopefully keep a hacker from being able to get a fake configuration into place.
The configuration still needs to be editable though so compiling an individual copy for each customer is not an option. |
Make sure you have the following set on the UpdatePanel:
ChildrenAsTriggers=false and UpdateMode=Conditional |
Is there a built in way in .Net AJAX to manually serialize an object to a JSON string? |
|.net-2.0|asp.net|json|serialization|vb.net| |
I've found [`ScriptingJsonSerializationSection`][1] but I'm not sure how to use it. I could write a function to convert the object to a JSON string manually, but since .Net can do it on the fly with the `<System.Web.Services.WebMethod()>` and `<System.Web.Script.Services.ScriptMethod()>` attributes so there must be a built in way.
[1]: http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx |
I've found [`ScriptingJsonSerializationSection`][1] but I'm not sure how to use it. I could write a function to convert the object to a JSON string manually, but since .Net can do it on the fly with the `<System.Web.Services.WebMethod()>` and `<System.Web.Script.Services.ScriptMethod()>` attributes so there must be a built-in way that I'm missing.
[1]: http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx |
"The system cannot find the file specified" when invoking subprocess.Popen in python |
|python|svnmerge| |
I'm trying to use svnmerge.py to merge some files. Under the hood it uses python, and when I use it I get an error - "The system cannot find the file specified". Colleagues at work are running the same version of svnmerge.py, and of python (2.5.2, specifically r252:60911) without an issue.
I found [this link][1], which describes my problem. Trying what was outlined there, I confirmed Python could find svn (it's in my path):
<pre>
P:\>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> i,k = os.popen4("svn --version")
>>> i.close()
>>> k.readline()
'svn, version 1.4.2 (r22196)\n'
</pre>
Looking at the svnmerge.py code, though, I noticed for python versions 2.4 and higher it was following a different execution path. Rather than invoking
os.popen4() it uses subprocess.Popen(). Trying that reproduces the error:
<pre>
C:\>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> p = subprocess.Popen("svn --version", stdout=subprocess.PIPE,
>>> close_fds=False, stderr=subprocess.PIPE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\lib\subprocess.py", line 594, in __init__
errread, errwrite)
File "C:\Python25\lib\subprocess.py", line 816, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
>>>
</pre>
For now, I've commented out the 2.4-and-higher specific code, but I'd like to find a proper solution.
If it's not obvious, I'm a complete python newbie, but google hasn't helped. Any pointers?
[1]: http://www.nabble.com/problem-under-some-windows-desktop-td15868057.html |
The svnbook has a section on how Subversion allows you to revert the changes from a particular revision without affecting the changes that occured in subsequent revisions:
[http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo][1]
I don't use Eclipse much, but in TortoiseSVN you can do this from the from the log dialogue; simply right-click on the revision you want to revert and select "Revert changes from this revision".
In the case that the files for which you want to revert "bad changes" had "good changes" in subsequent revisions, then the process is the same. The changes from the "bad" revision will be reverted leaving the changes from "good" revisions untouched, however you might get conflicts.
[1]: http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo |
How can I store user-tweakable configuration in app.config? |
|c#|.net|app-config| |
I know it is a good idea to store configuration data in app.config (e.g. database connection strings) instead of hardcoing it, even if I am writing an application just for myself. But is there a way to update the configuration data stored in app.config from the program that is using it? |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as
> far as I know) was brought to Amazon
> by Ron Braunstein. The question is
> quite a rich one, as it manages to
> probe a wide variety of important
> skills: OOP design, recursion, binary
> trees, polymorphism and runtime
> typing, general coding skills, and (if
> you want to make it extra hard)
> parsing theory.
>
> At some point, the candidate hopefully
> realizes that you can represent an
> arithmetic expression as a binary
> tree, assuming you're only using
> binary operators such as "+", "-",
> "*", "/". The leaf nodes are all
> numbers, and the internal nodes are
> all operators. Evaluating the
> expression means walking the tree. If
> the candidate doesn't realize this,
> you can gently lead them to it, or if
> necessary, just tell them.
>
> Even if you tell them, it's still an
> interesting problem.
>
> The first half of the question, which
> some people (whose names I will
> protect to my dying breath, but their
> initials are Willie Lewis) feel is a
> Job Requirement If You Want To Call
> Yourself A Developer And Work At
> Amazon, is actually kinda hard. The
> question is: how do you go from an
> arithmetic expression (e.g. in a
> string) such as "2 + (2)" to an
> expression tree. We may have an ADJ
> challenge on this question at some
> point.
>
> The second half is: let's say this is
> a 2-person project, and your partner,
> who we'll call "Willie", is
> responsible for transforming the
> string expression into a tree. You get
> the easy part: you need to decide what
> classes Willie is to construct the
> tree with. You can do it in any
> language, but make sure you pick one,
> or Willie will hand you assembly
> language. If he's feeling ornery, it
> will be for a processor that is no
> longer manufactured in production.
>
> You'd be amazed at how many candidates
> boff this one.
>
> I won't give away the answer, but a
> Standard Bad Solution involves the use
> of a switch or case statment (or just
> good old-fashioned cascaded-ifs). A
> Slightly Better Solution involves
> using a table of function pointers,
> and the Probably Best Solution
> involves using polymorphism. I
> encourage you to work through it
> sometime. Fun stuff!
So, let's try to tackle the problem all three ways. How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using cascaded-if's, a table of function pointers, and/or polymorphism?
Feel free to tackle one, two, or all three.
[update: title modified to better match what most of the answers have been.]
[1]: http://steve.yegge.googlepages.com/when-polymorphism-fails |
This [Introduction to Oracle Advanced Queuing](http://www.stanford.edu/dept/itss/docs/oracle/9i/appdev.920/a96587/qintro.htm#65422) states that you can interface to it through "Internet access using HTTP, HTTPS, and SMTP" so it should be straightforward to do that using a Perl script. |
I have not done it against database yet, your question is kinda open.
If you want to search an db, and can choose to use Lucene, I also guess that you can control when data is inserted to the database.
If so, there is little reason to poll the db to find out if you need to reindex, just index as you insert, or create an queue table which can be used to tell lucene what to index.
I think we don't need another indexer that is ignorant about what it is doing, and reindexing everytime, or uses resources wasteful. |
There's a good set of slides on Ruby Blocks as part of the "Rails with Passion" course:
[Ruby_Blocks.pdf][1]
This covers representing a block, how they get passed arguments and executed, and even further into things like Proc objects. It's very clearly explained.
It might then be of interest to look at how the JRuby guys handled these in their parsing to Java. Take a look at the source at [codehaus][2].
[1]: http://www.javapassion.com/rubyonrails/ruby_blocks.pdf
[2]: http://svn.codehaus.org/jruby/ |
That's an interesting problem because I suppose it depends on the quantity of each length you're producing. If they are all the same quantity and you can get Each different length onto one 5m extrusion then you have the optimum soloution.
However if they don't all fit onto one extrusion then you have a greater problem. To keep the same amount of cuts for each length you need to calculate how many lengths (not necessarily in order) can fit on one extrusion and then go in an order through each extrusion. |
From [Wikipedia on UTF-8][1]:
<blockquote>
UTF-8 (8-bit UCS/Unicode Transformation Format) is a <strong>variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard</strong>, yet the initial encoding of byte codes and character assignments for UTF-8 is backwards compatible with ASCII. For these reasons, it is steadily becoming the preferred encoding for e-mail, web pages[1], and other places where characters are stored or streamed.
</blockquote>
So, it's anywhere between one and four bytes depending on which character you wish to represent within the realm of Unicode.
[From Wikipedia on Unicode:][2]
<blockquote>
In computing, Unicode is an industry standard allowing computers to consistently represent and manipulate text expressed in <strong>most of the world's writing systems</strong>.
</blockquote>
So it's able to represent most (but not all) of the world's writing systems.
I hope this helps :)
[1]: http://en.wikipedia.org/wiki/UTF-8
[2]: http://en.wikipedia.org/wiki/Unicode |
Unfortunately your question is a little like "Should I use a sandwich or a cement mixer". HttpHandlers and User controls are completely different things.
HttpHandlers are used to process HTTP requests. For example, if you wanted to dynamically create an RSS feed, you could write an HTTP handler that handles all requests for ".rss" files, creates the output and sends it back to the user.
User controls are used within ASPX pages to encapsulate units of functionality that you want to re-use accross many pages.
Chances are, if you're using user controls successfully, you don't want to use HttpHandlers! |
This is a classic, difficult problem to solve efficiently. The algorithm you describe sounds like a [Greedy Algorithm][1]. Take a look at this Wikipedia article for more information: [The Cutting Stock Problem][2]
[1]: http://en.wikipedia.org/wiki/Greedy_algorithm
[2]: http://en.wikipedia.org/wiki/Cutting_stock_problem |
Even an Asp.Net page is an HttpHandler.
public class Page : TemplateControl, IHttpHandler
A user control actually resides within the asp.net aspx page. |
I haven't found a _simple_ way to do this yet, but I found [this site][1] helpful a few months back.
O'Reilly also published a book called Network Security Hacks (available on Safari) that has a section starting at Hack #45 on creating your own certificate authority.
[1]: http://www.herongyang.com/crypto/openssl_crt.html |
where is silverlight executed?
Is there any reason at all to send an complete picture to the client to make the client crop it?
Do it on the server... (if you are not creating an image editor that is..) |
Having a `favicon.*` in your root directory is automatically detected by most browsers. You can ensure it's detected by using:
<link rel="icon" type="image/png" href="/path/image.png" />
Personally I use .png images but most formats should work. |
[Wikipedia to the rescue][1]
[1]: http://en.wikipedia.org/wiki/Favicon |
If you need the numeric values, here's the quickest way:
(dog,cat,rabbit) = range(0,3)
|
[pgfouine][1] works fairly well for me. And it looks like there's a [FreeBSD port][2] for it.
[1]: http://pgfouine.projects.postgresql.org/
[2]: http://portsmon.freebsd.org/portoverview.py?category=databases&portname=pgfouine |
You are optimizing the wrong thing, both of those should be so fast that you'll have to run them billions of times just to get any measurable difference.
And just about anything will have much greater effect on your performance, for example, if the values you are swapping are close in memory to the last value you touched they are lily to be in the processor cache, otherwise you'll have to access the memory - and that is several orders of magnitude slower then any operation you do inside the processor.
Anyway, your bottleneck is much more likely to be an inefficient algorithm or inappropriate data structure (or communication overhead) then how you swap numbers.
|
With Appliance, we normally think about something like this:
http://www.garghouti.co.uk/vmTrac/
There is not much info about versions and such though.
But as others have pointed out, it is dead easy to install svn and svndeamon on an server that already exists, Svn takes very little resources, and can easily be put on an fileserver. Apache is not needed at all.
|
Well, the first thing to do is try all your queries from psql using "explain" and see if there are sequential scans that can be converted to index scans by adding indexes or rewriting the query.
Other than that, I'm as interested in the answers to this question as you are. |
For me, VisualSVN is pretty, but useless. AnkhSvn on the other hand, after it came in v2 as an scc provider, it works very good.
VisualSVN tries to think for you, which is not an good thing, the user should be the controller, not the software. |
If you're using multiple threads, the operating system will automatically take care of using multiple cores. |
I use .ico format and put the following two lines within the `<head>` element:
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
Non-Temporal SSE instructions (MOVNTI, MOVNTQ, etc.), don't follow the normal cache-coherency rules. Therefore non-temporal stores must be followed by an SFENCE instruction in order for their results to be seen by other processors in a timely fashion.
When data is produced and not (immediately) consumed again, the fact that memory store operations read a full cache line first and then modify the cached data is detrimental to performance. This operation pushes data out of the caches which might be needed again in favor of data which will not be used soon. This is especially true for large data structures, like matrices, which are filled and then used later. Before the last element of the matrix is filled the sheer size evicts the first elements, making caching of the writes ineffective.
For this and similar situations, processors provide support for non-temporal write operations. Non-temporal in this context means the data will not be reused soon, so there is no reason to cache it. These non-temporal write operations do not read a cache line and then modify it; instead, the new content is directly written to memory.
Source: <http://lwn.net/Articles/255364/> |
Any DVCS would likely work fine. My favorite is [Bazaar](http://bazaar-vcs.org/). It would be easiest to keep your config files in .config, version that, and then symlink as appropriate.
A benefit of DVCS is that you can version the per-machine config files as well, without interfering with versioning global configs. |
This would be an interesting project (has anyone done it already?)
I presume you'd give the tool your jar(s) as a starting point, and the library jar to clean up. It could use reflection to determine which classes your jar(s) reference directly, and which are used indirectly down the call tree (this is not trivial at all, but doable). If it encounters any reflection code in any of the two places, it should give a very loud warning. |
I like vmware. One nice feature is that it runs on multiple host OS's, so you can move your guest OS onto a linux server or a windows desktop as you like. |
Version control software isn't really great for home directories. Worse, some software doesn't really like the .svn folders or starts to interpret their contents. You could of course try to fix this with some very complex mirroring setup, but that's hard. |
You <i>can</i>, but probably don't want to, set the document root on a per-file basis in the <tt>head</tt> of your file:
<pre>
<base href="my-root">
</pre>
|
Hmm.. in Opera at least you can register your own protocol handlers.. i.e. I can map 'smb' to 'nautalis' which means clicking smb://computer/share actually works.
[Summary of how it works in Firefox][1].
[1]: http://kb.mozillazine.org/Register_protocol |
Hmm.. in Opera at least you can register your own protocol handlers.. i.e. I can map 'smb' to 'nautalis' which means clicking smb://computer/share actually works.
[Summary of how it works in Firefox][1] (although it looks like it may be a bit of fail as they have a whitelist of allowed protocols. Would not be surprised if smb aint one of them).
[1]: http://kb.mozillazine.org/Register_protocol |
Hmm, protocol handlers look interesting.
As [Mark][1] said, in Windows protocol handlers can be dealt with at the OS level
Protocol handlers can also be done at the browser level (which is preferred, as it is cross platform and doesn't involve installing anything).
[Summary of how it works in Firefox][2]
[Summary of how it works in Opera][3]
[1]: http://stackoverflow.com/questions/37804/link-to-samba-shares-in-html#38258
[2]: http://kb.mozillazine.org/Register_protocol
[3]: http://www.opera.com/support/search/view/535/ |
Seems odd to me why you'd want to store the same object both server side and client side - especially if you're comparing them on each trip.
I'd guess that deserializing the cookie and comparing it to the server side object would be equivalent in performance to just serializing the object again.
But, if you wanted to do this, I'd compare the serialized server side object with the cookie's value and update accordingly. Worst case, you did the serialization for naught. Best case, you did a string compare.
The alternative, deserializing and comparing the objects, has a worst case of deserializing, comparing n fields, and then serializing. Best case is deserializing and comparing n fields. |
If you use the Settings for the project, you can mark each setting as either application or user.
If they're set as user, they will be stored per-user and when you call the Save method it will be updated in the config for that user.
Code project has a really detailed article on saving all types of settings: http://www.codeproject.com/KB/dotnet/user_settings.aspx |
app.config isn't what you want to use for user-tweakable data, as it'll be stored somewhere in Program Files (which the user shouldn't have write permissions to). Instead, settings marked with `a UserScopedSettingAttribute` will end up in a user-scoped .config file somewhere in %LocalAppData%.
I found the best way to learn this stuff was to mess with the Visual Studio "Settings" tab (on your project's property pages), then look at the code that it generates and look in %LocalAppData% to see the file that it generates. |
It's a bug, see the [documentation of `subprocess.Popen`][1]. There either needs to be a `"shell=True`" option, or the first argument needs to be a sequence `['svn', '--version']`. As it is now, `Popen` is looking for an executable named, literally, "svn --version" which it doesn't find.
[1]: http://docs.python.org/lib/node528.html |
It's a bug, see the [documentation of `subprocess.Popen`][1]. There either needs to be a `"shell=True`" option, or the first argument needs to be a sequence `['svn', '--version']`. As it is now, `Popen` is looking for an executable named, literally, "svn --version" which it doesn't find.
I don't know why it would work for your colleagues though, if they are running the same OS and version of Python... FWIW it gives me the same error message on a mac, and either of the two ways I gave fixes it.
[1]: http://docs.python.org/lib/node528.html |
Check out the [F# Developer Center][1]. There is also [hubFS][2], a forum dedicated to F#.
[1]: http://msdn.microsoft.com/en-gb/fsharp/default.aspx
[2]: http://cs.hubfs.net/forums/default.aspx |
It's open source - use the source, Luke.
Look in wp-admin/js/theme-preview.js
|
Currying is a transformation that can be applied to functions to allow them to take one less argument than previously.
For example, in F# you can define a function thus:-
let f x y z = x + y + z
Here function f takes parameters x, y and z and sums them together so:-
f 1 2 3
Returns 6.
From our definition we can can therefore define the curry function for f:-
let curry f = fun x -> f x
Where 'fun x -> f x' is a lambda function equivilent to x => f(x) in C#. This function inputs the function you wish to curry and returns a function which *takes a single argument* and returns the specified function with the first argument set to the input argument.
Using our previous example we can obtain a curry of f thus:-
let curryf = curry f
We can then do the following:-
let f1 = curryf 1
Which provides us with a function f1 which is equivilent to f1 y z = 1 + y + z. This means we can do the following:-
f1 2 3
Which returns 6.
This process is often confused with 'partial function application' which can be defined thus:-
let papply f x = f x
Though we can extend it to more than one parameter, i.e.:-
let papply2 f x y = f x y
let papply3 f x y z = f x y z
etc.
A partial application will take the function and parameter(s) and return a function that requires one or more less parameters, and as the previous two examples show is implemented directly in the standard F# function definition so we could achieve the previous result thus:-
let f1 = f 1
f1 2 3
Which will return a result of 6.
In conclusion:-
The difference between currying and partial function application is that:-
Currying takes a function and provides a new function accepting a single argument, and returning the specified function with its first argument set to that argument. *This allows us to represent functions with multiple parameters as a series of single argument functions*. Example:-
let f x y z = x + y + z
let curryf = curry f
let f1 = curryf 1
let f2 = curryf 2
f1 2 3
6
f2 1 3
6
Partial function application is more direct - it takes a function and one or more arguments and returns a function with the first n arguments set to the n arguments specified. Example:-
let f x y z = x + y + z
let f1 = f 1
let f2 = f 2
f1 2 3
6
f2 1 3
6
|
Expect a better answer (probably before I finish typing this) but as a quick summary.
A user control is something that can be added to a page.
A HttpHandler can be used instead of a page. |
The GoF Command Pattern supports undoable operations.
I think the same pattern can be used for sequential operations (sequential commands). |
Basically a user control is a piece of server logic and UI. An HTTP Handler is only a piece of logic that is executed when a resource on your server is requested. For example you may decide to handle requests for images sent to your server through your own handler and serve images from a database instead of the file system. However, in this case there's no interface that the user sees and when he visits a URL on your server he would get the response you constructed in your own handler. Handlers are usually done for specific extensions and HTTP request types (POST, GET). Here's some more info on MSDN: <http://msdn.microsoft.com/en-us/library/ms227675(VS.80).aspx> |
ADO.NET Mapping From SQLDataReader to Domain Object? |
|ado.net| |
I have a very simple mapping function called "BuildEntity" that does the usual boring "left/right" coding required to dump my reader data into my domain object. (shown below) My question is this - If I don't bring back every column in this mapping as is, I get the "System.IndexOutOfRangeException" exception and wanted to know if ado.net had anything to correct this so I don't need to bring back every column with each call into SQL ...
What I'm really looking for is something like "IsValidColumn" so I can keep this 1 mapping function throughout my DataAccess class with all the left/right mappings defined - and have it work even when a sproc doesn't return every column listed ...
Using reader As SqlDataReader = cmd.ExecuteReader()
Dim product As Product
While reader.Read()
product = New Product()
product.ID = Convert.ToInt32(reader("ProductID"))
product.SupplierID = Convert.ToInt32(reader("SupplierID"))
product.CategoryID = Convert.ToInt32(reader("CategoryID"))
product.ProductName = Convert.ToString(reader("ProductName"))
product.QuantityPerUnit = Convert.ToString(reader("QuantityPerUnit"))
product.UnitPrice = Convert.ToDouble(reader("UnitPrice"))
product.UnitsInStock = Convert.ToInt32(reader("UnitsInStock"))
product.UnitsOnOrder = Convert.ToInt32(reader("UnitsOnOrder"))
product.ReorderLevel = Convert.ToInt32(reader("ReorderLevel"))
productList.Add(product)
End While
|
How do I declare a list of fixed length in specman? |
|specman| |
In E (specman) I want to declare variables that are lists, and I want to fix their lengths.
It's easy to do for a member of a struct:
thread[2] : list of thread_t;
while for a "regular" variable in a function the above doesn't work, and I have to do something like:
var warned : list of bool;
gen warned keeping {
it.size() == 5;
};
Is there a better way to declare a list of fixed size? |
|asp.net|vb.net|.net-2.0|serialization|json| |
I've found [`ScriptingJsonSerializationSection`][1] but I'm not sure how to use it. I could write a function to convert the object to a JSON string manually, but since .Net can do it on the fly with the `<System.Web.Services.WebMethod()>` and `<System.Web.Script.Services.ScriptMethod()>` attributes so there must be a built-in way that I'm missing.
PS: using Asp.Net 2.0 and VB.Net - I put this in the tags but I think people missed it.
[1]: http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx |
I'm a java developer but i think this is the same for c#.
I never expose a private collection property because other parts of the program can change it without parent noticing, so that in the getter method i return an array whith the objects of the collection and in the setter method i call a clearAll() over the collection and then an addAll() |
Out of pure curiosity, what's your reasoning for never wanting to load the file if it's been changed?
Why not just keep all of the configuration information compiled in the executable? Why bother with an external file at all? |
Out of pure curiosity, what's your reasoning for never wanting to load the file if it's been changed?
Why not just keep all of the configuration information compiled in the executable? Why bother with an external file at all?
***Edit***
I just read your edit about this being a credit card info program. That poses a very interesting challenge.
I would think, for that level of security, some sort of pretty major encryption would be necessary but I don't know anything about handling that sort of thing in such a way that the cryptographic secrets can't just be extracted from the executable.
Is authenticating against some sort of online source a possibility? |
It looks like using the Profiler is going to work. Once I've let it run for a while, I should have a good list of used tables. Anyone who doesn't use their tables every day can probably wait for them to be restored from backup. Thanks, folks. |
First, we have check-in (smoke) tests that must run before code can be checked in. It's done automatically by running a job that runs the tests and then makes the check-in to source control upon successful test completion. Second, cruise control kicks off build and regression tests. The product is built then several sets of integration tests are run. The number of tests vary by where we are in the release cycle. More testing is added late in the cycle during ramp down. Cruise control takes all submissions within a certain time window (12 minutes) so your changes may be built and tested with a small number of others. Third, there's an automated nightly build and tests that are quite extensive. We have load or milestone points every 2 or 3 weeks. At a load point, all automated tests are run plus manual testing is done. Performance testing is also done for each milestone. Performance tests can be kicked off on request but the hardware available is limited so people have to queue up for performance tests. Usually people rely on the load performance tests unless they are making changes specifically to improve performance. Finally, stress tests are also done for each load. These tests are focussed on making sure the product has no memory leaks or anything else that prevents 24/7 running of the product as opposed to performance. All of this is done with ant, cruise control, and Python scripts. |