Skip to content

Instantly share code, notes, and snippets.

View rjregenold's full-sized avatar

RJ Regenold rjregenold

  • Provider Science
  • Texas
View GitHub Profile
sealed trait KeyValueStore[+A] {
def map[B](f: A => B): KeyValueStore[B] =
this match {
case Put(k, v, q) => Put(k, v, f compose q)
case Get(k, q) => Get(k, f compose q)
case Del(k, q) => Del(k, f compose q)
}
}
case class Put[A](k: String, v: String, q: Option[String] => A) extends KeyValueStore[A]
case class Get[A](k: String, q: Option[String] => A) extends KeyValueStore[A]
@mpilquist
mpilquist / gist:3428731
Created August 22, 2012 19:46
Example of trampolining iteratees with scalaz 7
import scalaz._
import Scalaz._
import scalaz.iteratee._
import EnumeratorT._
def counter[A, F[+_]: Pointed] =
IterateeT.fold[A, F, Int](0) { (acc: Int, a: A) => acc + 1 }
def count[A, F[+_]: Monad](e: EnumeratorT[A, F]) =
(counter[A, F] &= e).run
@guillaumebort
guillaumebort / 1.sql
Created May 25, 2012 15:17
Play 2.0/Anorm
# --- !Ups
CREATE TABLE users(
email VARCHAR(255) NOT NULL PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE subjects(
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
title LONGTEXT NOT NULL,
@nebiros
nebiros / Gemfile
Created May 23, 2012 15:58
rails + unicorn + rbenv + init.d daemon
group :production do
gem "unicorn"
end
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@mpilquist
mpilquist / RWS.scala
Created April 12, 2012 01:41
Initial attempt at using Tony Morris's ReaderWriterStateT monad transformer (see https://gist.github.com/2360532)
object RWS extends App {
trait Pointed[P[_]] {
def point[A](a: A): P[A]
}
trait PointedFunctor[PF[_]] extends Pointed[PF] with Functor[PF]
implicit def listIsMonoid[A]: Monoid[List[A]] = new Monoid[List[A]] {
def id: List[A] = Nil
@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@fwenzel
fwenzel / lion-virtualenv.sh
Created July 21, 2011 17:42
Recreating virtualenvs after upgrading to OS X Lion.
# Upgrade to OS X Lion, notice your virtualenvs are all hosed.
# Install Xcode 4.1 from the app store (or //fs2/IT/Apple/).
# Make sure to actually *run* the install, it's an app inside Applications. Throw it away afterwards, if you want the space back.
sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper ipython
# blow the old one(s) away
rmvirtualenv playdoh
@kwhinnery
kwhinnery / Person.js
Created July 19, 2011 22:52
Monkey patch for require in Titanium Mobile
exports.Person = function(firstName,lastName) {
this.firstName = firstName;
this.lastName = lastName;
};