instruction
stringlengths
0
30k
Chaning fixed point representations is commonly called 'scaling'. If you can do this with a class with no performance penalty, then that's the way to go. If not, then you need a more traditional C-style approach. The oo approach will give you compiler-enforced type safety which the traditional implementation only ...
First, create a function (using CTE, common table expression does away with the need for a temp table) create function dbo.SplitString ( @str nvarchar(4000), @separator char(1) ) returns table AS return ( with tokens(p, a, b) AS ( ...
Date arithmetic in Unix shell scripts
|unix|shell|scripting|math|
I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs. I'm using a function to increment a day and another to decrement: <pre> IncrementaDia(){ echo $1 | awk ' BEGIN { diasDelMes[1] = 31 diasDelMes[2] = 28 diasDelMes[3] = 31 ...
|unix|shell|date|scripting|math|
I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs. I'm using a function to increment a day and another to decrement: IncrementaDia(){ echo $1 | awk ' BEGIN { diasDelMes[1] = 31 diasDelMes[2] = 28 di...
<code>[mod\_proxy\_ajp][1]</code> would be the easiest to use if you are using Apache 2.2. It is part of the Apache distribution so you don't need to install any additional software. In your <code>httpd.conf</code> you need to make sure that <code>mod\_proxy</code> and <code>mod\_proxy\_ajp</code> are loaded: <pr...
How to conduct blackbox testing on an AJAX application?
|.net|java|javascript|testing|ajax|
What's the best, crossplatform way to perform blackbox tests on AJAX web applications? Ideally, the solution should have the following attributes: <ul> <li>Able to integrate into a continuous integration build loop</li> <li>Cross platform so I you can run it on Windows laptops and Linux continuous integration ser...
From [http://www.faqs.org/docs/diveintopython/fileinfo_private.html][1] > Strictly speaking, private methods are > accessible outside their class, just > not easily accessible. Nothing in > Python is truly private; internally, > the names of private methods and > attributes are mangled and unmangled > on the f...
It's important to distinguish between direct, and indirect components. Strive to remove direct connections (one class referencing another) and to use indirect connections instead. Bind two 'ignorant' classes with a third which manages their interactions. This would be something like a set of user controls sitting on...
Play around with System.Diagnostics.ProcessStartInfo which allows you to specify a file you wish to open and also allows you to specify arguments. You can then use Process.Start(ProcessStartInfo) to kick off the process. The framework will determine which application to run based on the file specified in the Process...
If its really an X Window you get, and not a widget from some specific toolkit (like GTK+ maybe?) then you can use the XGetWindowAttributes function call. This fills out a provided XWindowAttributes structure, which includes integers for the x and y position of the window as well as its width and height and other us...
If its really an X Window you get, and not a widget from some specific toolkit (like GTK+ maybe?) then you can use the XGetWindowAttributes function call. This fills out a provided XWindowAttributes structure, which includes integers for the x and y position of the window as well as its width and height and other us...
What is the best way to handle photo uploads?
|php|java|flash|javascript|
I'm doing a website for a family member's wedding. A feature they requested was a photo section where all the guests could go after the wedding and upload their snaps. I said this was a stellar idea and I went off to build it. Well there's just the one problem: logistics. Upload speeds are slow and photos from moder...
|java|javascript|php|flash|
I'm doing a website for a family member's wedding. A feature they requested was a photo section where all the guests could go after the wedding and upload their snaps. I said this was a stellar idea and I went off to build it. Well there's just the one problem: logistics. Upload speeds are slow and photos from moder...
Chaning fixed point representations is commonly called 'scaling'. If you can do this with a class with no performance penalty, then that's the way to go. Depends heavily on the compiler and how it inlines. If not, then you need a more traditional C-style approach. The oo approach will give you compiler-enforced t...
diff a ruby string or array
|ruby|diff|
Is there a ruby library that will take two strings or two arrays and return the difference between the two strings/arrays?
Others have answered the broad strokes pretty well, so I'll throw in a few details. 1. Stack and heap need not be singular. A common situation in which you have more than one stack is if you have more than one thread in a process. In this case each thread has its own stack. You can also have more than one heap, f...
I'd suggest making a list of all the attributes you would need for each monster and store all of that in a database like [MySQL][1]. This way you don't need to make windows for each monster, only each time a monster appears (in which case you'd just get the necessary info from the database). If you're not familiar w...
Connecting Outlook 2007 to Domino 6.5 ?
|lotus-notes|outlook|
Outlook (2007 now) is my favorite mail client and I would like to keep using it for both private and work emails. But with my new work, I discovered (with horror) that we have to use Lotus Domino and Lotus Notes 6.5 as client. Is it possible to get my Lotus mails inside Outlook while maintaining my private POP mails...
|outlook|lotus-notes|
Outlook (2007 now) is my favorite mail client and I would like to keep using it for both private and work emails. But with my new work, I discovered (with horror) that we have to use Lotus Domino and Lotus Notes 6.5 as client. Is it possible to get my Lotus mails inside Outlook while maintaining my private POP mails...
From what I've seen I'd start with Awk for this sort of thing and then if you need something more complex, I'd progress to Python.
Should a Log4J logger be declared as transient?
|java|serialization|
I am using Java 1.4 with Log4J. Some of my code involves serializing and deserializing value objects (POJOs). Each of my POJOs declares a logger with private final Logger log = Logger.getLogger(getClass()); The serializer complains of org.apache.log4j.Logger not being Serializable. Should I use ...
|java|logging|serialization|log4j|
There's actually one very popular non-multitasking OS that's not been listed yet: while the normal version of Apple's MacOS X *is* a multitasking OS, the stripped-down version on the iPhone and iPod touch is *not*.
There's a popular non-multitasking OS that's not been listed yet: PalmOS.
Don't know what platform you're on but in .NET there's the System.Version class that will parse "n.n.n.n" version numbers for you.
Using DLR from Unmanaged Code
|.net|delphi|ironpython|unmanaged|ironruby|
Is it possible to call managed code, specifically IronRuby or IronPython from unamanaged code such as C++ or Delphi? For example, we have an application written in Delphi that is being moved to C#.NET We'd like to provide Ruby or Python scripting in our new application to replace VBSCRIPT. However, we would need t...
Have a look at the [rot13 bookmarklet][1] for an example of selecting text and performing an action (in this case substitution) when the bookmarklet is clicked. [1]: https://www.squarefree.com/bookmarklets/pagedata.html#rot13_selection "rot13 bookmarklet"
Translate C++.Net to C#
|c++|.net|c#|
I have a small to medium project that is in .Net Managed C++. I really hate the syntax extensions of Managed C++ and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other?
Translate C++/CLI to C#
|c#|.net|c++|
I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other? EDIT: When I said Managed c++ before I apparently meant c++/CLI
Out of curiosity, on what web stack is this to run? LAMP? 2k3+IIS? etc etc? Many of the open source solutions out there are cross-platform but others are not...
Another option could be to allow people to upload their photos to whatever service they're used to using (flickr, google, smugmug, or any other), and just accept a username for that service, or a URL for the folder. Then you can have your application grab a copy of those pictures to store locally with a consistent...
Is it possible to use Jackpot outside of netbeans, without netbeans projects?
|java|netbeans|
I know there is a Jackpot API <http://jackpot.netbeans.org/docs/org-netbeans-modules-jackpot/overview-summary.html> for programmatic access the the rules engine, has anyone had success seperating this from netbeans itself? So it can operate on any java source files?
Another advantage of [Access being a COM application][1] is that you can create an [.NET application to run and test an Access application via Automation][2]. The advantage of this is that then you can use a more powerful testing framework such as [NUnit][3] to write automated assert tests against an Access app. Th...
Regarding Kevin's idea of passing the parameter to a function that splits the text into a table, here's my implementation of that function from a few years back. Works a treat. [Splitting Text into Words in SQL][1] [1]: http://www.madprops.org/blog/splitting-text-into-words-in-sql-revisited/
Include files requiring a absolute path
|php|
I have a directory structure like the following; >/script.php > >/inc/include1.php<br/> >/inc/include2.php > >/objects/object1.php<br/> >/objects/object2.php > >/soap/soap.php Now, I use those objects in both script.php and /soap/soap.php, I could move them, but I want the directory structure like that for ...
Include files requiring an absolute path
How to include PHP files that require an absolute path?
Haml: how do I set a dymanic class value?
|ruby-on-rails|haml|
I have the following html.erb code that I'm looking to move to Haml: <span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span> What it does is associate the CSS class of the currently assigned status to the span. How is this done in Haml? I'm sure I'm missing somethi...
I have the following html.erb code that I'm looking to move to Haml: <span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span> What it does is associate the CSS class of the currently assigned status to the span. How is this done in Haml? I'm sure I'm missing somethi...
For C++, a Map might work well. Several million objects won't be a problem.
For C++, a map works well. Several million objects won't be a problem. 10 million items took about 4.4 seconds and about 57 meg on my computer. #include <stdio.h> #include <stdlib.h> #include <map> class triple { public: int x; int y; int z; bool operat...
To simplify Simon's code a bit, you could use the built in generic Action delegate. It saves peppering your code with a bunch of delegate types you don't really need. Also, in .NET 3.5 they added a params parameter to the Invoke method so you don't have to define a temporary array. void SomethingHappened(obj...
I think the quick and dirty answer is that * LINQ to SQL is the quick-and-easy way to do it. This means you will get going quicker, and deliver quicker if you are working on something smaller. * Entity Framework is the all-out, no-holds-barred way to do it. This means you will take more time up-front, develope sl...
While the previous examples answered the question, here are two simpler examples of how Currying can be beneficial for F# programming. open System.IO let appendFile (fileName : string) (text : string) = let file = new StreamWriter(fileName, true) file.WriteLine(text) fil...
The problem with these devices is everything is stored in the RAM and ROM. So you need a second alternate device storage for these settings, just like a real device. So that when a real device, or your device is reset, it has a statically stored configuration file outside of the RAM that can be loaded on start up. T...
Html entities inside asp.net page
|encoding|
Inside an asp.net page, shoul I use <html><title>My page's title from México</title></html> Or <html><title>My page's title from M&eacute;xico</title></html> Both examples have same output. Since asp.net encodes all my pages to utf-8 there is no need to use html entities, is that right? Thanks a...
Found [this in the second result][1] in Google when searching for "validate date string sql". ----Invalid date SELECT ISDATE('30/2/2007') RETURNS : 0 (Zero) ----Valid date SELECT ISDATE('12/12/20007') RETURNS : 1 (ONE) ----Invalid DataType SELECT ISDATE('SQL') RETURNS : 0 ...
HTTPS in IIS 5.1
I would use sed: # print section of file between two regular expressions (inclusive) sed -n '/Iowa/,/Montana/p' # case sensitive
I used rdiffbackup [http://www.nongnu.org/rdiff-backup/index.html][1] because it does all you need without any fancy options. It's based on the rsync algorithm. If you only need to copy one time, you can later remove the rdiff-backup-data directory on the destination host. rdiff-backup user1@host1::/source-dir ...
Ok , I found a way to do this. It does deal with the Window flags. So here is the code i used _______________________________________________ > Qt::WindowFlags flags = windowFlags() > > Qt::WindowFlags helpFlag = > Qt::WindowContextHelpButtonHint; > > flags = flags & (~helpFlag); > > setWindowFlag...
There is a really good article about optimizing javascript and anonymous functions here: http://dev.opera.com/articles/view/efficient-javascript/?page=2 enjoy!
YES! Anonymous functions are faster than regular functions. Perhaps if speed is of the utmost importance... more important than code re-use then consider using anonymous functions. There is a really good article about optimizing javascript and anonymous functions here: http://dev.opera.com/articles/view/efficient...
Loggers are not serializable so you must use transient when storing them in instance fields. If you want to restore the logger after deserialization you can store the Level (String) indide your object which does get serialized.
Is it possible to build a Linux/Motif Eclipse RCP application?
|java|linux|eclipse|rcp|motif|
Greetings, I am trying to build an Eclipse application that would work with a linux/motif installation target. However, this seems not to be possible even though the export option is available in the product export wizard. I've checked the content of the delta pack and indeed, the packages for linux/motif are mi...
CONVERT(varchar(10), [MyDateTimecolumn], 20) See this page for convert styles: [http://msdn.microsoft.com/en-us/library/ms187928.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ms187928.aspx
As recommended by other posters, definitely [Graphviz][1]. It takes an input file, let's call it foaf.dot, in the following format: graph G { "George Formby" [shape=custom, shapefile="file:formby.png"]; "Michael Jackson" [shape=custom, shapefile="file:jackson.png"]; "George Formby" -- ...
As someone who is color blind I believe it is good to try to add more separation then normal vision. The most common form of color blindness is red/green deficiency. It doesn't mean that you can't see red or green, it means that it is more difficult to see and more difficult to see the differences. So it takes a lar...
If you're new to game development, I'd recommend XNA- it's easy to program with. The advantage of Torque, however, is it has asset creation tools, which can also be invaluable. For a higher end game or FPS, the Source engine is great.
The static keyword in the above example is redundant (a nested interface is automatically "static") and can be removed with no effect on semantics; I would recommend it be removed. The same goes for "public" on interface methods and "public final" on interface fields - the modifiers are redundant and just add clutter t...
If your target is a PC, I think you can try C#, or embed **Lua** in your C++ app and run scripts for 'high-level' stuff. However if your target is a console, you **must** manage your own memory!
Once you have created your artwork, I would load it dynamically from the hard disk rather than compile it into one big EXE. You can use the PictureBox control's LoadPicture method.
I've never looked into this, but it's easy enough to guess: 1. [The clipboard is a shared resource][1] 2. Only one app (per desktop) can "own" the clipboard at any given point in time 3. Your app owns it (after calling `OpenClipboard()`) 4. VS wants it (probably because, among other things, it's an editor) ...
I'm working on something similar right now. Be aware that using swig from swig.org is often easier as it generates the stubs to the native library for you. The short answer to your question is that the ant file should run the make file after the java library has already been built, as the native library depends on t...
You need to learn about data, data structures and loops. Your monsters should consist of data, and maybe some code, then your monster display screen will display and operate a monster based upon this data and code. Copy and pasting widgets will not work out for you. Learn to abstract data and logic from widgets. ...
What do you mean by, 'when we want to add a monster'? Do you mean you have an individual window for each monster, which is shown when that monster appears? To build on what sit said; design, design, design. Ad Hoc design methods do not scale beyond the smallest of programs.
For .NET application I choose "[.NET Parallel Extensions (PLINQ)][1]" it's extremely easy to use and allows me to parallelize existing code in minutes. 1. It's simple to learn 2. Used to perform complex operations over large arrays of objects, so I can't comment on other applications 3. Supports tasks and...
For .NET application I choose "[.NET Parallel Extensions (PLINQ)][1]" it's extremely easy to use and allows me to parallelize existing code in minutes. 1. It's simple to learn 2. Used to perform complex operations over large arrays of objects, so I can't comment on other applications 3. Supports tasks and...
One tip is to load all plugins and such into an own AppDomain, since the code running can be potentially malicious. An own AppDomain can also be used to "filter" assemblies and types that you don't want to load. AppDomain domain = AppDomain.CreateDomain("tempDomain"); And to load an assembly into the applicat...