Skip to content

Instantly share code, notes, and snippets.

View arnorhs's full-sized avatar

arnorhs arnorhs

View GitHub Profile
@arnorhs
arnorhs / linux-command-cheatsheet.sh
Created January 21, 2011 22:43
a few linux commands i have hanging around.. collecting
# find only files and chmod
# because I never remember the syntax
find . -type f -exec sudo chmod 664 {} \;
# untar .tar.gz
tar xvzf file.tar.gz
# untar .tar.bz2
tar xjvf file.tar.b
@arnorhs
arnorhs / getQueryString-function.js
Created February 11, 2011 09:23
Javascript function to parse a query string
/*
This function is from my answer to a question on Stack Overflow
http://stackoverflow.com/questions/4963673/get-url-array-variables-in-javascript-jquery/4963817#4963817
*/
function getQueryString () {
var ret = {};
var parts = (document.location.toString().split('?')[1]).split('&');
@arnorhs
arnorhs / example1.php
Created February 20, 2011 15:21
Example code for a blog entry about delivering email using PHP on arnorhs.com
<?php
mail(
'ron.burgundy@KVWNTV.com',
'This is the subject',
'This is a message.'
);
?>
@arnorhs
arnorhs / form.html
Created February 21, 2011 02:07
work in progress for a blog post....
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Example how to send an email</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="mainwrap">
@arnorhs
arnorhs / move-site-wordpress-mysql-settings.sql
Created March 11, 2011 18:58
The SQL you need to execute to change a Wordpress site from one host to the other
# Update the options for site settings:
UPDATE wp_options
SET
option_value = replace(
option_value,
'http://oldsite.com/path',
'http://spankingnew.com/otherpath'
)
WHERE
@arnorhs
arnorhs / bookmarklet-compressed.js
Created March 13, 2011 15:43
From a blog post on how to create a bookmarklet using jQuery
var i,s,sc=['http://yourhostname.com/path/to/your/script.js'];if(!jQuery){sc.unshift('http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js');}for(i=0;i<sc.length;i++){s=document.createElement('script');s.src=sc[i];document.body.appendChild(s);}void(0);
@arnorhs
arnorhs / css.snipets
Created May 26, 2011 19:01
vim configs and snippets
snippet grad
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='${1:#cccccc}', endColorstr='${2:#ffffff}');
background: -webkit-gradient(linear, left top, left bottom, from($1), to($2));
background: -moz-linear-gradient(top, $1, $2);
${3}
snippet box
-moz-box-shadow: ${1:1px} ${2:1px} ${3:0px} ${4:0px} ${5:rgba(0,0,0, 0.1)};
-webkit-box-shadow: $1 $2 $3 $4 $5;
box-shadow: $1 $2 $3 $4 $5;
${6}
@arnorhs
arnorhs / super-simple-benchmark.js
Created August 21, 2011 04:47
js benchmarking
function testcase (func) {
var i, d = new Date();
for (i = 0; i < 10000; i++) {
func();
}
return new Date() - d;
}
time1 = testcase(function () {
// test 1
@arnorhs
arnorhs / example1.js
Created September 11, 2011 23:24
From the blog entry: Why use vim?
function myFunction () {
// do something here
}
function otherFunction () {
// call the other function:
}
@arnorhs
arnorhs / example1.js
Created October 14, 2011 05:24
Examples from a blog post about closures in Javascript
// This function accepts either an array or a single value and
// returns an array of the values that didn't match the string
// provided in argument #2
function y (myvar,str) {
// this variable will be returned from this function
var collection = [];
// Check if the provided variable is an array or not
if (myvar instanceof Array) {
// iterate through all elements and check if they