Welcome To Snipplr
Everyone's Recent Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This is meant to be run as root, so do it at your own risk. It's very raw and needs error checking, but works. I run this script to get new django sites off the ground in a few minutes.
0
1670
posted 17 years ago by mandric
found this on the adobe cookbook site. There is also some PHP to go along with this in my snippets.
1
1267
posted 17 years ago by mswallace
/* if (globalVariable) {
But this wouldn't work. That code is actually checking to see if the defined variable globalVariable has a null value. If the variable has not been defined, that code will cause an error.
Instead, here is the code that...
0
725
posted 17 years ago by zha
You can store an IP address in an INT UNSIGNED (4 bytes) which is of course much more efficient and faster than a CHAR(15).
MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP s...
0
1221
posted 17 years ago by zingo
Worst title ever. Basically, this takes a string like:
"Check this out: http://snipplr.com/view/5759/replace-a-url-its-domain-name-and-create-link/" and replaces it with "Check this out: snipplr.com [with a link to the full URL]"
1
1295
posted 17 years ago by jaytee
This bit of code allows you to turn code that looks like this:
x = {'foo':1, 'bar':2 }
x['foo'] = 3
Into this:
x = dictclass( {'foo':1, 'bar':2 } )
x.foo = 3
2
928
posted 17 years ago by kangell
Below is some code written for creating one response from survey questions where the respondent checks all that apply.
0
1238
posted 17 years ago by webonomic
Flash sucks, embedding it sucks more, find out how to make it not suck.
2
1203
posted 17 years ago by neal_grosskopf
Start mplayer with -vf screenshot, and press 's' when you want to capture a
frame.
0
878
posted 17 years ago by mandric
I often find something like this lurking at the end of my base templates - it'll show you which queries were run while generating the current page, but they'll start out hidden so as not to be a pain.
Of course, before this works, you'll need to s...
1
1222
posted 17 years ago by jonhenshaw
Run the specified command. If expect is not None then look for the given text in the output. If it is not there we throw an error. expect can also be a list of strings. In that case any match results in success unless matchall=True.
0
796
posted 17 years ago by kangell
Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.
* Does not affect timestamp functions, which are all GMT
0
980
posted 17 years ago by johnself
Check out the bash command 'shopt -s cdable_vars' From the man bash page: If set, an argument to the cd builtin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to.
0
828
posted 17 years ago by cczona