instruction stringlengths 0 30k ⌀ |
|---|
I use [Basic Date Picker][1] and swear by it. We use the pay version, but there is a free version which probably includes all of the features that we use.
[1]: http://www.basicdatepicker.com/ |
If you are going to use the Windows User Authentication, you should probably use some part of it that is more secure than the simple username/password combination. (And there is probably no way to access the password, as that would mean that every .NET application could access your full account information.)
For ins... |
Vincent, I'll answer again using your new requirements. Since you don't care about the content being hidden if it's too long, you don't need to float the header. Just put overflow hidden on the html and body tags, and set #content height to 100%. The content will always be longer than the viewport by the height of t... |
It is best to simply time yourself, record your estimates and determine the average percent you're off. Given that, as long as you are consistent, you can appropriately estimate actual times based on when you believed you'd get it done. It's not simply to determine how bad you are at estimating, but rather to take into... |
Redirect to different controler |
|asp.net-mvc| |
I have some code which redirects the user to a login page but I'm having trouble changing the controller which is used. So I might do
public void OnAuthorization(AuthorizationContext context)
{
UserController u = new UserController();
context.Result = u.Login();
context.Cancel = true;
... |
|asp.net|mvc| |
Redirect to different controller |
I have some code it an IAuthorizationFilter which redirects the user to a login page but I'm having trouble changing the controller which is used. So I might do
public void OnAuthorization(AuthorizationContext context)
{
UserController u = new UserController();
context.Result = u.Login();
... |
|asp.net-mvc| |
I have some code in an IAuthorizationFilter which redirects the user to a login page but I'm having trouble changing the controller which is used. So I might do
public void OnAuthorization(AuthorizationContext context)
{
UserController u = new UserController();
context.Result = u.Login();
... |
If you want to speed up for loops, I prefer declaring a max variable next to the counter so that no repeated lookups for the condidtion are needed:
instead of
for (int i = 0; i < array.length; i++) {
Object next = array[i];
}
I prefer
for (int i = 0, max = array.lenth; i < max; i++) {
... |
[Simpletest](http://simpletest.org/), which is very similar to PHPUnit, but a lot simpler, has a good [introductory tutorial](http://simpletest.org/en/first_test_tutorial.html). Even if you plan to use PHPUnit, this should teach you the basics of unit testing. |
You should read this Hanselman's entry: [http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramework.aspx][1]
It's really interesting if it comes to installing and thus minimalizing installation size of .NET framework. It should be somehow an answer to your question.
[1]: http://www.hanselman.com/blo... |
public override int GetHashCode()
{
unchecked
{
return (str1 ?? String.Empty).GetHashCode() +
(str2 ?? String.Empty);
}
}
Using the '+' operator might be better than using '^', because although you explicitly want ('AA', 'BB') and ('BB', 'AA') to... |
public override int GetHashCode()
{
unchecked
{
return (str1 ?? String.Empty).GetHashCode() +
(str2 ?? String.Empty).GetHashCode();
}
}
Using the '+' operator might be better than using '^', because although you explicitly want ('AA', 'BB') and (... |
For working code to do this, check out [snippet 1053][1] at [djangosnippets.org][2].
[1]: http://www.djangosnippets.org/snippets/1053/
[2]: http://www.djangosnippets.org |
From [my answer][1] to a different question:
> Distributed version control systems
> (DVCSs) solve different problems than
> Centralized VCSs. Comparing them is
> like comparing hammers and
> screwdrivers.
>
> [Centralized VCS][2] systems are
> designed with the intent that there is
> One True Source that ... |
Did you try [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html)? It's available for Windows too and it should be easy to integrate it in any build script/process. |
I notice that you are creating the object in the "Global" namespace but are trying to open it in a local namespace. Does adding "Global\\" to the name in the open call help?
Also, in the //error area, is there anything there to let you know it wasn't created? |
Use the reflection methods on Apache Commons EqualsBuilder (http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/builder/EqualsBuilder.html) and HashCodeBuilder (http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/builder/HashCodeBuilder.html) |
I found solution.
Add new group section (empty) and mark Keep together on this group. :)
|
[Murmur Hash][1] is pretty nice.
[1]: http://murmurhash.googlepages.com/ |
This looks like a good place to start: http://www.unessa.net/en/hoyci/2007/06/using-capistrano-deploy-django-apps/ |
Each page of a Wizard -- by itself -- shouldn't actually be the container for the information you're gathering.
Read up on the [Model-View-Control][1] design pattern. Your pages have the View and Control parts of the design. They aren't the data model, however.
You'll be happier if you have a separate object th... |
Deploying Django: How do you do it? |
|django|python|deployment| |
I have tried following guides like [this one](http://docs.djangoproject.com/en/dev/howto/deployment/modpython/) but it just didnt work for me.
**So my question is this:** What is a good guide for deploying Django, and how do you deploy your Django.
I keep hearing that capastrano is pretty nifty to use, but i have... |
I have tried following guides like [this one](http://docs.djangoproject.com/en/dev/howto/deployment/modpython/) but it just didnt work for me.
**So my question is this:** What is a good guide for deploying Django, and how do you deploy your Django.
I keep hearing that capastrano is pretty nifty to use, but i have... |
Well, it sounds like you already have the answer.. You just need to handle the expection that occurs when reading in the data within the main loop and make it stop there..
Now, I have not done VBScript for a LONG time so, to pseudo it:
While Not EndOfExcelSheet
ReadDataFromExcel();
If errOcc... |
Maybe Nose http://somethingaboutorange.com/mrl/projects/nose/ has a plugin http://somethingaboutorange.com/mrl/projects/nose/doc/writing_plugins.html
Found this: http://jeffwinkler.net/2006/04/27/keeping-your-nose-green/ |
You can use `ulimit` to limit the amount of resources a user can use, including memory. So you create a test user, limit their memory use to something just enough to launch your program, and watch it die :)
Example:
ulimit -m 64
Sets a memory limit of 64kb. |
Upsides for linking directly to SWF file:
- Faster access
- You know it's a flash movie even before you click on the link
- Skipping the html & js files (You won't use CSS to display 100% flash movie anyway)
Downsides:
- You have little control on movie defaults.
- You can't use custom background colors, t... |
You want the ulimit command in bash. Try
<pre>help ulimit</pre> at a bash shell prompt. |
Unfortunately, there's no way to easily do a bulk delete. Your best bet is to write a script that deletes a reasonable number of entries per invocation, and then call it repeatedly - for example, by having your delete script return a 302 redirect whenever there's more data to delete, then fetching it with "wget --max-r... |
Here's a simple way using OLINQ:
// Input array
List<String> lst = new List<string>();
for (int i = 0; i < 500; i += 1) lst.Add(i.ToString());
// Output array
List<String> lstRandom = new List<string>();
// Randomize
Random rnd = new Random();
lstRandom.AddRange(from s in l... |
J2EE is a collection of specifications for developing and deploying enterprise applications.
In general, enterprise applications refer to software hosted on servers that provide the applications that support the enterprise.
The specifications (defined by Sun) describe services, application programming interfaces ... |
A couple more possible reasons to use threads:
1. Your platform lacks asynchronous I/O operations, e.g. Windows ME (No completion ports or overlapped I/O, a pain when porting XP applications that use them.) Java 1.3 and earlier.
2. A third-party library function that can hang, e.g. if a remote server is down, an... |
In the interest of having the information here in case someone stumbles upon this, you would need to do something like
<code>$this->renderElement('display', array('flag' => 'value'));</code>
in your view, and then in `/app/views/elements/` you can make a file called `display.thtml`, where `$flag` will have the v... |
In the interest of having the information here in case someone stumbles upon this, it is important to note that the solution varies depending on the CakePHP version.
<h2>For CakePHP 1.1</h2>
<code>$this->renderElement('display', array('flag' => 'value'));</code>
in your view, and then in `/app/views/elements/`... |
Try replacing
"dir \*vim\*"
with
" -command { dir \*vim\* }" |
Try replacing
"dir \*vim\*"
with
" -command { dir \*vim\* }"
**EDIT:** Try using cmd.exe as the shell and put "powershell.exe" before "-command" |
Fetch one row per account id from list |
|sql|database|mysql| |
I have a table with game scores, allowing multiple rows per account id: `scores (id, score, accountid)`. I want a list of the top 10 scorer ids and their scores.
Can you provide an sql statement to select the top 10 scores, but only one score per account id?
Thanks!
|
The biggest gains, you will find in Maintenance phases. Generics are much easier to deal with and update, without having to deal with conversion and casting issues. If this is code that you continually visit, then by all means take the effort. If this is code that hasn't been touched in years, I wouldn't really b... |
Folks have mentioned already that statefulness isn't a big component of typical chatbots:
- a pure Markov implementations may express a very loose sort of state if it is growing its lexicon and table in real time—earlier utterances by the human interlocutor may get regurgitated by chance later in the conversat... |
I have some code in an IAuthorizationFilter which redirects the user to a login page but I'm having trouble changing the controller which is used. So I might do
public void OnAuthorization(AuthorizationContext context)
{
UserController u = new UserController();
context.Result = u.Login();
... |
If the extra resource **complement** your existing team it can be ideal. For example, if you are about to set up your production hardware and verify that the database is actually tuned as opposed to just returning good results (that your team knows as domain experts) borrowing time from a good dba who works on the th... |
If the extra resource **complement** your existing team it can be ideal. For example, if you are about to set up your production hardware and verify that the database is actually tuned as opposed to just returning good results (that your team knows as domain experts) borrowing time from a good dba who works on the the ... |
A closure is where an inner function has access to variables in it's outer function. That's probably the simplest one-line explanation you can get for closures. |
It seems to me that the biggest part is the indexing of sites. Making bots to scour the internet and parse their contents.
A friend and I were talking about how amazing Google and other search engines have to be under the hood. Millions of results in under half a second? Crazy. I think that they might have prese... |
It seems like the cleanest thing to do would be to create a custom property class that implements Comparable. For example:
class Color implements Comparable {
private int number;
private int color;
// (snip ctor, setters, etc.)
public int getNumber() {
return number;
... |
From [my answer][1] to a different [question][2]:
> Distributed version control systems
> (DVCSs) solve different problems than
> Centralized VCSs. Comparing them is
> like comparing hammers and
> screwdrivers.
>
> [Centralized VCS][3] systems are
> designed with the intent that there is
> One True Source ... |
SLIME's contrib directory seems to have SWANK implementations for MIT Scheme and Kawa. |
W. Craig Trader's answer sums up most of it, however, I find that personal work style makes a huge difference as well. Where I currently work we use subversion as our One True Source, however, many developers use git-svn on their personal machines to compensate for workflow issue we have (failure of management, but tha... |
i suppose this would help..
from httplib2 import Http
def get_html(uri,num_redirections=0): # put it as 0 for not to follow redirects
conn = Http()
return conn.request(uri,redirections=num_redirections)
|
i suppose this would help
from httplib2 import Http
def get_html(uri,num_redirections=0): # put it as 0 for not to follow redirects
conn = Http()
return conn.request(uri,redirections=num_redirections)
|
If you download F#, and reference one of the runtime libraries (I think it's FSharp.PowerPack), and use Microsoft.FSharp.Maths.Matrix. It optimises itself based on whether you are using a dense or sparse matrix. |
I found [this tutorial](http://dimuthuc.blogspot.com/2008/01/php-webservice-consume-from-flex.html) pretty helpful - it gives clear examples of consuming a basic webservice, with code on both sides (server and flex).
One thing to remember when accessing remote webservices on a remote server from flex is the need fo... |
Changing `VS_VERSION_INFO` will reflect when you right click on the file in Explorer and see properties only.
If you want to show the current SVN revision number in the Caption bar, i would suggest:
- Have a script get the version number and generate version.h file just with
> #define SVN_VERSION_N... |
Another option sometimes used for things like this is to use lists of syllables. ie. you have a list of syllables like ['a','ab', 'ba','bi','bo','ca','...] and transform the number into base(len(list_of_syllables)). This is longer in terms of letters, but it can often be easier to memorise something like "flobagoka' ... |
Another option sometimes used for things like this is to use lists of syllables. ie. you have a list of syllables like ['a','ab', 'ba','bi','bo','ca','...] and transform the number into base(len(list_of_syllables)). This is longer in terms of letters, but it can often be easier to memorise something like "flobagoka' ... |
try this before anything else:
(require :asdf)
you can steal some ideas from the environment we use. it's available at: [darcsweb][1]
see environment.lisp that loads and sets up asdf for us. (sbcl has asdf already loaded)
[1]: http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=cl-dwim-environment;... |
Use limit - you don't want to transfer masses of data from the database to the scripting engine if you can avoid it. |
I think there are 3 levels of the details of an error message for the 3 typical user groups:
1. The end user. This is a surfer on a web site or an user of a desktop application. He should receive an error message if the problem can not be compensate. It should include the minimum of information. The end user should... |
For normal, day-to-day operation, I give a data validation message that gives enough information that the user can fix the problem, so that the data validates. For example, if I have two fields (fieldA and fieldB) and one of them have to be greater than the other, then I would state that on the validation output, spe... |
Most of the LINQ extension methods return results. ForEach does not fit into this pattern as it returns nothing. |
**Main messages :)**
import this
# btw look at this module's source :) |
SQL-92 standard defines INFORMATION_SCHEMA which conforming rdbms's like MS SQL Server support.
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'myTable'
|
SQL-92 standard defines INFORMATION_SCHEMA which conforming rdbms's like MS SQL Server support. The following works for MS SQL Server 2000/2005/2008 and MySql
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'myTable'
MS SQl Server Specific:
exec sp_help 'myTable'
This solution ... |
SQL-92 standard defines INFORMATION_SCHEMA which conforming rdbms's like MS SQL Server support. The following works for MS SQL Server 2000/2005/2008 and MySql
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'myTable'
MS SQl Server Specific:
exec sp_help 'myTable'
This solution ... |
SQL-92 standard defines INFORMATION_SCHEMA which conforming rdbms's like MS SQL Server support. The following works for MS SQL Server 2000/2005/2008 and MySql 5 and above
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'myTable'
MS SQl Server Specific:
exec sp_help 'myTable'
Th... |
ForEach method was added before LINQ. If you add ForEach extension, it will never be called for List instances because of extension methods constraints. I think the reason it was not added is to not interference with existing one.
However, if you really miss this little nice function, you can roll out your own vers... |
**List comprehensions**
[list comprehensions][1]
[1]: http://www.secnetix.de/olli/Python/list_comprehensions.hawk |
There's also one in F#:
let zipped = Seq.zip firstEnumeration secondEnumation |
One of the issues you have with the switch is using strings, like "Bob", this will cause a lot more cycles and lines in the compiled code. The IL that is generated will have to declare a string, set it to "Bob" then use it in the comparison. So with that in mind your IF statements will run faster.
PS. Aeon's exam... |
One of the issues you have with the switch is using strings, like "Bob", this will cause a lot more cycles and lines in the compiled code. The IL that is generated will have to declare a string, set it to "Bob" then use it in the comparison. So with that in mind your IF statements will run faster.
PS. Aeon's exam... |
Assuming you mean the overhead of the call itself, rather than what the callee might do, it's definitely far, far quicker than all but the "simple" memory access.
It's probably slower than the memory access, but note that since the compiler can do inlining, function call overhead is sometimes zero. Even if not, it's... |
It depends, the best answer is to profile your code and see. I like AQTime but a number of packages exist for this.
In general, if an ArrayList is being used a LOT it may be worth switching it to a generic version. Really though, it's most likely that you wouldn't even be able to measure the performance difference. ... |
[Xapian][1] is another option for you. I've heard it scales better than some implementations of Lucene.
[1]: http://xapian.org/ |
Using a USB controller as auxiliary keyboard for Visual Studio |
|usb|controller| |
Our family no longer uses our [Mixman DM2][1] USB conbtroller for making music. This frees it up for me to use as an auxiliary keyboard with 31 "keys" (and a few "sliders"). I had the crazy idea to use these buttons to send keyboard shortcuts to Visual Studio. It just seems easier pressing one key than some of the f... |
Our family no longer uses our [Mixman DM2][1] USB controller for making music. This frees it up for me to use as an auxiliary keyboard with 31 "keys" (and a few "sliders"). I had the crazy idea to use these buttons to send keyboard shortcuts to Visual Studio. It just seems easier pressing one key than some of the fi... |
Our family no longer uses our [Mixman DM2][1] USB controller for making music. This frees it up for me to use as an auxiliary keyboard with 31 "keys" (and a few "sliders"). I had the crazy idea to use these buttons to send keyboard shortcuts to Visual Studio. It just seems easier pressing one key than some of the fi... |
If you'd be willing to allocate some extra space, you could generate another array, call it extra, with elements like this:
extra = [0,1,...,numbers.length-1]
Then you could sort this extra array using Arrays.sort() with custom comparator (that, while comparing elements i and j really compares numbers[ext... |
Sorting matched arrays in Java |
Question to clarify why you're attempting this: If the only user interface on the process is the system tray icon, why would you want to kill that and but leave the process running? How would the user access the process? And if the machine is "unattended", why concern yourself with the tray icon? |
Any version of Visual Studio will do the job. Remember to think about deployment and if you'd want to require the user to have this or that version of the .net framework installed. |
Phantom Referenced Objects |
|java| |
Phantom References serve for post-mortem operations.
The Java specification states that a **phantom referenced object** will not be deallocated until the phantom-reference itself is cleaned.
My question is: What purpose does this feature serve?
(The only idea i came up with, is to allow native code to do post-mo... |
|java|expert| |
Phantom References serve for post-mortem operations.
The Java specification states that a **phantom referenced object** will not be deallocated until the phantom-reference itself is cleaned.
My question is: What purpose does this feature (object not deallocated) serve?
(The only idea i came up with, is to allow ... |
|java|expert|finalize|phantom-reference|under-the-hood| |
There are lots of options for development tools for Office. The most obvious one is of course Office itself. It has rich support for macros and VBA. You could also use SharePoint to extend document sharing and management functionality. But if your add-in is more complex than can be handled inside of Office, I suggest... |
JAX-RS Frameworks |
|rest|java| |