instruction stringlengths 0 30k ⌀ |
|---|
When constructing an ArgumentException, a couple of the overloads take a string that is the invalid argument's parameter name. I figure it would be nice to not have to remember to update this ctor param whenever I change the method's param name. Is there a simple way to do this using reflection?
Thanks. :) |
|.net|reflection|refactoring|duplication| |
When constructing an ArgumentException, a couple of the overloads take a string that is the invalid argument's parameter name. I figure it would be nice to not have to remember to update this ctor param whenever I change the method's param name. Is there a simple way to do this using reflection?
**Update:** thanks t... |
As dj_segfault points out, the shell can do most of this for you. Looks like you'll have to fall back on something external for lower-casing the string, though. For this you have many options, like the perl one-liners above, etc., but I think tr is probably the simplest.
<pre><code># first, strip underscores
CLEAN=... |
in rails, how to return records as a csv file |
|ruby-on-rails|csv| |
I have a simple database table called "Entries":
class CreateEntries < ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.string :firstName
t.string :lastName
#etc.
t.timestamps
end
end
def self.down
... |
In short, when comparing two floats with unknown origins, picking an epsilon that is valid is almost impossible.
For example:
What is a good epsilon when comparing distance in miles between Atlanta GA, Dallas TX and some place in Ohio?
What is a good epsilon when comparing distance in miles between my left foo... |
The most interesting design pattern you will ever meet is one that you have created yourself, for obvious reasons.
That's not to say that it will be the best design pattern, just the most interesting. |
Where'd my generic ActionLink go? |
|asp.net|asp.net-mvc| |
Moved from preview 2 to preview 5 and now my Html.ActionLink calls are all failing. It appears that the generic version has been replaced with a non-type safe version.
// used to work
<li>
<%= Html.ActionLink<HomeController>(c => c.Index(), "Home")%>
</li>
// what appears I can only do now... |
Does the file in question (CSV_XS.so) exist?
Does it exist at the listed location?
If you do:
set |grep PERL
What is the output?
Have you successfully installed other local perl modules?
|
I agree with <B> not to do this </b>. The name Rick Van DenBoer would end up with a middle name of Van but it's part of the last name. |
Sure, there is a simple solution - split the string by spaces, count the number of tokens, if there is 2, interpret them to be FIRST and LAST name, if there is 3, interpret it to be FIRST, MIDDLE, and LAST.
The problem is that the simple solution will not be a 100% correct solution - someone could always enter a nam... |
Probably because 397 is a prime of sufficient size to cause the result variable to overflow and mix the bits of the hash somewhat, providing a better distribution of hash codes. |
Probably because 397 is a prime of sufficient size to cause the result variable to overflow and mix the bits of the hash somewhat, providing a better distribution of hash codes. There's nothing particularly special about 397 that distinguishes it from other primes of the same magnitude. |
My approach is to gather commands against the server or database into a table using SQL Server Profiler. Once you have that, you can query based on the max and avg execution times, max and avg cpu times, and (also very important) the number of times that the query was run.
Since I try to put all database access code... |
I would recommend UTF-16 for any kind of data manipulation and UI.
The Mac OS X and Win32 API uses UTF-16, same for wxWidgets, Qt, ICU, Xerces, and others.
UTF-8 might be better for data interchange and storage.
See [http://unicode.org/notes/tn12/][1]
But whatever you choose, I would definitely recommend against ... |
The most important single factor determining the cost of a project is the scale and ambition of the vision. The second most important is how well you (your team, your management, etc.) control the inevitable temptation to expand that vision as you progress. The factors you list are themselves just metrics of the scale ... |
Targeting Chrome/Chromium right now, I think is like targeting Konqueror web browser. It will get popular, but you should wait to a more stable beta, and/or some Linux and OS X client. |
Of the four options you gave, I'd go with #2 - the size of the project. A quick project for cleaning out spam is going to be generally quicker than developing a new word processor, after all.
After that I'd go with "The abstractions used while solving the problem." next - if you come up with the wrong method of sol... |
While after the fact you could point to the table size at which performance became a problem, I don't think you can predict it, and certainly not from the information given on a web site such as this!
Some questions you might usefully ask yourself:
- Is performance currently acceptable?
- How is performance ... |
Ok, I have found a partial solution:
EntityContext.EntitySet.OfType<Entry>().Where( obj => !(obj is CancelledEntry) )
This is quite awful however, since if I create a new derived object, I have to go in all the queries and specifically add a condition to remove it.
There has to be a better solution
|
I think Jeremy has hit the nail on the head - if you just want to detect if files are different, a hash algorithm like MD5 or SHA1 is a good way to go.
Linus Torvalds' Git source control software uses SHA1 hashing in just this way - to check when files have been modified. |
The following code is an in-place permutation of a given list, implemented as a generator. Since it only returns references to the list, the list should not be modified outside the generator.
The solution is non-recursive, so uses low memory. Work well also with multiple copies of elements in the input list.
... |
I have a CIFS share mounted on a Linux machine. The CIFS server is down, or the internet connection is down, and anything that touches the CIFS mount now takes several minutes to timeout, and is unkillable while you wait. I can't even run ls in my home directory because there is a symlink pointing inside the CIFS mo... |
You only freed the first row (or column) of first_matrix. Write another function like this:
void free_matrix(int **matrix, int rows)
{
int i;
for(i=0; i<rows; i++)
{
free(matrix[i]);
}
free(matrix);
}
You might want to make the matrix into a ... |
You can do it by walking the stack backwards. In reality, though, it's frequently easier to add an identifier onto a call stack at the beginning of each function and pop it at the end, then just walk that printing the contents. It's a bit of a PITA, but it works well and will save you time in the end. |
There is no platform independent way to do it.
The nearest thing you can do is to run the code without optimizations. That way you can attach to the process (using the visual c++ debugger or GDB) and get a usable stack trace.
|
Injecting a user account into mySQL |
|mysql|account| |
Tackling a strange scenario here.
We use a proprietary workstation management application which uses mySQL to store its data. Within the application they provide number of reports, such as which user logged into which machine at what time, all the software products installed on the monitored machines, so on and so ... |
|mysql|account| |
Tackling a strange scenario here.
We use a proprietary workstation management application which uses mySQL to store its data. Within the application they provide number of reports, such as which user logged into which machine at what time, all the software products installed on the monitored machines, so on and so ... |
What are Table-Driven Methods |
|table-driven| |
What are Table-Driven methods as mentioned by Bill Gates on Vista commercial on http://www.youtube.com/watch?v=gBWPf1BWtkw |
Images and other binaries should be in source control just like your code files. Especially since they are changing often.
That said, there is absolutely no harm in setting up a different project that only contains your binary files; and having it on a different deployment schedule.
|
First question - are you familiar with lambda expressions in C#? If so the -> in F# is the same as the => in C# (I think you read it 'goes to').
The -> operator can also be found in the context of pattern matching
match x with
| 1 -> dosomething
| _ -> dosomethingelse
I'm not sure if this is also... |
mysql: Got a packet bigger than 'max_allowed_packet' bytes |
|mysql| |
I'm importing a mysql dump and getting the following error:
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
This is on my local mcahine, a mac with mysql 5 installed from the mysql package. So I can do whatever I want.
Where do I change max_all... |
I'm importing a mysql dump and getting the following error:
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
This is on my local machine, a mac with mysql 5 installed from the mysql package. So I can do whatever I want.
Where do I change max_all... |
|mysql|fogbugz| |
Have you tried using the build in collections in System.Collections.Generic? And using serialization to push that puppy out to an XML document or something of the like. |
Bill Clementson has [http://bc.tech.coop/cltl2-ansi.htm](http://bc.tech.coop/cltl2-ansi.htm) which is a repost of [http://groups.google.com/group/comp.lang.lisp/msg/0e9aced3bf023d86](http://groups.google.com/group/comp.lang.lisp/msg/0e9aced3bf023d86)
I also found [http://www.ntlug.org/~cbbrowne/commonlisp.html#AEN... |
Bill Clementson has http://bc.tech.coop/cltl2-ansi.htm which is a repost of http://groups.google.com/group/comp.lang.lisp/msg/0e9aced3bf023d86
I also found http://web.archive.org/web/20060111013153/http://www.ntlug.org/~cbbrowne/commonlisp.html#AEN10329 while answering the question. I've not compared the two.
As ... |
Bill Clementson has http://bc.tech.coop/cltl2-ansi.htm which is a repost of http://groups.google.com/group/comp.lang.lisp/msg/0e9aced3bf023d86
I also found http://web.archive.org/web/20060111013153/http://www.ntlug.org/~cbbrowne/commonlisp.html#AEN10329 while answering the question. I've not compared the two.
As ... |
Using the MyISAM engine, you'll run into a 2GB hard limit on table size unless you change the default. |
If I may plug my own work, I'd direct you to my post at [http://www.sunsetlakesoftware.com/2008/08/05/lessons-molecules-opengl-es][1]. It's not the best overall introduction to OpenGL ES, and it gets fairly technical pretty quickly, but it's my take on the subject from my experience writing [Molecules][2]. Also, I've... |
Different.
You've saved the address of what temp1 is initially pointed to into temp2. You then changed what temp1 is pointed to, not the variable at the other end of what temp1 is pointed to.
If you had done
temp2 = temp1;
*temp1 = temp1->foo();
then temp1 & temp2 will both be pointing to (the same... |
Different.
You've saved the address of what temp1 is initially pointed to into temp2. You then changed what temp1 is pointed to, not the variable at the other end of what temp1 is pointed to.
If you had done
temp2 = temp1;
*temp1 = temp1->foo;
then temp1 & temp2 will both be pointing to (the same) ... |
They are an instruction to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction. This can be a big win, if the prediction is correct it means that the jump instruction is basically free and will take zero cycles. On the other hand if the prediction is wro... |
Found example here: [Generate an Excel Formatted File Right in Python][1]
Notice that you make a font object and then give it to a style object, and then provide that style object when writing to the sheet:
import pyExcelerator as xl
def save_in_excel(headers,values):
#Open new workbook
... |
Emacs, switching to another frame |
|emacs| |
I can switch between windows with "C-x o", but if I have opened multiple frames, can I move between them without the mouse as well? |
I can switch between windows with "C-x o", but if I have opened multiple frames, can I move between them without the mouse as well? I just realized that the question probably sounds braindead without this detail: I'm on OS X (finnish keyboard) and switching between windows of the same app is difficult. |
Emacs, switching to another frame (OS X) |
Just use [Trac](http://trac.edgewall.org). It has everything you need for a small project. You could use the ticketing system to distribute the tasks (in Agile you should think in terms of stories and not individual tasks anyway) but if it's not enough you could get extra plugins for time management etc. |
Index cards work great, but if you need it online, I'd try [Unfuddle](http://unfuddle.com/). You can use it for small groups for free, and it's lightweight enough that you can adjust it to your group's needs pretty easily.
I use it at work, and we keep all stories in its "notebooks" (read: wikis) and tasks in its ta... |
Instead of playing with thread starting and stopping, have you considered having the thread observe the properties that you're changing through your interface? You will at some point still want a stop condition for your thread, but this can be done this was as well. If you're a fan of MVC, this fits nicely into that so... |
Instead of playing with thread starting and stopping, have you considered having the thread observe the properties that you're changing through your interface? You will at some point still want a stop condition for your thread, but this can be done this was as well. If you're a fan of MVC, this fits nicely into that so... |
Windsor Interceptors AOP & Caching |
|.net|aop|castle-windsor| |
I'm considering using Castle Windsor's Interceptors to cache data for helping scale an asp.net site.
Does anyone have any thoughts/experience with doing this? |
|.net|castle-windsor|aop| |
I'm considering using Castle Windsor's Interceptors to cache data for helping scale an asp.net site.
Does anyone have any thoughts/experience with doing this?
Minor clarification:
My intention was to use Windsor to intercept 'expensive' calls and delegate to MemCacheD or Velocity (or another distributed cache) f... |
Standard, no...
That's why VCL components can register themselves to be notified of the destruction of an object, so that they can remove the reference from there internal list of components or just reset their property.
So if you'd want to make sure you haven't got any invalid references their are two options:
... |
If that's my own code, I would just use [SciTE][1]'s export to HTML and paste it.
Otherwise (highlighting code like it is done here), I would prefer to do it on server side: JS highlighting (as seen, for example, on JavaLobby) happens after the page have been displayed in default mode (so there is a sudden change of l... |
One problem that comes up is that the GLUT port on Nate Robin's site is c. 2001. It has some incompatibilities with versions of Visual Studio more recent than that. If you receive an error about a redefinition of the `exit()` prototype, there are two possible solutions:
1. Replace the exit template in glut.h wi... |
One problem that comes up is that the GLUT port on Nate Robin's site is c. 2001. It has some incompatibilities with versions of Visual Studio more recent than that. If you receive an error about a redefinition of the `exit()` prototype, there are two possible solutions:
1. Replace the exit template in glut.h wi... |
One problem that comes up is that the GLUT port on Nate Robin's site is c. 2001. It has some incompatibilities with versions of Visual Studio more recent than that. If you receive an error about a redefinition of the `exit()` prototype, there are two possible solutions:
1. Replace the exit template in glut.h wi... |
I'm importing a mysql dump and getting the following error:
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
This is on my local machine, a mac with mysql 5 installed from the mysql package. So I can do whatever I want.
Where do I change max_all... |
mysql: Got a packet bigger than 'max_allowed_packet' bytes; setting max_allowed_packet won't help |
mysql: Got a packet bigger than 'max_allowed_packet' bytes |
I'm importing a mysql dump and getting the following error:
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
The dump is a mysqldump of a FogBugz database. it's FogBugz 6.1.33, Unix.
Apparently FogBugz stores attachments in the database, which m... |
We've done this with templates. You could so something like this:
// Specialization for 2-byte types.
template<>
inline void endian_byte_swapper< 2 >(char* dest, char const* src)
{
// Use bit manipulations instead of accessing individual bytes from memory, much faster.
ushort* p... |
From asking the same question on MSDN forums:
TaylorMichaelL said:
> The command you are interested in is
> Edit.LineFirstColumn. **You'll want to
> change the scope to be the Text
> Editor.** You should remove any
> existing shortcut key associated with
> the command first. If you don't
> change the sco... |
The same way you do in C:
short big = 0xdead;
short little = (((big & 0xff)<<8) | ((big & 0xff00)>>8));
You could also declare a vector of unsigned chars, memcpy the input value into it, reverse the bytes into another vector and memcpy the bytes out, but that'll take orders of magnitude longer than bit-t... |
Looking at your red5 example flv in [richflv][1] (very handy flv editing tool) we can see that you have regular keyframes but the duration metadata isn't set.
The facebook example flv has hardly any keyframes (which would mean you wouldn't be able 'seek' within it very well) however the metadata duration is correct.... |
STL will be more familiar to a future programmer than your custom encapsulation, so you should avoid doing this if you can. There will be edge cases that you havent thought about which will come up later in the app's lifetime, wheras STL is failry well reviewed and documented.
Additionally most containers support... |
I have had some bad experiences when dealing with a Java based web service using the WS-Security specs. In that case there was very little, and mostly conflicting, documentation and no tech support at all from the vendor. It took us quite a bit of time to get it working but using a WS-Security sample as the basis we go... |
FWIW, I'm not a fan of using Google Charts when fit & finish is important. I find that the variables for sizing, in particular, are unpredictable - the chart does its own thing.
I haven't yet played with Gruff/Bluff/etc., but for a higher-profile project I won't use Google Charts. |
bouncycastle has a Java crypto-provider and support for OCSP requests and responses. The differences between OCSPReq and OCSPRequest and OCSPResp and OCSPResponse class are a little confusing, though. |
I believe you can create a text field that has the default value set to [Me] which should then be usable in a calculated field. |
Issues creating a box using CSS |
|css| |
I want to create a box shape and I am having trouble.
I want the box to have a background color, and then different color inside the box.
The box will then have a list of items using ul and li, and each list item will have a background of white, and the list item's background color is too stretch the entire distanc... |
You probably don't need to do anything fancy really. Something like this should work.
Name = Name.Trim();
arrNames = Name.Split(' ');
if (Name.Length > 0) {
GivenName = arrNames[0];
}
if (Name.Length > 1) {
FamilyName = arrNames[arrNames.Lengt... |
Unless you're deeply into theory, you can regard the Y combinator
as a neat trick with functions, like monads.
Monads allow you to chain actions, the Y combinator allows you to
define self-recursive functions.
Python has built-in support for self-recursive functions, so you
can define them without Y:
> ... |
Unless you're deeply into theory, you can regard the Y combinator
as a neat trick with functions, like monads.
Monads allow you to chain actions, the Y combinator allows you to
define self-recursive functions.
Python has built-in support for self-recursive functions, so you
can define them without Y:
> ... |
Unless you're deeply into theory, you can regard the Y combinator
as a neat trick with functions, like monads.
Monads allow you to chain actions, the Y combinator allows you to
define self-recursive functions.
Python has built-in support for self-recursive functions, so you
can define them without Y:
> ... |
The main benefit of Dependency Injection, at least in my applications, is the ability to write code that is context agnostic. From that perspective, your second solution seems like it really subverts the benefit DI could be giving you. If the 'god object' exposes different interfaces to each class that references it,... |
They cause the compiler to emit the appropriate branch hints where the hardware supports them. This usually just means twiddling a few bits in the instruction opcode, so code size will not change. The CPU will start fetching instructions from the predicted location, and flush the pipeline and start over if that turns o... |
The most common pattern used to solve this problem is to have an Initialize() method that your constructors call, but in the example you just gave, adding a static method that you called like the code below, would do the trick.
public MyClass(MyOtherClass inputObject): this(inputObject.ID, GetHelperText(inputObj... |
Wouldn't the normal approach for a Windows component be that the administrators of a set of servers use whatever their local software push technology (i.e. SMS) to ensure that component is installed? This is not that uncommon of a requirement for the remote management of servers via WMI.
By the way, the WMI Installe... |
off the top of my head...
**Functions**
arguments.callee refers to the function that hosts the "arguments" variable, so it can be used to recurse anonymous functions:
var recurse = function() {
if (condition) argument.callee(); //calls recurse() again
}
That's useful if you want to do someth... |
If the query is currently running watch the **onstat -g act -r 1** output and look for items with an ***rstcb*** that is not 0
Running threads:
tid tcb rstcb prty status vp-class name
106 c0000000d4860950 0 2 running 1... |