Skip to content

Instantly share code, notes, and snippets.

View pr1001's full-sized avatar

Peter Robinett pr1001

View GitHub Profile
@tj
tj / stack.js
Created November 5, 2010 10:14
var error = new Error;
Object.defineProperty(global, '__stack', {
get: function(){
Error.prepareStackTrace = function(err, frames){
err.frames = frames;
};
try {
throw error;
} catch (err) {
@fgnass
fgnass / LICENSE.txt
Created May 30, 2011 13:33 — forked from 140bytes/LICENSE.txt
display a loading spinner
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Felix Gnass <https://github.com/fgnass>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@kevinwright
kevinwright / PimpMyFilter.scala
Created October 4, 2011 22:11
Pimpin' + on a T => Either[ERR,T] for easy chaining
class Filters[T] {
//Some boilerplate-busting aliases
type FilterResult = Either[Rejection, T]
type FilterFunc = (T) => FilterResult
//Handy helpers
//Rejection can carry as much info as you wish;
// Filter name, value in error, an exception, etc.
case class Rejection(input: T, msg: String)
@louisremi
louisremi / LICENSE.txt
Created October 27, 2011 09:12 — forked from 140bytes/LICENSE.txt
c, an expressive className manipulation lib: c( elem, 'has/add/remove/toggle', class_name )
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 @louis_remi <http://louisremi.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@roidrage
roidrage / ebooks.md
Created December 2, 2011 15:15
Self-published and awesome
anonymous
anonymous / gist:2989822
Created June 25, 2012 16:49
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
@retronym
retronym / scala-hash.sh
Created September 17, 2012 21:54
scala-hash
#! /bin/bash
set -e
SCALA_DEV=~/code/scala
HASH=`git --git-dir $SCALA_DEV/.git rev-list "$1" | head -n1`
DESC=`git --git-dir $SCALA_DEV/.git describe $HASH`
shift
DIR=~/usr/scala-$DESC
SCALA=$DIR/pack/bin/scala
@wspringer
wspringer / gist:1649700
Created January 20, 2012 21:28
LZW Encoding *and Decoding* in Scala
object lzw {
trait Appendable[T] {
def append(value: T)
}
import scala.collection.generic._
case class GrowingAppendable[T](growable: Growable[T]) extends Appendable[T] {
def append(value: T) {
growable += value
@wboykinm
wboykinm / mask.mss
Last active December 11, 2015 17:58
Country-specific masking in CartoCSS
Map {
/*background-color: #b8dee6;*/
}
#countries[ADMIN='Nicaragua'] {
polygon-fill:#abd69b;
line-color:#754098;
polygon-opacity:0;
line-width:6;
line-opacity:0.8;
@acwright
acwright / gist:1535473
Created December 29, 2011 18:34
Create dynamic date predicate using now() function
// The goal...
[NSPredicate predicateWithFormat:@"dateModified >= CAST(CAST(now(), \"NSNumber\") - %d, \"NSDate\")", (30*86400)];
//"now()" is a function and takes no arguments
NSExpression *now = [NSExpression expressionForFunction:@"now" arguments:[NSArray array]];
//CAST(now(), 'NSNumber')
NSArray *castNowArguments = [NSArray arrayWithObjects:now, [NSExpression expressionForConstantValue:@"NSNumber"], nil];
NSExpression *castNow = [NSExpression expressionForFunction:@"castObject:toType:" arguments:castNowArguments];