instruction stringlengths 0 30k ⌀ |
|---|
|iphone|image|audio|user-interface| |
|iphone|image|user-interface|audio| |
Generating gradients programatically? |
|rgb|colors|gradient| |
Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is [this blog entry][1], but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code exampl... |
|java|colors|rgb|gradient| |
|java|colors|rgb|gradient| |
How do i resize and convert an uploaded image to a PNG using GD |
|php|gd|image|database|png| |
I want to allow users to upload avatar-type images in a variety of formats (GIF,JPEG,PNG at least), but to save them all as PNG database BLOBs. If the images are oversize, pixelwise, i want to resize them before DB-insertion.
What is the best way to use GD to do the resizing and PNG conversion?
|
Static classes can't be passed around as arguments; instances of a singleton can be. As mentioned in other answers, watch for threading issues with static classes.
rp |
PostbackUrl can be set on your asp button to post to a different page.
if you need to do it in codebehind, try Server.Transfer. |
There is a discussion on this point in [Less Than Dot]([http://forum.lessthandot.com/viewtopic.php?f=95&t=1262). Here is one example of code from the discussion.
public DataTable GetColumns(string tableName)
{
string[] restrictions = new string[4];
restrictions[2] = tableNam... |
There is a discussion on this point in [Less Than Dot](http://forum.lessthandot.com/viewtopic.php?f=95&t=1262). Here is one example of code from the discussion.
public DataTable GetColumns(string tableName)
{
string[] restrictions = new string[4];
restrictions[2] = tableName... |
Use POST for destructive actions such as creation (I'm aware of the irony), editing, and deletion, because you can't hit a POST action in the address bar of your browser. Use GET when it's safe to allow a person to call an action. So a URL like:
http://myblog.org/admin/posts/delete/357
Should bring you to a c... |
> i dont see a problem using get though, i use it for simple things where it makes sense to keep things on the query string.
Using it to update state - like a GET of `delete.php?id=5` to delete a page - is very risky. People found that out when Google's web accelerator started prefetching URLs on pages - it hit all... |
It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet.
However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system where the so... |
Are you using this compare in a very-frequently-executed path of a highly-performance-sensitive application? Alternatively, are you running this on strings which are megabytes in size? If not, then you shouldn't worry about the performance and just use the .lower() method.
The following code demonstrates that doin... |
Another simple and easy way:
<?php
function getTinyUrl($url) {
return file_get_contents('http://tinyurl.com/api-create.php?url='.$url);
}
?> |
You can declare a class with the same name inside the migration, it will override your app/models one:
class YourMigration < ActiveRecord::Migration
class User < ActiveRecord::Base; end
def self.up
# User.create(:name => 'admin')
end
end
Unfortunately, your IDE m... |
Kit, you comment above that VFP's binary-based source files are tough to work with in Subversion. The link I gave above mentions a couple of tools to make it easier, but the one I work with is Christof Wollenhaupt's TwoFox utility -- it converts a VFP project to text-only. You have to run it manually, but I don't have ... |
----------
You might want to check out this paper:
[Sentence similarity based on semantic nets and corpus statistics][1]
I've implemented the algorithm described. Our context was very general (effectively any two English sentences) and we found the approach taken was too slow and the results, while promising, no... |
[Java 5 new features][1]
[Java 6 new features][2]
The real meat is in Java 5. Generics, Autoboxing, Annotations.
[1]: http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html
[2]: http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html |
I have used CopyCat to create a replication project. It allows you create your own replication client/server configuration using CodeGear Delphi. This allows you complete flexibilty as to how you want your replication to work.
If you don't use Delphi, or need a prefabricated solution, CopyTiger does the same thin... |
Vista Console App? |
|windows|ruby|windows-vista|console| |
I'm doing a fair bit of work in Ruby recently, and using
ruby script/console
Is absolutely critical. However, I'm really disappointed with the default Windows console in Vista, especially in that there's a really annoying bug where moving the cursor back when at the bottom of the screen irregularly causes i... |
How do I install the mysql ruby gem under OS X 10.5.4 |
|ruby|rubygems|mysql| |
Here is the deal.
$ gem --version
> 1.1.0
$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
> Bulk updating Gem source index for:
> http://gems.rubyforge.org/ ERROR:
> could not find mysql locally or in a
> repository
$ sudo gem update
> Updating installed gems Bul... |
Here is the deal.
$ gem --version
> 1.1.0
$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
> Bulk updating Gem source index for:
> http://gems.rubyforge.org/ ERROR:
> could not find mysql locally or in a
> repository
$ sudo gem update
> Updating installed gems Bul... |
|ruby|mysql|rubygems| |
function foo() {
alert('hi');
setTimeout(foo, 5000);
}
Then just use an action like "onload" to kick off 'foo'
|
Seeking a good solution for SVG + Javascript framework |
|javascript|frameworks|svg| |
I'm looking to hear others experiences with SVG + Javascript Frameworks.
Things that I'd like the framework to handle - DOM creation, event handling and minimal size.
Jquery SVG plugin - <http://keith-wood.name/svg.html> seems to be the only one I can find.
|
<%= Resources.<ResourceName>.<Property> %> |
Howto import an oracle dump in an different tablespace |
|oracle-database| |
I want to import an oracle dump into a different tablespace.
I have a tablespace A used by User A. I've revoked DBA on this user and given him the grants connect and resource. Then I've dumped everything with the command
> exp a/*** owner=a file=oracledump.dmp log=log.log compress=y
Now I want to import the dump... |
I want to import an oracle dump into a different tablespace.
I have a tablespace A used by User A. I've revoked DBA on this user and given him the grants connect and resource. Then I've dumped everything with the command
> exp a/*** owner=a file=oracledump.dmp log=log.log compress=y
Now I want to import the dump... |
I want to import an oracle dump into a different tablespace.
I have a tablespace A used by User A. I've revoked DBA on this user and given him the grants connect and resource. Then I've dumped everything with the command
> exp a/*** owner=a file=oracledump.dmp log=log.log compress=y
Now I want to import the dump... |
@dbr said:
> There is a review machine with an absurd fiber-channel-RAID-array that can play 2K files direct from the array easily. The issue is with the artist-workstations, so it wouldn't be one $4000 RAID array, it'd be hundreds..
Well, if you can accept a limit of ~30GB, then maybe a single 36GB SSD drive wou... |
Dotnetnuke using PNG images with Transparency |
|internet-explorer-6|png|dotnetnuke|transparency| |
I have a Dotnetnuke site where my main logo is a PNG file using transparency. I tried GIF but the quality wasn't good enough.
Anyways it worked great on IE7 but I just saw my site in IE6 and noticed that the transparency isn't working with my logo.
Does anyone know of a quick way to fix this in a dotnetnuke port... |
Branch / merge management in Subversion 1.5 |
|version-control|subversion| |
I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it.
So, can someone give me a quick overview of how to track merges in a ... |
|svn|version-control| |
ie6 doesn't support transparent png's. it isn't a dot net nuke issue. you could try looking into some [javascript solutions](http://homepage.ntlworld.com/bobosola/index.htm) that help with ie6. |
Googling "pngfix" should find a lot of different techniques for enabling alpha transparency in IE6.
One common one is a [HTC behaviour file][1].
[1]: http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html |
How to convince a company to switch their Source Control. |
|version-control|subversion|visual-sourcesafe| |
My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced.
But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visual Studi... |
|svn|version-control|visual-sourcesafe| |
This is a classic example of encapsulation in object-oriented design.
A Form is an object whose responsibility is to present UI to the user and accept input. The interface between the Form object and other areas of the code should be a data-oriented interface, not an interface which exposes the inner implementation ... |
**EMAIL ADDRESS**
Rational
1. Users don't change emails very often
2. Removes the step of asking for username and email address, which you'll need anyway
3. Users don't often forget their email address (see number one)
4. Email will be unique unless the user already registered for the site, in which case f... |
**EMAIL ADDRESS**
Rational
1. Users don't change emails very often
2. Removes the step of asking for username and email address, which you'll need anyway
3. Users don't often forget their email address (see number one)
4. Email will be unique unless the user already registered for the site, in which case f... |
The [class documentation][1]
has this note:
> If you create an HttpListener using
> https, you must select a Server
> Certificate for that listener.
> Otherwise, an HttpWebRequest query of
> this HttpListener will fail with an
> unexpected close of the connection.
and this:
> You can configure Server C... |
The answer may depend on the target OS. For example, at least one RTOS implementation I'm familiar with will allow multiple sequential "get" operations against a single OS mutex, so long as they're all from within the same thread context. The multiple gets must be replaced by an equal number of puts before another th... |
Have you tried drawing a white rectangle to initialize the image before you call the DrawImage method? |
Is there a way around coding in Python without the tab, indent & whitespace criteria? |
|python| |
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?
I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting? |
Individual bits can be indexed as follows.
Define a struct like this one:
struct
{
unsigned bit0 : 1;
unsigned bit1 : 1;
unsigned bit2 : 1;
unsigned bit3 : 1;
unsigned reserved : 28;
} bitPattern;
Now if I want to know the individual bit values of a var na... |
Making code Misra compliant it not too much of a chore - if you follow fairly good programming practices. You might find some of the pointer rules slightly tricky, if the code you're trying to make comply has some weird and wonderful pointer arithmetic.
I'd second Greg's recommendation for PC Lint, but the open-sour... |
As people have answered programatically how to create and resolve tinyurl.com redirects, I'd like to (strongly) suggest something: caching.
In the twitter example, if every time you clicked the "expand" button, it did an XmlHTTPRequest to, say, `/api/resolve_tinyurl/http://tinyurl.com/abcd`, then the server created ... |
How about looping over all arrays t of n integers (n-tuples of integers are countable, so this is doable though it's an infinite loop of course), and for each of these:
- if its elements are exactly those of the input array (see algo below!) and the array is sorted (linear algo for example, but I'm sure we can do ... |
How about looping over all arrays t of n integers (n-tuples of integers are countable, so this is doable though it's an infinite loop of course), and for each of these:
- if its elements are exactly those of the input array (see algo below!) and the array is sorted (linear algo for example, but I'm sure we can do ... |
> The iterative algorithm for Fibonacci, because for me it nailed down the fact that the most elegant code (in this case, the recursive version) is not necessarily the most efficient.
> The iterative method, (curr = prev1 + prev2 in a forloop) does not tree out this way, nor does it take as much memory since it's on... |
Are you converting integers or something else? If you're converting anything other than simple types like integers or booleans, you'd need to write your own function/method for the type that you're trying to convert, otherwise PHP will just print the type (such as array, GoogleSniffer, or Bidet). |
[Minimax][1] taught me that chess programs aren't smart, that can just think more moves ahead than you can.
[1]: http://en.wikipedia.org/wiki/Minimax |
This [page][2] may help - it compairs a ***bunch*** of cpp unit test framework.
Check out [CPPUnit Lite][1]. Created by Michael Feathers, who originally ported JUnit to C++ as CPPUnit. He eventually created a 'Lite' version to avoid the complexities in CPPUnit. He claimed his CPPUnit to be too much like JUnit - but ... |
[This page may help][1] - it reviews a *bunch* of cpp unit test frameworks:
- CppUnit
- Boost.Test
- CppUnitLite
- NanoCppUnit
- Unit++
- CxxTest
Check out ***[CPPUnitLite][2]*** or ***[CPPUnitLite2][3]***. *CPPUnitLite* was created by Michael Feathers, who originally ported JUnit to C++ as CPPUnit. He ev... |
It has nothing to do with dotNetNuke, it's an IE6 thing. IE6 doesn't do very well with certain transparent PNG.
|
You can't. IE6 only supports a specific, and visually ugly, version of PNG transparency. I believe its PNG-8.
You can use a [conditional comment][1] to handle IE6 differently:
<!--[if IE 6]>
background-image:crappy.gif
<![endif]-->
[1]: http://www.quirksmode.org/css/condcom.html |
There is no such things as *GOTO considered harmful*.
GOTO is a tool, and as all tools, it can be used and *abused*.
There are, however, many tools in the programming world that have a tendency to be *abused* more than being *used*, and GOTO is one of them. the *WITH* statement of Delphi is another.
Personally... |
@lance
> Who says you have to create all the images on the server with each request? Maybe you could have a static list of images or pull them from flickr. I like the "click on the kitten" captcha idea. http://www.thepcspy.com/kittenauth
If you pull from a static list of images, it becomes trivial to circumvent the... |
@rob
>>What about a honeypot captcha?
>Wow, so simple! Looks good! Although they have highlighted the accessibility issue.. Do you think that this would be a problem at SO? I personally find it hard to imagine developers/programmers that have difficulty reading the screen to the point where they need a screen reader?... |
I had a load of spam issues on a phpBB 2.0 site I was running a while back (the site is now upgraded).<br><br>
I installed a custom captcha mod I found on the pbpBB forums that worked well for a period of time. I found the real solution was combining this with additional 'required' fields [on the account creation page... |
Ed's got the right function for you. Just don't forget to call `Monitor.Exit()`. You should use a `try-finally` block to guarantee proper cleanup.
if (Monitor.TryEnter(someObject))
{
try
{
// use object
}
finally
{
Monitor.Exit(someObj... |
If it were my source control server, I would not want to a) pay the added cost, or b)have to drive to the colo because I can't connect to my repository. |
There are three major factors here.
1. Cost. The colo will obviously be more expensive than sticking a server in your parents' closet.
2. Quality. The colo should be a lot more reliable than the server in your parents' closet. They aren't as likely to go down when there's a power surge. They should provide some... |
No. Indentation-as-grammar is an integral part of the Python language, for better and worse. |
I do not believe so, as Python is a whitespace-delimited language. Perhaps a text editor or IDE with auto-indentation would be of help. What are you currently using? |
The following code will set an interval and set the image to the next image from an array of image sources every second.
function setImage(){
var Static = arguments.callee;
Static.currentImage = (Static.currentImage || 0);
var elm = document.getElementById("imageContainer");
elm.src =... |
If you're using XNA (the idea could be extrapolated to other frameworks of course), you could use an in-game unit test framework that lets you access the game's state in the unit test. One such framework is [Scurvy.Test][1] :-)
[1]: http://www.codeplex.com/ScurvyTest |
Note also that on other unixes, the method of specifying the section differs. On solaris, for example, it is:
man -s 1 man
|
It ought to be a compile-time error, because the types are incompatible (value types can never be null). It's pretty sad that it isn't.
|
I agree with the majority of the stackoverflow respondents. JavaScript has matured and offers an "extra" level of functionality to a webpage, especially for forms. Those who turn off cookies and JS have likely been bitten while surfing in dangerous waters. For the corporate power users that pay my way either in B2B... |
When you display the log for a local versioned folder, it will show the changes that are relative to this particular folder. Externals are only **a link** to a different folder on the repository. The only thing you can track about external references, from a folder which depends on this external project, is the **refer... |
C# SQL Restore database to default data location |
|c#|sql| |
Copying from network share using BAT |
|windows|batch-file| |
What's the best way to copy a file from a network share to the local file system using a Windows batch file? Normally, I would use "net use *" but using this approach how can I get the drive letter? |
Sure. Ultimately the image comes from a URL of some sort. Do a view-source on the web page and see what that URL looks like. With a certain amount of reverse-engineering, usage of System.Web.UI.HtmlTextWriter, perhaps an HttpHandler, etc. you should be able to get what you want. |
Sometimes it is valid to use GOTO as an alternative to exception handling within a single function:
if (f() == false) goto err_cleanup;
if (g() == false) goto err_cleanup;
if (h() == false) goto err_cleanup;
return;
err_cleanup:
...
COM code seems to fall into this pattern... |
There is a proper place for each. Even if you don't follow [RESTful](http://en.wikipedia.org/wiki/REST) principles, a lot can be gained from learning about REST and how a resource oriented approach works.
A RESTful application will use GETs for operations which are both *safe* and *idempotent*. A safe operation is ... |