Skip to content

Instantly share code, notes, and snippets.

View jbarnette's full-sized avatar

John Barnette jbarnette

View GitHub Profile
@jbarnette
jbarnette / 0-shell.txt
Last active January 24, 2024 19:52
hype http block example (amd64)
$ go install github.com/c35s/hype@latest
# it'll take a few seconds to show the shell
$ hype -kernel https://cdn.c35s.co/bzImage-amd64 \
-block https://cdn.c35s.co/ubuntu-amd64.squashfs \
-cmdline "console=hvc0 reboot=t root=/dev/vda init=/bin/sh"
@discardableResult func cons(_ x: Any, _ y: Any) -> (((Any, Any) -> Any) -> Any) {
return { m in m(x, y) }
}
@discardableResult func car(_ z: (((Any, Any) -> Any) -> Any)) -> Any {
return z { p, q in p }
}
@discardableResult func cdr(_ z: (((Any, Any) -> Any) -> Any)) -> Any {
return z { p, q in q }
@jbarnette
jbarnette / gd.sh
Last active January 4, 2016 12:09
cd to any repo, cloning if necessary
function gd {
local parent=$(dirname "$1")
local name=$(basename "$1")
local owner=$(basename "$parent")
local nwo="$owner/$name"
local dir="$HOME/src/$nwo"
[ -d "$dir" ] || git clone "https://github.com/$nwo" "$dir"
cd "$dir"

On Hats and the Wearing Thereof

Jargon and Connotation

Authority and Responsibility

Failure and Prohibition

Hiring and Consequences

A daily glance at what's happening in a high velocity codebase, thanks to @defunkt:

https://github.com/your/repo/compare/master@{yesterday}...master

Bookmark, share, and enjoy.

#ifndef __ID_H
#define __ID_H
struct __closure
{
_imp_t method;
oop data;
};
struct __lookup
@jbarnette
jbarnette / stupid.rb
Created March 22, 2012 15:57
Incredibly stupid Ruby tricks. Please add more.
# The worst possible way to memoize something.
class X
def value
@value = really_expensive_operation
def value; @value end
@value
end
end
module Watchable
def events
@events ||= Hash.new { |h,k| h[k] = [] }
end
def fire event, *args
events[event].each { |e| e[*args] }
end
def on event, &block
class ActiveRecord::Base
attr_accessible nil
def update_attributes *args
raise "Don't call #{self.class.name}#update_attributes. " +
"Mass assignment is pure evil."
end
end
require "overlord/searchable"
module Overlord
# Mark an ActiveRecord model as having a state machine. Requires a
# string attribute called `state`. To set the default state for a
# class, set a default column value for `state` in the database.
#
# Use Symbols for all keys and values in state definitions.