Skip to content

Instantly share code, notes, and snippets.

View stanistan's full-sized avatar
🤷‍♂️

Stan Rozenraukh stanistan

🤷‍♂️
View GitHub Profile
@stanistan
stanistan / placeholder.jquery.js
Created February 21, 2011 14:21
Checks if the browser supports the HTML placeholder spec, if not, replaces it with the 'placeholder' attribute. Works in Chrome. IE7/IE8. Assuming it works in FF/Opera.
/*
Placehoder Plugin for jQuery By Stan Rozenraukh
Usage:
$('input').placeholder();
or
$('input').placeholder({
active: 'red',
blurred: 'green'
});
*/
@stanistan
stanistan / aqlmodule-usage.js
Created April 19, 2012 21:53
js-aqlmodule usage
/*
given an HTML element that corresponds to the selector '#el'
with "data-" attributes ['model', 'token', 'ide']
*/
var module = new Module($('#el'), options);
// or
@stanistan
stanistan / class.ct_staff.php
Created August 6, 2012 15:11
select/ column
<?php
class ct_staff extends Model
{
/**
* Staffing types
* [ db_value => display_value ]
* @var array
*/
@stanistan
stanistan / fizzbuzz.js
Created August 6, 2012 22:24
Messing around with fizzbuzz
var fizzbuzz = function(n) {
return [ { m: 3, word: 'Fizz'}, { m: 5, word: 'Buzz'} ]
.map(function(c) { return !(n % c.m) ? c.word : ''; })
.join('') || n;
};
for (var i = 1; i < 101; i++) {
console.log(fizzbuzz(i));
}
@stanistan
stanistan / gist:3809177
Created October 1, 2012 02:39
Higher order functions in PHP: partial/curry/compose
<?php
/**
* Higher order functions in PHP
*
* Please let me know of any differences in the the uses and actual definitions of partial v. curry.
*/
/**
* Returns a partially applied function.
@stanistan
stanistan / gist:3823100
Created October 2, 2012 20:33
kill-ps
#!/usr/bin/env python
"""
Use this to kill hanging processes that don't have a specific name,
greps for the name in the process name, and kills -9 by PID
"""
import subprocess
import re
import optparse

AQL

One purpose of this (abbreviated query language) is to generate SQL queries so that you don't have to repeat yourself.

artist {
    name
}
student {
    name
}
select now()
@stanistan
stanistan / usage.php
Created February 21, 2013 15:35
A closure for "sandboxing" settings.
<?php
// usage
withSetting::ini('display_errors', 'off', function() {
//.. do things
});
withSetting::timezone('America/New_York', function() {
//.. do things