I hereby claim:
- I am mattknox on github.
- I am mattknox (https://keybase.io/mattknox) on keybase.
- I have a public key whose fingerprint is DB08 CCF5 5322 B554 384C 8206 F755 6801 897B 2779
To claim this, I am signing this object:
#! /usr/bin/env ruby | |
# if run inside a git repo, this will pull current master and force remove all branches that have no diff against master. | |
# this is useful if you use squash-merge- or rebase-based merge strategies, and does not require anything particular of the | |
# developer to use. | |
in_repo = system("git status") | |
unless in_repo | |
puts "run this from inside a git repo" | |
exit 1 |
I hereby claim:
To claim this, I am signing this object:
This are my cheat sheets that I have compiled over the years. Tired of searching Google for the same things, I started adding the information here. As time went on, this list has grown. I use this almost everyday and this Gist is the first bookmark on my list for quick and easy access.
I recommend that you compile your own list of cheat sheets as typing out the commands has been super helpful in allowing me to retain the information longer.
// candidate syntax for a go-like language with less boilerplate around error return | |
func doStuff() (string, error) { | |
var err error | |
returnOn err, func() { return nil, err } // return the result of calling func if variable is ever non-nil | |
thing1, err := possiblyFailingCall() | |
thing2, err := possiblyFailingCall(thing1) | |
thing3, err := possiblyFailingCall(thing2) | |
thing4, err := possiblyFailingCall(thing3) | |
return thing4, err |
When judging statements by an unknown actor, I tend to evaluate such statements by the cost of making them. So if I work for a company that says they value me, that's nice, but it's cheap (~free!) to say and therefore unpersuasive. If they just bought my company/gave me a bunch of equity/took other expensive action, I would attach more weight to what they said. | |
So, you don't trust a16z's statements about whether we're in a bubble, presumably because he has an interest in the outcome. I do trust that he thinks we are not in a bubble, because he continues to invest his and others' money at current valuations. It's moderately expensive in reputation and monetary risk for him to do so, so I trust somewhat that he believes as he says he does. | |
The other metric I use for evaluating trustworthiness is how much value someone would derive by me believing what they say. By this metric, a16z has something to gain by people believing we are not in a bubble-they have holdings in a bunch of public companies, includin |
OPERATORS = %w{ + - * / } | |
def tokenize(s) | |
s.split.map do |x| | |
if OPERATORS.member? x | |
x.to_sym | |
else | |
x.to_i | |
end | |
end |
# Ever get tired of people messing with your ruby classes? | |
# now you can put the hammer down and stop them. Just | |
# include this module and no one will be able to modify the | |
# class implementation or any instance implementations. | |
module Stop | |
module CantTouchThis | |
def self.included(mod) |
def str_to_letter_hash(str) | |
str.downcase.gsub(/[^a-z]/, "").split("").sort.inject(Hash.new(0)) {|m, x| m[x] += 1; m } | |
end | |
def anagrams?(s1, s2) | |
str_to_letter_hash(s1) == str_to_letter_hash(s2) | |
end | |
anagrams? "Mitt Romney and Paul Ryan", "My ultimate Ayn Rand Porn" | |
=> true |
(ns sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) | |
(defn init [vars hints] |
require "rubygems" | |
require "rbench" | |
require "set" | |
RANGE = (1..1000) | |
ARRAY = RANGE.to_a | |
SET = Set.new(ARRAY) | |
HASH = ARRAY.inject({}) {|m, x| m[x] = true; m} | |
WORST_CASE_COMPLEXITY = ARRAY.size + 1 |