Skip to content

Instantly share code, notes, and snippets.

View idiomatic's full-sized avatar

Brian Harrison idiomatic

  • Portland, Oregon
View GitHub Profile
@idiomatic
idiomatic / components.coffee
Last active December 16, 2015 13:08
MERGED TO lawloop/mayhem AngularJS controller decorator and components
app = angular.module 'app'
app.directive 'demo', ->
restrict: 'E'
scope: true
templateUrl: 'demo.html'
slow_random = (autocb) ->
await setTimeout defer(), 100
Math.random()
slow_buggy_random = (bugginess=0.1, cb) ->
# cannot return multi values (e.g., err and value), thus no autocb
await setTimeout defer(), 100
if Math.random() < bugginess
cb "boom"
else
@idiomatic
idiomatic / github-ebmd-spec.md
Last active August 29, 2015 14:01
github estimating

Evidence-Based Milestone Deadlines

Compute the deadline of a GitHub Milestone based on corrected issue estimates.

  • incurs a low-impact process on assignees
  • puts estimates near all relevant details
  • permits estimate revision as easily as providing the original estimate
  • fosters single-source-of-truth for issue milestones and assignments
  • adjusts the deadline when things are added, reopened, moved, or closed
@idiomatic
idiomatic / wwdc.sh
Last active April 10, 2022 03:52
Fetch WWDC videos, slides, and sample code.
#!/bin/bash
# usage: get [ RESOLUTION [ YEAR [ IDS... ] ] ]
resolution=${1:-SD}
year=${2:-2015}
shift
shift
ids=$*
RESOLUTION=$(echo $resolution | tr '[:lower:]' '[:upper:]')
longestIncreasingSubsequence = (sequence) ->
startIndex = []
endIndex = []
subsequences = []
for value, i in sequence
for length in [endIndex.length..0] by -1
if (sequence[endIndex[length - 1]] ? Number.MIN_VALUE) < value < (sequence[endIndex[length]] ? Number.MAX_VALUE)
endIndex[length] = i
startIndex[length] = startIndex[length - 1] ? i
@idiomatic
idiomatic / !rclone-pretty.sh
Last active August 29, 2015 14:27
rclone output polish
#!/bin/sh
# TODO: output checking
fix_rclone_output() {
perl -ne '
BEGIN {
$|++;
sub human {
my ($size) = @_;
###
# Sample React Native App
# https://github.com/facebook/react-native
###
'use strict'
React = require 'react-native'
{AppRegistry, StyleSheet, Text, View} = React
CoffeeProject = React.createClass
package main
import (
"io"
"log"
"net/http"
)
type MethodMux struct {
GET http.Handler
@idiomatic
idiomatic / islands.js
Last active December 6, 2017 20:53
count the number of "islands" in an matrix of non-wraparound bits, where horizontally/vertically/diagonally adjacent bits are the same island
const tests = [
[0, [[0]]],
[1, [[1]]],
[1, [[1, 0], [0, 0]]],
[1, [[0, 1], [0, 0]]],
[1, [[0, 0], [1, 0]]],
[1, [[0, 0], [0, 1]]],
[1, [[1, 0], [0, 1]]],
[1, [[0, 1], [0, 1]]],
[1, [[1, 0], [1, 0]]],
@idiomatic
idiomatic / farmables.sql
Last active December 6, 2017 18:50
find things to farm in a classic WoW db, that drop "medium rarely" from few world mob types with longer average spawn durations
SELECT item.*,
CAST(oclt.ChanceOrQuestChance AS DECIMAL(6, 2)) as Chance,
COUNT(*) AS Spawns,
oct.entry as Creature,
oct.Name as `Creature Name`,
CAST(AVG(oc.SpawnTimeSecs) AS DECIMAL(6, 0)) AS `Spawn Time`
FROM (
SELECT i.*, COUNT(*) AS `Creature Types`
FROM (
SELECT iclt.item AS Item,