instruction stringlengths 0 30k ⌀ |
|---|
The usual approach of
<pre>test:
$(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INCDIRS)')" $(TEST_FILES)</pre>
fails to run Guile scripts, because it passes to Guile the extra parameter "-w".
One possible approach is to set up your project as follows.
Your directory structure i... |
**Original Question**
I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h... |
Making a PHP class behave like an array? |
|php|oop|arrays| |
I'd like to be able to write a PHP class that behaves like an array and uses normal array syntax for getting & setting.
For example (where Foo is a PHP class of my making):
$foo = new Foo();
$foo['fooKey'] = 'foo value';
echo $foo['fooKey'];
I know that PHP has the \_get and \_set mag... |
how about,
output = /(".+?"|\w+)/g.exec(input)
then do a pass on output to lose the quotes.
alternately,
output = /"(.+?)"|(\w+)/g.exec(input)
then do a pass n output to lose the empty captures.
|
`print("code sample");`So I had to change the way an ASP.NET 2.0 application called reports from pages. Originally, I used JavaScript to open a new window.
ViewCostReport.OnClientClick = "window.open('" + Report.GetProjectCostURL(_PromotionID) + "','ProjectCost','resizable=yes')";
The issue I had was that th... |
**Original Question**
I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h... |
If you do something like:
MySoundObject = undefined;
That should do it. |
Some googling found [this][1], where people had a discussion about this.
An unsigned char is basically a single byte. So, you would use this if you need one byte of data (for example, maybe you want to use it to set flags on and off to be passed to a function, as is often done in the Windows API).
[1]: http:... |
You can use [Rezilla][1] to edit resource files on Mac OS X, it has a CURS (and crsr) editor among others. It's a PowerPC binary but it runs well under rosetta on intel.
Also, you don't create a CURS resource file, you create a resource file and add as many CURS resources to it as you need. Resource forks are generi... |
An unsigned char is a (unsigned) byte value (0 to 255). You may be thinking of "char" in terms of being a "character" but it is really a numerical value. The regular "char" is signed, so you have 128 values, and these values map to characters using ASCII encoding. But in either case, what you are storing in memory i... |
You don't.
If you need a high level of confidence that a performance change, for example, hasn't changed the output of a query then test the hell out it.
If you need a really high level of confidence .. then errrm, test it even more.
Massive level's of testing aren't that hard to cobble together for a SQL quer... |
What datatype should be used for storing phone numbers in SQL Server 2005? |
|sql-server|indexing| |
I need to store phone numbers in a table. Please suggest which datatype should I use?
**Wait. Please read on before you hit reply..**
This field needs to be indexed heavily as customers can use this field for searching (including wild character search).
As of now, we are expecting phone numbers to come in a num... |
I need to store phone numbers in a table. Please suggest which datatype should I use?
**Wait. Please read on before you hit reply..**
This field needs to be indexed heavily as customers can use this field for searching (including wild character search).
As of now, we are expecting phone numbers to come in a num... |
**Original Question**
I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h... |
`So I had to change the way an ASP.NET 2.0 application called reports from pages. Originally, I used JavaScript to open a new window.
ViewCostReport.OnClientClick = "window.open('" + Report.GetProjectCostURL(_PromotionID) + "','ProjectCost','resizable=yes')";
The issue I had was that the window.open call wou... |
Best way to archive live MySQL database |
|database|mysql| |
We have a live MySQL database that is 99% INSERTs, around 100 per second. We want to archive the data each day so that we can run queries on it without affecting the main, live database. In addition, once the archive is completed, we want to clear the live database.
What is the best way to do this without (if possib... |
I'd suggest building for Mono. You'll run into some gray area, but overall it's great. However, if you want to build for Java, you might check out [Grasshopper](http://dev.mainsoft.com/Default.aspx?tabid=130). It's a commercial product, but it claims to be able to translate CIL (the output of the C# compiler) to Java b... |
img{
border: 0
}
or old-fashioned
<img border="0" src="..." />
^^^^^^^^^^
|
Just add:
border: 0;
or
a img{
border:0;
}
to remove border from all image links.
That should do the trick.
|
Excel has no way of gathering that attribute with it's built-in functions. If you're willing to use some VB, all your color-related questions are answered here:
http://www.cpearson.com/excel/colors.aspx
Example form the site:
> The SumColor function is a color-based
> analog of both the SUM and SUMIF
> funct... |
Simply put, static analysis collect information based on **source code** and dynamic analisys is based on the **system execution**, often using instrumentation.
##Advantages of dynamic analysis
- Is able to detect dependencies that is not possible in static analysis. Ex.: dynamic dependencies using reflection, ... |
Really killing a process in Windows |
|windows| |
Occasionally a program on a Windows machine goes crazy and just hangs. So I'll call up the task manager and hit the "End Process" button for it. However, this doesn't always work; if I try it enough times then it'll usually die eventually, but I'd really like to be able to just kill it immediately. On Linux I could ... |
I don't know if this applies for all cases, but on WinXP and .ico can be a bmp of size 16x16, 32x32 or 64x64. Just change the extension to ico from bmp and your ready to go.
Hope this helps
thing2k |
I don't know if this applies for all cases, but on WinXP an .ico can be a bmp of size 16x16, 32x32 or 64x64. Just change the extension to ico from bmp and you're ready to go.
Hope this helps
thing2k |
taskkill /im myprocess.exe /f
The "/f" is for "force".
If you know the PID, then you can specify that, as in:
taskkill /pid 1234 /f
Lots of other options are possible, just type taskkill /? for all of them. The "/t" option kills a process and any child processes; that may be useful to you. |
**Original Question**
I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h... |
I had a similar problem on my workstation at the office. It sounds like you need to reinstall (that's what worked for me). This is a known bug according BussinessObjects (I had to call them and use our maintenance support). Hopefully you can find more information by searching for, 'Crystal Business query corruption' ... |
Same boat. We're currently making pdfs this way: vb6 app drops a record into sql (with filename, create date, user, and final destination) and the xls (or doc) gets moved into a server directory (share) and the server has a vb.net service that has a filewatcher monitoring that directory. The file shows up, the service... |
Same boat. We're currently making pdfs this way: vb6 app drops a record into sql (with filename, create date, user, and final destination) and the xls (or doc) gets moved into a server directory (share) and the server has a vb.net service that has a filewatcher monitoring that directory. The file shows up, the service... |
I stick this in my .emacs:
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
I subsequently have basically no problems cutting and pasting back and forth from anything in Emacs to any other X11 or Gnome application.
Bonus: to get these things to happen in E... |
I need to store phone numbers in a table. Please suggest which datatype should I use?
**Wait. Please read on before you hit reply..**
This field needs to be indexed heavily as Sales Reps can use this field for searching (including wild character search).
As of now, we are expecting phone numbers to come in a nu... |
In terms of direct values a regular char is used when the values are known to be between CHAR_MIN and CHAR_MAX while an unsigned char provides double the range on the positive end. For example, if CHAR_BIT is 8, the range of regular char is only guaranteed to be [0, 127] (because it can be signed or unsigned) while uns... |
If you add "background-attachment: fixed" to the css in kavendek's suggestion above, you can "pin" the background image to the specified location in the window. That way, the watermark will always remain visible no matter where the user scrolls on the page.
Personally, I find fixed background images to be visually ... |
XSLT processing in/from ruby |
|ruby|linux|xml|xslt| |
Can anyone recommend an efficient method to execute XSLT transforms of XML data within a Ruby application? The XSL gem (REXSL) is not available yet, and while I have seen a project or two that implement it, I'm wary of using them so early on. A friend had recommended a shell out call to Perl, but I'm worried about reso... |
I'd use overloading:
public static void DoSomething<K,V>(IDictionary<K,V> items)
where V : IEnumerable
{
items.Keys.Each(key => { /* do something */ });
}
public static void DoSomething<K,V>(IDictionary<K,V> items)
{
items.Keys.Each(key => { /* do something else *... |
Remember that in SWT you must explicitly dispose any resources that you create when you are done with them. This includes widgets, fonts, colors, images, displays, printers, and GCs. If you do not dispose these resources, eventually your application will reach the resource limit of your operating system and the appli... |
Raymond Chen wrote few posts about dialog manager:
- [The dialog manager, part 1: Warm-ups][1]
- [The dialog manager, part 2: Creating the frame window][2]
- [The dialog manager, part 3: Creating the controls][3]
- [The dialog manager, part 4: The dialog loop][4]
- [The dialog manager, part 5: Converti... |
I dont program a lot of javascript but JSEclipse has been pretty helpful for me in the past. It comes as an Eclipse plug-in.
I've been using it for years for free
http://www.interaktonline.com/products/eclipse/jseclipse/overview/
I also rely heavily on FireBug for Firefox whenever I deal with Javascript |
Are there any JavaScript live syntax highlighters? |
|javascript|wysiwyg|syntax-highlighting| |
I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.
As a follow-up question, what is the WYSIWYG editor that stackoverflow uses? |
I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.
As a follow-up question, what is the WYSIWYG editor that stackoverflow uses?
Edit: Thanks to the answer below, I found two t... |
As my previous comments indicated, I don't think you can use *with* safely no matter how tempting it might be in any given situation. Since the issue isn't directly covered here, I'll repeat it. Consider the following code
user = {};
someFunctionThatDoesStuffToUser(user);
someOtherFunction(user);
... |
You do NOT want to use inheritance to do this! When table B, C and D inherits from table A, that means that querying table A will give you records from B, C and D. Now consider...
DELETE FROM a;
Instead of inheritance, use LIKE instead...
CREATE TABLE blah (
blah_id serial PRIMARY KEY
... |
First google hit:
svn sw --relocate svn://example1.com:22/name http://example2.com:24/edc |
Just change the address of the svn repository using switch --relocate command.
$svn switch --relocate file:///tmp/repos file:///tmp/newlocation.<br />
In your case it would be $svn switch --relocate http://mach1:81/ http://mach2:81/ |
Use of Int or Int32 are the same Int is just sugar to simplify the code for the reader.
Use the Nullable variant Int? or Int32? when you work with databases on fields containing null. That will save you from a lot of runtime issues. |
Another possible alternative is to use JSON, dynamically adding scripts references which will be automatically processed by browser.
Cheers. |
does a good swf to exe wraper open source exists ? |
|actionscript| |
i think the best part of flash is the possibility to create not squared user interfaces, so i like the idea to create desktop apps using flash. I know AIR is for that but it doesnt allow real access to OperatingSystem apis and dlls and the commercial options are kind of dificult to customize. |
Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter...
private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient)
{
return i != null && i.Contains(ingredientType) ... |
Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter...
private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient)
{
return i != null && i.Contains(ingredientType) ... |
If it suits your project, consider using the Boehm Garbage collector. That way you can freely allocate new objects and let the collector handle the deletes. Of course there are tradeoffs involved in using a garbage collector. You would have to weigh the costs and benefits. |
Use [smart pointers][1]!
Or, if you're uncomfortable depending on yet another library, you can always use [auto_ptr][2] from the C++ standard library.
[1]: http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm
[2]: http://www.gotw.ca/publications/using_auto_ptr_effectively.htm |
While those are indeed equivalent in a semantic sense (i.e. the code is doing something with a string), C#, like Java, keeps pointers completely out of its everyday use, relegating them to areas such as transitions to native OS functions - even then, there are framework classes which wrap those up nicely, such as SafeF... |
newLISP - http://www.newlisp.org/ - has support for MySQL, but I haven't used it (newLISP). |
EBGreen, good point, I shouldn't mentioned *why* I am looking to do this. Our teams frequently read and edit code from the surrounding teams. And I mean feature teams, not just dev/test/pm divisions.
There is just one of those little things that slow everybody down. Working on Team C's code? Got to track down their... |
EBGreen, good point, I should have mentioned *why* I am looking to do this. Our teams frequently read and edit code from the surrounding teams. And I mean feature teams, not just dev/test/pm divisions.
This is just one of those little things that slow everybody down. Working on Team C's code? Got to track down thei... |
Yes but only since VC++ 2005. The syntax for your example would be:
#define DBGPRINT(fmt, ...) printf(fmt, __VA_ARGS__)
A full reference is [here][1].
[1]: http://msdn.microsoft.com/en-us/library/ms177415(VS.80).aspx |
Using NodeEnvelopes or edge/node Factories sounds like overdesign to me.
Do you really want to expose a setName() method on Node at all? There's nothing in your example to suggest that you need that. If you make both your Node and Edge classes immutable, most of the integrity-violation scenarios you're envisioning... |
Maybe this extensive article about [Internet Explorer and the CSS box model][1] will help?
[1]: http://www.456bereastreet.com/archive/200612/internet_explorer_and_the_css_box_model/ |
With Windows Mobile 5.0 and higher, using the CreateWindowEx function passing it WS_EX_CAPTIONOKBTN for the extended style works.
@ctacke SHDoneButton may have also worked but I wanted to change the main window without handling it like a dialogbox, which is basically what SHInitDialog is doing. |
If you like using various types of specific length and signedness, you're probably better off with uint8_t, int8_t, uint16_t, etc simply because they do exactly what they say. |
You can have multiple form tags. The limitation is on server-side (runat="server") form tags. |
You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat="server") form tags.
You can implement two form tags (or more) as long as only one has the runat="server" attribute and one is not contained in the other. Example:
<body>
<form action="http://www.google.com/cse" ... |
You probably need to use the X Cursor Extensions. See the [XCURSOR(3)][1] manpage and the X11/Xcursor/Xcursor.h header file.
[1]: http://www.xfree86.org/4.3.0/Xcursor.3.html |
Have you checked out [F#][1]
[1]: http://research.microsoft.com/fsharp/fsharp.aspx |
I've started using VI because it's the default editor on pretty much every operating system except for Windows. Then again I don't do a lot of coding on Windows so that helps.
If you want to force yourself on a *NIX/OSX system just remove the other editors or alias them. For the rest it's up to yourself. Everytime y... |
Works for me:
Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> brothers = ['larry', 'curly', 'moe']
>>> random.choice(brothers)
'moe'
>... |
Force numerical order on a SQL Server 2005 varchar column, containing letters and numbers? |
|sql|sql-server|order| |
I have a column containing the strings 'Operator (1)' and so on until 'Operator (600)' so far.
I want to get them numerically ordered and I've come up with
select colname from table order by
cast(replace(replace(colname,'Operator (',''),')','') as int)
which is very very ugly.
Better suggestions? |
I use the excellent [Trac project management system][1] for my personal projects, and I use it's wiki as a brainstorming and note-taking tool. And, because it also hooks into the Subversion repository and the bug tracking system, I can link from my notes right to a particular section of code or a bug report.
[1]... |
An exception can be caught and swallowed making the error invisible to testing. That can't happen with Debug.Assert.
No one should ever have a catch handler that catches all exceptions, but people do it anyway, and sometimes it is unavoidable. If your code is invoked from COM, the interop layer catches all excepti... |
While source debugging is defintely better, you don't need pdbs or source for the VS debugger to set a bp on the function you want.
Make sure you go to Tools/Options/Debugger and turn off the option called "Just My Code". Since the framework is not 'your code' the debugger unhelpfully prevents you from setting bre... |
You need about 2.5 megs, so just using the heap should be fine. You don't need a vector unless you need to resize it. See [C++ FAQ Lite][1] for an example of using a "2D" heap array.
int *array = new int[800*800];
(Don't forget to delete[] it when you're done.)
[1]: http://www.parashift.com/c++-faq-lit... |
Recovering from a broken TCP socket in Ruby when in gets() |
|ruby|tcp|socket|gets| |
I'm reading lines of input on a TCP socket, similar to this:
class Bla
def getcmd
@sock.gets unless @sock.closed?
end
def start
srv = TCPServer.new(5000)
@sock = srv.accept
while ! @sock.closed?
ans = getcmd
end
end
... |
|ruby|sockets|tcp|gets| |
You could do a vector of vectors, but that would have some overhead. For a z-buffer the more typical method would be to create an array of size 800*800=640000.
const int width = 800;
const int height = 800;
unsigned int* z_buffer = new unsigned int[width*height];
Then access the pixels as follows:
... |
The problem isn't with your build scripts, but with Visual Studio not supporting [ANSI control codes][1] to change the color.
[1]: http://en.wikipedia.org/wiki/ANSI_escape_code |
[Use the -M switch.][1]
>>"Places the ssh client into 'master' mode for connection shar-ing. Multiple -M options places ssh into ``master'' mode with confirmation required before slave connections are accepted. Refer to the description of ControlMaster in ssh_config(5) for details."
I don't quite see how that a... |
<em>"No longer is the current directory searched first when loading DLLs! This change was also made in Windows XP SP1. The default behavior now is to look in all the system locations first, then the current directory, and finally any user-defined paths."</em>
(ref. <a href="http://weblogs.asp.net/pwilson/archive/200... |
The 32 bit kernel that is capable of loading and running 64 bit binaries has to have some 64 bit code to handle memory mapping, program loading and a few other 64 bit issues.
However, the scheduler and many other OS operations aren't required to work in the 64 bit mode in order to deal with other issues - it switche... |
SQL 2000 database copy to SQL 2005 options... |
|sql-server| |
We have a production web and database server with SQL Server 2000. (However, a few clients they have their own servers with SQL 2005.) So we have local installs of SQL 2005 Express for development on Windows XP SP3 boxes (which don't allow SQL 2000 Enterprise installations).
We often need to copy SQL 2000 databases... |
Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter...
private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient)
{
return i != null && i.Contains(ingredientType) ... |