instruction stringlengths 0 30k ⌀ |
|---|
in perl:
`$0`
As a matter of fact, this will work with any shell that supports the backquote-command syntax and stores its own name in <code>$0</code> |
Logically a lot of things like MIME-encoded mail messages, URLs, XML documents, and so on should be returned as `bytes` not strings. This could cause some consternation as the libraries start to be nailed down for Python 3 and people discover that they have to be more aware of the `bytes`/`string` conversions than they... |
If I'm writing against libraries I have the source to I rarely if ever use it because I have the source.
If I'm writing against .Net libraries I probably spend 5% of the time, only when using something I'm unfamiliar with and Google/MSDN/StackOverflow lets me down.
When working with 3rd party libraries I probabl... |
The right question to ask is 'How can I give the developers a **stable** environment, while still **responding only** to high benefit feature requests.' A SCRUM like approach would be:
##Stable environment:
Have the developers work on a small **fixed** set of features during a small **fixed** iteration interval.
... |
C++ Class design from database schema |
|c++|database|mysql|oop|class| |
I am writing a perl script to parse a mysql database schema and create C++ classes when necessary. My question is a pretty easy one, but us something I haven't really done before and don't know common practice. Any object of any of classes created will need to have "get" methods to popluate this information. So my q... |
Take a look at [http://www.adobe.com/devnet/flex/quickstart/embedding_assets/](http://www.adobe.com/devnet/flex/quickstart/embedding_assets/) and see if it helps.
I don't think you can embed PDF files directly (but I'm not really sure) but if you totally need to do it and you don't want to open a new window you coul... |
I was surprised by instance initializers the other day:
public class Foo {
public Foo() { System.out.println("constructor called"); }
static { System.out.println("static initializer called"); }
{ System.out.println("instance initializer called"); }
}
making a call to `new Fo... |
I was surprised by instance initializers the other day:
public class Foo {
public Foo() { System.out.println("constructor called"); }
static { System.out.println("static initializer called"); }
{ System.out.println("instance initializer called"); }
}
Executing the following ... |
I take it your jars don't include the source, since you can't "step into."
In cases like these what I do is find the appropriate source (just StateManager.java in this case, if it's available, or jars that include source), taking care that it is the version I'm using. Inside my project tree, I create the package hiera... |
Iterator simply adds a common way of going over a collection of items. One of the nice features is the i.remove() in which you can remove elements from the list that you are iterating over. If you just tried to remove items from a list normally it would have weird effects or throw and exception.
The interface is l... |
Because you may be iterating over something that's not a data structure. Let's say I have a networked application that pulls results from a server. I can return an Iterator wrapper around those results and **stream them** through any standard code that accepts an Iterator object.
Think of it as a key part of a good... |
Here's what I have done and its worked well for me:
1. Get a site traffic analysis tool
which will graph hourly user load
2. Select low-point in graph for doing
updates |
Entity Framework - Can you map the result type of an imported stored procedure to a custom entity type? |
|c#|linq-to-sql|orm|entity-framework| |
I already have an entity model in a separate dll that contains various objects that I need to use. I don't really want to create or duplicate entities using the EF designer. Instead I would like to configure it so that when I call a stored procedure it will map certain columns to specific properties.
I know you can ... |
Depends on your location: 4AM East Coast/1AM West Coast is typlically the lightest time. |
My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.
Building the boost librari... |
If you want to use custom shaders with SpriteBatch, check out this sample:
[http://creators.xna.com/en-us/sample/spriteeffects][1]
[1]: http://creators.xna.com/en-us/sample/spriteeffects |
ReferenceEquals(object obj1, object obj2) |
Best way to update multi-gigabyte program (DVD fulfillment? Updater software?) |
|windows|download|dvd|updating| |
Two years ago, we shipped a multi-gigabyte Windows application, with lots of video files. Now we're looking to release a significant update, with approximately 1 gigabyte of new and changed data.
We're currently looking at DVD fulfillment houses (like [these folks][1], for example), which claim to be able to ship DV... |
Different values of GetHashCode for inproc and stateserver session variables |
|asp.net|c#|session| |
I've recently inherited an application that makes very heavy use of session, including storing a lot of custom data objects in session. One of my first points of business with this application was to at least move the session data away from InProc, and off load it to either a stateserver or SQL Server.
After I made ... |
Damien
I'm not sure how useful your answer is. We have a large 700,000 lines of compiled codebase that was written over the last ten years which contains a large number of sql queries. Most are standardised down to a few functions which are the basis for most of the updates on the database. These can be updated ... |
GNU strip accepts regex arguments to --strip-symbols=
The STL and boost symbols are name-mangled because of the namespaces they're in. I don't have GCC binutils handy at this moment, but just peek at the name mangling used for namespaces and construct the regex for 'symbols from namespace X' and pass this to --strip-s... |
Where do I find the current {X} standard? |
|c++|c|standards| |
For many questions, especially for C-related ones, the answer seems to be found in "the standard". However, where do we find that - online?
Googling can sometimes feel futile, again especially for the C standards, since they are drowned in the flood of discussions on programming forums ;)
To get this started, si... |
The most efficient way to move psql databases |
|sql|pg-dump| |
What is the most efficient, secure way to pipe the contents of a postgresSQL database into a compressed tarfile, then copy to another machine?
This would be used for localhosting development, or backing up to a remote server, using *nix based machines at both ends. |
Apple clearly said that you cannot use dynamic libraries on their mobiles. And a private framework is just this.
You can, however, use static libraries. |
Thanks for the answers guys, ajryan, you seem to always come up with help for my questions so extra thanks.
Thankfully this time the answer was fairly straightforward....
ImageList_DragShowNolock(FALSE);
m_pDragDropTargetWnd->SendMessage(WM_USER_DRAG_DROP_OBJECT_DRAG_ENTER, (WPARAM)pDragDropObject, (LPAR... |
You could execute the blocking query in a different thread and never being bothered with the timeout. When some data arrives you notify the thread that needs to know about the status of the transaction. |
If you are worried about the user not realising the full impact of their delete, you might want to consider not actually deleting the data - instead you could simply set a flag on a column called say "`marked_for_deletion`". (the entries could then be deleted a safe time later)
The downside is that you need to reme... |
How do I fix a "broken" debugger in EclipseME (MTJ)? |
|eclipse|debugging|java-me|eclipseme| |
How do I fix a broken debugger, one that just won't start, in [EclipseME][1] (now Mobile Tools Jave)?
(This question has an answer which will be transferred from another question soon)
[1]: http://www.eclipseme.org/ |
The easiest fix would be to add `position: relative;` to the outer div. This will make IE7 work as intended.
(See: <http://rowanw.com/bugs/overflow_relative.htm>). |
Does fluent interfaces violate the Law of Demeter? |
|oop|desing|language-agnostic| |
The [wikipedia article][1] about [Law of Demeter][3] says:
> The law can be stated simply as "use only one dot".
However a [simple example][4] of a [fluent interface][2] may look like this:
static void Main(string[] args)
{
new ZRLabs.Yael.Pipeline("cat.jpg")
.Rotate(90)
... |
|oop|design|language-agnostic| |
|oop|language-agnostic|api-design| |
Do fluent interfaces violate the Law of Demeter? |
|language-agnostic|oop|api-design| |
You might want to check into the [WordNet][1] project at Princeton University. One possible approach to this would be to first run each phrase through a stop-word list (to remove "common" words such as "a", "to", "the", etc.) Then for each of the remaining words in each phrase, you could compute the semantic "similarit... |
**I'll go against the grain and say learn WPF first.**
Here's my reasoning:
- Much more resources are available for WPF than Silverlight, such as books, blogs, and msdn documentation
- [WPF Books][1]
- You're not dealing with a Beta, moving target
- You don't have to deal with working with only asynchr... |
.NET's SslStream is always negotiating to the least secure cipher I have. How can I change this? |
|.net|encryption|ssl|aes| |
SslStream is supposed to negotiate the cipher type, key length, hash algorithm, etc. with its peer SSL stack. When using it in my code, I find that the negotiation always defaults to RC4 & MD5. I would like to use 3DES or AES for some added security.
Looking around the web I find only a few references to this proble... |
Did you check here: http://cairographics.org/visualstudio/ ? What do you mean 'It uses MSCVRT runtime, which is incompatible with Visual C++ 2005/2008' ? What are the exact problems you're having? |
[WebClient][1] is sometimes eaiser to use than [WebRequest][2]. You may want to take a look at it.
For JSON deserialization you are going to want to look at the [JavaScriptSerializer][3] class.
WebClient example:
using (WebClient client = new WebClient ())
{
//manipulate request headers (opt... |
How to extend default timeout period in flash application? |
|flash|timeout|haxe| |
I have an application written in flash (actually it is written in haXe and run under SHWX but it doesn't matter here). I have a pretty complex task that consumes a lot of CPU power and sometimes executes for more that 15 seconds. If that happens, I've got an error saying 'A script has executed for longer than the defau... |
Check out this [list of free help authoring tools][1], bound to be something useful there.
[1]: http://www.thefreecountry.com/programming/helpauthoring.shtml |
When it comes to POSTing data to a web site, [System.Net.HttpWebRequest](http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx) (the HTTP-specific implementation of WebRequest) is a perfectly decent solution. It supports SSL, async requests and a bunch of other goodies, and is well-documented on MSDN.... |
There's possibly a phobia of stored procedures with mysql, partly due to not being overwhelmingly powerful ( compared to Postgresql and even MSSQL, mysqls stored procedures are greatly lacking ).
On the plus: They make interfacing with it from more than one language easier.
If somebody states that "*using store... |
I use [jQuery][1] for this. Here is a good example:
http://blog.reindel.com/2007/09/24/jquery-and-xml-revisited/
There are also lots and lots of good examples in the [jQuery][1] documentation:
http://www.webmonkey.com/tutorial/Easy_XML_Consumption_using_jQuery?oldid=20032
[1]: http://jquery.com/ |
-- Oracle SQl
CREATE TABLE ObjectState
(
startdate date NOT NULL,
state varchar2(10) NOT NULL
);
insert into ObjectState
select to_date('01-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Initial' union all
... |
Think of some of the problems that can occur if there is no newline. According to the ANSI standard the #include of a file at the beginning inserts the file exactly as it is to the front of the file and does not insert the new line after the "#include <foo.h>" after the contents of the file. So if you include a file wi... |
Think of some of the problems that can occur if there is no newline. According to the ANSI standard the #include of a file at the beginning inserts the file exactly as it is to the front of the file and does not insert the new line after the "#include <foo.h>" after the contents of the file. So if you include a file wi... |
Just M2C, if you weren't aware: you can avoid directly using the iterator interface in situations where the [for-each][1] loop will suffice.
[1]: http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html |
Business Objects, Validation And Exceptions |
|business-objects|c#|validation|exception| |
I’ve been reading a few questions and answers regarding exceptions and their use. Seems to be a strong opinion that exceptions should be raised only for exception, unhandled cases. So that lead me to wondering how validation works with business objects.
Lets say I have a business object with getters/setters for the ... |
|c#|exception|validation|business-objects| |
I’ve been reading a few questions and answers regarding exceptions and their use. Seems to be a strong opinion that exceptions should be raised only for exception, unhandled cases. So that lead me to wondering how validation works with business objects.
Lets say I have a business object with getters/setters for the ... |
|c#|asp.net|session| |
I've recently inherited an application that makes very heavy use of session, including storing a lot of custom data objects in session. One of my first points of business with this application was to at least move the session data away from InProc, and off load it to either a stateserver or SQL Server.
After I made ... |
You can actually use pure CSS to get positioned background images with alpha transparency in IE6 by taking advantage of IE6's alpha filters and the CSS `clip` property. Julien Lecomte [describes the technique on his blog][1].
Note that this technique does result in a performance hit for each use of an alpha filter.
... |
Avoiding double-thunking with C++/CLI properties |
|.net|c++|properties|c++-cli| |
I've read (in Nish Sivakumar's book **C++/CLI In Action** among other places) that you should use the \_\_clrcall decorator on function calls to avoid double-thunking, in cases where you know that the method will never be called from unmanaged code. Nish also says that if the method signature contains any CLR types, th... |
Suggestions on how build an HTML Diff tool? |
|html|diff|c#|dom| |
In <a href="http://stackoverflow.com/questions/48669/are-there-any-tools-out-there-to-compare-the-structure-of-2-web-pages">this post</a> I asked if there were any tools that compare the structure (not actual content) of 2 HTML pages. I ask because I receive HTML templates from our designers, and frequently miss minor ... |
You want to think about where that list comes from. Generally that information is in the database somewhere. For example, instead of this:
SELECT * FROM [Table] WHERE ID IN (1,2,3)
You could use a subquery like this:
SELECT * FROM [Table] WHERE ID IN ( SELECT TableID FROM [OtherTable] WHERE OtherTabl... |
"They can make deleting records more cumbersome - you can't delete the "master" record where there are records in other tables where foreign keys would violate that constraint."
It's important to remember that the SQL standard defines actions that are taken when a foreign key is deleted or updated.
The ones I know ... |
I think it should be possible to use the $Rev$ macro inside it with the Office 2007 XML formats, but I am not too sure what will happen with older formats that might contain binary data.
Read this for detailed infos on $Rev$ replacement: http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html |
I think it should be possible to use the $Rev$ macro inside it with the Office 2007 XML formats, but I am not too sure what will happen with older formats that might contain binary data. You might need to tweak svn settings a bit so it sees .ppt files as text and not binary for this to work, I am not sure what is the d... |
Type-1 is the older format, and dates back to the days when Adobe where pioneering DTP with PostScript and vector fonts. At the time Type 1 and Type 3 were the only formats understood by PostScript printers, and only Type 1 could include hints needed to make fonts look good, and the format was a trade secret. This way ... |
What time should I build to production? |
|deployment|timing| |
My users use the site pretty equally 24/7. Is there a meme for build timing? |
My users use the site pretty equally 24/7. Is there a meme for build timing?
International audience, single cluster of servers on eastern time, but gets hit well into the morning, by international clients.
1 db, several web servers, so if no db, simple, whenever.
But when the site has to come down, when would ... |
The answers here and even the Wikipedia article describe round-robin scheduling to inherently include periodic timeslicing. While this is very common, I believe that Round-Robin scheduling and timeslicing are ***not*** exactly the same thing. Certainly, for timeslicing to make sense, round-robin schedling is implied wh... |
The answers here and even the Wikipedia article describe round-robin scheduling to inherently include periodic timeslicing. While this is very common, I believe that Round-Robin scheduling and timeslicing are ***not*** exactly the same thing. Certainly, for timeslicing to make sense, round-robin schedling is implied wh... |
Like many things, it's a tradeoff. It's a question of where you want to do the work to verify the data integrity:
(1) use a foreign key (a single point to configure for a table, feature is already implemented, tested, proven to work)
(2) leave it to the users of the database (possible multiple users/apps updatin... |
I use the template below to flatten structured XML. Actually there was some case-specific code in the original version (it actually turned the XML into CSV) that I just stripped. I didn't test this version, but the basic way it works should be clear: it prints everything that doesn't have node children and otherwise re... |
I use the template below to flatten structured XML. Actually there was some case-specific code in the original version (it actually turned the XML into CSV) that I just stripped. I didn't test this version, but the basic way it works should be clear: it prints everything that doesn't have node children and otherwise re... |
I have used an expanded version of the template below to flatten structured XML. Warning: There was some case-specific code in the original version (it actually turned the XML into CSV) that I just stripped and I didn't test this version.
The basic way it works should be clear: it prints everything that doesn't hav... |
Calculate a powerspectrum with a sliding window FFT:
Take 1024 samples:
double[] signal = stream.Take(1024);
Feed it to an FFT algorithm:
double[] real = new double[signal.Length];
double[] imag = new double[signal.Length);
FFT(signal, out real, out imag);
You will get a real part and a... |
How about this:
Use that "times" table, but with two columns, containing the 15-minute intervals. The from_times are the 15-minutely times, the to_times are a second before the next from_times. For example 12:30:00 to 12:44:59.
Now get your person work table, which I've called "activity" here, with start_time and... |
.htaccess mod rewrite 301-redirect |