instruction stringlengths 0 30k ⌀ |
|---|
FXRuby FXFileDialog box default directory |
|fxruby| |
In FXRuby; how do I set the FXFileDialog to be at the home directory when it opens? |
It's two times faster than Firefox 3 on my Windows XP box. FWIW, the updates in Fx3.1 are supposed to make it an order of magnitude faster. |
I've compared it to Firefox and Internet Explorer using this link: http://celtickane.com/webdesign/jsspeed.php
The difference is impressive.
212ms in Chrome, 341ms in Firefox 3, and 2188ms for Internet Explorer 7. |
A while back I ran across [this blog post][1] (by Todd Werth) which presented a rather lengthy skeleton for command-line scripts in Ruby. His skeleton uses a hybrid approach in which the application code is encapsulated in an application class which is instantiated, then executed by calling a "run" method on the applic... |
A core dump is a copy of the memory the process had access to when crashed. Depending on how the leak is occurring, it might have lost the reference to the handles, so it may prove to be useless.
lsof lists all currently open files in the system, you could check its output to find leaked sockets or files. Yes, you'd... |
Assuming you have a hibernate session to hand then something like the following should work:
Criteria c = session.createCriteria(Whatever.class);
Disjunction or = new Disjunction();
or.add(Restrictions.eq("name",searchString));
or.add(Restrictions.eq("address",searchString));
or.add(Restricti... |
Assuming you have a hibernate session to hand then something like the following should work:
Criteria c = session.createCriteria(Whatever.class);
Disjunction or = Restrictions.disjunction();
or.add(Restrictions.eq("name",searchString));
or.add(Restrictions.eq("address",searchString));
or.add(... |
Not sure this answers your question but I've found that if I need to do anything like that with Rhino (or any similiar framework/library), anything that I didn't know how to do upfront, then I'm better just creating a manual mock.
Creating a class that implements the interface and sets a public boolean field to tru... |
Which C# project type would you use to redeveloped a MFC C++ activex control? |
|c#|c++|visual-studio|code-migration| |
Looking at the C# project templates in VS2k8 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and .NET? |
Which C# project type would you use to redevelop a MFC C++ activex control? |
About a year ago me and a buddy used AnkhSVN for a project... several commits later while moving namespaces around, it broke the SVN repository. Broke as in, the last commit we did got corrupted, and we couldn't commit anymore.
After that we used [TortoiseSVN][1] and did the namespace moving manually, it just... *wo... |
Another way to find out what files a process has opened - again, only during runtime - is looking into /proc/PID/fd/ , which contains symlinks to open files. |
If the User, Person and Special person all have the same foreign keys, then I would have a single table. Add a column called Type which is constrained to be User, Person or Special Person. Then based on the value of Type have constraints on the other optional columns.
For the object code it doesn't make much diffe... |
As a C++ Developer here's some simply guidelines:
1. Use pointers only when absolutely necessary
2. If you need a pointer, doublecheck if a [SmartPointer][1] is a possibility
3. Use the GRASP [Creator][2] pattern.
As for the detection of memory leaks personally I've always used [Visual Leak Detector][3] and fin... |
I'd say that, depending on what differentiates Person and Special Person, you probably don't want polymorphism for this task.
I'd create a User table, a Person table that has a nullable foreign key field to User (i.e, the Person can be a User, but does not have to).
Then I would make a SpecialPerson table which... |
There are generally three ways of mapping object inheritance to database tables.
You can make one big table with all the fields from all the objects with as special field for the type. This is fast but wastes space. Although modern databases save space by not storing empty fields. And if your only looking for all u... |
There is no out of box support for IN in LINQ. You need to join 2 queries. |
SQL: How to get the id of values I just INSERTed? |
|sql| |
I inserted some values into a table. There is a column whose value is auto-generated. In the next statement of my code, I want to retrieve this value.
Can you tell me how to do it the right way? |
Microsoft VC++ in debug mode shows memory leaks, although it doesn't show where your leaks are.
If you are using C++ you can never use explicitly new, you have all vector, string, auto_ptr and shared_ptr in your arsenal.
When using of new is unavoidable try to hide it in constructor(destructor for delete), same... |
This way:
UPDATE skills
SET level = level + 1
WHERE id = $id |
How about:
UPDATE skills SET level = level + 1 WHERE id = $id; |
Automate builds for Java RCP for deployment with JNLP |
|java|build-automation|rcp|jnlp| |
I've found many sources that talk about the automated Eclipse PDE process. I feel these sources don't do a good job explaining what's going on.
I can create the deployable package, in a semi-manual process via the Feature Export.
The automated process requires knowledge of how the org.eclipse.pde.build scripts... |
Mat: That's what pasted in from the question. It hasn't been edited, so I attribute that to a bug in Markdown. But, oddly enough, I did notice.
Also: yes, mysql_escape_string()! |
It might be worth checking out what some of the other guys are doing in this space and not necessarily in the C# arena either.
[This is a library written in c#][1]
SVN also has a binary diff algorithm and I know there's an implementation in python although I couldn't find it with a quick search. They might give y... |
I get downmodded for this?
$sql = "UPDATE skills SET level = level+1 WHERE id = $id";
$result = $db->sql_query($sql);
$db->sql_freeresult($result); |
I get downmodded for this?
$id = mysql_real_escape_string($id);
$sql = "UPDATE skills SET level = level+1 WHERE id = $id";
$result = $db->sql_query($sql);
$db->sql_freeresult($result); |
I get downmodded for this?
$sql = "UPDATE skills SET level = level+1 WHERE id = $id";
$result = $db->sql_query($sql);
$db->sql_freeresult($result); |
Depending on what you're trying to do with the shell, [rxvt][1] in [cygwin][2] is good.
You'll get the nicety of auto copy on selection and middle click paste. The biggest downside is that some windows console apps don't play nice with cygwin.
[1]: http://www.google.com/search?q=rxvt+cygwin
[2]: http://www.... |
Does the e-mail content need to be in the e-mail? Could you store the large content somewhere centrally (file-share/FTP site) then just send a link to the content?
This makes the recipient have an extra step, but you have a consistent e-mail size, so won't run into reliability problems due to unexpectedly large or ... |
By putting the data into a form, I was able to make the body around 1800 characters long before the form stopped working.
The code looked like this:
<form action="mailto:youremail@domain.com">
<input type="hidden" name="Subject" value="Email subject">
<input type="hidden" name="Body" value="... |
Picasa Plugin |
|plugins|api|google|photo|picasa| |
Does anyone here know any resources on how to get started writing a plugin for Google's Picasa? I love it for photo management, but I have some ideas for how it could be better.
* Riya-esque facial search: given a large enough corpus of faces and pictures (people tend to be repeated often in individuals' albums (... |
Does anyone here know any resources on how to get started writing a plugin for Google's Picasa? I love it for photo management, but I have some ideas for how it could be better.
* Riya-esque facial search: given a large enough corpus of faces and pictures (people tend to be repeated often in individuals' albums (... |
|api|google|plugins|photo-management|picasa| |
Use the visual block command v (or V for whole lines and C-V for rectangular blocks). While in visual block mode, you can use any motion commands including search; I use } frequently to skip to the next blank line. Once the block is marked, you can :w it to a file, delete, yank, or whatever. If you execute a command an... |
Use Shift+V to go in visual mode, then you can select lines and delete / change them. |
Provided that your iframe is hosted on the same server as the containing page, you can [access it via javascript](http://www.esqsoft.com/javascript_examples/iframe_talks_to_parent/).
There are a number of suggested methods for [setting the iframe to the full height of the contents](http://www.programmersheaven.com... |
Provided that your iframe is hosted on the same server as the containing page, you can [access it via javascript](http://www.esqsoft.com/javascript_examples/iframe_talks_to_parent/).
There are a number of suggested methods for [setting the iframe to the full height of the contents](http://www.programmersheaven.com... |
Has anyone connected BizTalk with QuickBooks? |
|biztalk|quickbooks| |
We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that d... |
You might want to take a look at ScottGu's latest post for ASP.Net prev 5. It walks through a validation sample that is very interesting:
[http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx][1]
[1]: http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-... |
What I'm going to say here is going to send database architects into conniptions but here goes:
Consider a database *view* as the equivalent of an interface definition.
And a table is the equivalent of a class.
So in your example, all 3 person classes will implement the IPerson interface.
So you have 3 tables -... |
SELECT @@Scope_Identity as Id
There is also @@identity, but if you have a trigger, it will return the results of something that happened during the trigger, where scope_identity respects your scope. |
Remember that @@IDENTITY returns the most recently created identity for your current connection, not necessarily the identity for the recently added row in a table. You should always use SCOPE_IDENTITY() to return the identity of the recently added row.
|
What database are you using? As far as I'm aware, there is no database agnostic method for doing this. |
Right click on a project, select **Add->Existing Item->Add as link** (press on small arrow on Add button) |
This is how I do my store procedures for MSSQL with an autogenerated ID.
CREATE PROCEDURE [dbo].[InsertProducts]
@id INT = NULL OUT,
@name VARCHAR(150) = NULL,
@desc VARCHAR(250) = NULL
AS
INSERT INTO dbo.Products
(Name,
Description)
VAL... |
If your using PHP and MySQL you can use the mysql_insert_id() function which will tell you the ID of item you Just instered.<br />
But without your Language and DBMS I'm just shooting in the dark here. |
@@IDENTITY is not scope safe and will get you back the id from another table if you have an insert trigger on the original table, always use SCOPE_IDENTITY() |
NUnit and Rhino suit well and the [auto-mocking container][1] might be of interest.
If you're looking at BDD too then [NBehave][2] is probably a good choice. If however you just mean the style of BDD that relates to unit testing (xSpec) though you can get away with adding a framework (though things like [specunit][3... |
Well, first of all, you can set vim to work with the mouse, which would allow you to select text just like you would in Eclipse.
You can also use the Visual selection - 'v', by default. Once selected, you can yank, cut, etc.
As far as commenting out the block, I usually select it with VISUAL, then do
:s/^... |
v enters visual block mode, where you can select as if with shift in most common editors, later you can do anything you can normally do with normal commands (substitution :'<,'>s/^/#/ to prepend with a comment, for instance) where '<,'> means the selected visual block instead of all the text. |
There's roughly a gajillion HTTP client libraries (Restlet is quite a bit more than that, but I already had that code snippet for something else), but they should all provide support for sending GET requests. Here's a rather less featureful snippet that uses [HttpClient](http://hc.apache.org/httpclient-3.x/tutorial.htm... |
Press `V` (uppercase V) and then press `40j` to select 40 lines and then press `d` to delete them. Or as @zigdon replied, you can comment them out. |
When to use stl bitsets instead of separate variables |
|c++|performance|stdlib| |
In what situation would it be more appropriate for me to use a bitset (stl container) to manage a set of flags rather than having them declared as a number of separate (bool) variables ?
Will I get a significant performance gain if I used a bitset for 50 flags rather than using 50 separate bool variables ? |
|c++|performance|bitsets| |
The visual mode is the solution for your main problem. As to commenting out sections of code, there are many plugins for that on vim.org, I am using tComment.vim at the moment.
There is also a neat way to comment out a block without a plugin. Lets say you work in python and # is the comment character. Make a visual... |
[XPathmania](http://donxml.com/allthingstechie/archive/2006/07/07/2792.aspx) is a good little tool for writing and testing XPath queries. |
>> **Daniel Auger:**
>> As others have said, it is possible.
>> However, if both the service and
>> client use an object that has the
>> exact same domain behavior on both
>> sides, you probably didn't need a
>> service in the first place.
>
> **lomax:**
> I have to disagree with this as it's a
> somewhat... |
>> **Daniel Auger:**
>> As others have said, it is possible.
>> However, if both the service and
>> client use an object that has the
>> exact same domain behavior on both
>> sides, you probably didn't need a
>> service in the first place.
>
> **lomax:**
> I have to disagree with this as it's a
> somewhat... |
I have accomplished this by using reflection. Where I name the column from the Select statement of the object.
This assumes you have a Templated helper class. If you want to put it on the object yourself you can just replace all the T with the object.
This is an example:
private T ObjectFromRow(DataRow r... |
Try two different incognito windows. |
Another option is to put an image control on your form. There is a property of that control (Picture) that is simply the path to the image. Here is a short example in VBA of how you might use it.
txtPhoto would be a text box bound to the database field with the path to the image
imgPicture is the image control
T... |
For vmware users, you can download a free edition of [vmware converter][1] which not only lets you resize virtual disks but also lets you convert from physical to virtual machines and vice-versa.
[1]: http://www.vmware.com/products/converter/ |
Perhaps a bit anecdotal but comparing runs between Firefox and Chrome showed a drastic significant difference in benchmarks.
http://www2.webkit.org/perf/sunspider-0.9/sunspider.html
Try for yourself. |
Perhaps a bit anecdotal but comparing runs between Firefox and Chrome showed a significant difference in benchmarks.
http://www2.webkit.org/perf/sunspider-0.9/sunspider.html
Try for yourself. |
Easiest way, as I see it, is to use a for loop that calls a second batch file for processing, passing that second file the base name.
According to the for /? help, basename can be extracted using the nifty ~n option. So, the base script would read:
for %%f in (*.in) do call process.cmd %%~nf
Then, in proce... |
As far as I know, TortoiseSVN does not offer any way to do this.
Presumably it's not seen as a big issue, since file based access is not practical for multi-user scenarios, and for single-user the author-name is of lesser importance.
A possible workaround would be to create another Windows username with the autho... |
Jeremy's answers should work; but that said, if you find yourself writing code like
(setf (nth i my-list) new-elt)
you're probably using the wrong datastructure. Lists are simply linked lists, so they're O(N) to access by index. You might be better off using arrays.
Or maybe you're using lists as tuples. In t... |
We use [Buckminster][1]. It's a build and assembly framework, which takes care of the resolution of dependencies, the fetching from various repositories, building and packaging of the product.
It's an Eclipse Tools project. It integrates well with PDE.
This means that all the meta-data we use to build the RCP is... |
We use Test::More extensively for our unit tests as a lot (most) of our data processing scripts are written in Perl. We don't have a specific convention for the function names but rather do something like Jagmal suggests, namely breaking the tests up into smaller chunks and initializing locally.
In our case each su... |
I've never hosted svn on a Windows machine, so this is a shot in the dark. You might be able to create a new Windows user and specify that user when browsing, checking out, committing, etc. Let's say you want to make changes as `msznajder`. Create a user with that name in Windows, then try browsing the repository us... |
You can get number of days between two dates like this:
$days = (strtotime("2008-09-10") - strtotime("2008-09-12")) / (60 * 60 * 24);
And you can make function something like that (I don't have php installed in my work computer so i can't guarantee syntax is 100% correct)
function isWorkDay($date)
... |
To make it work cross-platform, just put the following in your `vimrc`:
nmap <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR>
Now you can just press F3 any time inside Vi/Vim and you'll get the current timestamp inserted at the cursor. |
If the program forgot to close those resources it might be because something like the following happened:
fd = open("/tmp/foo",O_CREAT);
//do stuff
fd = open("/tmp/bar",O_CREAT); //Oops, forgot to close(fd)
now I won't have the file descriptor for foo in memory.
If this didn't happen, you might b... |
How to tweak Eclipse CDT's Indexer? |
|c++|eclipse|eclipse-cdt|lazy-c++|indexer| |
I'm using Eclipse as my IDE for a C++ project, and I would love for it to tell me where a given symbol is defined and what the parameters are for a function.
However, there's a catch: I also use [Lazy C++][1], a tool that takes a single source file and generates the .h and the .cpp files. Those .lzz files look like ... |
First convention I'd suggest is ditching Test::More for Test::Most
|
from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where .. select b.id).Contains(a.Id) select a.Id, a.Name |
from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where .. select b.id).Contains(a.Id) select new { a.Id, a.Name } |
Require and include are 2 different things.
Require is to strictly load a file once from a load path. The loadpath is a string and this is the key used to determine if the file has already been loaded.
Include is used to "mix-in" modules into other classes. Include is called on a module and the module methods a... |
Thanks @aku!
I knew this could be done, but I didn't know how to do this from Visual Studio. It shows up as a shortcut to the file and the csproj file generates the resulting XML like this:
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
I've seen ... |
I'd need to go back to the basics for this one too. I'd recommend O'Reilly's excellent *Java in a Nutshell* that includes code examples for just such a case (available [online][1] as well). See Chapter 7 for a pretty good overview of the decisions you'd want to make early on.
[1]: http://oreilly.com/catalog/java... |
Catalyst is the way to go. There is also Jifty, but (last time I looked), it had terrible documentation. |
If a to Implement a website With User Profiles/Logins, Extensions, Gallery's etc s a Newbi then a CMS like Joomla, Etc are good , but Else if you presently have only Static Content then Its good to go with Good Old HTML, About JPEG , I though Presently Its better to use PNG or GIF as its Less Bulky.
Also About you ... |
Rob's answer would be the most vendor-agnostic, but if you're using **MySQL** the safer and correct choise would be the built-in `LAST_INSERT_ID()` function. |
There's three basic strategies for handling inheritance in a relational database, and a number of more complex/bespoke alternatives depending on your exact needs.
- Table per class hierarchy. One table for the whole hierarchy.
- Table per subclass. A separate table is created for every sub class with a 0-1 asso... |