Skip to content

Instantly share code, notes, and snippets.

@savage69kr
savage69kr / object-watch.js
Created September 4, 2012 13:00 — forked from eligrey/object-watch.js
object.watch polyfill
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@savage69kr
savage69kr / perfnow.js
Created September 9, 2012 11:45 — forked from BKcore/perfnow.js
Performance.now() polyfill
(function(w){
var perfNow;
var perfNowNames = ['now', 'webkitNow', 'msNow', 'mozNow'];
if(!!w['performance']) for(var i = 0; i < perfNowNames.length; ++i)
{
var n = perfNowNames[i];
if(!!w['performance'][n])
{
perfNow = function(){return w['performance'][n]()};
break;
(function($) {
function parseImagesFromCSS(doc) {
var i, j,
rule,
image,
pattern = /url\((.*)\)/,
properties = ['background-image', '-webkit-border-image'],
images = {};
if (doc.styleSheets) {
@savage69kr
savage69kr / demo.htm
Created October 3, 2012 12:29 — forked from bennadel/demo.htm
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
<!DOCTYPE html>
<html>
<head>
<title>Cross-Origin Resource Sharing (CORS) With jQuery And Node.js</title>
</head>
<body>
<h1>
Cross-Origin Resource Sharing (CORS) With jQuery And Node.js
</h1>
@savage69kr
savage69kr / ajax_intercepter
Created October 10, 2012 13:05 — forked from creotiv/ajax_intercepter
Ajax Intercepter
<html>
<body>
<script>
var xml_type;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
@savage69kr
savage69kr / maxcomplexity.js
Created October 13, 2012 01:25 — forked from elijahmanor/maxcomplexity.js
JSHint Function Complexity
{
"globals": {
"console": false,
"jQuery": false,
"_": false
},
"maxparams": 5,
"maxdepth": 5,
"maxstatements": 25,
"maxcomplexity": 10,
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<style>
li.selected { background-color: red; }
</style>
</head>
@savage69kr
savage69kr / some.sh
Created October 27, 2012 07:13 — forked from tj/some.sh
change terminal tab name on cd
function tabname {
printf "\e]1;$1\a"
}
if [ x`type -t cd` == "xfunction" ]; then
# previously wrapped cd
eval $(type cd | grep -v 'cd is a function' | sed 's/^cd/original_cd/' | sed 's/^}/;}/' )
else
# builtin
eval "original_cd() { builtin cd \$*; }"
@savage69kr
savage69kr / readme.md
Created October 27, 2012 07:13 — forked from wilmoore/readme.md
Terminal Tab reflecting your current git project name

NOTE: the potential downside to this approach is that git is a requirement; however, this is simple to extend for other VCSes.

First, setup a git alias:

% git alias project-name '!git config project.info.name'

Use it like this (your CWD should be a git project):

@savage69kr
savage69kr / some.sh
Created October 27, 2012 07:14 — forked from samsonjs/some.sh
change terminal tab name on cd
tabname() {
printf "\e]1;$1\a"
}
cd() {
if [[ $# -gt 0 ]]; then
builtin cd "$*"
else
builtin cd
fi