instruction stringlengths 0 30k ⌀ |
|---|
Timeslicing is inherent to any round-robin scheduling system in practice, AFAIK.
I disagree with InSciTek Jeff's implication that the following *is* round-robin scheduling:
> That is, each task at the same priority in the round-robin rotation can be allowed to run until they reach a resource blocking condition befo... |
Consider a Flyweight factory of Strategy objects, one per 'class' of event.
For each event, look up the appropriate parsing strategy from the flyweight factory, and then pass the event to the strategy for parsing. Strategies can inherit from a base strategy which handles the shared properties and provides common par... |
Consider a Flyweight factory of Strategy objects, one per 'class' of event.
For each line of event data, look up the appropriate parsing strategy from the flyweight factory, and then pass the event data to the strategy for parsing. Each of the 60 strategy objects could be of the same class, but configured with a dif... |
Since you're dealing with code you don't have access to you're probably out of luck. The standard procedure (as outlined in the other answers) is to have a flag that is checked periodically by the running thread. If the flag is set, do cleanup and exit.
Since that option is not available to you, the only other opti... |
These link may be of help:
http://www.ai.uga.edu/mc/SingleInstance.html
It has code to detect another instance running, not sure what you can do with it once you've got the instance though. |
The switch() will compile out to code equivalent to a set of else ifs. The string comparisons will be much slower than the type comparisons. |
The first issue is to make sure the Debugger type is set to mixed. Then you get useful exceptions. |
U should lookup [Dmigrations][1], it functions a little bit diffrent from django-eveoltions.
It shows you everything it is doing and for compliccated things it asks you for your intervetnions. It should be great.
[1]: http://code.google.com/p/dmigrations/ |
You can set application current culture this way:
static void Main()
{
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("fi-FI");
Application.CurrentCulture = cultureInfo;
Application.EnableVisualStyles();
Application.SetCompatibleTextRe... |
Generics avoid the performance hit of boxing and unboxing. Basically, look at ArrayList vs List<T>. Both do the same core things, but List<T> will be a lot faster because you don't have to box to/from object. |
Generics let you use strong typing for objects and data structures that should be able to hold any object. It also eliminates tedious and expensive typecasts when retrieving objects from generic structures (boxing/unboxing).
One example that uses both is a linked list. What good would a linked list class be if it co... |
Sql Server compatibility mode |
|sql-server|data|compatibility|update|upgrade| |
Were currently running a server on Compatability mode 8 and I want to update it.
- What are the implications of just going in and changing it?
- What is likely to break?
- Is there anything that checks the data will survive before I perform it?
- Can I rollback to mode 8 without performing a restore a... |
I've had good success with SBCL and CL-SQL. CL-SQL has a object mapping API, but I used the plain SQL API which simply returns lists and this worked well enough. And in the Clojure language, you interact with JDBC through a maps or structs {:col1 "a", :col2 "b"}, so a generated class library doesn't get you any simpl... |
It's rare to find a boss who will give you time to refactor...just do it as you go along. |
Similar to Robert Paulson, above, our organization keeps the database under source control. However, our difference is that we try to limit the number of scripts we have.
For any new project, there's a set procedure. We have a schema creation script at version 1, a stored proc creation script and possibly an initia... |
I think that the rule of single assertion is a little too strict. In my unit tests, I try to follow the rule of **single group of assertions** -- you can use more than one assertion in one test method, as long as you do the checks one after another (you don't change the state of tested class between the assertions).
... |
I think that you will find that in practice developers will prefer to use a central repository than pushing and pulling between each other's local repositories. Once you've cloned a central repository, while working on any tracking branches, fetching and pushing are trivial commands. Adding half a dozen remotes to all ... |
Get Form request with Seam/JSF |
|seam|jsf|java| |
I have a query form that I would like to submit as a GET request so the result page may be bookmarked. It's your classical text field with a submit button. How do I induce Seam/JSF to use GET and include the query expression as a parameter rather than POST, the default? |
|java|rest|jsf|seam| |
I have a query form that I would like to submit as a GET request so the result page may be bookmarked and otherwise RESTful. It's your classical text field with a submit button. How do I induce Seam/JSF to use GET and include the query expression as a parameter rather than POST, the default? |
This requires the **sp___drop___constraints** script you can find at [Database Journal][1]:
sp_MSforeachtable @command1="print 'disabling constraints: ?'", @command2="sp_drop_constraints @tablename=?"
GO
sp_MSforeachtable @command1="print 'dropping: ?'", @command2="DROP TABLE ?"
GO
[1]: htt... |
This requires the **sp___drop___constraints** script you can find at [Database Journal][1]:
sp_MSforeachtable @command1="print 'disabling constraints: ?'", @command2="sp_drop_constraints @tablename=?"
GO
sp_MSforeachtable @command1="print 'dropping: ?'", @command2="DROP TABLE ?"
GO
**NOTE** thi... |
I've had to look at monster(runaway) log files (20+ GB). I used hexedit(http://www.download.com/3001-2352_4-10823211.html) FREE version which can work with any size files. It is also open source. Cool ?
|
I'm considering using GWT on an intranet project and considering suggesting to the users that use Chrome to take advantage of the enhanced Javascript performance. Any AJAX-heavy app would be a great candidate to target Chrome. |
In SQL Server, use the nolock directive. It allows the select command to complete without having to wait - usually other transactions to finish.
SELECT * FROM Orders (nolock) where UserName = 'momma'
|
The [Google chrome][1] browser has a reasonable wee JS debugger built-in. There's a good list of the available commands [here][2].
[1]: http://www.google.com/chrome
[2]: http://www.pascarello.com/lessons/browsers/ChromeDebugHelp.html |
SHA1 is [broken][1]. Course, there isn't much information out on what a good replacement is. SHA2?
[1]: http://www.schneier.com/blog/archives/2005/02/sha1_broken.html |
Does Weblogic 9.x support the 2.4 Servlet standard? |
|java|servlets|weblogic| |
Seems like a simple enough question but I can't seem to find the answer. And hey, dead simple questions like this with dead simple answers is what Joel and Jeff want SO to be all about, right? |
This is very, very subjective because it all depends on what your application does! However, I've just had a look at the Gems I have installed and the one that absolutely does leap out as mandatory is [Capistrano][1].
BTW Restful Authentication is a Rails plugin not a Gem.
[1]: http://www.capify.org/ |
Passing int array as parameter in web user control |
|asp.net| |
I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax:
<uc1:mycontrol runat="server" myintarray="1,2,3" />
This will fail at runtime because it will be expecting an actual int array, but a string is being passed instead. I can make... |
|asp.net|web-user-controls| |
I don't know the correct way to do it, but this manual method is the approach I've used for simple scripts which seems to have preformed suitably.
I'll assume that whatever directory I'm in, the Python files for my program are in the relative `src/` directory, and that the file I want to execute (which has the prope... |
I recently looked carefully at [py-amqplib][1] to act as an AMQP client to a RabbitMQ broker. The latter tool is written in Erlang.
If you're looking to decouple your app. then why couple it to the language itself? Consider using message queues which are language neutral and then you've really got room to grow!
... |
The RCP book mentioned above is great
Also there are some older online articles on the eclipse site starting with http://www.eclipse.org/articles/Article-RCP-1/tutorial1.html. Unfortunately they are a bit out of date. |
You can use reflection, you can get a MethodInfo object for the get/set accessors and call it's Invoke method.
The code example assumes you have both a get and set accessors and you really have to add error handling if you want to use this in production code:
For example to get the value of property Foo of object... |
[CrossFTP][1]: Clients available for Windows, Mac OSX and Linux. Download is [here][2].
[1]: http://www.crossftp.com/
[2]: http://www.crossftp.com/download.htm |
cookies are available to javascript through document.cookie - try using flash's getURL to call a javascript function.
`getURL('javascript:document.cookie = "varname=varvalue; expires=Thu, 2 Aug 2001 20:47:11 UTC; path="');` |
You can instantiate the appropriate ActionResult directly, then set it on the context. For example:
public void OnAuthorization(AuthorizationContext context)
{
if (!context.HttpContext.User.Identity.IsAuthenticated)
{
context.Result = new ViewResult { ViewName = "Whatever" };
... |
How do you change the http header information sent in IIS 6 |
|asp.net|iis| |
Currently IIS sends an expires http header of yesterday minus 1 hour on ASP.NET pages. How do I change this to 60 seconds in the further instead? |
jQuery is great - it can do whatever javascript can do, but quicker, and in less code. Its only limitations are the ones inherent in javascript as a client-side scripting language. Like any tool, it's possible to missuse, but unless your scripting needs are profoundly basic there's almost no reason NOT to use it. |
Re: aku's answer:
Then you have to obtain that property info first. It seems "use reflection" is the standard answer to the harder C# questions, but reflection yields not-so-pretty hard-to-maintain code. Dror, why not just create a delegate that reads the property for you? It's a simple one-liner and is probably the... |
Another method is to use the shell's internal parsing tools, which avoids the cost of creating child processes:
<pre>
oIFS=$IFS
IFS=-
file="system-source-yyyymmdd.dat"
set $file
IFS=$oIFS
echo "Source is $2"
</pre>
|
[FileZilla][1]
is my favourite FTP client.
[1]: http://filezilla-project.org/ |
|java| |
I hope this question is not considered too basic for this forum, but we'll see. I'm wondering how to refactor some code for better performance that is getting run a bunch of times.
Say I'm creating a word frequency list, using a Map (probably a HashMap), where each key is a String with the word that's being counted ... |
|java|collections| |
I hope this question is not considered too basic for this forum, but we'll see. I'm wondering how to refactor some code for better performance that is getting run a bunch of times.
Say I'm creating a word frequency list, using a Map (probably a HashMap), where each key is a String with the word that's being counted ... |
|java|optimization|collections| |
After applying debugger to the Hibernate code, it is fixed!
It is not visible in the question's text, but the problem is that Place passed to the createCriteria() method is from another package, not com/example/data, specified in the configuration XML files. Hibernate invokes Class.isAssignableFrom(), and if false i... |
When the page first loads, have Search appear in the text box, colored gray if you want it to be.
When the input box receives focus, select all of the text in the search box so that the user can just start typing, which will delete the selected text in the process. This will also work nicely if the user wants to use... |
The timezone in the email will not show in which timezone it was send. Some programs use ever UTC or GMT. Of course the time zone is part of the date time value and must also be parse.
Why do you want know it.
- Do you want normalize the timestamp? Then use a DateFormat for parsing it.
- Do you want detect th... |
There is a SourceForge project, <http://java-readline.sourceforge.net/>, that provides JNI-based bindings to GNU readline. I've played around with it (not used in an actual project), and it certainly covers all of the functionality. |
TextMate not for "advanced programmers". That does not make sense, TextMate contains everything an "advanced programmer" would want. It allows them to define a bundle that allows them to quickly set up the way they want their source code formatted, or one that follows the project guidelines, quick easy access to create... |
I've personally not had any GDB specific issues when debugging a multi-threaded application, so it may helpful for you to elaborate on exactly what "issues" you are having. It will help us answer you better.
There are several aids that I have used in the past when debugging multi-threaded applications in linux, most... |
Because of all the trouble that a partially created class can cause, I'd say never.
If you need to validate something during construction, make the constructor private and define a public static factory method. The method can throw if something is invalid. But if everything checks out, it calls the constructor, whic... |
If your collection contains value types, they don't need to box/unbox to objects when inserted into the collection so your performance increases dramatically. Cool add-ons like resharper can generate more code for you, like foreach loops. |
You can just use any test framework. The hard part is writing the tools to send/retrieve the data from your test system, not the actual string comparisons.
Your tests would just all look like this:
x = read_input_file(ifilename);
y1 = read_expected_data(ofilename);
send_input_file_to_server();
... |
Java Applet - Partially Signed? |
|java|security|applet|signing| |
Is it possible to sign only part of an applet? Ie, have an applet that pops up no security warnings about being signed, but if some particular function is used (that requires privileges) then use the signed jar?
From what I can tell, some (perhaps most) browsers will pop up the warning for a signed applet even if y... |
What must I do to ensure that a web server (Apache) running on a machine is not accessible to the outside world? |
|development-environment|web-server| |
I would like to use my laptop as a web development (PHP, Python, etc.) machine, but I'm hesitant to do this unless I can ensure that it can not be accessed by the outside world.
I'm guessing that something more than a firewall is necessary, such as configurations to the Apache configuration files, but I'm not sure w... |
There is a good article on [Macros](http://stackoverflow.com/questions/96196/when-are-c-macros-benificial). One of the answers how to use conditional compilation based on OS/COmpiler (its near the top).
The use of the Autoconfiguration tools is a nice addition on top of this but is not needed for small projects ... |
> Validate and format it when the user exits the field.
Yes. Provide noninvasive feedback to the user if validation or formatting rules fail. By noninasive I mean don't popup an alert or modal dialog box, thereby forcing the user to click something. Rather dynamically display a message adjacent or underneath the ... |
> Validate and format it when the user exits the field.
Yes. Provide noninvasive feedback to the user if validation or formatting rules fail. By noninasive I mean don't popup an alert or modal dialog box, thereby forcing the user to click something. Rather dynamically display a message adjacent or underneath the ... |
You can set application current culture this way:
static void Main()
{
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("fi-FI");
Application.CurrentCulture = cultureInfo;
Application.EnableVisualStyles();
Application.SetCompatibleTextRe... |
Correct me if I am misreading the intent of your question, but the underlying question seems to be less about how to force the session to end when a user closes the browser and more about how to prevent a session from ending until the browser is closed.
I think the real answer to this is to re-evaluate what you are ... |
You want to use this:
Enumeration<URL> resources = Thread.getCurrent().getContextClassLoader().getResources("META-INF/MANIFEST.MF");
You can parse the URL to figure out WHICH jar the manifest if from and then read the URL via getInputStream() to parse the manifest. |
You can also the -geometry parameter when firing up emacs: `emacs -geometry 80x60+20+30` will give you a window 80 characters wide, 60 rows high, with the top left corner 20 pixels to the right and 30 pixels down from the top left corner of the background. |
Eclipse memory use |
|java|eclipse|ide|memory| |
I use the recent Ganymede release of Eclipse, specifically the distro for Java EE and web developers. I have installed a few additional plugins (e.g. Subclipse, Spring, FindBugs) and removed all the Mylyn plugins.
I don't do anything particularly heavy-duty within Eclipse such as starting an app server or connectin... |
The value property is only available server-side. Using it client-side won't do anything. Setting it would have to be done server-side, or you'll need to craft fun javascript to address the text of the element that the control is actually rendered as in the browser.
<http://help.infragistics.com/Help/NetAdvantage/NE... |
When running a command with lots of output (like a big "make") I want to not only save the output, but also see it:
make install 2>&1 | tee E.make |
(define (sublist list start number)
(cond ((> start 0) (sublist (cdr list) (- start 1) number))
((> number 0) (cons (car list)
(sublist (cdr list) 0 (- number 1))))
(else '())))
|
Try something like this:
(define (slice l offset length)
(if (null? l)
l
(if (> offset 0)
(slice (cdr l) (- offset 1) length)
(if (> length 0)
(cons (car l) (slice (cdr l) 0 (- length 1)))
'()))))... |
Get it direct from the UK's Meteorological Office. they provide [datafeeds][1] for the world in several formats. If you prefer european dedicated feeds (of which the UK provides data anyway), you want to check [ecomet][2]
[1]: http://www.metoffice.gov.uk/newmedia/datafeed/catalogue.html
[2]: http://www.ecomet... |
How to play a sound in Actionscript 3 that is not in the same directory as the SWF? |
|flash|url|actionscript|audio|urlrequest| |
I have a project with a bunch of external sounds to a SWF. I want to play them, but any time I attempt load a new URL into the sound object it fails with either "Error #2068: Invalid Sound" or raises an ioError with "Error #2032 Stream Error".
// Tried with path prefixed with "http://.." "file://.." "//.." and ".."... |
I don't think you should worry so much about how often. The important thing here is what, when and why. Saying that you have to commit every 3 hours or every 24 hours really makes no sense. Commit when you have something to commit, don't if you don't.
Here's an extract from my <a href="http://blog.looplabel.net/2008... |
There is an 'exceptions' window in VS2005 ... try Ctrl-Alt-E when debugging and click on the 'Thrown' checkbox for the exception you want to stop on. |
One way: call the shell, and use [`cacls`][1] or [`xcacls`][2].
[1]: http://technet.microsoft.com/en-us/library/bb490872.aspx
[2]: http://support.microsoft.com/kb/318754 |
wget has a -r option to make it recursive, try **wget -r -l1** (in case the font makes it hard to read: that last part is a lower case L followed by a number one)
The -l1 part tells it to recurse to a maximum depth of 1. Try playing with this number to scrape more. |
Well, I tried to messure it up with the code below:
For runs = 1 and iterations = 1 the URL method is fastest most times followed by channel. I runned this with some pause fresh about 10 times. So for one time access, using the URL is the fastest way I can think of:
LENGTH sum: 10626, per Iteration: 10626.0
... |
This post describes the GIL at a fairly high-level:
* http://www.pyzine.com/Issue001/Section_Articles/article_ThreadingGlobalInterpreter.html
Of particular interest are these quotes:
> Every ten instructions (this default
> can be changed), the core releases the
> GIL for the current thread. At that
> po... |
Use Rhino Mocks, it can generate implementations of the abstract class at runtime and you can call the non-abstract methods. |
Ruby Soap4R Web Service, .NET Consumer |
|ruby|web-services|soap4r| |