Skip to content

Instantly share code, notes, and snippets.

class GoogleAnalytics
@init: (webPropertyId) ->
@_initQueue(webPropertyId)
scriptTag = @_createScriptTag()
@_injectScriptTag(scriptTag)
@_initQueue: (webPropertyId) ->
window._gaq ?= []
window._gaq.push ['_setAccount', webPropertyId]
window._gaq.push ['_trackPageview']
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},
@scan
scan / .htaccess
Created October 17, 2012 09:44 — forked from dennisreimann/.htaccess
Uberspace htaccess for Rails apps
RewriteEngine On
RewriteBase /
# ensure the browser supports gzip encoding
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]
# ensure correct Content-Type and add encoding header
<FilesMatch \.css\.gz$>
@scan
scan / database.yml.example mysql2
Created September 25, 2012 09:07 — forked from erichurst/database.yml.example mysql2
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@scan
scan / app.hs
Created July 28, 2012 18:40
app.hs
application :: MVar ServerState -> WS.Request -> WS.WebSockets WS.Hybi10 ()
application state rq = do
WS.acceptRequest rq
WS.getVersion >>= liftIO . putStrLn . ("Client version: " ++)
sink <- WS.getSink
msg <- WS.receiveData
clients <- liftIO $ readMVar state
url <- liftIO fbUrl
let prefix = "Facebook code "
@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.
@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.
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"]
@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