instruction
stringlengths 0
30k
⌀ |
---|
Assuming you're joining on columns with no duplicates, which is by far the most common case:
- An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection.
- An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union.
**Examples**
Suppose you have two Tables, with a single column each, and data as follows:
A B
- -
1 3
2 4
3 5
4 6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
**inner join**
An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b;
a | b
--+--
3 | 3
4 | 4
**left outer join**
A left outer join will give all rows in A, plus any common rows in B.
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b(+);
a | b
--+-----
1 | null
2 | null
3 | 3
4 | 4
**full outer join**
A full outer join will give you the union of A and B, i.e. All the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;
a | b
-----+-----
1 | null
2 | null
3 | 3
4 | 4
null | 6
null | 5 |
Don't get too caught up on trying to optimize string operations in PHP. Doing a concatenation vs. interpolation is meaningless (in real world performance) if your database queries are poorly written or you aren't using any kind of caching scheme. Write your string operations in such a way that debugging your code later will be easy, the performance differences are negligible. |
Don't get too caught up on trying to optimize string operations in PHP. Concatenation vs. interpolation is meaningless (in real world performance) if your database queries are poorly written or you aren't using any kind of caching scheme. Write your string operations in such a way that debugging your code later will be easy, the performance differences are negligible.
@uberfuzzy Assuming this is just a question about language minutia, I suppose it's fine. I'm just trying to add to the conversation that comparing performance between single-quote, double-quote and heredoc in real world applications in meaningless when compared to the real performance sinks, such as poor database queries.
|
Why don't you create rights & profiles to manage wich pages a user can see?
I usually create a user class which implements the IPrincipal security interface. On every request to your application, you check the rights of a particular user and output the SiteMap's nodes allowed for this user.
|
Most of the digital libraries uses RSS/ATOM to display their search/results, data update, according to the [OAI-PMH protocol](http://www.openarchives.org/OAI/openarchivesprotocol.html) |
there are many examples. Here are a couple.
SharePoint provides RSS feeds from its lists.
Many faceted navigation products allow you to get an RSS feed based on a selected filter. For example, you can navigate to view 24" LCD Monitors on newegg.com and then get an RSS feed of that view. |
[Mantis](http://www.mantisbt.org/) bug tracker includes RSS feeds although I wish they were more configurable. Also we use [MediaWiki](http://www.mediawiki.org/wiki/MediaWiki) for documentation which has all sorts of RSS Feeds including a per page watch, and recent changes. |
Visual Assist X by Whole Tomato software is not free, but it's absolutely worth the money if you use Visual Studio for C++.
http://www.wholetomato.com/ |
I was hoping for something a little more automatic. VS will create a new .suo file every time the project is saved. So I would have to delete that file every time I open the project. I also don't want to have to remember to close all the files before closing VS.
Other IDEs that I have used have similar functionality, but also make it rather simple to turn on/off.
Thanks for your help.
|
One of the fastest ways is to use python with a gui binding like pyQt, PyFLTK, tkinter, wxPython or even via pygame which uses SDL.
Its easy fast and platform independent.
Also the management of the packages is unbeatable.
See:
* http://wiki.python.org/moin/PyQt
* http://www.fltk.org/
* (tkinter is default and already packaged with python)
* http://wxpython.org/
* http://www.pygame.org/news.html |
Modulus operation with negatives values - weird thing ?? |
|python|modulo| |
Can you please tell me how much is (-2) % 5 ?
According to my pyhton interpreter is 3, but do you have a wise explanation for this ?
I've read that in some languages the result can be machine-dependent, but I'm not sure though.
Thanks for your help. |
|python|math|modulo| |
The result depends on the language. Python returns the sign of the divisor, where for example c# returns the sign of the dividend (ie. -2 % 5 returns -2 in c#). |
TFS - Branching for experimental development: Solution fails to load |
|tfs|version-control| |
*Disclaimer: I'm stuck on TFS and I hate it.*
My source control structure looks like this:
- /dev
- /releases
- /branches
- /experimental-upgrade
I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merged to experimental-upgrade. Somehow TFS complained that I had changes in both source and target and I had to resolve them. I chose to "Copy item from source branch" for all 5 items.
I check out the experimental-upgrade to a local folder and try to open the main solution file in there. TFS prompts me:
> "Projects have recently been added to this solution. Would you like to get them from source control?
If I say yes it does some stuff but ultimately comes back failing to load a handful of the projects. If I say no I get the same result.
Comparing my sln in both branches tells me that they are equal.
Can anyone let me know what I'm doing wrong? This should be a straightforward branch/merge operation...
TIA. |
|version-control|tfs| |
*Disclaimer: I'm stuck on TFS and I hate it.*
My source control structure looks like this:
- /dev
- /releases
- /branches
- /experimental-upgrade
I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merged to experimental-upgrade. Somehow TFS complained that I had changes in both source and target and I had to resolve them. I chose to "Copy item from source branch" for all 5 items.
I check out the experimental-upgrade to a local folder and try to open the main solution file in there. TFS prompts me:
> "Projects have recently been added to this solution. Would you like to get them from source control?
If I say yes it does some stuff but ultimately comes back failing to load a handful of the projects. If I say no I get the same result.
Comparing my sln in both branches tells me that they are equal.
Can anyone let me know what I'm doing wrong? This should be a straightforward branch/merge operation...
TIA.
----------
**UPDATE:**
I noticed that if I click "yes" on the above dialog, the projects are downloaded to the $/ root of source control... (i.e. out of the dev & branches folders)
If I open up the solution in the branch and remove the dead projects and try to re-add them (by right-clicking sln, add existing project, choose project located in the branch folder, it gives me the error...
> Cannot load the project c:\sandbox\my_solution\proj1\proj1.csproj, the file has been removed or deleted. The project path I was trying to add is this: c:\sandbox\my_solution\branches\experimental-upgrade\proj1\proj1.csproj
What in the world is pointing these projects _outside_ of their local root? The solution file is identical to the one in the dev branch, and those projects load just fine. I also looked at the vspscc and vssscc files but didn't find anything.
<sigh>Ideas?</sigh> |
I would be wary of automatically upcasing all whitespace-preceded-words in scenarios where I would run the risk of attracting the fury of nitpickers.
I would at least consider implementing a dictionary for exception cases like articles and conjunctions. Behold:
> "Beauty and the Beast"
And when it comes to proper nouns, the thing gets much uglier. |
The most popular (==standard?) way of determining the time zone I've seen around is simply *asking the user ximself.* If your website requires subscription, this could be saved in the users' profile data. For anon users, the dates could be displayed as UTC or GMT or some such.
I'm not trying to be a smart-alec. It's just that sometimes some problems have finer solutions outside of any programming context. |
mbUnit is worth alook, it has a set of features comparable to NUnit, it has its own GUI, or can be integrated into VS if you have Resharper. I would also recommend Rhino Mocks if you are doing any sort of TDD. |
Have you tried changing the target CPU to x86 instead of "Any CPU" in the advanced compiler options? I know that this solves some problems with other OLEDB providers by forcing the use of the 32-bit version. |
ASP, need to use SFTP |
|asp|sftp|ftp| |
This is ASP classic, not .Net. We have to get a way to SFTP into a server to upload and download a couple of files, kicked off by a user.
What have other people used to do SFTP in ASP classic? Not necessarily opposed to purchasing a control.
Thanks for any help! |
|asp|sftp| |
There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings in the list, add that string concatenated with each character in the string individually.
Some pseudocode:
list = originalString.split('')
for iteration n in 1 to y:
for string s in list:
for character c in originalString:
list.add(s + c)
you'd then need to remove all strings less than x in length, they'll be the first (x-1) * len(originalString) entries in the list.
Cheers,
Andy |
There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings produced in the last iteration, add that string concatenated with each character in the string individually. (the variable index in the code below keeps track of the start of the last and the next iteration)
Some pseudocode:
list = originalString.split('')
index = (0,0)
list = [""]
for iteration n in 1 to y:
index = (index[1], len(list))
for string s in list.subset(index[0] to end):
for character c in originalString:
list.add(s + c)
you'd then need to remove all strings less than x in length, they'll be the first (x-1) * len(originalString) entries in the list.
Cheers,
Andy
> Mike Stone wrote:
>> FYI, alumb's pseudocode has a bug...
Good call Mike. I have amended my solution to fix this issue and an initialization bug. |
This is what I use to read from a Magtek card reader:
//Open file on the device
deviceHandle =
CreateFile (deviceDetail->DevicePath,
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
Try those options and see if you can at least read from the device.
I understand your pain here... I found the USB HID documentation to be basically wrong in several places.
[Edit] There's not much out there on this problem. Here's a [codeproject link][1] that lightly touches on the subject in a thread at the bottom. Sounds like maybe if it's a keyboard or mouse windows grabs it exclusively.
[1]: http://www.codeproject.com/KB/cs/USB_HID.aspx?fid=398968&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2657157&fr=26 |
It should not be used in event handlers (though most browsers work defensively, and will no punish you). I would also argue that it should not be used in the href attribute of an anchor. If a browser supports javascript, it will use the properly defined event handler. If a browser does not, a javascript: link will appear broken. IMO, it is better to point them to a page explaining that they need to enable javascript to use that functionality, or better yet a non-javascript required version of the functionality. So, something like:
<a href="non-ajax.html" onclick="niftyAjax(); return false;">Ajax me</a> |
It should not be used in event handlers (though most browsers work defensively, and will not punish you). I would also argue that it should not be used in the href attribute of an anchor. If a browser supports javascript, it will use the properly defined event handler. If a browser does not, a javascript: link will appear broken. IMO, it is better to point them to a page explaining that they need to enable javascript to use that functionality, or better yet a non-javascript required version of the functionality. So, something like:
<a href="non-ajax.html" onclick="niftyAjax(); return false;">Ajax me</a>
Edit: Thought of a good reason to use javascript:. Bookmarklets. For instance, this one sends you to google reader to view the rss feeds for a page:
var b=document.body;
if(b&&!document.xmlVersion){
void(z=document.createElement('script'));
void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');
void(b.appendChild(z));
}else{
location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)
}
To have a user easily add this Bookmarklet, you would format it like so:
<a href="javascript:var%20b=document.body;if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}">Drag this to your bookmarks, or right click and bookmark it!</a> |
As always, <http://www.csszengarden.com/>. Note that the images aren't public domain. |
Anything, but I would learn a modern system like git or subversion myself. My first VCS was RCS, but I got the basics down. |
Well, if you are just wanting to learn on your own, I would say you should go with something free, like subversion. If you are a company who has never used source control before, then it really depends on your needs. |
[Recursive Descent Parsing](http://en.wikipedia.org/wiki/Recursive_descent_parser) - I remember being very impressed how such simple code could do something so seemingly complex. |
TFS Linking Backlog items |
|tfs| |
In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time? |
In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time?
I do not have access to the underlying database so am unable to write a query to do it. |
This is just a natural for Google. This way they can control how well their apps work in a container on & off line. Expect more tools, potentially GUI designer type tools and an IDE for use with their cloud offerings as well as a mobile version of this for Android. It's most likely a lead in to Visual Google.
If they are smart they will have this container/browser perform other tasks like parsing content for a fresher Google cache and search results. |
I think the whole purpose or at least the emphasis of the release, as Kamiel said, is to provide better javascript performance. So many of Google's services rely on *heavy* javascript usage that this is a smart move by them. This should be good for everyone as IE and Firefox work to compete against Google every browser should get better at javascript. |
If encryption/decryption is performed on the server, there is no way you can make sure that the cleartext is not dumped somewhere in some log file or the like.
You need to do the encryption/decryption inside the browser using JavaScript/Java/ActiveX or whatever. As a user, you need to trust the client-side of the web service not to send back the info unencrypted to the server.
Carl |
If you're performing a lot of procedures (no return values), you can simplify your benchmarking code by stuffing it in a utility class like this...
public delegate void Proc();
public static class With
{
public static Int64 Benchmark(Proc action)
{
Stopwatch watch = Stopwatch.StartNew();
action();
watch.Stop();
return watch.ElapsedMilliseconds;
}
}
and use it like this
public static void Main()
{
Int64 time1 = With.Benchmark(MyLongMethod);
Int64 time2 = With.Benchmark(delegate { MyLongMethod(1, true); });
}
private static void MyLongMethod() { }
private static void MyLongMethod(Int32 index, Boolean someSwitch) { } |
How to address semantic issues with tag-based web sites? |
|stackoverflow|tags|del.icio.us| |
Tag-based web sites often suffer from the delicacy of language such as synonyms, homonyms, etc. For programmers looking for information, say on SO, concrete examples are:
- Subversion or SVN (or svn, with case-sensitive tags)
- .NET or Mono
- [Will add more]
The problem is that we *do* want to preserver our delicacy of language and make the machine deal with it as good as possible.
A site like del.icio.us sees its tag base grow a lot, thus probably hindering usage or search. Searching for SVN-related entries will probably list a majority of entries with both subversion and svn tags, but I can think of three issues:
1. A search is incomplete as many entries may not have both tags (which are 'synonyms').
2. A search is less useful as Q/A often lead to more Qs! Notably for newbies on a given topic.
3. Tagging a question (note: or an answer separately, sounds useful) becomes philosophical: 'Did I Tag the Right Way?'
One way to address these issues is to create semantic links between tags, so that subversion and svn are automatically bound by the system, not by poor users.
*Is it an approach that sounds good/feasible/attractive/useful? How to implement it efficiently?* |
That is because technically .NET 3.5 is an extension of the 2.0 framework. The quickest way is to include an assembly from .NET 3.5 and see if it breaks.
System.Web.Extensions
Is a good assembly that is only included in version 3.5. Also it seems that you are using ASP.NET to run this check, this really limits you because you will be unable to check the file system or the registry running in the protected mode of ASP.NET. Or you can always problematically try loading an assembly from the GAC that should only be in .NET 3.5, however you may run in to problems with permissions again.
This may be one of those times where you ask your self "What am I trying to accomplish?" and see if there are alternative routes. |
I've accepted Fredriks answer as it appears to solve the problem with the least amount of effort however the Request object doesn't appear to conatin the ResolveUrl method.
This can be accessed through the Page object or an Image control object:
myImage.ImageUrl = Page.ResolveUrl(photoURL);
myImage.ImageUrl = myImage.ResolveUrl(photoURL);
An alternative, if you are using a static class as I am, is to use the VirtualPathUtility:
myImage.ImageUrl = VirtualPathUtility.ToAbsolute(photoURL);
|
Perhaps try [ctypes ][1]instead of SWIG. If it has been included as a part of Python 2.5, then it must be good :-)
[1]: http://python.net/crew/theller/ctypes/ |
In my experience, there are two easy ways to call into C code from Python code. There are other approaches, all of which are more annoying and/or verbose.
The first and easiest is to compile a bunch of C code as a separate shared library and then call functions in that library using ctypes. Unfortunately, passing anything other than basic data types is non-trivial.
The second easiest way is to write a Python module in C and then call functions in that module. You can pass anything you want to these C functions without having to jump through any hoops. And it's easy to call Python functions or methods from these C functions, as described here: <http://www.python.org/doc/ext/callingPython.html>
I don't have enough experience with SWIG to offer intelligent commentary. And while it is possible to do things like pass custom Python objects to C functions through ctypes, or to define new Python classes in C, these things are annoying and verbose and I recommend taking one of the two approaches described above. |
With our internal [TRAC][1] server, I'm subscribed to the timeline view for each project that I work on. It's great for keeping track of checkins and bug tickets. This is pretty exclusive to a developer position though.
I also am subscribed to the recent changes for our installation of [MediaWiki][2] that we use for our intranet. That way it's easy to see if documents that I need have been changed, or if there's new policies etc.
Our website has a news page that I wrote an RSS feed for as well. While you mentioned that you weren't really interested in recent news, it is nice to keep up with our press releases.
[1]: http://trac.edgewall.com/
[2]: http://www.mediawiki.org/wiki/MediaWiki |
@Blair Conrad: You could also implement your glob/reduce using sum, like so:
files = sum([glob.glob(f) for f in args], [])
This is less verbose than either of your two examples, is perfectly Pythonic, and is still only one line of code.
So to answer the original question, I personally try to avoid using reduce because it's never really necessary and I find it to be less clear than other approaches. However, some people get used to reduce and come to prefer it to list comprehensions (especially Haskell programmers). But if you're not already thinking about a problem in terms of reduce, you probably don't need to worry about using it. |
Visual Studio Setup Project - Per User Registry Settings |
|visual-studio|registry|installation| |
I'm trying to maintain a Setup Project in Visual Studio 2003 (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to HKCU for every user on the computer. They need to be in the HKCU rather than HKLM because they are the default user settings, and do change per user. My feeling is that
1. This isn't possible
2. This isn't something the installer should be doing, but something the application should be doing (after all what happens when a user profile is created after the install?).
With that in mind, I still want to change as little as possible in the application, so my question is, **is possible to add registry entries for every user in a Visual Studio 2003 setup project?**
And, at the moment the project lists five registry root keys (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, and User/Machine Hive), I don't really know anything about the Users root key, and haven't seen User/Machine Hive. Can anyone enlighten me on what they are? Perhapes they could solve my problem above. |
The magic all seems to be in
visitortime.getTimezoneOffset()
That's cool, I didn't know about that. Does it work in IE, etc?
From there you should be able to use JS to ajax, set cookies, whatever. I'd probably go the cookie route myself.
You'll need to allow the user to change it though. We tried to use geolocation (via maxmind) to do this a while ago, and it was wrong reasonably often - enough to make it not worth doing, so we just let the user set it in their profile, and show a notice to users who haven't set theirs yet. |
I'm partway to my solution with this entry on MSDN (don't know how I couldn't find it before).
User/Machine Hive
Subkeys and values entered under this hive will be installed under the HKEY_CURRENT_USER hive when a user chooses "Just Me" or the HKEY_USERS hive or when a user chooses "Everyone" during installation.
[http://msdn.microsoft.com/en-us/library/x6kd89c5(VS.80).aspx][1]
[1]: http://msdn.microsoft.com/en-us/library/x6kd89c5(VS.80).aspx |
First: Yes, this is something that belongs in the Application for the exact reson you specified: What happens after new user profiles are created? Sure, if you're using a domain it's possible to have some stuff put in the registry on creation, but this is not really a use case. The Application should check if there are seetings and use the default settings if not.
That being said, it IS possible to change other users Keys through the HKEY_USERS Hive.
I have no experience with the Visual Studio 2003 Setup Project, so here is a bit of (totally unrelated) VBScript code that might just give you an idea where to look:
const HKEY_USERS = &H80000003
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = ""
objReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
strKeyPath = "\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing"
For Each subkey In arrSubKeys
objReg.SetDWORDValue HKEY_USERS, subkey & strKeyPath, "State", 146944
Next
(Code Courtesy of [Jeroen Ritmeijer][1])
[1]: http://jritmeijer.spaces.live.com/blog/cns!8A48A27460FB898A!965.entry |
I'd suggest you try Subversion, for example with the [1-click SVN installer][1]. Try searching SO for "Subversion", and you'll find loads of questions with answers that point to good tutorials.
Good luck!
[1]: http://svn1clicksetup.tigris.org/ |
My first exposure was CVS with WinCVS as a client. it was horrid. Next was Subversion, with TortoiseSVN and Eclipse's integration. It was intuitive, and heavenly. I think that using CVS with TortoiseCVS and Eclipse's would be nice as well, though I prefer the way SVN handles revisioning. The entire repository is versioned with each check in, not individual files. |
Never. Ever. If you have variable shadowing, your naming conventions are on crack. I mean, really, no distinguishing naming for member variables? *Facepalm* |
To expand on Konrad's comment:
> As a consequence, a purely functional program always yields the same value for an input, and the order of evaluation is not well-defined;
Because of this, functional code is generally easier to parallelize. Since there are (generally) no side effects of the functions, and they (generally) just act on their arguments, a lot of concurrency issues go away.
Functional programming is also used when you need to be capable of *proving* your code is correct. This is much harder to do with procedural programming (not easy with functional, but still easier).
Disclaimer: I haven't used functional programming in years, and only recently started looking at it again, so I might not be completely correct here. :) |
There are a few core concepts that I think are important to learn:
1. Check-ins/check-outs (obviously)
2. Local versions vs. server versions
3. Merging your changes back into a file that contains changes from
others.
4. Branching (what it is, when/why to use it)
5. Merging changes from a branch back into a main branch or trunk.
Most modern source control systems require some knowledge of the above topics and should help facilitate you learning them. Then you have distributed source control, which I don't have any experience with but is supposed to be fairly complicated and may not be suitable for a beginner.
[Subversion][1] is great because it has all of the modern features you'd want and is free.
[1]: http://subversion.tigris.org/ |
I think it would be good to store somewhere all possible primes smaller then n and just iterate through them to find the biggest divisior. You can get primes from [prime-numbers.org][1].
Of course I assume that your number isn't too big :)
[1]: http://www.prime-numbers.org/ |
Silverlight programmer's don't know what they're missing out on, when it comes to Flex. Silverlight lacks the component model and event triggering capabilites that Flex has. Using XNA, and C#, a friend of mine has to jump through all kinds of hoops to get his Silverlight application to work. Then, it has to be handed off to a designer to get it to look half way decent.
Listen to the deepfriedbytes.com podcasts on Silverlight, and you'll hear how even a couple guys that really push Silverlight, acknowledge some of these issues. (I *think*, if I recall correctly, one of the guys works for Microsoft, but I could be wrong - I listened to it last week). They agree that Silverlight isn't quite ready for any huge applications, in its current state.
I would go with Flex, for a nice clean, straightforward approach - especially if you're already familiar with Flash and ActionScript 3.0. Flex makes alot more sense, in my opinion - Silverlight still has to mature. |
MVP the View is in charge.
The View, in most cases, creates it's Presenter. The Presenter will interact with the model and manipulate the View through an interface. The View will sometimes interact with the Presenter, usually through some interface. This comes down to implementation, do you want the View to call methods on the presenter or do you want the View to have events the Presenter listens to. It boils down to this: The View knows about the Presenter. The View delegates to the Presenter.
MVC the Controller is in charge.
Controller is created or accessed based on some event/request, the controller then creates the appropriate View and interacts with the Model to further configure the View. It boils down to: Controller creates and manages View, View is slave to Controller. View does not know about Controller. |
You could also look at a migrations solution like Migrator.net. These allow you to specify your database schema in C# code, and roll your database version up and down using MSBuild. |
If by fastest you mean fastest to type in the code, here's the [golfscript](http://www.golfscript.com/golfscript/examples.html) solution:
;''6666,-2%{2+.2/@*\/10.3??2*+}*`1000<~\; |
After having this problem for weeks on Vista 64, I found a post by Dave Bouwman just today, and it fixed this problem.
<http://blog.davebouwman.net/2008/08/05/TroubleRunningMbUnitTestsWithTestDrivennetOnVista64.aspx> |
We don't store the database schema, we store the changes to the database. What we do is store the schema changes so that we build a change script for any version of the database and apply it to our customer's databases. I wrote an database utility app that gets distributed with our main application that can read that script and know which updates need to be applied. It also has enough smarts to refresh views and stored procedures as needed. |
You can try Emacs with ruby-mode, [Rinari](http://rinari.rubyforge.org/) (for Rails) and [yasnippet](http://code.google.com/p/yasnippet/) which provides automatic snippets like Textmate. |
You should take a look at [Git][1] instead of SVN. It's a <acronym title="Distributed Version Control System">DVCS</acronym> that's blazing-fast and very powerful. It's not as user-friendly as SVN, but it's improving in that regard, and it's not *that* hard to learn.
[1]: http://git-scm.com |
Unhandled Exception Handler in .NET 1.1 |
|.net|.net1.1|exception|c#| |
I'm maintaining a .NET 1.1 application, and one of the things I've been tasked with is making sure the user doesn't see any unfriendly error notifications.
I've added handlers to Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, which do get called. My problem is that the standard CLR is still displayed (before the exception handler is called).
Jeff talks about this problem on his blog [here][1] and [here][2]. But there's no solution. So what is the standard way in .NET 1.1 to handle uncaught exceptions and display a friendly dialog box?
[1]: http://www.codinghorror.com/blog/archives/000201.html
[2]: http://www.codinghorror.com/blog/archives/000216.html |
Web App - Dashboard Type GUI - Interface |
|c#|asp.net|javascript|user-interface| |
I'm looking to create a dashboard type gui for a web application. I'm looking for the user to be able to drag and drop different elements (probably either image buttons, anchor tags, or maybe just divs) to different (defined) places and be able to save their setup (in a cookie or on the server). I'm working with c# in the .Net 2.0 framework. I've tried using mootools but their recent update has left their drag/drop capabilities un-useful for me. I'm looking for a bit of direction because I know there is something out there that is just what I'm looking for so I wont have to build from scratch.
Thanks. |
@komradekatz, your solution below from MSDN for convenience for others looking into this. I do not like this solution because it uses the user agent to determine the version. This is not viable for what I need (I am writing a class library that needs to know whether .NET 3.5 is installed). I also question how reliable this solution may prove to be.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
<TITLE>Test for the .NET Framework 3.5</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<SCRIPT LANGUAGE="JavaScript">
<!--
var dotNETRuntimeVersion = "3.5.0.0";
function window::onload()
{
if (HasRuntimeVersion(dotNETRuntimeVersion))
{
result.innerText =
"This machine has the correct version of the .NET Framework 3.5."
}
else
{
result.innerText =
"This machine does not have the correct version of the .NET Framework 3.5." +
" The required version is v" + dotNETRuntimeVersion + ".";
}
result.innerText += "\n\nThis machine's userAgent string is: " +
navigator.userAgent + ".";
}
//
// Retrieve the version from the user agent string and
// compare with the specified version.
//
function HasRuntimeVersion(versionToCheck)
{
var userAgentString =
navigator.userAgent.match(/.NET CLR [0-9.]+/g);
if (userAgentString != null)
{
var i;
for (i = 0; i < userAgentString.length; ++i)
{
if (CompareVersions(GetVersion(versionToCheck),
GetVersion(userAgentString[i])) <= 0)
return true;
}
}
return false;
}
//
// Extract the numeric part of the version string.
//
function GetVersion(versionString)
{
var numericString =
versionString.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
return numericString.slice(1);
}
//
// Compare the 2 version strings by converting them to numeric format.
//
function CompareVersions(version1, version2)
{
for (i = 0; i < version1.length; ++i)
{
var number1 = new Number(version1[i]);
var number2 = new Number(version2[i]);
if (number1 < number2)
return -1;
if (number1 > number2)
return 1;
}
return 0;
}
-->
</SCRIPT>
</HEAD>
<BODY>
<div id="result" />
</BODY>
</HTML>
On my machine this outputs:
> This machine has the correct version
> of the .NET Framework 3.5.
>
> This machine's userAgent string is:
> Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 6.0; SLCC1; .NET CLR
> 2.0.50727; .NET CLR 3.0.04506; InfoPath.2; .NET CLR 1.1.4322; .NET
> CLR 3.5.21022; Zune 2.5).
|
We use nginx and FastCGI for all of our Django deployments. This is mostly because we usually deploy over at Slicehost, and don't want to donate all of our memory to Apache. I guess this would be our "use case".
As for the remarks about the documentation being mostly in Russian -- I've found most of the information on the [English wiki][1] to be very useful and accurate. This site has sample configurations for Django too, from which you can tweak your own nginx configuration.
[1]: http://wiki.codemongers.com/Main |
The "Message" term can refer to sending a message to an object, which is supported in some programming languages and not others.
If the object supports the message, then it will execute some code. Otherwise it will just ignore it. This is a more dynamic approach than an explicit function/method call where the object must support that function.
Objective-c, I believe, uses this messaging approach.
|
How do You Build a Date or Calendar Object From a String in Java? |
|java|dates| |
I have a string representation of a date that I need to create an object from. I've looked through Date and Calendar API but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution? |
Is it possible that the newest version has not yet been ported to Win32 yet? Since this particular gem does have bindings to compiled code, it would require a platform-specific gem. If I force installation of version 1.2.3 rather than the current 1.2.4, the platform-specific version does install, but when I allow gem to try to install the current version, I get the generic 1.2.4 version (in the gems library folder, it lacks the -x86-mswin32 suffix that the other sqlite3-ruby folders have in their names.
Maybe someone else can answer how gem handles platform specific gems. Are separate gems uploaded for each platform and the gem software selects which one to pull down? |
Pros and Cons of different approaches to web programming in Python |
|python|html|cgi| |
I'd like to do some server-side scripting using Python. But I'm kind of lost with the number of ways to do that.
It starts with the do-it-yourself CGI approach and it seems to end with some pretty robust frameworks that would basically do all the job themselves. And a huge lot of stuff in between, like [web.py](http://webpy.org/), [Pyroxide](http://pyroxide.org/) and [Django](http://wiki.python.org/moin/Django).
* What are the **pros** and **cons** of the frameworks or approaches that *you've worked on*?
* What **trade-offs** are there?
* For **what kind of projects** they do well and for what they don't? |
|python|html|cgi|wsgi|frameworks| |
|python|html|frameworks|cgi|wsgi| |
I'd like to do some server-side scripting using Python. But I'm kind of lost with the number of ways to do that.
It starts with the do-it-yourself CGI approach and it seems to end with some pretty robust frameworks that would basically do all the job themselves. And a huge lot of stuff in between, like [web.py](http://webpy.org/), [Pyroxide](http://pyroxide.org/) and [Django](http://wiki.python.org/moin/Django).
* What are the **pros** and **cons** of the frameworks or approaches that *you've worked on*?
* What **trade-offs** are there?
* For **what kind of projects** they do well and for what they don't?
Edit: I haven't got much experience with web programing yet.
I would like to avoid the basic and tedious things like parsing the URL for parameters, etc.
On the other hand, while the video of [blog created in 15 minutes](http://www.rubyonrails.org/screencasts) with [Ruby on Rails](http://www.rubyonrails.org/) left me impressed, I realized that there were hundreds of things hidden from me - which is cool if you need to write a working webapp in no time, but not that great for really understanding the magic - and that's what I seek now.
|
The [IntelliJ][1] IDE (Java, Scala, Ruby,...) has a [Locate Duplicate...][2] tool. Usefull indeed !
[1]: http://www.jetbrains.com/idea/index.html
[2]: http://www.jetbrains.com/idea/features/code_duplicate.html |
I ran into this situation recently when I attempted (in InnoDB tables) to make a foreign key reference to a column that had a different data type.
[MySQL 5.1 Documentation][1]
[1]: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html |
You could always try doing a `ulimit -n 2048`. This will only reset the limit for your current shell and the number you specify must not exceed the hard limit
Each operating system has a different hard limit setup in a configuration file. For instance, the hard open file limit on Solaris can be set on boot from /etc/system.
set rlim_fd_max = 166384
set rlim_fd_cur = 8192
On OS X, this same data must be set in /etc/sysctl.conf.
kern.maxfilesperproc=166384
kern.maxfiles=8192
Under Linux, these settings are often in /etc/limits.conf.
Hard limits are maintained by the kernel while the soft limits are enforced by the shell. By definition, the shell limit can not exceed the kernel limit. Even the root user can not reset the system limits without modifying the config file and rebooting the machine.
In addition to the hard limits, there are often defaults set when the machine boots. So, even though you may reset your ulimit in an individual shell, you may find that it resets back to the previous value on reboot. You may want to grep your boot scripts for the existence ulimit commands if you want to change the default.
|
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
$( '#switches li' ).mouseover(
function(){
$( "#slides div" ).hide();
$( '#switches li' ).css( 'font-weight', 'normal' );
$( this ).css( 'font-weight', 'bold' );
$( '#slide' + $( this ).attr( 'id' ).replace( 'switch', '' ) ).show();
}
);
}
);
</script>
</head>
<body>
<ul id="switches">
<li id="switch1" style="font-weight:bold;">First slide</li>
<li id="switch2">Second slide</li>
<li id="switch3">Third slide</li>
<li id="switch4">Fourth slide</li>
</ul>
<div id="slides">
<div id="slide1">Well well.</div>
<div id="slide2" style="display:none;">Oh no!</div>
<div id="slide3" style="display:none;">You again?</div>
<div id="slide4" style="display:none;">I'm gone!</div>
</div>
</body>
</html> |
Project->Properties->Configuration Properties->C/C++->Output Files
There you should see an option for Assembler Output.
John.
|
1. Open the Properties page for a project
2. Select the `Configuration Properties -> C/C++ -> Output Files` branch
3. Change the Assembler Output option to something other than `No Listing`
4. Make sure ASM List Location is set to a valid path or sub-path
5. Build. |
There's no such thing as a “good hash function” for universal hashes (ed. yes, I know there's such a thing as “universal hashing” but that's not what I meant). Depending on the context different criteria determine the quality of a hash. Two people already mentioned SHA. This is a cryptographic hash and it isn't at all good for hash tables which you probably mean.
Hash tables have very different requirements. But still, finding a good hash function universally is hard because different data types expose different information that can be hashed. As a rule of thumb it is good to consider *all* information a type holds equally. This is not always easy or even possible. Statistically, it is also important to generate a good stretch over the problem space, i.e. all possible objects. This means that when hashing numbers between 100 and 1050 it's no good to let the most significant digit play a big part in the hash because for ~ 90% of the objects, this digit will be 0. It's far more important to let the last three digits determine the hash.
Similarly, when hashing strings it's important to consider all characters – except when it's known in advance that the first three characters of all strings will be the same; considering these then is a waste.
This is actually one of the cases where I advise to read what Knuth has to say in *The Art of Computer Programming*, vol. 3. Another good read is Julienne Walker's [The Art of Hashing](http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.