Skip to content

Instantly share code, notes, and snippets.

Eric Miller SimplGy

View GitHub Profile
SimplGy / 2xBackground
Created Aug 12, 2013
Creates 1x and 2x background images. The 200% means that the pixel offsets will work on both the small and large images. Make sure your sprites line up exactly, so that the 2x images are exactly twice as big, twice as low, and twice as left.
View 2xBackground
//Support 1 and 2x image sizes
@mixin 2xBackground($url)
background-image: url($url + ".png")
@media only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)
background-image: url($url + "@2x.png")
background-size: 200%
SimplGy / algorithm test
Created Aug 30, 2013
Favorite unit test yet :) Uses a loop over a hash to test expectations
View algorithm test
define [
) ->
_data = [
{ size: 2 }
{ size: 2 }
SimplGy / promise.js
Last active Apr 17, 2020
Sample Promise Implementation. Wrote in
View promise.js
// --------------------------------------------- Promise Implementation
Promise = function () {
this._stack = [];
this._isResolved = false;
Promise.prototype = {
success: function(callback){
// Is the promise already resolved?
if(this._isResolved) {
callback( this._result );
SimplGy / rotationalCipher.rb
Created Oct 10, 2013
Ruby Implementation of a Rotational Cipher. Wrote in
View rotationalCipher.rb
$alphabet = 'abcdefghijklmnopqurstvwxyz'
# Get an index of an alphabetic letter based on the index and offset
def calculateOffset(index, offset)
index += offset
index -= 26 while index >= 26 # keep subtracting until we get to the right range
SimplGy /
Created Feb 10, 2014
Mac Setup Script
#!/usr/bin/env bash
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
xcode-select —install
sh -c "`curl -fsSL`"
rake update
chsh -s $(which zsh)
SimplGy / angularEventBus.js
Last active Aug 29, 2015
Angular decoration makes $rootScope an event bus that cleans up after itself automaticaly. From:
View angularEventBus.js
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
$rootScope.prototype.$onRootScope = function(eventName, callback) {
var unbind = $rootScope.$on(eventName, callback);
this.$on('$destroy', unbind);
SimplGy / angularDirectiveCompileOrder.js
Created Aug 5, 2014
Compile order of parent and child directives in AngularJS
View angularDirectiveCompileOrder.js
1. compile methods of all directives, run in order
2. controller
3. pre-link
4. (all actions of children directives)
5. post-link (AKA regular `link` function)
var app = angular.module('app',[]);
SimplGy /
Last active Aug 29, 2015
A few short methods that are helpful in navigating around angular scopes and watchers. For debugging or learning/exploring.
# A few short methods that are helpful in navigating around angular scopes and watchers.
# Useful for debugging or learning/exploring.
# Given a scope, count its direct children
# Use the to tell (in the case of fancy nested directives) if you're cleaning up what you think you're cleaning up
countScopeChildren = (scope) ->
count = 0;
if scope.$$childHead
SimplGy /
Last active Aug 29, 2015
Common OSX setup tasks
# Symlink the javsscript interpreter OSX has
ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin
# Check if it works by just typing: jsc
# Remove apps I never use
sudo rm -rf
sudo rm -rf
sudo rm -rf
SimplGy / functions.playground.swift
Created Mar 5, 2015
Playing around with functions as params and return types in Swift
View functions.playground.swift
func double (a:Int) -> Int { return a * 2 }
func quadruple (a:Int) -> Int { return a * 4 }
// ------------Q: How do I accept a function as a parameter?
func modifyInt (num a:Int, modifier fn: Int -> Int) -> Int {
return fn(a)
You can’t perform that action at this time.