instruction stringlengths 0 30k ⌀ |
|---|
In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading these files sometimes contain garbage, because the codepage these files where created in a different/unknown codepage.
Is there a way to (automatically) detect the codepage of a text file?
(I use .Net / C#).
The de... |
How do I iterate a .Net IList collection in the reverse order? |
|.net|collections|iteration| |
I have an IList that contains items ( parent first ), they need to be added to a Diagram Document in the reverse order so that the parent is added last, drawn on top so that it is the first thing to be selected by the user.
What's the best way to do it? Something better/more elegant than what I am doing currently
w... |
Besides the usual support for latest versions of framework and integrated unit testing, i personally find out VS 2008 to be more stable, with better refactoring support and more mature (read stable) product than VS 2005.
I was using VS 2005 since it showed up on the market, until the first release of VS 2008, so i c... |
NewItems is my List here... This is a bit clunky though.
for(int iLooper = obEvtArgs.NewItems.Count-1; iLooper >= 0; iLooper--)
{
GoViewBoy.Document.Add(CreateNodeFor(obEvtArgs.NewItems[iLooper] as IMySpecificObject, obNextPos));
}
|
Also, Common Table Expressions and exception management in TSQL. Very useful.
|
|javascript|browser|google-chrome| |
As the title states, I'd be interested to find a safe feature-based (that is, without using navigator.appName or navigator.appVersion) way to detect Google Chrome.
By feature-based I mean, for example:
if(window.ActiveXObject) {
// internet explorer!
}
**Edit:** As it's been pointed out, the ... |
I second Garry Shutlers recommendation of using NumericUpDown. You might not like the up-down-controls, but that *is* the standard look of a numeric entry control in Windows, and you should think twice about using a different look.
If you end up coding your own implementation (or finding one on the web), there are s... |
There is also a way to specify an encoding to the flex compiler but that does not seem to work.
Right now the only solution I have found is to re-encode the incomming requests on the server side.
I am surprised this limitation is not written black on white in the flex reference documentation. |
It sounds like you have a DLL that gets locked every now and then, preventing VS from overwriting/locking it. Have you tried using tools like Process Explorer (<http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx>), or Unlocker (<http://ccollomb.free.fr/unlocker/>) to see what is locking the DLL? Unlocker in ... |
It sounds like you have a DLL that gets locked every now and then, preventing VS from overwriting/locking it. Have you tried using tools like Process Explorer (<http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx>), or Unlocker (<http://ccollomb.free.fr/unlocker/>) to see what is locking the DLL? Unlocker in ... |
If you check `Use option as meta key` in the keyboard tab of the preferences, then the default emacs style commands for forward- and backward-word and `⌥F` (alt+f) and `⌥B` (alt+b) respectively.
I'd recommend reading [From Bash to Z-Shell](http://www.amazon.com/Bash-Z-Shell-Conquering-Command/dp/1590593766 "Amazon.c... |
Compare Quagga to XORP |
|networking|routes|internet|ospf|bgp| |
What do you think of <a href="http://quagga.net">Quagga</a> compared to <a href="www.xorp.org">XORP</a> as a dynamic software routing engine? What are the technical merits of each engine comparatively? Additionally, what do most people think of them from a programming view. Who has manipulated networks using these engi... |
I don't think that you can do what you are trying. Firstly, your instantiate method doesn't know that its dealing with a parameterised type (you could just as easily pass it java.util.Date.class). Secondly, because of erasure, doing anything particularly specific with parameterised types at runtime is difficult or im... |
it is possible :
Using your unix shell script, generate an sql script and use the cli to the database to execute the sql script.
if the amount of information is small enough you could build the SQL in memory, I advise against it though since you never know what the future holds (and it could be very large amount o... |
The [Visual Studio Express][1] products are all free. Unless the fact that you're using Linux changes things :)
[1]: http://www.microsoft.com/Express/ |
The answer I discovered eventually was that while OpenGL only has its one amalgamated `MODELVIEW` matrix, in D3D the "world" and "view" transforms are kept separate, and placing lights seems to be the major reason for this. So the answer is you use `D3DTS_VIEW` to set up matrices that should apply to your lights, and ... |
Eclipse might be a good option (if a little overwhelming at first).
You obviously need to look at a cross-platform IDE. Eclipse is one of the best in this regard, as well as having support for many languages. It also comes with a good set of tutorials. |
Shell scripting (Bash or similar) primary intention is not to deal with databases. Go for Java or even better, ride this opportunity to learn the basics of a scripting language like Python or Ruby. |
My suggestion is [Textpad][1]. You can teach her javascript, all the basic, and some advanced concepts are there. It's fun for the student see the output in a browser, and you can even teach a little HTML if the mood strikes.
[1]: http://www.textpad.com/ |
On Windows Vista, if you bring up the Start menu and search for a program, pressing Ctrl+Shift+Enter will run the selected program as Administrator. So to open an Administrator command prompt:
Windows key, type "cmd", Ctrl+Shift+Enter |
I completely agree with you on that subject. In *practice* I think TDD often has some very negative effects on the code base (crappy design, procedural code, no encapsulation, production code littered with test code, interfaces everywhere, hard to refactor production code because everything is tightly coupled to many... |
SMTP is the protocol that is used to receive email from the rest of the world so I doubt that Microsoft has dropped that. There must be some other misconfiguration on your server.
Try double-checking your relay-settings and the event-log on your exchange-server. |
And another: Literal strings (strings declared in source code) are by default [interned][1] into a pool to save memory.
string s1 = "MyTest";
string s2 = new StringBuilder().Append("My").Append("Test").ToString();
string s3 = String.Intern(s2);
Console.WriteLine((Object)s2==(Object)s1); // Dif... |
And another: Literal strings (strings declared in source code) are by default [interned][1] into a pool to save memory.
string s1 = "MyTest";
string s2 = new StringBuilder().Append("My").Append("Test").ToString();
string s3 = String.Intern(s2);
Console.WriteLine((Object)s2==(Object)s1); // Dif... |
As far as I know this is not possible, I have wanted to do this myself several times. |
Just found [Light Bot][1]. Program your robot to move around and perform tasks to complete a puzzle. Even includes subroutines.
[1]: http://armorgames.com/play/2205/light-bot |
In Windows Forms, set the control's AcceptDrop property, then listen for DragEnter event and DragDrop event.
When the DragEnter event fires, set the argument's AllowedEffect to something other than none (e.g. e.Effect = DragDropEffects.Move).
When the DragDrop event fires, you'll get a list of strings. Each strin... |
Yes, you can. The pointer to the class member variable is stored on the stack with the rest of the struct's values, and the class instance's data is stored on the heap.
Structs can also contain class definitions as members (inner classes). |
Yes, you can. The pointer to the class member variable is stored on the stack with the rest of the struct's values, and the class instance's data is stored on the heap.
Structs can also contain class definitions as members (inner classes).
Here's some really useless code that at least compiles and runs to show t... |
For testing the output of a program, there is [Test::Command][1]. It allows to easily verify the stdout and stderr (and the exit value) of programs. E.g.:
use Test::Command tests => 3;
my $echo_test = Test::Command->new( cmd => 'echo out' );
$echo_test->exit_is_num(0, 'exit ... |
In .NET you could use [HTMLAgilityPack](http://www.codeplex.com/htmlagilitypack).
See this [previous question](http://stackoverflow.com/questions/2861/options-for-html-scraping) on StackOverflow for more information.
|
private void button1_Click( object sender, EventArgs e )
{
string s = @"p1=6&p2=7&p3=8";
NameValueCollection nvc = new NameValueCollection();
foreach ( string vp in Regex.Split( s, "&" ) )
{
string[] singlePair = Reg... |
Breadcrumbs in webapps: <br/>
<a>Tell</a> -> <a>The</a> -> <a>User</a> -> <a>Where</a> -> <a>She</a> -> <b>Is in the system</b>
This is pretty hard to do in "dynamic" systems with multiple paths to the same data, but it often helps navigate the system. |
I think nobody cares how a website was designed/implemented when it behaves great and it works fast.
I use both "table" and "div"/"span" tags in HTML markup.
Let me give you few arguments why I am choosing divs:
1. for a table you have to write at least 3 tags (table, tr, td, thead, tbody), for a nice design, ... |
Same problem like Java. Try using interfaces with abstract functions for solving that problem |
Maybe you can replace an 'is-a' relation with a 'has-a' relation? An Invitation might have a Message, but it does not necessarily need to 'is-a' message. An Invitation f.e. might be confirmed, which does not go well together with the Message model.
Search for 'composition vs. inheritance' if you need to know more ab... |
It depends on your requirements. A full distribution of Lucene (Java) is up to 3MB JAR file, but in practice can be stripped down to well under 1MB. CLucene is probably considerably smaller in practice. How low do you need to go?...
|
How to create a path to a temporary file on Windows XP/Vista |
|windows|windows-vista|file|temporary| |
What is the best way of doing this?
tmpnam() returns a path to a file in the root of the drive, which requires administrator privileges on Windows Vista, so this is not an option.
|
Schemas - Okay, 2000 has owners, but they can be a real pain to get permissions right on. |
your test file is in test.xml.
sed -n 's/^\s*<myel\s*name="\([^"]*\)".*$/\1,/p' test.xml
It has it's pitfalls, for example if it is not strictly given that each <strong>myel</strong> is on one line you have to "normalize" the xml file first (so each <strong>myel</strong> is on one separate line)<br />
|
your test file is in test.xml.
<nowiki>sed -n 's/^\s`*`<myel\s`*`name="\([^"]`*`\)".`*`$/\1,/p' test.xml</nowiki>
It has it's pitfalls, for example if it is not strictly given that each <strong>myel</strong> is on one line you have to "normalize" the xml file first (so each <strong>myel</strong> is on one sepa... |
#define foreach(var, container) for (typeof((container).begin()) var = (container).begin(); var != (container).end(); ++var)
There's no typeof in C++... how is this compiling for you? (it's certainly not portable)
|
Keep them in a separate file, trivially encrypted, and make a separate user in the database with read only access to necessary tables. If you think the file has been read, then you can shut off access to just that user.
If you want to get fancy, a SUID program could check the /proc/<parent pid>/exe and cmdline (in L... |
I'd vote with guid in a database and then use the Content-Disposition header to name it back to the original filename if necessary. One thing I would advocate is that the folders you use are stored outside of the web root; you don't want users uploading files into your application folders. |
Following on from dansays' comment, the following seems to work perfectly well:
`$('#thing') .animate({dummy:1}, 2000)
.animate({ etc ... });`
|
You have in you first route {action} token/parameter which gets in conflict with setting of default action. Try changing parameter name in your route, or remove default action name. |
Using WCF's rest binding is very valid when working with code that doesn't interact with a database at all. The HTTP verbs don't always have to go against a data provider. |
Since you're using a form, the easier way is to use the [BackgroundWorker][1] component.
> The BackgroundWorker class allows you
> to run an operation on a separate,
> dedicated thread. Time-consuming
> operations like downloads and database
> transactions can cause your user
> interface (UI) to seem as though ... |
What happens when the stylus "lifts" on a tablet pc? How best to capture that event? |
|c++|windows|tablet-pc|stylus|events| |
I am working on a legacy project in VC++/Win32/MFC. Recently it became a requirement that the application work on a **tablet pc**, and this ushered in a host of new issues:
> 1. the software keyboard has to use a "toggle" mode for shift and control
> keys because the stylus cannot "press"
> control and "C" at the... |
I'm a big fan of [GWT][1]. It lets you write your components as normal Java classes and then you can insert them into your pages at will. The whole thing ends up being compiled to Javascript.
Here's an example:
public class MyApplication implements EntryPoint, HistoryListener
{
static final St... |
One simple way is:
<pre>
$ touch a b c d e f g h i j k l m n o p q r s t u v w x y z
$ mv $(ls | awk '{nr++; if (nr % 4 == 0) print $0}') destdir
</pre> |
This may be a bug in the Oracle optimizer. I can reproduce the same behavior on the query with 3 tables. Intuitively it does seem that it should produce an error. If I rewrite it in either of the following ways, it does generate an error (table names changed):
(1) Using old-style outer join
select ptno, ca... |
This may be a bug in the Oracle optimizer. I can reproduce the same behavior on the query with 3 tables. Intuitively it does seem that it should produce an error. If I rewrite it in either of the following ways, it does generate an error (table names changed):
(1) Using old-style outer join
select ptno, ca... |
There are GPL routing applicaitons available that use Openstreetmap data, e.g. [Gosmore][1] which works on Windows (+ mobile) and Linux. There are a number of interesting [routing applications][2] using the same data, but gosmore has some cool uses [ e.g. interface with websites][3].
The biggest problem with routing... |
I've yet to find a good tutorial on routing but there are lots of code to read:
There are GPL routing applications that use Openstreetmap data, e.g. [Gosmore][1] which works on Windows (+ mobile) and Linux. There are a number of interesting [applications using the same data, but gosmore has some cool uses [ e.g. int... |
[`SHSetFolderPath` Function][1] should help, since [this][2] article mentions its use for folder redirection by the Group Policy API.
[1]:http://msdn.microsoft.com/en-us/library/bb762247(VS.85).aspx
[2]:http://technet.microsoft.com/en-us/library/cc787939.aspx |
I am reading the following:
http://msdn.microsoft.com/en-us/library/a5kfekd2.aspx
It says:
To get the index value of the selected item, read the value of the SelectedIndex property. The index is zero-based. If nothing has been selected, the value of the property is -1.
In the same time, at http://msdn.microsof... |
See here: <http://faq.wordpress.com/2007/09/03/how-do-i-post-source-code/>
Wrap your code in these tags: [sourcecode language='css']..[/sourcecode]
Available language codes:
- cpp
- csharp
- css
- delphi
- html
- java
- jscript
- php
- python
- ruby
- sql
- vb
- xml
H... |
How to blog code at wordpress.com |
|blogs|formatting| |
got a new blog at wordpress few days ago (http://ghads.wordpress.com) and I want to post some code snippets now or then. Is there anyway to make it look like code without paying for extra plugins? Thanks a lot! |
|blogs|code-formatting| |
Not to be the negative one here, but these kinds of questions are very academic. It completely depends on the application. I can think of very good reasons for doing it either way, and I've seen too many good programmers get bogged down in this kind of moot design details. |
Usually, the browser will preserve the page viewport if you navigate away and then back (try it with any pages on your favorite news site). The only exception to this is probably if you adjust your cache settings to re-download and re-render the page each time.
Not doing that (that is, not setting your page to never... |
As of version 1.4, I have been running all my server side code, in my container of choice (Glassfish) and hooking up the GWTShell to that. Are you using Netbeans, Eclipse or something else? The Netbeans plugin gwt4nb does this for you out of the box, you just have to start your web project in debug mode. I'm sure the G... |
As of version 1.4, I have been running all my server side code, in my container of choice (Glassfish) and hooking up the GWTShell to that. Are you using Netbeans, Eclipse or something else? The Netbeans plugin gwt4nb does this for you out of the box, you just have to start your web project in debug mode. I'm sure the G... |
Here's PHP.net's explanation of why it does it:
> ### Dots in incoming variable names
>
> Typically, PHP does not alter the
> names of variables when they are
> passed into a script. However, it
> should be noted that the dot (period,
> full stop) is not a valid character in
> a PHP variable name. For the ... |
This may be a bug in the Oracle optimizer. I can reproduce the same behavior on the query with 3 tables. Intuitively it does seem that it should produce an error. If I rewrite it in either of the following ways, it does generate an error:
(1) Using old-style outer join
select ptno, catcd
from parts, c... |
Komodo Edit from active vision is free, open source, and available for Windows and Linux. Very nice features.
Otherwise, Emacs as it is available on both platforms and can be configured for CUA controls.
The Cream version of VIM is also a good option. |
It really depends on the language you are teaching her.
EditPlus is a good simple editor. Free trial version and pretty cheap license. |
I found the following page with a number of webcasts very usefull:
<http://msdn.microsoft.com/en-us/vsx/cc677256.aspx> |
How do I configure Eclipse to work on QT-based applications in a subversion tree? |
|eclipse|svn|qt| |
Most of the work being done at my company is QT-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the... |
For Perl, there is [Feed::Find][1] , which does automate the discovery of syndication feeds from the webpage. The usage is quite simplicistic:
use Feed::Find;
my @feeds = Feed::Find->find('http://example.com/');
It first tries the `link` tags and then scans the `a` tags for files named `.rss` and somethi... |
[Dev-C++][1] as a non-MS alternative.
Quote: "Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler."
... |
[ASP.NET] How to dynamically generate combination of user controls? |
|asp.net|user-controls| |
I have several user controls, let's say A, B, C and D. Based on some random input, I need to generate a combination of these. For e.g. if input is 2a3d1a2c I need to show two of the A's, 3 D's after that, an A again, etc.
I will also need to stabilize clientid's in order for them to work correctly. Because each of t... |
How to dynamically generate combination of ASP.NET user controls? |
Have you tried with the environment variables TEMP and TMP set to a directory writable by all?
To change environment variables in XP (not familiar with Vista), you go to System Properties, [Advanced] tab, [Environment Variables] button. |
Actually, to use getimagesize(), you do **NOT** need to have GD compiled in.
You can also use mime_content_type() to get the MIME type. |
I wrote about some of <a href="http://confusion.tweakblogs.net/blog/1052/the-disadvantages-of-the-google-web-toolkit.html">the disadvantages of GWT</a> recently. Mainly, the disadvantages are: long deployment cycle for changes to some parts of the application and a rather steep learning curve. As a seasoned Java progra... |
Don't know for sure if this'll work, but reflector shows that the get and set methods for an indexed property are called get\_Item and set\_Item. Perhaps you could try Item and see if that works. |
Check out [Jiffy-web][1], developed by netflix to give them a more accurate view of the total page -> page rendering time
[1]: http://code.google.com/p/jiffy-web/ |
[GetTempPath][1] and [GetTempFileName][2] should work.
[1]: http://msdn.microsoft.com/en-us/library/aa364992(VS.85).aspx
[2]: http://msdn.microsoft.com/en-us/library/aa364991(VS.85).aspx |
This is an interesting question, so I did a bit of experimentation. I used this code:
static void Main (string [] args)
{
float
a = float.MaxValue / 3.0f,
b = a * a;
if (a * a < b)
{
Console.WriteLine ("Less");
}
else
{
Console.... |
I don't know if this one is fast or not, but at least it is simple.
Simply, convert it first to a set and then again to a list
def unique(container):
return list(set(container))
|
How do you place EXIF tags into a JPG, having the raw jpeg buffer in C++? |
|c++|jpeg|exif| |
I am having a bit of a problem.
I need to embed GPS information in an JPG with EXIF metadata, this is not a problem for a file already on disk.
But I get a RAW char* buffer from a camera and I need to add this tags before I can save it to disk. Writing the file to disk and reading it back again is not an option, ... |