Skip to content

Instantly share code, notes, and snippets.

jQuery.ajax({
url: "https://BSD-CLIENT-DOMAIN.com/page/spud?jsonp=?",
dataType: "jsonp",
data: {
type: "getm",
field: "firstname,lastname,email,lastlogin,source"
},
jsonp: "jsonp",
success: function(data){
console.log(data ,data.source, data.email);
@yahelc
yahelc / zip-to-state.js
Created August 5, 2013 19:49
US Zip Code to State mapping
function zipToState(zip) {
var state;
if (zip >= '99501' && zip <= '99950') { state = 'AK'; }
else if (zip >= '35004' && zip <= '36925') { state = 'AL'; }
else if (zip >= '71601' && zip <= '72959') { state = 'AR'; }
else if (zip >= '75502' && zip <= '75502') { state = 'AR'; }
else if (zip >= '85001' && zip <= '86556') { state = 'AZ'; }
else if (zip >= '90001' && zip <= '96162') { state = 'CA'; }
else if (zip >= '80001' && zip <= '81658') { state = 'CO'; }
else if (zip >= '06001' && zip <= '06389') { state = 'CT'; }
@yahelc
yahelc / intro.md
Last active April 29, 2022 01:34

Twig for Template Designers

This document describes the syntax and semantics of the template engine and will be most useful as reference to those creating Twig templates.

Synopsis

A template is simply a text file. It can generate any text-based format (HTML,

@yahelc
yahelc / gist:5246860
Last active December 15, 2015 10:39
Bash script for Mac OS X to check, every 10 seconds, if the audio recordings for the #DOMA case are posted yet, and will open the page in Safari when it's posted.
while true
do
if (curl -is http://www.supremecourt.gov/oral_arguments/argument_audio_detail.aspx?argument=12-307 | grep -q "Location");
then
echo "Not posted yet :(" && sleep 10;
else
open http://www.supremecourt.gov/oral_arguments/argument_audio_detail.aspx?argument=12-307; break;
fi
done
@yahelc
yahelc / README.md
Last active December 14, 2015 03:59 — forked from gmarik/README.md

About

minimal example of using [phantomjs] with [qunit]

$ phantomjs run-qunit.js file://`pwd`/test.html
'waitFor()' finished in 200ms.
Tests completed in 21 milliseconds.
5 tests of 5 passed, 0 failed.

Installation

var _gaq = {
push : function(){
var args = Array.prototype.slice.call(arguments, 0);
if(args[0] === "_link"){
window.location = args[1];
}
}
}
@yahelc
yahelc / jQuery-geo.js
Last active December 10, 2015 21:48 — forked from anonymous/jQuery-geo.js
(function($){
$.geo = function(callback){
if(!$.geo.data){
$.ajax({
cache: true,
url: '//www.google.com/jsapi',
dataType: "script",
success: function(){
@yahelc
yahelc / states_hash.json
Created October 21, 2012 00:46 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"DC": "District Of Columbia",
@yahelc
yahelc / abba-bookmarklet.js
Created September 10, 2012 18:09
Bookmarklet for calculating data for A/B significance by just clicking.
javascript:(function(){function%20abba_url(data_array){var%20url%20=%20%22http://www.thumbtack.com/labs/abba/#%22;for(var%20i%20=%200;%20i<data_array.length;%20i++){url%20+=%20%22Variation+%22%20+%20(i+1)%20+%20%22=%22%20+%20data_array[i]%20+%20%22%2C%22%20+%20data_array[++i]%20+%20%22&%22;}url%20+=%20%22abba%3AintervalConfidenceLevel=0.95&abba%3AuseMultipleTestCorrection=true%22;return%20url;}if(window.abbaDispatchOnNext){window.open(abba_url(abbaData));this.removeEventListener(%27click%27,%20arguments.callee,%20true);}window.abbaDispatchOnNext%20=%20true;window.abbaData%20=%20window.abbaData%20||%20[];document.addEventListener(%22click%22,%20function(e){var%20num%20=%20e.target.textContent.replace(/\D/g,%27%27);if(typeof%20+(num)%20===%20%22number%22%20&&%20!isNaN(+num)){abbaData.push(num);}},%20true);}());
@yahelc
yahelc / chosen-for-openair.js
Created August 6, 2012 13:58
Chosen for OpenAir
// ==UserScript==
// @name Chosen for OpenAir
// @author Yahel Carmon
// @description Uses Chosen for Open Air Client Selector. Might break if they change anything. Must set it such that you display ALL CLIENTS in the settings. Use at your own risk.
// @namespace https://gist.github.com/gists/blahblah
// @match https://www.openair.com/timesheet.pl*
// @include https://www.openair.com/timesheet.pl*
// ==/UserScript==
window.unsafeWindow || (