instruction stringlengths 0 30k ⌀ |
|---|
What is the best C++ IDE for a *nix envirnoment? I have heard the C/C++ module of Eclipse is decent as well as Notepad++ but beyond these two I have no real idea. Any thoughts or comments? |
|c++|ide| |
I can't really vouch for the Eclipse module, but that might be attributed to the fact that I'm on Windows and have nearly no idea what I'm doing.
Can't go wrong with your favorite text editor though. |
You can use named scopes in rails 2.1 and above
Class Test < ActiveRecord::Base
named_scope :created_after_2005, :conditions => "created_on > 2005-01-01"
named_scope :named_fred, :conditions => { :name => "fred"}
end
then you can do
Test.created_after_2005.named_fred
Or you can gi... |
The code example below asks the user for a file path and then outputs the creation date and time:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(final String[] args) {
try {
... |
There's the [cheese](http://www.gnome.org/projects/cheese/) gnome application. Really simple to use. Not too much features, just video capture. |
That's as good as it gets. You can use a StringWriter but it's still writing into a StringBuilder |
Levenshtein distance implementation:
- [Using LINQ][1]
- [Not using LINQ][2]
I have a .NET 1.1 project in which I use the latter. It's simplistic, but works perfectly for what I need. From what I remember it needed a bit of tweaking, but nothing that wasn't obvious.
[1]: http://dotnetperls.com/Cont... |
You might be able to adapt something [like this][1] to load a test dataset of values, depending on what you are looking for
[1]: http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/249/creating-random-sql-server-test-data.aspx |
I'm building a function to extend the Enum.Parse concept that
- allows a default value to be parsed in case that an Enum value is not found
- Is case insensitive
So I wrote the following
public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum
{
... |
Method Local Inner Class |
|java| |
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
Can some one tell me how to print the message from bMethod. Thanks. |
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
... |
How can I merge many SQLite databases? |
|database|sqlite| |
If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases?
I know it is possible to use [ATTACH][1] to do this but it has [a limit][2] of 32 and 64 databases depending on the memory system on the machine.
[1]... |
Does use of anonymous functions affect performance? |
|javascript|performance|optimization| |
I've been wondering, is there a performance difference between using named functions and anonymous functions in Javascript?
for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = function() {
// do something
};
}
vs
function myEventHandler() {
// do someth... |
Most probly sun's administrative server..
It's usually bundled along with sun's directory and a few other webmin-ish stuff that is in the default installation
|
firefox http://perldoc.perl.org/perlvar.html#%ENV
By the way, many many many bugs have been fixed since 5.8.0. |
First of all, I will answer you second question. Only methods can be declared virtual.
You would choose virtual instead of abstract when you want some default functionality in your base class, but you want to leave the option of overriding this functionality by classes that inherit from your base class.
For examples:... |
First of all, I will answer you second question. Only methods can be declared virtual.
You would choose virtual instead of abstract when you want some default functionality in your base class, but you want to leave the option of overriding this functionality by classes that inherit from your base class.
For examples:... |
Delete DataGridView line |
|.net|winforms| |
How can I delete a line form a binded DataGridView when pressing Delete key? |
Nice to hear someone is using CruiseControl.NET. That is a nice tool. You can use a command line tool for obfuscation as RemoteSoft .NET Obfuscator and integrate a call to the tool in the build script. See example on how to execute a file below from CruiseControl.NET wiki.
http://www.remotesoft.com/salamander/obfusc... |
![How to Solve it by computer][1] - R.G.Dromey
[1]: http://g-ecx.images-amazon.com/images/G/01/ciu/31/89/d4ac024128a044c186a18010._AA207_.L.jpg |
Consider to use reflection on a built binary instead of parsing the C# code directly. The reflection API is really easy to use and perhaps you can get all the information you need? |
File a bug with a test case. |
You can not store files as there is not a traditional file system. You can only store them in their own DataStore (in a field defined as a [BlobProperty][1])
There is an example in the previous link:
class MyModel(db.Model):
blob = db.BlobProperty()
obj = MyModel()
obj.blob = db.Blob( ... |
Having tried a few different solutions, I found [One-JAR](http://one-jar.sourceforge.net/) the easiest to work with, and have managed to make do exactly that: produce a single, executable JAR which contains everything I need.
One-JAR uses a custom class-loader which can navigate nested resources. Look at the .bat f... |
Sometimes it can be more conveniant to use the [specification pattern][1].
Eg: GetEmployee(ISpecification<Employee> specification)
And then start defining your specifications...
NameSpecification : ISpecification<Employee>
{
private string name;
public NameSpecification(string name) { this.name = name; }
... |
Sometimes it can be more conveniant to use the <a href="http://en.wikipedia.org/wiki/Specification_pattern">specification pattern</a>.
Eg: GetEmployee(ISpecification<Employee> specification)
And then start defining your specifications...
NameSpecification : ISpecification<Employee><br/>
{<br/>
p... |
For more on named_scopes see [Ryan's announcement][1] and the [Railscast on named_scopes][2]
class Person < ActiveRecord::Base
named_scope :registered, lambda { |time_ago| { :conditions => ['created_at > ?', time_ago] } }
named_scope :with_names, lambda { |names| { :conditions => { :names => names ... |
Give this a try:
SELECT * FROM Employees
WHERE DATEADD(yyyy, DATEPART(yyyy, @Today)-DATEPART(yyyy, Birthday), Birthday) > @Today
AND DATEADD(yyyy, DATEPART(yyyy, @Today)-DATEPART(yyyy, Birthday), Birthday) < DATEADD(dd, @NumDays, @Today) |
If this is a one time thing just to get data into the system I really see no issue with using a cursor as much as I hate cursors they do have their place. |
You might want to try out the preview of Mono 2.0. DataGridView is vastly better in this version, though there are still several places where it is still lacking.
http://mono.ximian.com/monobuild/preview/download-preview/ |
The guys [here][1] claim to have developed a k nearest neighbors approach to determining the concave hull of a set of points which behaves "almost linearly on the number of points". Sadly their paper seems to be very well guarded and you'll have to ask [them][2] for it.
Here's a [good set of references][3] that incl... |
Additionally, if you are just doing this for testing or one time use I would say that an elegant solution is not really necessary. |
Listview Multiple Selection |
|c#|winforms| |
Is there any way to force a listview control to treat all clicks as though they were done through the Control key?
I need to replicate the functionality of using the control key (selecting an item sets and unsets its selection status) in order to allow the user to easily select multiple items at the same time.
Th... |
When it comes to security, stored procedures are much more secure. Some have argued that all access will be through the application anyway. The thing that many people are forgetting is that most security breaches come from inside a company. Think about how many developers know the "hidden" user name and password for yo... |
If I have the following:
Public Class Product
Public Id As Integer
Public Name As String
Public AvailableColours As List(Of Colour)
Public AvailableSizes As List(Of Size)
End Class
and I want to get a list of products from the database and display them on a page a... |
|.net|database|performance| |
If you're using vim, the 'u' command (in command mode) will Undo the last command you typed. You can use this command repeatedly to undo mistakes you may have made before saving the file. |
I doubt that the CreatePatternBrush() API copies the bitmap you give it, since an HBITMAP is:
1. a GDI handle, the maximum number of which is limited, and
2. potentially quite large.
Win32 and GDI tend to be conservative about creating internal copies of your data, if only because when most of their APIs were ... |
TMyObject = class
private
class var FLogger : TLogLogger;
procedure SetLogger(value:TLogLogger);
property Logger : TLogLogger read FLogger write SetLogger;
end;
procedure TMyObject.SetLogger(value:TLogLogger);
begin
// sanity checks here
... |
TMyObject = class
private
class var FLogger : TLogLogger;
procedure SetLogger(value:TLogLogger);
property Logger : TLogLogger read FLogger write SetLogger;
end;
procedure TMyObject.SetLogger(value:TLogLogger);
begin
// sanity checks here
... |
There's always a risk of overdoing either the TDD design or the upfront design. So the answer is that it depends. [A great "debate" about this has been recorded][1] between Robert C. Martin and James Coplien, where the former is a TDD advocate and the latter has stated that it ruins the design of a system. This is what... |
There's always a risk of overdoing either the TDD design or the upfront design. So the answer is that it depends. I prefer starting with a user story/acceptance test which is the base of the requirement that my tests will aid in producing. Only after I've established that, I start writing detailed unit tests TDD-style.... |
when using a FTPS connection to transfer a file, what is the difference between a 'Binary mode taransfer' and 'ASCII mode transfer' ? |
How to write an emacs mode for a new language? |
|emacs|mode| |
I would like to write an <b>emacs major mode</b> for a 4GL.
Can some one show me a tutorial.
As far as i googled i was able to find only this broken link <a>http://two-wugs.net/emacs/mode-tutorial.html</a> |
Is there an efficient\easy way to draw a concave polygon in Direct3d |
|c#|directx|polygon|concave| |
I'm trying to draw a polygon using c# and directx
All I get is an ordered list of points from a file and I need to draw the flat polygon in a 3d world.
I can load the points and draw a convex shape using a trianglefan and drawuserprimitives.
This obviously leads to incorrect results when the polygon is very co... |
Will everything in the standard library treat strings as unicode in Python 3.0? |
|python|unicode|cgi|string|python-3.x| |
I'm a little confused about how the standard library will behave now that Python (from 3.0) is unicode-based. Will modules such as CGI and urllib use unicode strings or will they use the new 'bytes' type and just provide encoded data? |
First, I'll throw this question out: why do your private members need isolated testing? Are they that complex, providing such complicated behaviors as to require testing apart from public surface? It's unit testing, not 'line-of-code' testing. Don't sweat the small stuff.
If they are that big, big enough that the... |
I'd use the RETURN value from the stored procedure, like this:
CREATE PROCEDURE checkReturnValue
AS
BEGIN
DECLARE @err AS INT
SET @err = 0
IF (rand() < 0.5)
BEGIN
SET @err = 1
END
SELECT * FROM table
PRINT @err
RETURN @err
... |
If you have .NET 3.5 you could use LINQ's Reverse?
foreach(var item in NewItems.Reverse())
{
GoViewBoy.Document.Add(CreateNodeFor(item as IMySpecificObject, obNextPos));
} |
If you have .NET 3.5 you could use LINQ's Reverse?
foreach(var item in NewItems.Reverse())
{
...
}
(Assuming your talking about the generic IList) |
|ftp|sap|edi|file-tranfer|ftps| |
I am using a <B> FTPS </b> connection to send a text file
<i>[this file will contain EDI(Electronic Data Interchange) information]</i>to a mailbox INOVIS.I have configured the system to open a FTPS connection and using the PUT command I write the file to a folder on the FTP server.
The problem is: what mode of file t... |
There's no flat file storing in Google App Engine. Everything has to go in to the [Datastore][1] which is a bit like a relational database but not quite.
You could store the files as [TextProperty][2] or [BlobProperty][3] attributes.
There is a 1MB limit on DataStore entries which may or may not be a problem.
... |
I think, the matter is, that the JVM supports only two types of stack values: word sized and double word sized.
Then they probably decided that they would need only one operation that works on word sized integers on the stack. So there's only iadd, imul and so on at bytecode level (and no operators for bytes and sh... |
Let us assume the database character set is UTF-8, which I believe is the default in recent version of Oracle. In this case, some characters take more than 1 byte to store in the database.
If you define the field as `VARCHAR2(11 BYTE)`, Oracle will allocate 11 bytes for storage, but you may not actually be able to s... |
And hereby I answer my own question, based on [original answer from *cspirz*][1].
Here's a function that given absolute, relative or network path, will return the path with upper/lower case as it would be displayed on Windows. If some component of the path does not exist, it will return the passed in path from that ... |
Here's an algorithm in 5 lines of ruby:
#!/usr/bin/env ruby
chars = STDIN.gets.chomp.split("")
STDIN.each do |string|
chars = string.chomp.split("").zip(chars).map {|x,y| x == y ? x : nil }
end
chars.each_index {|i| puts "#{chars[i]} #{i}" if chars[i] }
Put this in commonletters.rb... |
Another flash option, with a pre-built GWT integration - [Open Flash Chart / ofcgwt](http://code.google.com/p/ofcgwt/). |
First, check [Windows Update](http://www.windowsupdate.com) and make sure both VS environments are up to date.
If that doesn't help, uninstall them both completely, reinstall only 2005, update and test it. If 2005 doesn't crash, install 2008, update and test them both. Don't install any add-ons you may have been usi... |
I didn't like the licensing for the Java Service Wrapper. I went with ActiveState Perl to write a service that does the work.
I thought about writing a service in C#, but my time constraints were too tight. |
Since you said that you're using Windows, you may be able to take advantage of Microsoft's user-mode dump heap utility, [UMDH][1], which comes with the [Debugging Tools for Windows][2]. UMDH makes snapshots of your application's memory usage, recording the stack used for each allocation, and lets you compare multiple s... |
Since you said that you're using Windows, you may be able to take advantage of Microsoft's user-mode dump heap utility, [UMDH][1], which comes with the [Debugging Tools for Windows][2]. UMDH makes snapshots of your application's memory usage, recording the stack used for each allocation, and lets you compare multiple s... |
You can, but it might be a bit ugly, for example if you're using mysql and suppose you have an SQL string stored in $sql
echo $sql | mysql -u[username] -p -f
the -f flag reads sql from a file as input. in this case, $sql is being piped to the mysql command as if it was reading a file.
p.s. it might be a good ... |
You can, but it might be a bit ugly, for example if you're using mysql and suppose you have an SQL string stored in $sql
echo $sql | mysql -u[user] -p[password] -h[host]
p.s. it might be a good idea to tell us what database you're using so we can offer more specific help :p
edit: changed the example line so it... |
I'd do it this way:
[in the public header]
typedef unsigned long E;
void Foo(E e);
[in the internal header]
enum Econtent { FUNCTIONALITY_NORMAL, FUNCTIONALITY_RESTRICTED, FUNCTIONALITY_FOR_PROJECT_X,
FORCE_32BIT = 0xFFFFFFFF };
By adding FORCE_32BIT we ensure that Econtent compiles... |
For a function to be called, by definition there must be either a listener or setTimeOut somewhere, or the timeline must be playing. Make sure you remove all listeners and all references to the object. What kind of object is it?
The output window or debugger should show you the stack of function calls that led to th... |
Another one in **JavaScript**:
(new function() { arguments.callee();}); |
Here is the implementation I use to audit tables:
[Pop Rivett's SQL Server FAQ No.5: Pop on the Audit Trail][1]
[1]: http://www.simple-talk.com/sql/database-administration/pop-rivetts-sql-server-faq-no.5-pop-on-the-audit-trail/ |
[Notepad++][1] for editing is awesome to me: it's Windows only, but maybe you can use it with Wine under Linux. But if you want someting more like an IDE, then Eclipse, or [NetBean][2] (both use java) can be very useful, although they are very resource expensive on old PC.
[1]: http://notepad-plus.sourceforge.ne... |
You could use something similar to the [Reddit algorithm][1] - the basic principle of which is you compute a value for a post based on the time it was posted and the score. What's neat about the Reddit algorithm is that you only need recompute the value when the score of a post changes. When you want to display your fr... |
IIS is keeping hold of my generated files |
|asp.net|iis| |
My web application generates pdf files and either e-mails or faxes them to our customers. Somehow IIS6 is keeping hold of the file and blocking any other requests for it claiming the old '..the process cannot access the file 'xxx.pdf' because it is being used by another process.'
When I recycle the application pool ... |
This mechanism puts in a lot of extra effort at runtime.
If you use Eclipse as your IDE, consider using [Log4e][1]. This handy plugin will generate logger declarations for you using your favourite logging framework. A fraction more effort at coding time, but **much** less work at runtime.
[1]: http://log4e.ja... |
Best technology for adding plugin support to a J2SE application? |
|java|plugins| |
I'm writing a J2SE desktop application that requires one of its components to be pluggable. I've already defined the Java interface for this plugin. The user should be able to select at runtime (via the GUI) which implementation of this interface they want to use (e.g. in an initialisation dialog). I envisage each plug... |
Let's not forget to mention the new 'auto' use:
auto it = lotsOfThingys.begin(); // Let the compiler figure it out.
auto it2 = lotsOfFoos.begin();
if (it==it2) // It's still strongly typed; a Thingy iter is not a Foo iter.
|
Best he-aac encoder on linux ? |
|encoding|mp3|aac|aac+| |
I need an encoder that can convert mp3 files to he-aac (aka aac+).
So far the best one I have found is [nero aac encoder][1] .
I have two problemes with it :
- Only one input format : wav . It is a little bit slow to transform mp3 files to wav and then to he-aac.
- a free license for **non commercial** use.
... |
Actually, I'm quite proud of this for generating Excel docments: http://www.aaron-powell.com/blog.aspx?id=1237 |
In general you can answer "does module $x work on platform $y" questions by looking at the CPAN testers matrix, [like here][1].
[1]: http://bbbike.radzeit.de/~slaven/cpantestersmatrix.cgi?dist=Sys-Syslog+0.26 |