Skip to content

Instantly share code, notes, and snippets.

@dubbs
dubbs / gist:1230639
Created September 20, 2011 22:37
jquery get url param
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results){ return null; }
return results[1] || null;
}
@dubbs
dubbs / gist:1333925
Created November 2, 2011 15:25
ie - fix broken onafterprint
function beforePrint(e) {}
function afterPrint(e) {}
if ($.browser.msie) {
window.onbeforeprint = beforePrint;
window.onafterprint = function() {
setTimeout(function () { afterPrint(); }, 1000);
};
}
@dubbs
dubbs / gist:1730900
Created February 3, 2012 16:13
svn helpers
function branch()
{
echo "http://havok.thezoo/repos/$1/trunk/ http://havok.thezoo/repos/$1/branches/$2/ -m \"BRANCH $2 created from trunk\""
}
function tag()
{
args=$2
major=`echo $args | awk -F"." '{print $1}'`
minor=`echo $args | awk -F"." '{print $2}'`
@dubbs
dubbs / csv.pegjs
Created November 26, 2012 23:36 — forked from trevordixon/csv.pegjs
Javascript CSV Parser generated by PEG.js
{
var separator = ',';
}
start
= comma
comma
= & { return separator = ','; } sv:sv { return sv; }
@dubbs
dubbs / .htaccess
Last active May 17, 2024 04:29
far future Expires header
<FilesMatch "\.(gif|png|jpg|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 10 years"
</FilesMatch>
@dubbs
dubbs / app.php
Last active May 17, 2024 04:29
versioning filenames with last modified time - PHP
<?php
function autoVer($url) {
$path = pathinfo($url);
$ver = '.' . filemtime($_SERVER['DOCUMENT_ROOT'] . $url) . '.';
echo $path['dirname'] . '/' . str_replace('.', $ver, $path['basename']);
}
<link rel="stylesheet" href="<?php autoVer('/css/main.css'); ?>" type="text/css" />
<script type="text/javascript" src="<?php autoVer('/scripts/main.js'); ?>"></script>
@dubbs
dubbs / .htaccess
Last active December 10, 2015 16:18
RewriteRule ^(js|css|img)/(.+)\.(.+)\.(js|css|jpg|gif|png)$ $1/$2.$4 [L]
@dubbs
dubbs / gist:4477834
Created January 7, 2013 19:53
Cross browser print request detection
(function() {
var beforePrint = function() {
console.log('before');
};
var afterPrint = function() {
console.log('after');
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
@dubbs
dubbs / vim.md
Last active May 17, 2024 04:29
Useful Vim Commands

Execute the macro stored in register a on lines 5 through 10.

:5,10norm! @a

Execute the macro stored in register a on all lines.

:%norm! @a

Jumping