Skip to content

Instantly share code, notes, and snippets.

Eric Miller SimplGy

View GitHub Profile
@SimplGy
SimplGy / macSetup.sh
Created Feb 10, 2014
Mac Setup Script
View macSetup.sh
#!/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 https://raw.github.com/skwp/dotfiles/master/install.sh`"
rake update
chsh -s $(which zsh)
@SimplGy
SimplGy / angularEventBus.js
Last active Aug 29, 2015
Angular decoration makes $rootScope an event bus that cleans up after itself automaticaly. From: https://github.com/angular/angular.js/issues/4574
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
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
SimplGy / angularHelpers.coffee
Last active Aug 29, 2015
A few short methods that are helpful in navigating around angular scopes and watchers. For debugging or learning/exploring.
View angularHelpers.coffee
# 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
count++
@SimplGy
SimplGy / osxSetupTasks.sh
Last active Aug 29, 2015
Common OSX setup tasks
View osxSetupTasks.sh
# 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 Mail.app
sudo rm -rf Stickies.app
sudo rm -rf Chess.app
@SimplGy
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 }
double(10)
quadruple(10)
// ------------Q: How do I accept a function as a parameter?
func modifyInt (num a:Int, modifier fn: Int -> Int) -> Int {
return fn(a)
}
@SimplGy
SimplGy / Change-MAC-Address.md
Created Mar 14, 2015
Change a MAC address in OSX and disconnect correctly from the current WIFI network.
View Change-MAC-Address.md

Quick Start

Figure out which en interface to use

ifconfig 

See the mac address

ifconfig en0 | grep ether
@SimplGy
SimplGy / osxWifiTerminal.md
Last active Aug 29, 2015
OSX wifi-related terminal commans
View osxWifiTerminal.md

Turn off wifi on your macbook from the Mac OSX terminal command line:

networksetup -setairportpower en0 off

Turn on wifi on your macbook from the Mac OSX terminal command line:

networksetup -setairportpower en0 on

List available wifi networks from the Mac OSX terminal command line:

@SimplGy
SimplGy / countWirelessNetworks.sh
Created Mar 27, 2015
Count the number of wireless networks your mac has ever connected to
View countWirelessNetworks.sh
networksetup -listpreferredwirelessnetworks en0 | wc -l
@SimplGy
SimplGy / infiniteBacon-start.html
Last active Aug 29, 2015
FRP Infinite Scroll with Bacon.js -- Starting File
View infiniteBacon-start.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FRP Infinite Scroll using Bacon.js</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.53/Bacon.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.7.0/lodash.min.js"></script>
<style type="text/css">
body {
You can’t perform that action at this time.