Skip to content

Instantly share code, notes, and snippets.

View juniorbird's full-sized avatar

Wade Armstrong juniorbird

View GitHub Profile
@juniorbird
juniorbird / sayings.md
Last active June 24, 2018 19:36
Sayings

Sayings worth remembering

On life

  • "He who quotes others is an idiot" - Thomas Jefferson
  • "Wine we need for health, and the health we need to drink vodka." - Viktor Chernomyrdin
  • "To answer before listening -- that is folly and shame." - Proverbs 18:13
  • "Some name it disappointment and become poorer, others name it experience and become richer" - Siegmund Warburg
  • "If we want to fully experience love and belonging, we must believe that we are worthy of love and belonging." - Brene Brown
  • In some ways suffering ceases to be suffering at the moment it finds a meaning, such as the meaning of a sacrifice." - Viktor Frankl
@juniorbird
juniorbird / minty.js
Created March 18, 2016 22:27
Minty Example
const minty = require('./index.js');
const path = require('path');
function hello(a,b,c) {
console.log(a);
var d = b + c;
console.log(d);
}
minty.file(path.join(__dirname, '/lib/test.js'));
@juniorbird
juniorbird / git-rebase-todo
Created June 2, 2016 03:02
Sample git rebase todo
pick 019325e 0.1.0
pick a4b689d Fetch all dependencies
squash 714a49d Matches keywords to Docker repos
pick d2d1ca3 parseDependencies returns an object of dependencies.
squash e3b6cd9 Clean up packageParser
squash 57acd67 Initial commit
squash 3f3e05e Rough out how we'll make Dockerfiles
squash 9e10b94 Can check for, make Docker files
squash a27b0ee Write docker files
pick a0980b8 Build Dockerfiles
@juniorbird
juniorbird / reduce.js
Last active March 25, 2022 22:23
A simple implementation of Reduce in Javascript
'use strict';
function reducer(array, callback, initializer) {
let accumulator = (initializer === undefined) ? 0 : initializer;
for (let i = 0; i < array.length; i++) {
accumulator = callback(accumulator, array[i]);
}
return accumulator;
@juniorbird
juniorbird / reduce.py
Last active June 17, 2016 22:47
A simple implementation of Merge Ranges in Python, using reduce
from functools import reduce
def merge_arrays(accumulator, new):
# Since Python doesn't have multiline lambdas
# we define our reducer function here
last = len(accumulator) - 1
if (new[0] <= accumulator[last][1]):
start = accumulator[last][0]
@juniorbird
juniorbird / forloop.py
Last active June 17, 2016 22:40
A simple implementation of Merge Ranges in Python, using a for loop
def free_times(calendar_list):
output = []
# This is easier with a list sorted by start time
# sort() is mergesort, with O(n) = n log n
# which is fast enough to not manually sort.
calendar_list.sort(key = lambda event: event[0])
for index in range(len(calendar_list)):
if (index > 0):
@juniorbird
juniorbird / composefunctions.php
Last active June 21, 2016 23:01
Composing functions in PHP
<?php
$sorted_arr = function ($range_to_sort) {
// Annoyingly, PHP can't return the sorted array from a sort
// Do it manually
usort($range_to_sort, function ($a, $b)
{
@juniorbird
juniorbird / compose.js
Last active June 21, 2016 23:02
Reducing and composing in Javascript
'use strict';
function sortedCal(calArray) {
return calArray.sort((a, b) => a[0] > b[0]);
}
function mergeRanges(sortedCal) {
let start;
let end;
@juniorbird
juniorbird / planner.scpt
Last active August 31, 2016 19:20
Simple applescript day planner
##############
# Time-related tasks
set plannerMonth to (month of (current date) as text)
set plannerDay to (day of (current date) as text)
set plannerYear to (year of (current date) as text)
################
# Set up our file paths
# Base paths
@juniorbird
juniorbird / portforward.sh
Created August 8, 2016 21:20
Forward Mac OS >= 10.10.x 8080 to 80
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -