Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
@schmmd
schmmd / binary.scala
Created October 8, 2011 04:57
scala binary tree
/* contravariance required so Empty can be used with Nodes ( Nothing <: T ) */
class Tree[+T]
case object Empty extends Tree[Nothing]
case class Node[T](val elem: T, val left: Tree[T], val right: Tree[T]) extends Tree[T]
def inOrder[T](t: Tree[T]): List[T] = t match {
case Empty => Nil
case Node(e, left, right) => inOrder(left) ::: List(e) ::: inOrder(right)
}
@abbood
abbood / gist:cacd1fd8b485a8abc8c7d5d73f46e993
Created August 11, 2017 13:49
example of automating scripts on multiple tabs on iterm
tell application "iTerm"
tell current window
-- create a tab for background db stuff
create tab with default profile
tell current session
write text "mongod &"
write text "redis-server &"
end tell
close current tab
@escapedcat
escapedcat / yourCtrl.js
Last active February 13, 2018 17:48
angular-google-maps directions service example
addresses = addressService.query();
addresses.$promise.then(function (result) {
console.log('task query done');
createWaypointsFromAddresses(addresses);
return uiGmapGoogleMapApi;
})
.then( function(maps) {
@Marak
Marak / mockreadwritestream.js
Created May 20, 2011 06:29 — forked from indexzero/mockreadwritestream.js
A mock stream for node.js that is both Readable and Writeable.
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
//
// No need to do anything here, it's just a mock.
//
};
util.inherits(MockReadWriteStream, events.EventEmitter);
lazy val dotEnvFile = taskKey[String]("Defines the file to load environment variables from")
dotEnvFile := ".env"
// The task returns the loaded dotEnv file and a map of the loaded variables, in case it would need to be manipulated somewhere else
lazy val loadEnv = taskKey[(File, Map[String, String])]("""Loads the environment variables from file defined by task `dotEnvFile` (they must follow the format "export X=Y")""")
loadEnv := {
val logger = ConsoleLogger()
val sourceFileName = dotEnvFile.value
@bleathem
bleathem / gist:50b4dd2fd4377503eaad
Last active August 22, 2018 20:54
Creating an Rx.js Observable from a STOMP over Websocket source (with error handling)
// see: https://github.com/jmesnil/stomp-websocket
var client = Stomp.client('ws://...');
client.debug = undefined;
var live = Rx.Observable.create(function (observer) {
console.log('Connecting...')
client.connect(username, password, function(frame) {
console.log(frame.toString());
observer.onNext(frame);
@nmccready
nmccready / $httpDecorator.coffee
Last active November 26, 2018 13:30
$http decorator to cancel requests for all $http methods
app.config([ '$provide', ($provide) ->
# attempting to create a cancelable $http on all its functions
$provide.decorator '$http', [ '$delegate', '$q', ($delegate, $q) ->
http = {}
methods = ['get', 'delete', 'head', 'jsonp']
dataMethods = ['post', 'put', 'patch']
allMethods = methods.concat(dataMethods)
allMethods.forEach (m) ->
http[m] = $delegate[m]
http.root = $delegate
@coldnebo
coldnebo / Default (OSX).sublime-keymap -- User
Created February 3, 2012 16:21
Sublime Text 2 fix for OSX home/end keys
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }
@sixfeetover
sixfeetover / notes.md
Last active October 21, 2019 03:52
MacOS Sierra upgrade for Rubyists

Upgrading to Sierra for Ruby Devs

Often when upgrading to the latest OS X MacOS you have to do a few things to account for changing to underlying libraries. Here are the post-upgrade steps I took to get back to a fully operational state. I use homebrew and rbenv to manage my environment.

1. Get your Developer Command line tools upgraded.

To do this just run

$ xcode-select --install
@mafintosh
mafintosh / bitcoin-for-laypeople.md
Last active April 1, 2020 12:46
Blog post about how Bitcoin works in a way non computer people can understand it

Bitcoin for laypeople

(Chinese version available here, courtesy of @jiangplus

(This is an English translation of my Danish blog post, Bitcoin for voksne)

Bitcoin is a digital currency that has no central authority. It's a currency where you do not have to rely on anyone to know it's worth it. As a concept, it's similar to gold. Gold has a value in itself, as opposed to, say a $100 note that only has value if the U.S. government says it has value. Similarly, the idea of ​​Bitcoins is that they have value by themselves.

Let's try to understand how Bitcoin works.