Skip to content

Instantly share code, notes, and snippets.

@jeremy-w
jeremy-w / demo.hs
Created February 10, 2014 01:18
Euterpea demo. Use this to verify your install is working. To install Euterpea under OS X, see: https://jeremywsherman.com/blog/2014/02/09/installing-and-using-euterpea-under-os-x-10-dot-9/
import Euterpea.Music.Note.Music
import Euterpea.IO.MIDI.ToMidi
-- Writes |test.mid| in the current directory.
main = test chord
where chord = foldl1 (:=:) $ map (note 1.0) pitches
pitches = [(Fs, o), (As, o), (Cs, o + 1), (Fs, o + 1)]
o = 6::Int

What Are OKRs?

Jeremy W. Sherman. January 2013.

OKR = Objectives & Key Results

  • 3-5 objectives, or high-level, measurable goals
  • 2-3 key results per objective, plus one "stretch" result.
  • Should not be able to achieve ALL goals/results; you need to stretch yourself.

7Geese

@jeremy-w
jeremy-w / bitmask.m
Last active August 29, 2015 13:57
Beware truncation when testing option bits or other bitmasks. Also: Why _Bool is better than BOOL.
//cc -Weverything -fobjc-arc -framework Foundation bitmask.m -o bitmask
/** @file bitmask.m
* @author Jeremy W. Sherman (@jeremy-w on Github)
* @license ISC (http://opensource.org/licenses/isc-license.txt)
*
* Provides an example where assignment of the result of a naive bitmask check
* to BOOL fails.
*
* Demonstrates 2 ways to avoid this issue.
*
@jeremy-w
jeremy-w / rot13.swift
Created August 4, 2014 21:36
Demonstrates rot13 in Swift with non-[A-Z][a-z] pass-through.
import Cocoa
var input = "This is a test"
var expected = "Guvf vf n grfg"
/// Advances `i` by `by` through `string`, wrapping to start on hitting
/// end.
/// NOTE: `by` must be non-negative.
func wrappingAdvance(string: String, i: String.Index, by: Int)
-> String.Index {

Keybase proof

I hereby claim:

  • I am jeremy-w on github.
  • I am jws (https://keybase.io/jws) on keybase.
  • I have a public key whose fingerprint is D160 F4D7 9492 A094 48ED F227 DF87 8DEB 3A74 C49F

To claim this, I am signing this object:

set-option -g prefix C-e
unbind-key C-e
bind-key C-e send-prefix
set-window-option -g mode-keys vi
# Fix weirdness with OS X bootstrap namespaces and daemon.
# See https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard for details.
set-option -g default-command "reattach-to-user-namespace -l zsh"
@jeremy-w
jeremy-w / RSLRandomValueObject.h
Created April 3, 2015 15:34
AppCode can generate all you need for a value object. Wow.
#import <Foundation/Foundation.h>
@interface RSLRandomValueObject : NSObject<NSCopying, NSCoding>
/* The @property bits are the only code I wrote. */
@property(copy) NSString *name;
@property NSNumber *someNumber;
@property BOOL supYo;
/* Everything else in here and the implementation file
* was generate by AppCode, either by the New File
import Data.Vect
import Data.Fin
-- Start by representing our universe as a product type.
data Ty = TyInt | TyBool | TyFun Ty Ty
interpret : Ty -> Type
interpret TyInt = Int
interpret TyBool = Bool
interpret (TyFun A T) = interpret A -> interpret T
@jeremy-w
jeremy-w / pipe.rs
Last active August 29, 2015 14:27
Implements Elixir's |> for Rust as pipe!.
/*
* Compile with:
* rustc -Z unstable-options --pretty expanded pipe.rs
*/
/* @file pipe.rs
* @author Jeremy W. Sherman (GitHub: @jeremy-w)
* @license ISC
*
* Implements and demonstrates use of the "pipe" (aka "thread-first") macro.
*/
@jeremy-w
jeremy-w / dispatch_after_example.m
Created June 3, 2011 18:43
Using `dispatch_after` to update UI regularly
// clang -framework Foundation dispatch_after_example.m -o dispatch_after_example
// Compiling with gcc requires separating declaration of b from assignment,
// but you can omit the -framework flag for GCC.
/* @author Jeremy W. Sherman
* @date 2011-06-03
*
* Demonstrates use of a recursive block to set up a repeating action
* using `dispatch_after()`.
* Assumes 10.6+ or iOS with GCD and blocks (whichever version that was).
*/