Skip to content

Instantly share code, notes, and snippets.

@scan
scan / .gitignore
Created September 28, 2012 09:27
Javascript to read an image and then cut it into tiles
node_modules/
*.sw*
@scan
scan / Model.rb
Created October 6, 2012 20:54
Get All By Week
class Model < ActiveRecord::Base
attr_accessible :date
def self.find_by_week(week, year)
dates = Date.commercial(year,week)..Date.commercial(year,week+1)
Model.where :date => dates.take(7)
end
end
# encoding: utf-8
def words = %w[Berg Hügel Tal Ebene]
@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 / ControlV.cabal
Created October 29, 2012 13:31
ControlV by Stepcut
Name: ControlV
Version: 0.1
Synopsis: yet another pasteboard
Description: A demo pasteboard intended to show off happstack-foundation
Homepage: http://www.happstack.com/
License: BSD3
License-file: LICENSE
Author: Jeremy Shaw
Maintainer: [email protected]
Category: Happstack
@scan
scan / vbo.hs
Created November 2, 2012 22:41
vboOfList :: Int -> [Float] -> IO BufferObject
vboOfList size elems =
let ptrsize = toEnum $ size * 4
arrayType = ElementArrayBuffer
in do
[array] <- genObjectNames 1
bindBuffer arrayType $= Just array
arr <- newListArray (0, size - 1) elems
withStorableArray arr (\ptr -> bufferData arrayType $= (ptrsize, ptr, StaticDraw))
bindBuffer ArrayBuffer $= Nothing
CREATE TRIGGER updated AFTER UPDATE ON users
FOR EACH ROW BEGIN
UPDATE users SET `updated`=CURRENT_TIMESTAMP WHERE id=NEW.id;
END;
<?php
class Application_Form_NewUser extends Twitter_Bootstrap_Form_Horizontal
{
public function init()
{
$this->setMethod('post');
$this->setName('newUserForm');
$this->addElement('text', 'email', array(
@scan
scan / app.js
Last active December 10, 2015 05:58
app.configure(functon() {
app.use(express.cookieParser());
app.use(express.session({secret: 'Fluttershy is best Pony'}));
var passport = require('passport');
app.use(passport.initialize());
app.use(passport.session());
});
@scan
scan / auth.js
Last active December 10, 2015 05:58
var passport = require('passport'),
TwitterStrategy = require('passport-twitter').Strategy,
GoogleStrategy = require('passport-google-oauth').Strategy,
users = require('./model').users;
/*
This is for serializing a user object.
Basically, it should return all of an user object
that is necessary to identify it. Usually, the id
field will do just fine.