Skip to content

Instantly share code, notes, and snippets.

View sleepynate's full-sized avatar

Nathan Dotz sleepynate

View GitHub Profile
@sleepynate
sleepynate / gist:2154978
Created March 22, 2012 01:15
backbone derp?
RedrawCheckbox = Backbone.View.extend({
el: '#redrawCheckbox',
events: {
'click' : 'checkState'
},
checkState: function() {
this.trigger('redrawOnMove', this.$el.is(':checked'));
}
});
@sleepynate
sleepynate / gist:2639407
Created May 8, 2012 21:21
spinning record view
public class Deck extends View {
// private static final String TAG = "Deck";
private Bitmap mRecordImage;
private RotateAnimation anim;
public Deck(Context context, AttributeSet attrs) {
super(context, attrs);
mRecordImage = BitmapFactory.decodeResource(getResources(),
@sleepynate
sleepynate / BYB OSCON 2012 Presentation.org
Created July 16, 2012 19:27
BYB OSCON 2012 Presentation

Backyard Brains

Neuroscience For Everyone!

Timothy Marzullo & Gregory Gage (Founders)

The Challenge

Can you listen to neurons for under $100?

The Spikerbox

World’s first consumer-grade neural amplifier

Schematics, parts list, and lessons are CC-BY-NC

99$

DIY Kit for 49$

@sleepynate
sleepynate / gist:3172614
Created July 24, 2012 20:56
problem23.hs
{-
- Problem 23
- Extract a given number of randomly selected elements from a list.
- Example:
- Prelude System.Random>rnd_select "abcdefgh" 3 >>= show
- "eda"
-}
pure_rnd_select :: [a] -> Int -> [a]
pure_rnd_select x y = unsafePerformIO $ rnd_select x y

Map git branches to each of your web service instances

When I have multiple server instances deployed from the same repo, I prefer to keep track of them with local branches, especially when using multiple clouds services like heroku and openshift. This makes it really easy to merge features branches into a particular instance's deploy without ever bringing it into master, but still allow the inclusion of those commits into other instances after it folds into master.

The usual feature-branching

So, I have master, which stays as the primary place to put new commits. I then split features branches off of master and then merged in when they are accepted.

% git checkout -b wicked-sweet-login-page
% vim static/teh_loginz.html
@sleepynate
sleepynate / rps.hs
Last active December 14, 2015 19:58
import Control.Monad
data Gesture = Rock | Paper | Scissors deriving (Eq, Show, Read)
instance Ord Gesture where
a `compare` b
| a == b = EQ
Rock `compare` Scissors = GT
Paper `compare` Rock = GT
Scissors `compare` Paper = GT
@sleepynate
sleepynate / androids_under_the_stairs.md
Last active November 8, 2016 12:08
Androids Under the Stairs: Mobile Scala

Blurb

Scala is a sometimes-intimidating programming language that is Object-Oriented, functional, statically typed and wicked badass. It comes batteries-included, featuring a rich collections API, Type inference, and dead-simple concurrency. Perhaps most poignantly though, it's also a 30MB JVM library that can compile to dalvik.

Come take a heads first dive into crafting an APK with glorious, nutritionally

[error] app/models/Job.scala:22: ambiguous implicit values:
[error] both object IntReads in trait DefaultReads of type play.api.libs.json.Reads.IntReads.type
[error] and object LongReads in trait DefaultReads of type play.api.libs.json.Reads.LongReads.type
[error] match expected type play.api.libs.json.Reads[T]
[error] case Some(bs) => bs.map(Json.fromJson(_))
# == WHAT
# Simple script for irssi to trigger Mac OS X 10.8's Notification Center
#
# == WHO
# Patrick Kontschak 2012
#
# Forked from Nate Murray's irssi-growl: https://github.com/jashmenn/irssi-growl
#
# == CONFIG
# /SET notifier_on_regex [regex]
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org
mQINBFVshvUBEADE3XJLjYAQhAXRhUd3/ghzBqWEQ+gvGWLlQP14A7W6gcvu8h/n
abeyswyl1fSSYZt73H6CvdO0EcMcD2m4V1FpxAgkrQoAc+XfZetLprxNqfiqfOE+
STTK0XueKlr1o/g5yBzQm2qnkaRA4Tk4yjps+xP4qy/F30/eR5/CnFyCRcf1Uc0/
RQucePtLxuOr5UGju64mdqHcukOu6m7aNJ7m5w9lHJrR2JHYLcXp0KxHx2KpOBrX
yHzEK8TtJ14XfBf9F+AbigaIMc+NJ5trKtbudHsA6FlUSDAvrrbNAlSFQmKnanNh
rjNJCo0E+00xKGWdZNSzGomDxB0MRvwep8RzXgqK2wLxIEY5XKWo+YGcfl2W6tAs
SVuJHPizUop8xqt+iAFfWmbKM57DXps/CTozB04jSVmKCHe1wfUbEtdv6wswRTEB