Skip to content

Instantly share code, notes, and snippets.

class WebSocketHandler(tornado.websocket.WebSocketHandler):
_PING_INTERVAL = 3.0
_DISCONNECT_TIMEOUT = 10.0
connections = set()
button = Button()
def open(self):
self.id = self.get_argument("id")
WebSocketHandler.connections.add(self)
package main
import "github.com/go-martini/martini"
func main() {
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()
-- +goose Up
CREATE TABLE photos (
id uuid primary key default uuid_generate_v4() NOT NULL,
reel_id uuid NOT NULL REFERENCES reels(id),
path text NOT NULL,
thumbnail text,
bytes bigint NOT NULL,
rev text NOT NULL,
exif text,
cleaned boolean NOT NULL default false,
package controllers
import (
"net/http"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/martini-contrib/render"
. "github.com/madebymany/riru/models"
package models
import (
"time"
)
type Reel struct {
ID string `json:"id"`
Name string `json:"name"`
Folder string `json:"folder"`
-- +goose Up
CREATE TABLE reels (
id uuid primary key default uuid_generate_v4() NOT NULL,
name text NOT NULL,
folder text NOT NULL,
auth_provider_id uuid NOT NULL REFERENCES auth_providers(id),
owner_id uuid NOT NULL REFERENCES users(id),
updated_at timestamp NOT NULL default now(),
created_at timestamp NOT NULL default now()
package controllers
import (
"encoding/json"
"io"
"net/http"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/jrallison/go-workers"
package app
import (
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/kylelemons/go-gypsy/yaml"
_ "github.com/lib/pq"
"github.com/martini-contrib/render"
"github.com/martini-contrib/secure"
"github.com/martini-contrib/sessions"
func AuthenticateUser(session sessions.Session, db gorm.DB, c martini.Context, r render.Render) {
user := FetchUser(session, db)
if user.ID != "" {
c.Map(user)
return
}
r.Error(http.StatusUnauthorized)
}
run:
goose -env=development up
go run main.go
resetdb:
dropdb riru-dev
createdb riru-dev
goose up
test: