Skip to content

Instantly share code, notes, and snippets.

View elrasguno's full-sized avatar

Dan Racanelli elrasguno

View GitHub Profile
@elrasguno
elrasguno / 538.sh
Created October 17, 2016 03:06 — forked from mmaelzer/538.sh
Bash script to fetch latest polls-only forecast from fivethirtyeight.com. Defaults to US but allows an optional state argument.
#!bin/bash
# Fetches data from http://projects.fivethirtyeight.com/2016-election-forecast/summary.json,
# parses the results using python, and prints the polls-only forecast results in the format:
# "{STATE} D {PROBABILITY} R {PROBABILITY}"
#
# The script takes an optional argument that specifies an individual two letter abbreviation (case insensitive)
# of a U.S. state. By default, the state is US which returns the national results.
#
# Examples:
@elrasguno
elrasguno / aggregate_json_parser.js
Created December 1, 2014 05:39
Aggregate multiple JSON strings into one to save on JSON.parse CPU consumption.
/**
* Aggregate multiple JSON strings into one to save on CPU.
*
* @param {Array} jsonStringsArray An array of valid JSON strings to be parsed together.
* @returns {Array} An array of JavaScript Objects, or an empty array if any members of the input array are invalid JSON.
*/
function aggregateParseJSON(jsonStringsArray)
{
var tmpArray = '[' + jsonStringsArray.join(',') + ']',
parsed = [];
@elrasguno
elrasguno / how_unit_testing_saves_lives_or_your_sanity.md
Last active August 29, 2015 14:10
How Unit Testing Saves Lives, or Your Sanity

(See original post, and some photography here)

For the longest time, I didn't really understand what it meant to unit test code. I remember thinking something along the lines of "wait, so I write a function that adds one to a number. then I write a test to prove that it added one to a number?" It just seemed to me, as I'm sure it does to many people, like extra work, and unit testing wasn't worth the overhead involved it testing all of my code. I mean, I tested it all when I was developing it, right?

Those were the good old days of back end development, when all you needed to do to test your app was hit your web interface, validate input for malicious data, and display error messages to users when they missed a spot filling in a form. Maybe you used an IDE for remote breakpoint debugging, but old school error logging usually did the trick just fine. Load page, fill form, validate error conditions, rinse, repeat.

In a mobile develop

@elrasguno
elrasguno / vimrc
Created December 22, 2011 16:17
My vimrc file
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 1999 Jul 25
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
set noswapfile
@elrasguno
elrasguno / jquery.animateDiv.js
Created April 13, 2011 22:27
Convert a container that normally holds a number into an "odometer" style collection of animated divs.
(function($) {
$.extend($.fn, {
animateDiv : function(rValue, rOptions, rSpriteOrImg) {
var selff = this,
debug = false,
vFrames = rOptions['pFrames'] || 10,
vFrameSize = rOptions['pFrameSize'],
vOrientation = (rOptions['pOrientation'] > -1 ? rOptions['pOrientation'] : 1),
vClassName = rOptions['pClassName'] || 'numbers_test',
vSpriteOrImg = rSpriteOrImg || 'sprite';
@elrasguno
elrasguno / Ringz.js
Created April 12, 2011 22:05
Possible approach to platform specific handling for ringz app.
console && console.log('this is ringz!');
var RingzApp = function(rPlatform) {
var vPlatform = rPlatform || 'web',
vClickerConfig,
vRingzEventHandler;
/***
* Platform specific Clicker/Event config
**/
@elrasguno
elrasguno / index.html
Created April 5, 2011 15:08
InterviewHello.js
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./interview_hello.js"></script>
</head>
<body>
</body>
</html>