Skip to content

Instantly share code, notes, and snippets.

View ecasilla's full-sized avatar
🏠
Working from home

Ernie Casilla ecasilla

🏠
Working from home
  • This Crust Planet
  • Washington,DC
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ecasilla on github.
  • I am erniecasilla (https://keybase.io/erniecasilla) on keybase.
  • I have a public key ASBdSB8vESShvzF51b1dUXUPp_bNN7VQcjAYgjHKsr_Pkgo

To claim this, I am signing this object:

@ecasilla
ecasilla / Mock Module
Created November 13, 2014 19:30
Node Mock Module Loader
var vm = require('vm');
var fs = require('fs');
var path = require('path');
/**
* Helper for unit testing:
* - load module with mocked dependencies
* - allow accessing private state of the module
*
* @param {string} filePath Absolute path to module (file to load)
@ecasilla
ecasilla / extract.js
Created May 14, 2016 22:21
Extract Github Issues Lables
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/ecasilla/github-labelmaker !
var labels = [].slice.call(document.querySelectorAll(".label-link"))
.map(function(ele) {
return {
name: ele.textContent.trim(),
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: 0;
background: #222;
min-width: 960px;
}
@ecasilla
ecasilla / Cycle Speed
Created January 3, 2014 22:05
Processors
# The first term is the speed of light in meters per second
# (this is actually exact - a meter is defined as
# "the length of the path travelled by light in vacuum during a time interval of 1/299 792 458 of a second.".
# The second term, 100 is the number of centimeters in a meter.
# The third term, 1.0/1000000000 is one billionth. (Note that we need the .0 here (or at least 1.)
# to make Ruby do floating point division. Otherwise, 1/1000000000 would evaluate to 0.)
# So, the first three terms in the product compute the distance in centimeters

The workflow we will follow looks like this:

  1. Planning
  2. Initializing Application
  3. Building the Rails Model
  4. Configure our Dev Environment
  5. Defining Routes
  6. Writing Controllers and their Views (iterate)
  7. Styling Views
  8. Share!
@ecasilla
ecasilla / object_diff.js
Last active November 19, 2015 17:32
Js Object Diff
import * as _ from 'lodash';
function objectDiff(prev, now){
// sanity checks, prev and now must be an object.
if ( ! _.isObject(prev) || ! _.isObject(now) ){
return new TypeError("Arguments must both be objects",__filename);
}
var changes = {};
for (var prop in now) {
// if property is new in now i.e unknown, add it too changes
@ecasilla
ecasilla / tools.js
Created August 25, 2015 16:45
Node js prod tools
var heapdump = require('heapdump');
//Grab a heapdump if the memory increase goes over 250mb
var nextMBThreshold = 0;
setInterval(function () {
var memoryMB = process.memoryUsage().rss / 1048576;
if (memoryMB > nextMBThreshold) {
heapdump.writeSnapshot();
nextMBThreshold += 250;
}
@ecasilla
ecasilla / dot.js
Last active August 29, 2015 14:25
DOT operator
DOT = function(obj,prop){
if(obj.hasOwnProperty(prop)){
return obj[prop];
}else if(obj.__proto__){
return DOT(obj.__proto__,prop)
}
}
DOTCALL = function(obj,props,args){
var fn = DOT(obj,props);