Skip to content

Instantly share code, notes, and snippets.

@scan
scan / MultiChat.scala
Created January 4, 2012 23:08 — forked from tjweir/MultiChat.scala
Multi-room Chat server / client with Lift
package myproject.comet
import net.liftweb._
import actor.LiftActor
import common.{Full, Empty, Box}
import http._
import js.JE._
import js.JE.JsArray._
import js.JE.JsRaw._
import js.JsCmds._
@scan
scan / Main.hs
Created January 10, 2012 07:30 — forked from biilmann/Main.hs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.Trans
import Network.Wai.Handler.Warp (run)
import Network.Wai
import Network.HTTP.Types (statusOK)
import Data.Enumerator ((>>==), ($$))
import qualified Data.Enumerator as E
@scan
scan / Settings.hs
Created February 27, 2012 09:32
Settings for coffee and lucius only.
-- | Settings are centralized, as much as possible, into this file. This
-- includes database connection settings, static file locations, etc.
-- In addition, you can configure a number of different aspects of Yesod
-- by overriding methods in the Yesod typeclass. That instance is
-- declared in the Foundation.hs file.
module Settings
( widgetFile
, PersistConfig
, staticRoot
, staticDir
@scan
scan / Cakefile
Created March 2, 2012 14:02
Cakefile for .coffee -> .julius
fs = require 'fs'
coffee = require 'coffee-script'
option '-f', '--folder [DIR]', 'template directory'
task 'build:all', 'compile all coffee files', (options) ->
dir = options.output or './templates'
console.log "Reading #{dir}"
fs.readdir dir, (err, files) ->
if err? then console.error err else
@scan
scan / coffeemaker
Created March 11, 2012 09:04 — forked from gsklee/coffeemaker
Carefree CoffeeScript Auto-compiler
#!/bin/bash
#
# --------------------------------------------------------------------------------------
# http://blog.gantrithor.com/post/12535461464/carefree-coffeescript-auto-compiler-part-3
# --------------------------------------------------------------------------------------
DIR_ROOT="$(cd "$(dirname "$0")" && pwd)"
function compile_tree() {
find "$1" -name "*.coffee" -type f | while read PATH_COFFEE; do
module Main where
import Data.List
main = interact epicWin
epicWin :: String -> String
epicWin s = let x :: Integer
x = read (head (lines s))
in (show $ div (getTotal (tail (lines s))) x) ++ "\n"
@scan
scan / deviantart-strategy.coffee
Created April 4, 2012 16:55
Deviantart Strategy for Passport
til = require('util')
OAuth2Strategy = require('passport-oauth').OAuth2Strategy
class Strategy extends OAuth2Strategy
constructor: (options = {}, verify) ->
options.authorizationURL or= 'https://www.deviantart.com/oauth2/draft15/authorize'
options.tokenURL or= 'https://www.deviantart.com/oauth2/draft15/token'
OAuth2Strategy.call this, options, verify
@name = 'deviantart'
getSid = do
msid <- optional $ lookCookieValue "ponysession"
case msid of
Nothing -> do
sid <- genSessionId
addCookie Session $ mkCookie "ponysession" $ B.unpack sid
return sid
Just sid -> return $ B.pack sid
{-
@scan
scan / MongoDB.hs
Created April 9, 2012 22:25 — forked from mightybyte/MongoDB.hs
Snap.Snaplet.Auth.Backends.MongoDB
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Snap.Snaplet.Auth.Backends.MongoDB
( initMongoAuth
) where
------------------------------------------------------------------------------
import Control.Arrow
module Jade where
import Text.Parsec
import qualified Text.Parsec.Token as L
import Text.Parsec.Language (emptyDef)
import Text.Parsec.Text (Parser)
import Data.Text (Text)
import Control.Monad (mzero)
import Control.Applicative ((<$>))
import Data.Maybe (isJust, fromMaybe)