instruction
stringlengths
0
30k
Your best bet is to use WCF. You will be able to create a service host in the windows service and expose a well defined interface that the GUI application can consume. WCF will let you communicate via named pipes if you choose, or you can choose any other communication protocal like TCP, HTTP, etc. Using WCF you get...
Brian, the classic ASP equivalent of a Perl hash is the [Scripting.Dictionary](http://www.microsoft.com/technet/scriptcenter/guide/sas_scr_ildk.mspx?mfr=true) object.
Painting javax.microedition.lcdui.Graphics on LWUIT Component
|java-me|lwuit|
What would be the best method for getting a custom element (that is using J2ME native Graphics) painted on LWUIT elements? The custom element is an implementation from mapping library, that paints it's content (for example Google map) to Graphics object. How would it be possible to paint the result directly on LWUIT...
|java|java-me|lwuit|
What would be the best method for getting a custom element (that is using J2ME native Graphics) painted on LWUIT elements? The custom element is an implementation from mapping library, that paints it's content (for example Google map) to Graphics object. How would it be possible to paint the result directly on LWUIT...
See the [Database Publishing Wizard][1] which is part of the **SQL Server Hosting Toolkit** which generates a single SQL file for both schema and data. [1]: http://www.codeplex.com/sqlhost/Wiki/View.aspx?title=Database%20Publishing%20Wizard
You are correct, if you use BufferedReader for reading HTTP content and headers you will want InputStreamReader so you can read byte for byte. BufferedReader in this scenario sometimes does weird things...escpecially when it comes to reading HTTP POST headers, sometimes you will be unable to read the POST data, if ...
Java: Programatic Way to Determine Current Windows User
|java|windows|
I see many similar questions, however I want to find the Username of the currently logged in user using Java. Its probably something like: System.getProperty(current.user); But, I'm not quite sure.
My gut tells me that since you're already performing buffering by using the byte array, it's redundant to use the BufferedReader.
Yes because of the Global Interpreter Lock (GIL) there can only run on thread at a time. Here are some links with some insights about this: * http://blog.snaplogic.org/?p=94 * http://www.artima.com/weblogs/viewpost.jsp?thread=214235 * http://effbot.org/pyfaq/can-t-we-get-rid-of-the-global-interpreter-lock.htm * h...
> Must be a Vista problem. I have XP SP 2 and it looks normal. So it is. I tried it on XP and it's fine, and on vista with the theme set to windows classic it's also fine. Must just be a bug in the firefox-vista-aero theme.
[RedGate SqlCompare][1] is a way to go in my opinion. We do DB deployment on a regular basis and since I started using that tool I have never looked back. Very intuitive interface and saves a lot of time in the end. The Pro version will take care of scripting for the source control integration as well. [1]:...
You're actually really close. Try this instead: System.getProperty("user.name")
You're actually really close. This is what you're looking for: System.getProperty("user.name")
There's [Cursed GTK][1], but it seems a bit dated. I found some references to a port of Qt to ncurses called Qt Console, but it seems to have disappeared. [1]: http://zemljanka.sourceforge.net/cursed/
I doubt sh/bash can do it. ZSH would be a better bet, with its MULTIOS and coproc features.
The one time I've seen this before, I was working with a library which also defined Exception and the usings I had meant that the actual Catch was referring to a different "Exception" type (if it had been fully qualified it was Company.Lib.Exception but it wasnt because of the using) so when it came to catching a norma...
The one time I've seen this before, I was working with a library which also defined Exception and the usings I had meant that the actual Catch was referring to a different "Exception" type (if it had been fully qualified it was Company.Lib.Exception but it wasnt because of the using) so when it came to catching a norma...
Personally I'm not convinced by the threading theory at all. The one time I've seen this before, I was working with a library which also defined Exception and the usings I had meant that the actual Catch was referring to a different "Exception" type (if it had been fully qualified it was Company.Lib.Exception but it...
Personally I'm not convinced by the threading theory at all. The one time I've seen this before, I was working with a library which also defined Exception and the usings I had meant that the actual Catch was referring to a different "Exception" type (if it had been fully qualified it was Company.Lib.Exception but it...
.egg files are basically a nice way to deploy your python application. You can think of it as something like .jar files for Java. More info [here][1]. [1]: http://peak.telecommunity.com/DevCenter/PythonEggs
Eggs are a pretty good way to distribute python apps. Think of it as a platform independent .deb file that will install all dependencies and whatnot. The advantage is that it's easy to use for the end user. The disadvantage are that it can be cumbersome to package your app up as a .egg file. You should also offer...
Thanks, that helped because it showed what was wrong: My file paths were different. Here's how I fixed it: 1) Load database from SQL 2000 backup 2) Set compatibility mode to SQL 2005 USE mydb GO ALTER DATABASE mydb SET COMPATIBILITY_LEVEL = 90 GO 3) Get the filegroup names SELECT n...
To answer your additional question: > [This](http://stackoverflow.com/questions/47878/codereview-tiny-encryption-algorithm-for-arbitrary-sized-data) > question precipitated my inquiry. The > tea.h file makes no reference to the > tea.c file. Does the compiler "know" > that every .h file has a corresponding > .c...
To answer your additional question: > [This](http://stackoverflow.com/questions/47878/codereview-tiny-encryption-algorithm-for-arbitrary-sized-data) > question precipitated my inquiry. The > tea.h file makes no reference to the > tea.c file. Does the compiler "know" > that every .h file has a corresponding > .c...
I don't think you have the ASP.Net master pages translated to the *WPF Page* world just yet. A workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level "[Application Setting][1]". You can update the string property like MyAp...
There is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword The second is an ID that can do updates. That id is Fred_app / mypassword_mangled. Th...
Don't do it! * Trying to create identifiers that are not valid in your language is not a good idea. * If you really want to set variables like that, use attribute macros. attr_writer :bar attr_reader :baz attr_accessor :foo
Don't do it! Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros: attr_writer :bar attr_reader :baz attr_accessor :foo
Don't do it! Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros: attr_writer :bar attr_reader :baz attr_accessor :foo
Don't do it! Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros: attr_writer :bar attr_reader :baz attr_accessor :foo Okay, now that you have been warned, here's how to do it. Just return anothe...
Does a language-specific IDE have any advantages over a plugin for a multi-language IDE?
|ide|
I do mostly Java and C/C++ development, but I'm starting to do more web development (PHP, Rails) and Eiffel (learning a new language is always good). Currently, I use Eclipse for Java, C/C++, and Ruby (not Rails). Since I know the environment, I'm thinking that it would be easier for me to find a plugin and use Ecli...
2.0 Has the `ConvertAll` method where you can pass in a converter function List<int> l1 = new List<int>(new int[] { 1,2,3 } ); List<string> l2 = l1.ConvertAll<string>(delegate(int i) { return i.ToString(); });
If you can fit the data into memory and you like python then I recommend checking out the UniTable portion of [Augustus][1]. (Disclaimer: Augustus is open source (GPLv2) but I work for the company that writes it.) It's not very well documented but this should help you get going. from augustus.kernel.unitable...
The only CIL book on my shelf is [Expert .NET 2.0 IL Assembler][1] by Serge Lidin. In terms of what the individual opcodes do or mean, the Microsoft documentation on System.Reflection.Emit has some pretty good information. And it's always useful to look at existing IL with [Reflector][2]. [1]: http://www.apres...
The only CIL book on my shelf is [Expert .NET 2.0 IL Assembler][1] by Serge Lidin. In terms of what the individual opcodes do or mean, the Microsoft documentation on System.Reflection.Emit has some pretty good information. And it's always useful to look at existing IL with [Reflector][2]. **Edit:** CIL (and indeed...
You wouldn't be able to directly cast it as no explicit or implicit cast exists from int to string, it would *have* to be a method involving .ToString() such as:- foreach (int i in intList) stringList.Add(i.ToString());
You wouldn't be able to directly cast it as no explicit or implicit cast exists from int to string, it would *have* to be a method involving .ToString() such as:- foreach (int i in intList) stringList.Add(i.ToString()); **Edit** - or as others have pointed out rather brilliantly, use intList.ConvertAll(delega...
Is C# 2.0 able to do List`<T`>.Convert? If so, I think your best guess would be to use that with a delegate: List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); list.Convert(delegate (int i) { return i.ToString(); }); Something along those lines.
Is C# 2.0 able to do List`<T`>.Convert? If so, I think your best guess would be to use that with a delegate: List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); list.Convert(delegate (int i) { return i.ToString(); }); Something along those lines. ---------- Upv...
Check out Billy McCafferty's [S#arp Architecture][1] project for a great ASP.NET MVC starter project filled with best practices. If you want something a little simpler, I threw together a rudimentary version of the S#arp Architecture project, called [Blunt Architecturehere][2]. [1]: http://code.google.com/p/s...
You can use a [Derived Column Transformation][1] in which you'll create a new output column and set its value to 2. You can then use that column when outputting to SQL. [1]: http://msdn.microsoft.com/en-us/library/ms141069.aspx
@Daniel <blockquote>The distinction between fork/exec and dynamic linking, besides being kind of artificial, doesn't carry over to interpreted languages: what about a Python/Perl/Ruby plugin, which gets loaded via import or execfile?</blockquote> I'm not sure that the distinction **is** artificial. After a dynamic l...
> he distinction between fork/exec and dynamic linking, besides being kind of artificial, I don't think its artificial at all. Basically they are just making the division based upon the level of integration. If the program has "plugins" which are essentially fire and forget with no API level integration, then the ...
How much info are you sharing between the Plugins and the main program? If you are doing anything more than just executing them and waiting for the results (sharing no data between the program and the plugin in the process) then you could most likely get away with them being proprietary, otherwise they would probably n...
NHIbernate: Difference between Restriction.In and Restriction.InG
|c#|nhibernate|orm|
When creating a criteria in NHibernate I can use Restriction.In() or Restriction.InG() What is the difference between them?
The short answer is because I can. The long answer, expanding on what the OP said, is to be more compatible with apache and mysql/postgresql. They are all 64bit (apache is a fat binary with ppc, ppc64 x86 and x86 and x86_64, the others just straight 64bit). **Mysqldb and mod_python wont compile unless they are all runn...
You can use Windows.Forms.NotifyIcon for this. http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx Add NotifyIcon to the form, set some properties and you are done. this.ShowIcon = false;//for the main form this.ShowInTaskbar = false;//for the main form ...
Update: Looks like I posted too soon. I was also using the below hack for a tool of mine. Waiting for the right solution for this.......... You can use Windows.Forms.NotifyIcon for this. http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx Add NotifyIcon to the form, set some properties a...
You should implement in your client code javax.jms.ExceptionListener. You will need a method called onException. When the client's connection is lost, you should get an JMSException and this method will be called automatically. The only thing you have to control for is if you are actually trying to disconnect from J...
The key to this matter is the historical usage of both systems, I think. Windows (and DOS before that) have originally been single-user systems for _personal_ computers. As such, these systems typically don't have to create a lot of processes all the time; (very) simply put, a process is only created when this one lone...
As you say, I probably wouldn't do it in SQL, but as a thought exercise have a MySQL implementation: CASE WHEN compare_date between date_sub(now(), INTERVAL 60 minute) and now() THEN concat(minute(TIMEDIFF(now(), compare_date)), ' minutes ago') WHEN datediff(now(), compare_date) = 1 THEN 'Yeste...
As you say, I probably wouldn't do it in SQL, but as a thought exercise have a MySQL implementation: CASE WHEN compare_date between date_sub(now(), INTERVAL 60 minute) and now() THEN concat(minute(TIMEDIFF(now(), compare_date)), ' minutes ago') WHEN datediff(now(), compare_date)...
For the mouse you can use [GPM][1]. I'm not sure off the top of my head for keyboard or joystick. It probably wouldn't be too bad to read directly off there /dev files if need be. Hope it helps, Brian Gianforcaro [1]: http://www.linuxjournal.com/article/4600
any issues with using log4net in a multi-threaded environment?
|log4net|
Just like the title, I'm wondering if anyone has any experience using log4net in a multi-threaded environment like asp.net. We are currently using log4net and I want to make sure we won't run into any issues.
Are there any issues with using log4net in a multi-threaded environment?
How to repeatedly merge branches in Mercurial
|version-control|mercurial|
We're using Mercurial where I work and I want to have a setup similar to how I used SVN: * Trunk * Tags * Production * Branches Since Mercurial supports branches natively, I know how to create a named branch, but I can't find any documentation on how to repeatedly merge 'Trunk' with 'Production'. Quite si...
If Subversion with TortiseSVN is too complex - and it may be, since version control is a whole paradigm different from Open, Modify, Save - then you might start them off with a much simpler hand version control: myDocument-20080908-beverlyd.doc It's simple, easy to understand, and you can write a script that ever...
I think [Redmine][1] can do some of what you're asking for. [1]: http://www.redmine.org/
As mentioned in Arbash's Black Book, one of the most simple and straight forward ways to get a huge speedup is to keep a change list. Instead of iterating through the entire cell grid each time, keep a copy of all the cells that you change. This will narrow down the work you have to do on each iteration.
Best to URL encode those, as they are clearly not supported in all web servers. Sometimes, even when there is a standard, not everyone follows it.
What is PI? The circumference of a circle divided by its diameter. In computer graphics you can plot/draw a circle with its centre at 0,0 from a initial point x,y, the next point x',y' can be found using a simple formula: x' = x + y / h : y' = y - x' / h h is usually a power of 2 so that the divide can be done e...
Datetime arithmetic with a string in Ruby
|ruby|time|datetime|
In Ruby, I'm trying to do the following. def self.stats(since) return Events.find(:all, :select => 'count(*) as this_count', :conditions => ['Date)event_date) >= ?', (Time.now - since)]).first.this_count end where "since" is a string representing an amount of time ('1 hour', '1 day', '3 days') and...
Try using [Chronic](http://chronic.rubyforge.org/) to parse the date strings into actual datetime objects.
Two ideas: (1) Many configurations are mostly empty space. Keep a linked list (not necessarily in order, that would take more time) of the live cells, and during an update, only update around the live cells (this is similar to your vague suggestion, OysterD :) (2) Keep an extra array which stores the # of live c...
Pretty much the only characters not allowed in pathnames are # and ? as they signify the end of the path. The uri rfc will have the definative answer: http://www.ietf.org/rfc/rfc1738.txt > Unsafe: > Characters can be unsafe for a number of reasons. The space > character is unsafe because significa...
I'm posting the [OWASP Top 2007 abbreviated list][1] here so people don't have to look through to another link and in case the source goes down. [Cross Site Scripting (XSS)][2] -------------------------- - XSS flaws occur whenever an application takes user supplied data and sends it to a web browser without fi...
I generally prefer to use mocks because of Expectations. When you call a method on a stub that returns a value, it typically just gives you back a value. But when you call a method on a mock, not only does it return a value, it also enforces the expectation that you set up that the method was even called in the first...
prop and exception are my favorites.
There's plenty of code snippets within Visual Studio for basic programming structure but I wouldn't necessarily rate one higher than another. I would definitely say the best ones are the custom snippets you define yourself to accomplish more specific tasks that you may find yourself using on a regular basis. Defini...
I saw the onex command, but I couldn't find a break command. The two commands below don't seem to work. onex break onex b
It's not that duck typing is more productive than static typing as much as it is simply different. With static typing you always have to worry that your data is the correct type and in Java it shows up through casting to the right type. With duck typing the type doesn't matter as long as it has the right method, so it ...
There is currently no way to compile DirectX code to directly target Linux. You would build your application like you normally would, then run it using a compatibility layer like Wine/Cedega.
I have created a small static util class just for that purpose Below code should read like an English sentence. public static bool DataSetIsEmpty(DataSet ds) { return !DataTableExists(ds) && !DataRowExists(ds.Tables[0].Rows); } public static bool DataTableExists(D...
I have used many many IDE's and in most cases to me it breaks down to personal preferences. Sometimes the language specific ones have some addins/addons/features that are nice but unless they are things you can not live without you should go with what is most comfortable for you. I would think that if you are comfor...
#Lambda Expressions Func&lt;int, int, int&gt; add = (a, b) =&gt; (a + b); #Obscure String Formats Console.WriteLine("{0:D10}", 2); // 0000000002 Dictionary<string, string> dict = new Dictionary<string, string> { {"David", "C#"}, {"Johann", "Perl"}, {"Morgan", "Python"} }; Console.WriteLine( "{0...
**Lambda Expressions** Func<int, int, int> add = (a, b) => (a + b); **Obscure String Formats** Console.WriteLine("{0:D10}", 2); // 0000000002 Dictionary<string, string> dict = new Dictionary<string, string> { {"David", "C#"}, {"Johann", "Perl"}, {"Morgan", "Python"} ...
One thing to watch out for at things that expire (I think httpContext does), if you are using it for operations that are "fire and forget" remember that all of a sudden if the asp.net cleanup code runs before your operation is done, you won't be able to access certain information.
Does you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may soun...
Not to repeat an answer, but I think I can add a bit more. [Slickedit][1] is an excellent IDE. It supports large code-bases well without slowing down or spending all its time indexing. (This is a problem I had with eclipse's cdt). Slickedit's speed is probably the nicest thing about it, actually.<br> The code c...
How do you programmatically change the tab order in a Win32 dialog?
|winapi|dialog|
I saw this functionality in older versions of VS.Net (2003 I think). It may still exist in current versions, but I haven't encountered it. Seems that files with the same name, even in different directories confuse VS.Net, and it ends up setting a break point in a file with the same name. May only happen if the class...
Restriction.In definately creates a subquery with whatever criteria you pass to the .In() method, but not sure what InG() does. never seen it.
> hg: unknown command 'view' (Maybe I need to install something - but it's not native, nonetheless). There is one "native" application out there, but it's not especially user-friendly. In fact, I'd go as far as saying that it's harder to use than the command line. There was some talk a year or so ago about a ...
While performance is an issue, I think modern database designs have made it much less of an issue for small files. Performance aside, it also depends on just how tightly-coupled the data is. If the file contains data that is closely related to the fields of the database, then it conceptually belongs close to it and ...