instruction stringlengths 0 30k ⌀ |
|---|
C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello `std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()`), and boring me with long compile times. What's the single best alternative for serious real-time graphics programming? Garbage collection is ... |
I'm going to join the choir here and say FlashDevelop for an alternative. The only reasons you might want FlexBuilder are:
1. Flex charts
2. Step-through debugging.
3. Profiler (I haven't used it)
4. Visual style editor
However, the code-completion and general bloody-awesomeness of FlashDevelop's code-complet... |
For the FTP protocol, the ASCII transfer mode will consider the 8th bit of each of your character as insignificant and will use it for error checking. As for binary transfer mode, your data will be sent as is. Note that sending binary data in ASCII mode will (almost) always end up in data corruption. However, transferr... |
Try a rake task. For example:
1. Create the file **/lib/tasks/bootstrap.rake**
2. In the file, add a task to create your default user:
<pre><code>
namespace :bootstrap do
desc "Add the default user"
task :default_user => :environment do
User.create( :name => 'default', :password => '... |
I have used Selenium for exactly this task, but found it to be brittle.
Check out this talk by two Googlers: [Does my button look big in this? Building testable AJAX applications][1]
They isolate the testable javascript (non DOM-interaction) and test that using the Rhino javascript engine.
[1]: http://video.... |
Use a helper function like [this one][1] to tie the textboxes to their associated buttons.
[1]: http://geekswithblogs.net/jawad/archive/2005/05/15/TextBoxButtonTie.aspx |
Consistently getting ~4ms on my Athlon 64 4200+ (~7ms with original code)
for( const unsigned char* pChar = _pArray; pChar != pEnd; pChar++) {
const char* pchars = _hex2asciiU_value[*pChar];
*pszHex++ = *pchars++;
*pszHex++ = *pchars;
}
|
Including files case-sensitively on Windows from PHP |
|php|windows|apache|pear| |
We have an issue using the PEAR libraries on Windows from PHP.
Pear contains many classes, we are making use of a fair few, one of which is the Mail class found in Mail.php. We use PEAR on the path, rather than providing the full explicit path to individual PEAR files:
require_once('Mail.php');
Rather than... |
We have an issue using the PEAR libraries on Windows from PHP.
Pear contains many classes, we are making use of a fair few, one of which is the Mail class found in Mail.php. We use PEAR on the path, rather than providing the full explicit path to individual PEAR files:
require_once('Mail.php');
Rather than... |
in theory an associative container (set, multiset, map, multimap) should be your best solution.
In practice it depends by the average number of the elements you are putting in.
for less than 100 elements a vector is probably the best solution due to:
- avoiding continuous allocation-deallocation
- cache friendly ... |
Here's a question: Do you <i>really</i> need to create a channel with the exact contract type in your specific case?
Since you're doing routing, there's a very good chance you could simply deal with the generic channel shapes. For example, if you're routing a one-way only message, then you could create a channel to ... |
How to Call a method via AJAX without causing the page to render at all? |
|asp.net|ajax|asp.net-ajax| |
I am working with ASP.net.<br><br>
I am trying to call a method that exists on the base class for the page I am using. I want to call this method via Javascript and do not require any rendering to be handled by ASP.net.<br><br>
What would be the easiest way to accomplish this.
<br><br>
I have looked at PageMethods ... |
<p>A possible fix is by synchronising the switch using Display.callSerially(). The flicker is probably caused by the app attempting to draw to the screen while the switch of the Canvas is still ongoing. callSerially() is supposed to wait for the repaint to finish before attempting to call run() again.</p>
<p>But all t... |
I'm not sure if it's a mature enough approach for a production
system, but I had quite a lot of success with monitoring database
traffic using a network traffic sniffer.
Send the raw data between the application and database off to another
machine and decode and analyse it there.
I used PostgreSQL, and decodi... |
These days implicit cursors are more efficient than explicit cursors.
[http://www.oracle.com/technology/oramag/oracle/04-sep/o54plsql.html][1]
[http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1205168148688][2]
[1]: http://www.oracle.com/technology/oramag/oracle/04-sep/o54plsql.html
[... |
Yes. A different path is the same from the caches perspective. |
Maybe you're looking for `__len__`. If that method exists, then len(a) calls it:
>>> class Spam:
... def __len__(self): return 3
...
>>> s = Spam()
>>> len(s)
3
|
It just isn't.
You can, however, do:
>>> [1,2,3].__len__()
3
Adding a `__len__()` method to a class is what makes the `len()` magic work. |
-O3 is not deemed "sane", -O2 is generally the upper threshold except maybe for some multimedia apps.
Some apps can't even go that far, and die if you go beyond -O1 .
If you have a new enough GCC ( I'm on 4.3 here ), it may support this command
gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
If you'... |
Tom you coud specify and appenders for each job. Let's that you have 2 jobs corresponding to two different java packages com.tom.firstbatch and com.tom.secondbatch, you would have something like this in log4j.xml :
<category name="com.tom.firstbatch">
<appender-ref ref="FIRST_APPENDER"/>
</... |
This is no longer allowed according to C99 rules on pointer aliasing. Pointers of two different types cannot point to the same location in memory. The exceptions to this rule are void and char pointers.
So in your code where you are casting to a pointer of size_t, the compiler can choose to ignore this. If you want ... |
Error code or Exception - which is the best practice for an ASP.Net web service? |
|web-services|asp.net| |
I've read this [thread][1] for WCF has inbuilt Custom Fault codes and stuff.
But what is the best practice for ASP.Net web services. Do I throw exceptions and let the client handle the exception or send Error code (success, failure etc) that the client would rely upon to do it's processing.
[1]: http://stacko... |
I love how RPO is plug and play.
It will take time to create a module like theirs and depending on work load can be worth the $750/year versus the development time it takes to re-create it.
I'm very excited about RPO and reviewing it's effect on my sites.
Something I used quite recently was page optimization mo... |
Session variables are stored in the server so you can forget the device browser capabilities.
I've not practice developing for mobile device, but 4 years ago I was using a service that used cookie authentication and the phone was not top-notch so... I think you can take for granted the cookie availability. Full futu... |
Another way would be creating a mutable integer:
class MutableInt {
int value = 0;
public void inc () { ++value; }
public int get () { return value; }
}
...
Map<String,MutableInt> map = new HashMap<String,MutableInt> ();
MutableInt value = map.get (key);
if (value ==... |
Did you consider an updatable view? Depending on your database server and the integrity of your database design you will be able to create a view that, when its values change, in turn it will update the constituent tables. |
Thank you all for the answers. First, A quick follow up on all answers.
1. (alexvictor) Yes, you can have concrete _enum_ as annotation param, but not _java.lang.Enum_.
2. Answer provided by flicken is correct, but unfortunately a bit scary. I am not a Spring expert but doing things this way (creating methods for... |
Prevent implicit import of units in Delphi packages |
|delphi|compiler-construction|package| |
Is there a way to prevent packages in Delphi to implicitly import units that are not listed in the "Contains" list? I'm looking for a compiler directive that makes the build to fail if it tries to do an implicit import.
Problems occur when you install a package into the IDE that implicitly imports unit A and then yo... |
Connection Timeouts (assuming a local network and several client machines) typically result from
a) some kind of firewall on the way that simply eats the packets without telling the sender things like "No Route to host"
b) packet loss due to wrong network configuration or line overload
c) too many requ... |
So, like this?
var theMap = /* the stuff you posted */;
var someHdr = "Make";
var whichIndex = 0;
var correspondingData = theMap["data"][whichIndex][someHdr];
That should work, if I'm understanding you correctly... |
Actually, as the "root" node is a special case of node, maybe you need RootHtmlPageNode : HtmlPageNode.
Another idea: as you do not specify what is the difference between a "root" and normal node, maybe just a flag in node specifying if it is root or not also will be a good design. |
Actually, as the "root" node is a special case of node, maybe you need RootHtmlPageNode : HtmlPageNode.
Another idea: as you do not specify what is the difference between a "root" and normal node, maybe just a flag in node specifying if it is root or not also will be a good design.
EDIT: Per your clarification, t... |
Converting SQL Result Sets to XML. |
|sql|xml| |
I am looking for a tool that can serialize and/or transform SQL Result Sets into XML. Getting dumbed down XML generation from SQL result sets is simple and trivial, but that's not what I need.
The solution has to be database neutral, and accepts only regular SQL query results (no db xml support used). A particular c... |
You kind of have to get a "feel" for what programmers had to do back in the day. The vast majority of the code I work with is older than I am and ran on machines that were "new" when my parents were in high school.
Common FORTRAN-isms I deal with, that hurt readability are:
- Common blocks
- Implicit variabl... |
Dynamically sorted STL containers |
|c++|stl|containers| |
I'm fairly new to the STL, so I was wondering whether there are any dynamically sortable containers? At the moment my current thinking is to use a vector in conjunction with the various sort algorithms, but I'm not sure whether there's a more appropriate selection given the (presumably) linear complexity of inserting ... |
I'm fairly new to the STL, so I was wondering whether there are any dynamically sortable containers? At the moment my current thinking is to use a vector in conjunction with the various sort algorithms, but I'm not sure whether there's a more appropriate selection given the (presumably) linear complexity of inserting ... |
This website has a fixed element "First time at Stack Overflow? Check out the FAQ!", and it's slow as hell in firefox. Works better with Opera and Chrome though.
FF3, Windows XP, ATI. |
Is there a guide I can follow to convert my procedural actionscript 3 to OOP? |
|actionscript-3| |
I'm wanting to change my movie clips to actionscript classes in AS3. Is there a standard list of things I need to do to make sure the classes work? |
|asp.net|web-services| |
I've read this [thread][1] for WCF has inbuilt Custom Fault codes and stuff.
But what is the best practice for ASP.Net web services. Do I throw exceptions and let the client handle the exception or send Error code (success, failure etc) that the client would rely upon to do it's processing.
Update: Just to discus... |
Of course it has to use the whole path '/r20/example.js' vs '/r21/example.js' could be completely different images to begin with. What you suggest is a viable way to handle version control. |
After a little poking around, isn't it the extrinsic matrix that tells you where the camera actually is in 3-space?
I worked at a company that did a lot of this, but I always used the tools that the algorithm guys wrote. :) |
I agree, Trac should work. IMHO setting up Subversion should be relatively easy on Windows too, there are great Windows clients for it (tortoiseSvn), and Trac runs on python, so it will work on Windows too. |
Turn off the on-the-fly compilation (which, unfortunately, is one of its best features) |
Something like (untested code):
UPDATE yourtable
SET yourfield= CHAR(32+ROUND(RAND()*95,0));
Obviously, concatenate more random characters if you want up to ten chars.
It's possible that the query optimizer might set all fields to the same value; in that case, I would try
SET yourfield=LEFT(yourfie... |
I would not say "stored procedures are a no-go", I would say "Don't use them without a good reason".
MySQL stored procedures have a particularly horrible syntax (Oracle and MSSQL are pretty awful too), maintaining them just complicates your application.
Do use a stored procedure if you have a real (measurable) r... |
This is bad C code. Your cast breaks C aliasing rules, and the optimiser is free do things that break this code. You will probably find that GCC has cheduled the size_t read before the floating-point write (to hide fp pipeline latency).
You can set the -fno-strict-aliasing switch, or use a union or a reinterpret_ca... |
The function you want is `remove-if-not`, which is built-in.
(defun remove-low-words (word-list)
(remove-if-not #'good-enough-score-p word-list))
If you feel like you are re-inventing something to do with lists, you probably are. Check the Hyperspec to see.
- [The Hyperspec documentation on `re... |
OSGI is certainly a valid way to go. But, assuming you dont need to unload to reload the plugin, it might be using a hammer to crack a nut.
You could use the classes in 'java.util.jar' to scan each JAR file in your plugins folder and then use a 'java.net.URLClassLoader' to load in the correct one.
|
override constraint from no action to cascading at runtime |
|sql|constraints|cascade| |
I feel like I have a verry basic/stupid question, yet I never saw/read/heard anything in this direction.
Say I have a table *users(userId, name)* and a table *preferences(id, userId, language)*. The example is trivial, but could be extended to a situation with multi-level relations and way more tables..
When my UI ... |
I used D for my research project on developing a global optimization algorithm. I applied it to the problem of training neural networks. It's up to you whether you want to call this "real world". |
Upload files in Google App Engine |
|google-app-engine| |
I am planning to create a web app that allows users to downgrade their visual studio project files. However, I am not very sure whether Google App Engine accepts files uploading and flat file storing on the Google Server.
Anyone knows about this? |
I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through db.TextProperty and db.BlobProperty.
I'll be glad anyone can provide code sample ( both the client and the... |
If you have your 3 copy and pasted test methods, you should be able to refactor (extract method) it to get rid of the duplication.
|
If you have your 3 copy and pasted test methods, you should be able to refactor (extract method) it to get rid of the duplication.
I'm not sure I fully understand the question - it seems as though the private GetRepository() function is a test function.
Can it be changed to something like:
private IReposit... |
I would try commenting out the InvalidateArrange in the OnPropertyChanged and see what happens. |
'Arc the daft' pretty much nailed exactly what one should try to do to learn LabVIEW. However, I would not skip Basic's I and II. The classes do teach basic programming concepts and are geared to non-programmers, however they do cover the IDE extensively. The LabVIEW IDE is strange coming from a text based language ... |
try this plugin for BCB compiler:
[Bcc32Pch IDE Plugin][1]
[1]: http://andy.jgknet.de/cpp/ |
string path = @"c:\folders\newfolder"; // or whatever
if (!System.IO.Directory.Exists(path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
}
From [here][1].
[1]: http://www.csharpfriends.com/For... |
Make sure you are using the "make" command and not the "build" command, unless it is required.
Making a project with the Borland tools has always seemed to have that issue -- that it doesn't necessarily notice which ones have changed and starts to compile everything.
Look at the Pre-Compiled Headers options, whic... |
Try this:
switch (val)
{
case VAL:
{
int newVal = 42;
}
break;
} |
After some frenzied coding i saw the light and did like this
import org.custommonkey.xmlunit.Diff
import org.custommonkey.xmlunit.XMLUnit
def input = '''<root><data></data></root>'''
def expectedResult = '''<root><data>value</data></root>'''
def xml = new XmlParser().parseText(input)
... |
Interfaces actually add some degree of dynamic lang-like flexibility to static languages that have them, like Java. They offer a way to query an object for which contracts it implements _at runtime_.
That concept ports well into dynamic languages. Depending on your definition of the word "dynamic", of course, that... |
What's a good way to store raster data? |
|database|data|geodata|raster|time-series| |
I have a variety of time-series data stored on a more-or-less georeferenced grid, e.g. one value per 0.2 degrees of latitude and longitude. Currently the data are stored in text files, so at day-of-year 251 you might see:
251
12.76 12.55 12.55 12.34 [etc., 200 more values...]
13.02 12.95 12.70 1... |
- Skip the File.Exists(); either handle it elsewhere or let CreateText()/OpenText() raise it.
- The end-user usually only cares if it succeeds or not. If it fails, just say so, he don't want details.
I haven't found a built-in way to get details about what and why something failed in .NET, but if you go nativ... |
The rules are:
* a single star (\*) matches zero or more characters *within a path name*
* a double star (\*\*) matches zero or more characters *across directory levels*
* a question mark (?) matches exactly one character within a path name
Another way to think about it is double star (\*\*) matches slash (/) b... |
I would use the using statement to simplify closing the file. See [MSDN the C# using statement][1]
From MSDN:
using (TextWriter w = File.CreateText("log.txt")) {
w.WriteLine("This is line one");
w.WriteLine("This is line two");
}
using (TextReader r = File.OpenText("log.txt... |
It's a documented bug with Silverlight 2 Beta 2. You can't animate two custom dependancy properties on the same object. |
If you have your 3 copy and pasted test methods, you should be able to refactor (extract method) it to get rid of the duplication.
i.e. this is what I had in mind:
private IRepository GetRepository(RepositoryType repositoryType)
{
switch (repositoryType)
{
case Reposit... |
Inner interfaces are implicitly static. The static modifier in your example can be removed without changing the semantics of the code. See also the [relevant part of the Java Language Specification](http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.5.2) |
I really don't see your problem behind the join.
Naturally, asking directly by the FK_LeadSourceID is wrong, but using the JOIN seems to be the right way to go as I masks changing IDs perfectly fine. If, for example, "foo" becomes 3 at one day (and you update the foreign key field), the last query you've displayed ... |
HP also had a JVM called HP Chai on their old models of Pocket PC |
Agree with Richard Szalay, but his regex didn't get quoted right:
var exptags = /\[(b|u|i|s|center|code)](.*)\[\/\1]/ig;
is cleaner. Note that I also change `.+?` to `.*`. There are two problems with `.+?`:
1. you won't match [u][/u], since there isn't at least one character between them (+)
1. a non-... |
I'm doing something similar using erb, and the performance is fine for me.
As Jordi said though, it depends what context you want to run this in - if you're literally going to use templates like the one you listed, eruby would probably work better, but I'd guess you're actually going to be passing variables to the t... |
Make Web Application Accessible |
|html|javascript|usability|accessibility| |
What things have to be done before I can honestly tell myself my web application is accessible? Or even better, convince Joe Clark. I don't have any video or audio to worry about, so I know I won't need transcripts. What else do I have to check? |
|javascript|html|usability|accessibility| |
What things have to be done before I can honestly tell myself my web application is accessible by anyone? Or even better, convince Joe Clark. I don't have any video or audio to worry about, so I know I won't need transcripts. What else do I have to check? |
Multiple keyboards and low-level hooks |