Skip to content

Instantly share code, notes, and snippets.

View mrgenixus's full-sized avatar

Benjamin West mrgenixus

View GitHub Profile
<html>
<head>
<link rel="stylesheet" href="https://raw.github.com/harvesthq/chosen/master/chosen/chosen.css" />
</head>
<body>
<form>
<select name='Organization' class='chzn-select'><option value=''></option><option value='Our Company'></option><option value='Test Company'></option>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="https://github.com/harvesthq/chosen/blob/master/chosen/chosen.jquery.js" type="text/javascript"></script>
@mrgenixus
mrgenixus / README.md
Created August 15, 2011 05:41 — forked from davidjbeveridge/README.md
wtf.sh

wtf.sh

A simple search for when you find yourself typing wtf on the command line. Works on mac.

Instructions

Put this somewhere in your path, make it executable, and either rename it to wtf, or create a symlink. Then, whenever you type wtf on the command line, you'll actually get something.

@mrgenixus
mrgenixus / config
Created January 31, 2012 04:05 — forked from davidjbeveridge/Gemfile
Routing
---
BUNDLE_PATH: json
BUNDLE_DISABLE_SHARED_GEMS: '1'
@mrgenixus
mrgenixus / Gemfile
Created March 28, 2012 02:13 — forked from davidjbeveridge/attribute_observers.rb
Attribute Observers
source "http://rubygems.org"
gem "json"
@mrgenixus
mrgenixus / ctrr.md
Created October 25, 2012 19:57 — forked from esmooov/ctrr.md
Carats and Tildes, Resets and Reverts

Until last night I lived in fear of tildes, carats, resets and reverts in Git. I cargo culted, I destroyed, I laid waste the tidy indicies, branches and trees Git so diligently tried to maintain. Then Zach Holman gave a talk at Paperless Post. It was about Git secrets. He didn't directly cover these topics but he gave an example that made me realize it was time to learn.

A better undo

Generally, when I push out bad code, I panic, hit git reset --hard HEAD^, push and clean up the pieces later. I don't even really know what most of that means. Notational Velocity seems to be fond of it ... in that I just keep copying it from Notational Velocity and pasting it. Turns out, this is dumb. I've irreversibly lost the faulty changes I made. I'll probably even make the same mistakes again. It's like torching your house to get rid of some mice.

Enter Holman. He suggests a better default undo. git reset --soft HEAD^. Says it stag

var double = function(a){ return a * 2; }
var getterSetter = (function(){ //don't work in the global scope
var process_validation = function(validation_params){
if (validation_params) return function(val){
// do magjiks
if (validation_params.filter) val = val.match(validation_params.filter)[0];
if (validation.process && typeof validation.process == 'function') val = validation.process(val);
if (validation_params.min) val = Math.max(val,validation_params.min);
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
$(function(){
$('*[data-repeat]').each(function(){
var n = $(this).data('repeat');
var parent = $(this).parent();
self = $(this);
for (var i = 0; i < n; i++) {
parent.append(self.clone());
}
})
});
/*
* This decorates Handlebars.js with the ability to load
* templates from an external source, with light caching.
*
* To render a template, pass a closure that will receive the
* template as a function parameter, eg,
* T.render('templateName', function(t) {
* $('#somediv').html( t() );
* });
* Source: https://github.com/wycats/handlebars.js/issues/82
(function (n) { // function has no name, is therefore "anonymous"
var i=n*2;
if (i > 4) {
return undefinedFunc(); // causes a "ReferenceError: undefinedFunc is not defined at Object.<anonymous>"
} else {
arguments.callee(i); // recurses, adding the anonymous function to the call stack
}
})(1);