instruction stringlengths 0 30k ⌀ |
|---|
Self Updating |
|updating|patch| |
What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself? |
The load should just be a normal GET request, and the saving of new data should be a POST to the URL which currently has the data...
For example, load the current data from http://www.example.com/record/matt-s-example and then, change the data, and POST back to the same URL with the new data.
A PUT request could ... |
- The extra RAM is great for your OS X environment, but my experience has shown you shouldn't exceed VMWare's recommended RAM settings of 1M.
- I was unsuccessful at getting a good experience running my VM(s) from an external drive. And it's a firewire 800. Keep your dev image pruned to as little space as possib... |
- The extra RAM is great for your OS X environment, but my experience has shown you shouldn't exceed VMWare's recommended RAM settings of 1G.
- I was unsuccessful at getting a good experience running my VM(s) from an external drive. And it's a firewire 800. Keep your dev image pruned to as little space as possib... |
What is the design pattern for processing command line arguments |
|design-patterns|command-line|arguments| |
If you are writing a program that is executable from the command line, you often want to offer the user several options or flags, along with possibly more than one argument. I have stumbled my way through this many times, but is there some sort of design pattern for looping through args and spinning off the appropriate... |
If you're using Vim then you'll have the visual mode, which is like selecting, but with the separating modes thing that's the basis of vi/vim.
What you want to do is use visual mode to select the source, then yank, then use visual mode again to select the scope of the destination, and then paste to text from the def... |
you probably just need 2 service hosts.
_host1 and _host2. |
The only one i've ever heard of and used is statsvn, searching google doesnt return many results. |
What's cleanest, shortest Javascript to submit a URL the user is at to another process via URL? |
|javascript|submission|urlhacks| |
Like the Delicious submission bookmarklet, I'd like to have some standard Javascript I can use to submit any visited URL to a 3rd party site when that's possible by URL. Suggestions?
For example, I've been using
javascript:void(location.href="http://www.yacktrack.com/home?query="+encodeURI(location.href))
... |
|c#|.net|image|resize| |
Does anyone have the secret formula to resizing transparent images (mainly GIFs) *without* ANY quality loss - what so ever?
I've tried a bunch of stuff, the closest I get is not good enough.
Take a look at my main image:
[http://www.thewallcompany.dk/test/main.gif][1]
And then the scaled image:
[http... |
Colorizing images in Java |
|java|colors|bufferedimage|colorize| |
I'm working on some code to colorize an image in Java. Basically what I'd like to do is something along the lines of GIMP's colorize command, so that if I have a BufferedImage and a Color, I can colorize the Image with the given color. Anyone got any ideas? My current best guess at doing something like this is to get t... |
|java|colors|colorize|bufferedimage| |
Setting Colors in SWT. |
|java|colors|swt| |
This is pretty simple, I come from a swing/awt background.
I'm just wondering what the proper way to set the background color for a SWT widget is?
I've been trying:
widget.setBackGround( );
Am I on the right track?
Thanks,
Brian Gianforcaro |
I don't know of a way to do it without a second program that the primary program launches prior to shutting down. Program 2 downloads and installs the changes and then relaunches the primary program. |
We did something like this in our previous app. We captured the termination of the program (in .NET 2.0) from either the X or the close button, and then kicked off a background update process that the user didn't see. It would check the server (client-server app) for an update, and if there was one available, it would ... |
You have a couple options:
You could use another application .exe to do the auto update. This is probably the best method.
You can also rename a program's exe while it is running. Hence allowing you to get the file from some update server and replace it. On the program's next startup it will be using the new .... |
[@aku][1]
Yes, I know that xaml doesn't include any indication of base types or interfaces. But I do know the interface of the root objects, and the interface that the collection holds, at compile time.
The serialized graphs are stored in a sql database as XML, and we're using linq to retrieve them as XElement... |
It makes it easier if you have a secondary app that runs to do the updates. You would execute the "updater" app, and then inside of it wait for the other process to exit. If you need access to the regular apps DLLs and such but they also need updating, you can run the updater from a secondary location with already upda... |
If you're submitting the data via plain HTML, you're restricted to doing a POST based form. The URI that the POST request is sent to shouldn't be the URI for the resource being modified. You should either POST to a collection resource that ADDs a newly created resource each time or POST to an updater resource that upda... |
If you're submitting the data via plain HTML, you're restricted to doing a POST based form. The URI that the POST request is sent to **should not** be the URI for the resource being modified. You should either POST to a collection resource that ADDs a newly created resource each time (with the URI for the new resource ... |
ViewState and changing control order |
|viewstate|arrrrrrrrrrrg| |
This has been a fun week (if you look back at my questions you'll see a common theme).
I have a repeater that is bound to a collection. Each repeater item dynamic control that corresponds to the collection item, it also renders out a header over each control that contains a Delete link.
When the delete link is cl... |
|asp.net|viewstate| |
Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or transmi... |
Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or transmi... |
First step... check if the table already exists... if it does, delete it. Next, explicitly create the table rather than using SELECT INTO...
You'll find it much more reliable that way.
IF OBJECT_ID('tempdb..#temptable', 'U') IS NOT NULL
BEGIN
DROP TABLE #temptable
END
CREATE TABL... |
If a singleton is something you can dispose of, to clean up after it, you can consider it when it's a limited resource (ie. only 1 of it) that you don't need all the time, and have some kind of memory or resource cost when it is allocated.
The cleanup code looks more natural when you have a singleton, as opposed to ... |
I don't know of any, but if all else fails you could use [ctypes][1] to directly use libdwarf, libelf or libbfd.
[1]: http://docs.python.org/lib/module-ctypes.html |
Data Validation Design Patterns |
|design-patterns|validation|oop| |
If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into?
Sp... |
How do I lock certain SQL rows while running a process on them? |
|sql|vb.net| |
My work has a financial application, written in VB.NET with SQL, that several users can be working on at the same time. At some point, one user might decide to Post the batch of entries that they (and possibly other people) are currently working on. Obviously, I no longer want any other users to add, edit, or delete ... |
How do you implement resource "edit" forms in a RESTful way? |
|rest| |
We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the ... |
This is pretty simple, I come from a swing/awt background.
I'm just wondering what the proper way to set the background color for a SWT widget is?
I've been trying:
widget.setBackGround( );
Except I have no idea how to create the color Object in SWT?
Thanks,
Brian Gianforcaro |
|java|colors|swt| |
Function for creating color wheels |
|colors|language-agnostic|algorithm| |
This is something I've pseudo-solved many times and never quite found a solution that's stuck with me. The problem is to come up with a way to generate N colors that are as distinguishable as possible where N is a parameter. |
|language-agnostic|algorithm|colors|colorspaces| |
|language-agnostic|algorithm|colors|colorspaces| |
Efficient JPEG Image Resizing in PHP |
|php|image|gd|jpeg| |
Whats the most efficient way to resize large images in PHP?
I'm currently using the GD function imagecopyresampled to take hi-res images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall).
This works great on small (under 2MB photos) and the entire resize operati... |
|php|image|gd|jpeg| |
What algorithm to compare two images |
|algorithm|image| |
My task is pretty simply (well, it SOUNDS simple): given two different image file (in whatever format I choose), I need to write a program to predict the chance if one is the illegal copy of another. The author of the copy may do stuffs like rotating, make negative, or adding trivial details (as well as changing the di... |
I ran the aformentioned sunspider javascript benchmark on FF3 and Chrome and got over a 2x speed increase moving from [FF3][1] to [Chrome][2] (on a Vista 64 system - Core 2 duo 6600 2.4GHz, 2GB RAM).
The links above show you my results - I'm very interested to see what, if any, difference the underlying OS makes.
... |
I would like to point out an excellent post by Andrew Koenig on Code Talk very recently.
http://dobbscodetalk.com/index.php?option=com_myblog&show=Efficiency-versus-intent.html&Itemid=29
At our company also we use convention of ++iter for consistency and performance where applicable. But Andrew raises over-looked... |
The JVM responds to signals on its own. Some will cause the JVM to shutdown gracefully, which includes running shutdown hooks. Other signals will cause the JVM to abort without running shutdown hooks.
<http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)>
I don't think th... |
Step 1
gem update --system
It probably won't provide the fix itself, but You *really* want rubygems 1.2. It will save you about 8 days waiting as it doesn't need to do the 'Bulk updating 102304 gems' rubbish any more
It actually looks like it can't find the mysql gem at all, let alone download or install i... |
This answer doesn't apply to all JMS brokers, but if you happen to be using [Apache ActiveMQ](http://activemq.apache.org/), the web-based admin console (by default at <http://localhost:8161/admin>) allows you to manually send text messages to topics or queues. It's handy for debugging. |
I'm backing @1800 Information on this one.
Serializing objects for long-term storage is never a good idea
> while i appreciate your stance on the matter, this is a special case of data that I get from a webservice that gets refreshed only about once a month.
It's not a matter of stances. It's because one day, ... |
We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the ... |
I'd return some type of ValidationSummary for each one... or an IList<ValidationSummary> depending on how you want to structure it.
you could also opt to do some magic like this:
using(var validation = new ValidationScope())
{
ValidateTable1();
ValidateTable2();
ValidateTable3();
... |
Take from: [http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx][1]
"Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that... |
Taken from: [http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx][1]
> Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types th... |
SQL Server 2005 error |
|temp-tables| |
Why can't you do this and is there are work around?
declare @x int
set @x = 1
if (@x = 0)
begin
select 1 as Value into #temptable
end
else
begin
select 2 as Value into #temptable
end
select * from #temptable
drop table #temptable
... |
Why can't you do this and is there are work around?
You get this error.
Msg 2714, Level 16, State 1, Line 13
There is already an object named '#temptable' in the database.
declare @x int
set @x = 1
if (@x = 0)
begin
select 1 as Value into #temptable
end
else
... |
|sql-server|temp-tables| |
The two can be quite similar, but remember that the true Singleton must *itself* be instantiated (granted, once) and then served. A PHP database class that returns an instance of `mysqli` is not really a Singleton (as some people call it), because it is returning an instance of another class, not an instance of the cla... |
cfqueryparam with like operator in coldfusion |
|coldfusion| |
I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding `<cfqueryparam`> tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfqueryparam with the ... |
What is the ASP.NET process for IIS 7.0? |
|asp.net|iis-7| |
Looking at what's running and nothing jumps out.
Thanks! |
I think your problem is that only the update panel is receiving data from the server after the method executes. The panel your are trying to change is outside of the update panel so it does not know that its properties have changed.
You either need to do a full page postback or have the panel you wish to modify in... |
Deferred name resolution is also the reason you cannot be sure that sp_depends gives back correct results, check out this post I wrote a while back [Do you depend on sp_depends (no pun intended)][1]
[1]: http://sqlblog.com/blogs/denis_gobo/archive/2008/05/06/6653.aspx |
Taken from: [http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx][1]
> Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types th... |
Automatic serialVersionUID is calculated based on members of a class. These can be shown for a class file using the javap tool in the Sun JDK.
In the case mentioned in the question, the member that is added/removed is the static initialiser. This appears as <clinit>()V in class files. The contents of the method can ... |
While looking through the code, I discovered that the menu is being cleared and reloaded whenever the form data is being refreshed. The menu only needs to be loaded once, when the form is initially loaded.
I think that the menu may be getting cleared while the form is in the process of being painted. Do you think t... |
What's the easiest way to convert Wiki markup to HTML? |
|html|wiki|markup| |
I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow.
What is the best way to convert "==Heading=="" to "< h2>Heading< / h2>", or "--bold--" to "< b> bold < /b>"?... |
I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow.
What is the best way to convert "==Heading=="" to "< h2>Heading< / h2>", or "--bold--" to "< b> bold < /b>"?... |
There will be 2 issues:
1) Datatypes. There isn't always a direct analog between an MS SQL type and a MySQL type. For example, MySQL handles timestamps very differently and has the cut-off for when you need to switch between varchar(n) and varchar(max)/text at a different value of n. There are also some small diffe... |
My current toy project uses dynamic_cast twice; once to work around the lack of multiple dispatch in C++ (it's a visitor-style system that could use multiple dispatch instead of the dynamic_casts), and once to special-case a specific subtype.
Both of these are acceptable, in my view, though the former at least stems... |
PHP ToString() equivalent |
|php|string| |
How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string works:
$myText = $myVar . '';
like the ToString() method in Java or .NET. |
You could always do a Random sort. It works by rearranging all the elements randomly, then checking to see if it's sorted. If not, it randomly resorts them. I don't know how it would fit in big-O notation, but it will definitely be slow!
|