instruction
stringlengths
0
30k
|.net|abstraction|mono|operating-system|max|
I really want to write .NET apps that run on any platform (PC, Linux and Mac). I am not really concerned about UI capabilities because these are mostly background services. I have heard of MONO and that it allows you to write .NET apps that run on Mac and Linux, but I want to be able to write a single app that when c...
|build-automation|automated-tests|finalbuilder|dailybuilds|testcomplete|
We are trying to integrate tests in our daily builds using TestComplete, so far we have a machine dedicated for testing and our build script copies to this machine everything TestComplete needs for its tests (Application, Database, Test script project and source files, etc). Basically we can open the TestComplete pr...
[Firebug lite][1] is a cross browser, lite version of Firefbug that'll at least give you console.log capabilities on most browsers. [1]: http://getfirebug.com/lite.html
Hmm actually, now I look into it a bit, it's a bit more complicated than that. Have a read of these links on [John Resig's blog](http://ejohn.org/blog/offline-events/) and the [Mozilla site](http://developer.mozilla.org/En/Online_and_offline_events). The above poster may also have a good point - you're making requests ...
Use sp_settriggerorder. You can specify the first and last trigger to fire depending on the operation. [sp_settriggerorder on MSDN](http://msdn.microsoft.com/en-us/library/ms186762.aspx) From the above link: <b>A. Setting the firing order for a DML trigger</b> The following example specifies that trigger u...
What about [Firebug Lite][1] (for those non-Firefox browsers)? I haven't used it much except when debugging Dojo code in IE. But it tries as best it can to put a Firebug console in IE, Safari, and Opera. Of course there is always the ever reliable 'alert (err_msg);' :D [1]: http://getfirebug.com/lite.html
There is [JQuery Logging][1], which looks promising. [1]: http://ajaxian.com/archives/jquery-logging
See [here][1]. [1]: http://stackoverflow.com/questions/94103/sql-server-triggers-order-of-execution#94162
I'm making several assumptions based on your writeup: * Keys are cheap to copy and compare * There should be only one copy of the object in the system * The same key may refer to many objects, but only one object corresponds to a given key (one-to-many) * You want to be able to efficiently look up which objects c...
(**Update**: I updated the API for IO::CaptureOutput to make this even easier.) There are several ways to do this. Here's one option, using the [IO::CaptureOutput](http://search.cpan.org/perldoc?IO::CaptureOutput) module: use IO::CaptureOutput qw/capture_exec/; my ($stdout, $stderr, $success, $exit_co...
Assuming you have exactly two lists and they are exactly the same length, here is a solution originally by merlyn (Randal Schwartz), who called it perversely perlish: sub zip2 { my $p = @_ / 2; return @_[ map { $_, $_ + $p } 0 .. $p - 1 ]; } What happens here is that for a 10-element l...
Assuming you have exactly two lists and they are exactly the same length, here is a solution originally by merlyn (Randal Schwartz), who called it perversely perlish: sub zip2 { my $p = @_ / 2; return @_[ map { $_, $_ + $p } 0 .. $p - 1 ]; } What happens here is that for a 10-element l...
If you use `exec` in a function the variable lookup rules change drastically. Closures are no longer possible but Python allows arbitrary identifiers in the function. This gives you a "modifiable locals()" and can be used to star-import identifiers. On the downside it makes every lookup slower because the variables ...
If you need to access multiple users, then [JeniT's `<xsl:key />` approach][1] is ideal. Here is my alternative take on it: <xsl:template match="current/login_name"> <xsl:variable name="person" select="//people/person[login_name = .]" /> <xsl:value-of select="concat($person/first, ' ', $person/l...
Why is quicksort better than mergesort?
|language-agnostic|algorithm|
I was asked this question during an interview. They're both O(nlogn) and yet most people use Quicksort instead of Mergesort. Why is that?
|language-agnostic|algorithm|homework|
Filling PDF Forms with PHP
|php|pdf|
Is there a way to fill PDF forms and then save (flatten) them to PDF files from within PHP? Which library would you recommend?
Also read this blog post on Cocoa with Love: [http://cocoawithlove.com/2008/06/speed-test-nsmanagedobject-objc-20.html][1] There the author compares the speed of custom accessor and dot notations for NSManagedObject, and finds no difference. However, KVC access (setValue:forKey:) appears to be about twice as slow...
Converting a Uniform Distribution to a Normal Distribution
|statistics|random|rng|normal-distribution|gaussian-distribution|
How can I convert a uniform distribution (as most random number generators produce, e.g. between 0.0 and 1.0) into a normal distribution, specifically with a mean and standard deviation of my choosing?
How can I convert a uniform distribution (as most random number generators produce, e.g. between 0.0 and 1.0) into a normal distribution? What if I want a mean and standard deviation of my choosing?
|random|normal-distribution|gaussian-distribution|algorithm|language-agnostic|
|homework|random|normal-distribution|algorithm|language-agnostic|
|language-agnostic|algorithm|random|normal-distribution|
There are a few factors you'll want to consider when deciding where to store temporary data. Session storage is great for data that is specific to a single user. If you find the default file-based session storage handler is inefficient you can implement something else, possibly using a database or memcache type of ba...
|.net|mono|cross-platform|operating-system|abstraction|
Yes, Mono has the windows service stuff ported to Linux, but you are going to have to think of a better way to store configuration settings than Registry... Using XML files for instance would be cross platform. You should also check out mono's wiki on how to develop portable applications [here][1]. [1]: http:...
Stop setInterval call in javascript
|javascript|
I am using `setInterval(fname, 10000);` to call a function every 10 secs in javascript. Is it possible to stop calling the calling on some event? I want the user to be able to stop the repeated refresh of data.
For more complicated formulae (i.e. anything with conditional logic), try creating an event handler for the content type (or doc library). This will allow you full control to set the fields to what you desire. The field can be hidden from the user inside the edit screens. Make sure use the STSDev from [codeplex][...
I found the [The Algorithm Design Manual][1] to be a very beneficial read. I also highly recommend [Programming Pearls][2]. [1]: http://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena/dp/1848000693/ref=pd_bbs_4?ie=UTF8&s=books&qid=1221938795&sr=8-4 [2]: http://www.amazon.com/Programming-Pearls-2nd-ACM-Pr...
What do you means with "Best algorithm"? The shorted code or the fasted code? Your code look very elegant and it has a constant execution time. The code is also very short. But if the speed is the major factor and not the code size then I think the follow can be faster: static final int[] BIT_COUNT = { 0, 1, 1, ....
You might add something like this in your .aspx page <form name="counter"><input type="text" size="8" name="d2"></form> <script> <!-- // var milisec=0 var seconds=30 document.counter.d2.value='30' function display(){ if (milisec<=0){ ...
if you setup the return of setInterval to a variable you can use clearInterval to stop it. var myTimer = setInterval(...); clearInterval(myTimer);
Directory Modification Monitoring
|c#|file|directory|filesystems|scanning|
I'm building a C# application that will monitor a specified directory for changes and additions and storing the information in a database. I would like to avoid checking each individual file for modifications, but I'm not sure if I can completely trust the file access time. What would be the best method to use fo...
a true object (i.e. std::string) etc. inside, because the true object will be initialized before, and then, overwritten by zeroes. Use the initialization list, instead. It will go faster than calling memset, and it will be C++ friendly: class CMyStruct : public MY_STRUCT { public: CMyStruct...
Putting a true object (i.e. std::string) etc. inside will break, because the true object will be initialized before the memset, and then, overwritten by zeroes. Using the initialization list doesn't work for g++ (I'm surprised...). Initialize it instead in the CMyStruct constructor body. It will be C++ friendly: ...
Putting a true object (i.e. std::string) etc. inside will break, because the true object will be initialized before the memset, and then, overwritten by zeroes. Using the initialization list doesn't work for g++ (I'm surprised...). Initialize it instead in the CMyStruct constructor body. It will be C++ friendly: ...
If you're not too bothered about efficiency, you can simply write: var lineCount = File.ReadAllLines(@"C:\file.txt").Length; For a more efficient method you could do: var lineCount = 0; using (var reader = File.OpenText(@"C:\file.txt")) { while (reader.ReadLine() != null) { ...
If you're not too bothered about efficiency, you can simply write: var lineCount = File.ReadAllLines(@"C:\file.txt").Length; For a more efficient method you could do: var lineCount = 0; using (var reader = File.OpenText(@"C:\file.txt")) { while (reader.ReadLine() != null) { ...
Vista skin l&f
|java|windows-vista|themes|
is there anywhere on the web free vista look and feel theme pack for java?
better not wonder about the complexity and time these kinds of algorithms need. If you have interest in this - here [.ps document linked here](http://www.acm.org/jea/ARTICLES/Vol4Nbr2.ps) you can find a good introduction into this thematic. If a good implementation for these algorithms exist, I can not tell. May...
I will be boring and recommend actually taking university courses in math. Without lectures and lessons with an assistant I know I would never be able to learn as much as I have. I just need some kind of motivation, since higher math is really hard. That is, if you are looking for quite advanced stuff and actually ...
I remember reading an article somewhere that pointed out that pretty well everything can be, at some level, part of the business logic, and so the question is meaningless. I think the example given was the display of an invoice onscreen. The decision to mark an overdue one in red is a business decision...
Technically the performance of generics is, as you say, better. However, unless performance is hugely important AND you've already optimised in other areas you're likely to get MUCH better improvements by spending your time elsewhere. I would suggest: - use generics going forward. - if you have solid unit tests...
PostgreSQL has the DISTINCT ON clause, that works this way: SELECT DISTINCT ON (accountid) id, score, accountid FROM scoretable ORDER BY score DESC LIMIT 10; I don't think it's standard SQL though, so expect other databases to do it differently.
2GB (is there a minimum length for answers?)
Okay, I found the answer and I'm a little embarrassed by it. In fact, my question was pretty much off the mark. First, there is no involvement in this problem with XML Notepad 2007. It didn't hijack a file extension or make a registry entry or anything else like that. It's a great little program if you just want ...
Depends on how much is out there in your code. If you binding or display large lists in the UI, you would probably see a great gain in performance. If your ArrayList are just sprinkled about here and there, then it probably wouldn't be a big deal to just get it cleaned up, but also wouldn't impact overall perform...
Most of the other examples are merely overlooked, not unexpected uses for module. fnmatch, like shlex, can be applied in unexpected ways. fnmatch is a kind of poor-person's RE, and can be used for more than matching files, it can compare strings with the simplified wild-card patterns.
Making a beta code for a public django site
|django|python|beta|authentication|
I'm about to put a beta version of the site I'm working on up on the web. It needs to have a beta code to restrict access. The site is written in django. I don't want to change the fundamental Auth system to accommodate a beta code, and I don't care particularly that the security of the beta code is iron-clad, just ...
I'm about to put a beta version of the site I'm working on up on the web. It needs to have a beta code to restrict access. The site is written in django. I don't want to change the fundamental Auth system to accommodate a beta code, and I don't care particularly that the security of the beta code is iron-clad, just ...
|python|authentication|django|beta|
I'm about to put a beta version of the site I'm working on up on the web. It needs to have a beta code to restrict access. The site is written in django. I don't want to change the fundamental Auth system to accommodate a beta code, and I don't care particularly that the security of the beta code is iron-clad, just ...
You can use an ISAPI filter to rewrite URLs which will allow you to have the nice URLs while still on IIS 6. Look, for example, [here][1] [1]: http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx
Every object has a `__dict__` variable containing all the variables and its values in it. Try this >>> hi_obj = hi() >>> hi_obj.__dict__.keys()
Putting a true object (i.e. std::string) etc. inside will break, because the true object will be initialized before the memset, and then, overwritten by zeroes. Using the initialization list doesn't work for g++ (I'm surprised...). Initialize it instead in the CMyStruct constructor body. It will be C++ friendly: ...
From 2.5 onwards dicts have a special method `__missing__` that is invoked for missing items: >>> class MyDict(dict): ... def __missing__(self, key): ... self[key] = rv = [] ... return rv ... >>> m = MyDict() >>> m["foo"].append(1) >>> m["foo"].append(2) >>> dict(m) ...
The best article I found for binding columns from a crosstab query to a report is from [ewbi.develops][1]'s notes. Specifically, PARAMETERS foryear Short; TRANSFORM Sum(mytable.amount) AS total SELECT mytable.project FROM mytable WHERE mytable.year In ([foryear],[foryear]+1) GROUP BY ...
You could try exporting all of your stored procedures into a text file and then use a simple search. A more advanced technique would be to use a regexp search to find all SELECT FROM and INSERT FROM entries.
Highlighting an entity in a query and pressing ALT+F1 will run sp_help for it, giving you a breakdown of any columns, indexes, parameters etc.
Business logic is usually embodied by objects, and the various language constructs of encapsulation, inheritance, and and polymorphism. For example, if a banking application is passing around money, there may be a Money type that defines the business elements of what "money" is. This, opposed to using a primitive decim...
If you have the complete standard library and the real `re` module (google for IronPython community edition) it might work. But IronPython is an incredible bad python implementation, I wouldn't count on that. Besides, give `html5lib` a try. That parser parses with the same rules firefox parses documents.
There's a difference between C++ and C# in this specific case. In C++ the object is not initialized and therefore it is forbidden to call a virutal function inside a constructor. In C# when a class object is created all its members are zero initialized. It is possible to call a virtual function in the constructor but...
There's a difference between C++ and C# in this specific case. In C++ the object is not initialized and therefore it is unsafe to call a virutal function inside a constructor. In C# when a class object is created all its members are zero initialized. It is possible to call a virtual function in the constructor but if...
Oracle databases are quite expensive Oracle does what it does well but the licensing costs are horrendous. That has been improved by the release of Oracle XE but the limitations of that mean that it is a growth constraint on you solution.
SELECT Distinct SO.Name FROM sysobjects SO (NOLOCK) INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID AND SO.Type = 'P' AND (SC.Text LIKE '%UPDATE%' OR SC.Text LIKE '%INSERT%') ORDER BY SO.Name [This link][1] was used as a resource for the SP search. [1]: http://www.kn...
PostgreSQL doesn't have a good failover solution, but I understand they're working on it.
You can compile C# code "on the fly" into an in-memory assembly. I think this is possible with IronPython and IronRuby as well. Look at the [CodeDomProvider.CreateProvider][1] method. If you need to run scripts a lot, or if your process runs for a long time, you might want to load these assemblies into another AppDo...
For SQLServer, there are a couple of options. 1. A while loop to update an empty column with one random number at a time 2. A .net Assembly that contains a function that returns a random number
That very documentation says that the file parameter is "A URI string that references the file to load into a new XDocument." Furthermore, I have code that does exactly that---uses `XDocument.Load` with a URI.
select column1, column2, cast(new_id() as varchar(10)) as column3 from table1
If you are already using jQuery, I can heartily recommend the jQuery Debug plugin (a.k.a., jquery.debug.js). See <a href="http://trainofthoughts.org/blog/2007/03/16/jquery-plugin-debug/">http://trainofthoughts.org/blog/2007/03/16/jquery-plugin-debug/</a>. This plugin allows you to switch debug logging off or on via ...
How do you rate-limit an IO operation?
|language-agnostic|algorithm|io|
Suppose you have a program which reads from a socket. How do you keep the download rate below a certain given threshold?
How could you be sure, that you reached the declaration part in your catch block? What if the declaration throws the exception?
Alternative to 'truss -p' instruction
|unix|solaris|process|status|truss|
I am looking for a command in Unix that returns the status of a process(active, dead, sleeping, waiting for another process, etc.) is there any available?<br> A shell script maybe?
My thought would be that because something in the try block triggered the exception its namespace contents cannot be trusted - ie referencing the String 's' in the catch block could cause the throw of yet another exception.
Just remember that 2^(10\*x) is approximately 10^(3\*x) - you're probably already used to this with kilobytes/kibibytes etc. That is: 2^10 = 1024 ~= one thousand 2^20 = 1024^2 = 1048576 ~= one million 2^30 = 1024^3 = 1073741824 ~= one billion Since an int uses 31 bits (+ ~1 bit fo...
Well if it doesn't throw a compile error, and you could declare it for the rest of the method, then there would be no way to only declare it only within try scope. It's forcing you to be explicit as to where the variable is supposed to exists and doesn't make assumptions.
If using Sharepoint Designer is an option you can create a workflow for that list. Set it to start when a new item is created -or- edited, use a condition of "If Created_By equals ..." and an action of "Set yourfield to yourvalue", then add an Else If branch and repeat. This will always override anything a user enters ...
Best algorithm to count the number of set bits in a 32-bit integer?
|algorithm|integer|