instruction stringlengths 0 30k ⌀ |
|---|
SLIME for EMACS is a wonderful tool for LISP programming. The best part is sending code written in your editor straight to a live LISP session. You can get similar behavior out of Vim using the tips here:
[http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/][1]
I adjusted my own script so that I can... |
Your macro is misnamed, it should be called ARRAYSIZE. It is used to determine the number of elements in an array whos size is fixed at compile time. Here's a way it can work:
> char foo[ 128 ]; // In reality, you'd
> have some constant or constant
> expression as the array size.
>
> for( unsigned i = 0; i <... |
Try interrupt() as some have said to see if it makes any difference to your thread. If not, try destroying or closing a resource that will make the thread stop. That has a chance of being a little better than trying to throw Thread.stop() at it.
If performance is tolerable, you might view each 3D update as a discr... |
If you have low priority intermittent operations, don't use specific timers to wake up to deal with them, but deal with when processing other events.
Use logic to avoid stupid scenarios where your app might go to sleep for 10 ms and then have to wake up again for the next event. For the kind of platform mentioned i... |
Subversion + Cruisecontol.Net is a good alternative.
SVN is is feature-rich, stable and flexible. |
How to do Flash pseudo-streaming? |
|flash|flv|streaming| |
I need to build something that starts serving a H.264 encoded video to a flash server halfway through the file (to support skipping to a point in the video that has not been buffered yet).
Currently, the videos are in the FLV container format, but transcoding is an option. I managed to re-write the file header and ... |
|flash|flv|streaming|video| |
|flash|video|streaming|flv| |
I need to build something that starts serving a H.264 encoded video to a flash player halfway through the file (to support skipping to a point in the video that has not been buffered yet).
Currently, the videos are in the FLV container format, but transcoding is an option. I managed to re-write the file header and ... |
Sample application from [MSDN][1]
And some inside information from [ADO.NET Team Blog][2]
[1]: http://msdn.microsoft.com/en-us/library/bb399296.aspx
[2]: http://blogs.msdn.com/adonet/ |
Here are some that Julie Lerman wrote:
<http://www.thedatafarm.com/blog/2008/04/04/EightEntityFrameworkTutorialsOnDataDeveloperNET.aspx>
And here's of course some info from Microsoft:
<http://msdn.microsoft.com/en-us/library/bb386876.aspx> |
[Microsoft BizTalk Server][1] does a very good job of this.
[1]: http://www.microsoft.com/biztalk/en/us/default.aspx |
If you are using SQL server 2005 (or greater) you might want to consider switching to nvarchar(max) in your table definition, because TEXT, NTEXT and IMAGE data types of SQL Server 2000 will be deprecated in future version of SQL Server, SQL Server 2005 provides backward compatibility to data types but it is recommande... |
Do a [Graphics.rotateTransform](http://msdn.microsoft.com/en-us/library/system.drawing.graphics.rotatetransform.aspx) before the drawString call. |
Do a [Graphics.rotateTransform](http://msdn.microsoft.com/en-us/library/system.drawing.graphics.rotatetransform.aspx) before the drawString call. Don't forget to reverse the change afterwards, as Phil Wright points out. |
Switch over PropertyType |
|csharp|propertytype|switch-statement| |
How can I make this work?
switch(property.PropertyType){
case typeof(Boolean):
//doStuff
break;
case typeof(String):
//doOtherStuff
break;
default: break;
}
I don't want to use the name since string comparing for types is just... |
|c#|switch-statement| |
How can I make this work?
switch(property.PropertyType){
case typeof(Boolean):
//doStuff
break;
case typeof(String):
//doOtherStuff
break;
default: break;
}
I don't want to use the name since string comparing for types is ju... |
[Real World Haskell](http://book.realworldhaskell.org/read/) is a really good book. |
You can do conditional compilation like this:
CONFIG::debugging {
// this will be removed if CONFIG::debugging resolves to false at compile time
}
And then add this to the compiler flags:
-define+=CONFIG::debugging,true
for debug builds, and
-define+=CONFIG::debugging,false
... |
Thanks for the answer. I created a separate solution and was able to get good performance, as you suggest.
My SQL connection is OK and works with other features in the app.
Given that I'm using XAF and not doing anything extra/fancy, aren't my sessions managed by XAF?
The session I use is read from the Detail... |
What do you need from a test harness? |
|unit-testing|testing|tap|testng|xunit| |
I'm one of the people involved in the <a href="http://testanything.org/wiki/index.php/TAP_at_IETF:_Notes">Test Anything Protocol (TAP) IETF group</a> (if interested, feel free to join the mailing list). Many programming languages are starting to adopt TAP as their primary testing protocol and they want more from it th... |
STL Alternative |
|stl|c++|performance|debug-build| |
I really hate using STL containers because they make the debug version of my code run really slowly. What do other people use instead of STL that has reasonable performance for debug builds? |
|c++|performance|stl|debug-build| |
I really hate using STL containers because they make the debug version of my code run really slowly. What do other people use instead of STL that has reasonable performance for debug builds?
I'm a game programmer and this has been a problem on many of the projects I've worked on. It's pretty hard to get 60 fps when ... |
Try using .update or .update_attributes instead: those are designed for edits (as opposed to .save, which is for creating new rows) |
What is the best way to localize a WPF application, sans LocBAML? |
|wpf|xaml|localization|globalization| |
There seems to be no good way to localize a WPF application. MSDN seems to think that littering my XAML with `x:Uid`'s, generating CSV files, and then generating new assemblies (using their sample code!) is the answer. Worse, this process doesn't address how to localize images, binary blobs (say, PDF files), or strin... |
If you want not to type class name twice during instantiation like in:
new SomeContainer<SomeType>(SomeType.class);
You can use factory method:
<E> SomeContainer<E> createContainer(Class<E> class);
Like in:
public class Container<E> {
public static <E> Container<E> create(Class<E... |
Check out [EASTL](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html). |
Try right-clicking, select "Open with...", mark "CSharp Editor" and select "Set as Default".
That works for avoiding the WinForms Designer. |
Using .save! will also throw an error if it fails to save. |
In Rails, after using find with :select, my objects don't save |
|ruby|ruby-on-rails|active|activerecord| |
Running something like:
@users = User.find(:first, :select => "name, lastname, salary")
for @user in @users do
@user.salary = 100000
@user.save
end
After this looking up in the Mysql table, the users aren't updated.
|
There is no way from command line to get Explorer to show the Search Files pane. But you can get over it with some VBScript.
Try this
'ExplorerFind.vbs
Dim objShell
Set objShell = WScript.CreateObject("Shell.Application")
objShell.FindFiles
And compile it with cscript /nologo ExplorerFind.vb... |
from [http://www.pcreview.co.uk/forums/thread-1468270.php][1]
@echo off
echo CreateObject("Shell.Application").FindFiles >%temp%\myff.vbs
cscript.exe //Nologo %temp%\myff.vbs
del %temp%\myff.vbs
[1]: http://www.pcreview.co.uk/forums/thread-1468270.php |
Does an application-wide exception handler make sense? |
|python|exception| |
Long story short, I have a substantial Python application that, among other things, does outcalls to "losetup", "mount", etc. on Linux. Essentially consuming system resources that must be released when complete.
If my application crashes, I want to ensure these system resources are properly released.
Does it mak... |
you may want to lookup standard exception handling styles, but my understanding is this: handle exceptions at the level where you can add extra detail to the exception, or at the level where you will present the exception to the user.
in your example you are doing nothing but catching the exception, logging it, and ... |
You can do it be examining the DWORD value **EnableLUA** in the following registry key:
HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System
If the value is 0 (or does not exist) then the UAC is OFF. If it's present and non-zero, then UAC is ON:
BOOL IsUacEnabled( )
{
LPCTSTR pszSub... |
I suggest that you just prevent multiple Threads by using wait and notify so that if the user changes the value many times it will only run the Thread once. If the users changes the value 10 times it will fire off the Thread at the first change and then any changes made before the Thread is done all get "rolled up" in... |
|c#|.net|performance|configuration|properties| |
I plan to be storing all my config settings in my application's app.config section (using the ConfigurationManager.AppSettings class). As the user changes settings using the app's UI (clicking checkboxes, choosing radio buttons, etc.), I plan to be writing those changes out to the AppSettings. At the same time, while t... |
I'd say it really depends on your needs. TFS is very nice, I've used it extensively, but it's very much aimed at the enterprise level, if you don't need all of those features it might not be necessary. If you do need those features (especially branching, scalability, work item tracking, etc.) they are worth every penny... |
>Stop the MySQL process.
>Start the MySQL process with the --skip-grant-tables option.
>Start the MySQL console client with the -u root option.
List all the users;
SELECT * FROM mysql.user;
Reset password;
UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]'; |
CLIPBRD_E_CANT_OPEN error when setting the Clipboard from .NET |
|clipbrd-e-cant-open|.net|clipboard| |
This is caused by a bug/feature in the .NET implementation of the clipboard when a delay occurs (sometimes caused by Terminal Services).
The solution is to try multiple times within a loop and sleep in between.
for (int i = 0; i < 10; i++)
{
try
{
Clipboard.SetText(sb.ToString());
ret... |
This is caused by a bug/feature in the .NET implementation of the clipboard when a delay occurs (sometimes caused by Terminal Services).
The solution is to try multiple times within a loop and sleep in between.
for (int i = 0; i < 10; i++)
{
try
{
Clipboard.SetText(sb.ToStr... |
|.net|clipboard|clipbrd-e| |
This is the solution to a problem I found and thought it would be good to share it. Is there another way of posting a Solution instead of a question?
This is caused by a bug/feature in the .NET implementation of the clipboard when a delay occurs (sometimes caused by Terminal Services).
The solution is to try mult... |
|.net|clipboard| |
Why does the following code sometimes causes an Exception with the contents "CLIPBRD_E_CANT_OPEN":
Clipboard.SetText(str);
This usually occurs the first time the Clipboard is used in the application and not after that. |
## Windows XP/NT Embedded or Windows CE/Mobile ##
You an use the QueryPerformanceCounter() to get the value of a VERY FAST counter before and after your function. Then you substract those 64-bits values and get a delta "ticks". Using QueryPerformanceCounterFrequency() you can convert the "delta ticks" to an actual t... |
ComboBox.view.setStore() should help.
If view is a private variable, just try to mention it between Combobox config params when creating. If it doesn't help - you can use plugin like that:
view_plugin = {
init: function(o) {
o.setNewStore = function(newStore) {
... |
Do not worry about using strings within a switch because if you have several the compiler will automatically convert it into a hash lookup giving decent performance despite it looking pretty aweful.
The problem of type strings changing can be solved by making it into an explicit hash lookup yourself and populating ... |
You can't do this with switch in c# as the case has to be constant.
What is wrong with:
if(property.PropertyType == typeof(bool)) {
//dostuff;
}
else if (property.PropertyType == typeof(string)) {
//do other stuff;
} |
Organize your work flow in the following way and it'll reduce a lot of time wasting.
1. Make sure you **declare a doc-type**.
2. Use one of the reset methods others have mentioned here.
3. Work on your structure
4. Avoid using width and padding where you can.
5. Always think of reducing unneeded HTML and css rat... |
Organize your work flow in the following way and it'll reduce a lot of time wasting.
1. Make sure you **declare a doc-type**.
2. Use one of the reset methods others have mentioned here.
3. Work on your structure
4. Avoid using width and padding where you can.
5. Always think of reducing unneeded HTML and css rat... |
Just use the normal if/else if/else pattern:
if (property.PropertyType == typeof(Boolean))
{
}
else if (property.PropertyType == typeof(String))
{
}
else if (...)
{
}
|
I get the same kind of issue on a default Ubuntu 8.04 install. I had to get the libc developer headers/files manually for it to work. |
[MiniExiftool](http://miniexiftool.rubyforge.org/), which is just a wrapper around the [Exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/) command-line app, is the only open-source one I know of.
There's a [commercial library called Chilkat](http://www.chilkatsoft.com/ruby-xmp.asp), but I do not have experienc... |
MySql - Create Table If Not Exists Else Truncate? |
|ruby|ruby-on-rails|activerecord| |
Unfortunately the DataGrid does not support editing. What I do, is use it for displaying read only data and then provide a separate form for editing the selected record.
If you must support editing in a grid layout, then I would look for a third party component. |
A word of caution that a very great deal of what you read on the Internet about GUID creation may well be wrong, or at least out of date for your specific platform.
I once single-stepped through a heap of Windows code to settle an argument about GUID creation on WinXP. Unfortunately, it turned out that I was wrong ... |
Either
ListView1.SelectedItems.Clear();
or
ListView1.SelectedIndices.Clear();
should do the trick for select none, anyway. |
How do I choose a CMS/Portal solution for a small website(s)? |
|comparison|content-management-system|evaluation|portal| |
I currently maintain 3 websites all revolving around the same concept. 2 of them are WinForms applications where the website gives a few basic details, and download links. The third is a web application to query data. I also have a forum (SMF/TinyPortal) that has been serving as a tech support/news hub for the three si... |
To answer the second question first: yes, I would create a separate table for each pick list in most cases. Especially if they are for completely different types of values (e.g. states and cities). The general table format I use is as follows:
id - identity or UUID field (I actually call the field xxx_id where... |
My method is to log the exceptions only in the handler. The 'real' handler so to speak. Otherwise the log will be very hard to read and the code less structured. |
When should I consider changing thread priority |
|language-agnostic|multithreading| |
I once was asked to increase thread priority to fix a problem. I refused, saying that changing it was dangerous and was not the root cause of the problem.
My question is, under what circumstannces *should* I conider changing priority of threads? |
Change the lineendings in the view:
:e ++ff=dos
:e ++ff=mac
:e ++ff=unix
This can also be used as saving operation (:w alone will not save using the lineendings you see on screen):
:w ++ff=dos
:w ++ff=mac
:w ++ff=unix
And you can use it from the command-line:
for file in $... |
oAuth REST and C# What's the missing piece |
|c#|rest|oauth| |
I found a library that makes it easy to get my oAuth_token and oAuth_token_secret with c#. If I'm trying to make a POST to a RESTful web service (ie. http://brightkite.com/places/356a192b7913b04c54574d18c28d46e6395428ab/checkins) how are those two keys leveraged to varify authentication. A C# example would be awesome... |
I think Prado never really caught on because it's an event-driven framework, which is a bit hard to wrap your head around coming from a more procedural background where many PHP developers originate. |
I think Prado never really caught on because it's an event-driven framework, which is a bit hard to wrap your head around. Especially for the many PHP developers coming from a more procedural background. |
If it's anything like the scripting used for the old Flash IDE, then I think it's just straight javascript/ECMAScript. The only real difference is the APIs you have avaialble. I expect anyone who's good with javascript would be able to pick it up fairly quickly. |
Application wide handler is fine. They are great for logging. Just make sure that the application wide one is durable and is unlikely to crash itself. |
My solution would be something along the lines of what John Dyer said. I'd add a second column (e.g. phoneStripped) that gets stripped on insert and update. Index this column and search on it (after stripping your search term, of course).
You could also add a trigger to automatically update the column, although I've... |
It's a little unclear whether the end-result you want is the open "find" dialog, or if you're just looking for a command-line way to search an arbitrary directory. If the latter there's FINDSTR (assuming you want to search the content of files and not their names):
http://stackoverflow.com/questions/87350/what-are-g... |
|mysql|truncate|exists| |
I've been having a hard time trying to figure out if the following is possible in MySql without having to write block sql:
<pre>
CREATE TABLE fubar IF NOT EXISTS ELSE TRUNCATE TABLE fubar
</pre>
If I run truncate separately before the create table, and the table doesn't exist, then I get an error message. ... |
<strong>Here is the updated question:</strong><br>
<br>
the current query is doing something like:<br>
<pre>
$sql1 = "TRUNCATE TABLE fubar";
$sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu";
</pre>
The first time the method containing this is run, it generates an error message on... |
You can get a stack trace from the Java console associated with the WebStart app. The console actually lists the available options on start up:
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
m: print memory usage
... |