Skip to content

Instantly share code, notes, and snippets.

View arbarlow's full-sized avatar

Alex Barlow arbarlow

  • UK
  • 00:11 (UTC +01:00)
View GitHub Profile
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)
}
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"
package controllers
import (
"encoding/json"
"io"
"net/http"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/jrallison/go-workers"
-- +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 models
import (
"time"
)
type Reel struct {
ID string `json:"id"`
Name string `json:"name"`
Folder string `json:"folder"`
package controllers
import (
"net/http"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/martini-contrib/render"
. "github.com/madebymany/riru/models"
-- +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 main
import "github.com/go-martini/martini"
func main() {
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()
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 (
"fmt"
"net/http"
"os"
"strings"
"strconv"
"github.com/Terry-Mao/paint"
"github.com/Terry-Mao/paint/wand"