Skip to content

Instantly share code, notes, and snippets.

require 'redis'
# SADD key, member
# Adds the specified <i>member</i> to the set stored at <i>key</i>.
redis = Redis.new
redis.sadd 'my_set', 'foo' # => true
redis.sadd 'my_set', 'bar' # => true
redis.sadd 'my_set', 'bar' # => false
redis.smembers 'my_set' # => ["foo", "bar"]
db.foo.insert({ 'created at': new Date(), ooc: false, nsfw: false, body: '<p>Moo</p>\n', keywords: [ 'Moo' ], mentioned: [], tags: [], sender: { id: 'stuff', name: 'lambdadusk', 'display name': 'Lambda' } })
name: textr
version: 0.0.0
build-type: Simple
cabal-version: >=1.6
executable textr
main-is: Main.hs
build-depends: base, text, bytestring, happstack-server, ixset, acid-state, safecopy, aeson
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Happstack.Server
import Data.Text (Text)
main :: IO ()
main = simpleHTTP nullConf $ ok ("{\"hello\": \"world\"}" :: Text)
@scan
scan / mapgen.hs
Created June 5, 2012 13:21 — forked from splinterofchaos/mapgen.hs
A simple roguelike map generator. Uses naiive splatter pattern to create rooms.
import System.Random
import System.Console.GetOpt
import System.Environment(getArgs, getProgName)
type Coord = (Int,Int)
type Range = (Int,Int)
type Area = (Coord,Coord) -- Upper-left and lower-right bounds.
@scan
scan / mapgen.hs
Created June 7, 2012 09:55 — forked from splinterofchaos/mapgen.hs
A simple roguelike map generator. Uses naiive splatter pattern to create rooms.
import System.Random
import System.Console.GetOpt
import System.Environment(getArgs, getProgName)
type Coord = (Int,Int)
type Range = (Int,Int)
type Area = (Coord,Coord) -- Upper-left and lower-right bounds.
{-# LANGUAGE Arrows #-}
module Main where
import Control.Arrow
import Control.Monad
import Data.Maybe
import Data.Monoid
import Data.VectorSpace
import Graphics.UI.GLUT
{-# LANGUAGE Arrows #-}
module Tile where
import Control.Arrow
import Control.Monad (void)
import FRP.Yampa
import Graphics.UI.SDL (Rect(..), blitSurface, Surface)
data Tile = Tile !Rect Bool
| AnimatedTile ![Rect] Bool
{-# LANGUAGE GADTs #-}
module LenList where
data Zero
data Succ n
data LenList n a where
Nil :: LenList Zero a
Cons :: a -> LenList n a -> LenList (Succ n) a
abstract class InterpolationMethod(val s: Traversable[(Double, Double)]) extends (Double => Double) {
protected val x_i = s.map(_._1)
protected val y_i = s.map(_._2)
def this(f: Double => Double, f2: Int => Double, n: Int) = this(for(i <- 0 to n) yield {
val x = f2(i)
(x, f(x))
})
def this(f: Double => Double, n: Int) = this(f, _.toDouble, n)