Skip to content

Instantly share code, notes, and snippets.

View app.ts
app.get(function(req, res) => {
post.findById(req.params.postId) {
app.get( "/posts/:postId", ( req: any, res ) => {
post.findById(req.params.postId) {
hoguej / gist:dc09550137b71ba698b7
Created Dec 30, 2014
example pundit policy file
View gist:dc09550137b71ba698b7
class MessagePolicy < ApplicationPolicy
def create?
return true if user.admin?
def show?
return true if user.admin?
package Shutterstock::WWW::Controller::LightboxShow;
use Moose;
extends 'Shutterstock::WWW::Controller::Base';
with 'Shutterstock::WWW::Controller::Role::CheckMasonAutologout';
with 'Shutterstock::WWW::Controller::Role::Dispatcher';
with 'Shutterstock::WWW::Controller::Role::EnsureMasonLogin';
with 'Shutterstock::WWW::Controller::Role::GlobalPageData';
with 'Shutterstock::WWW::Controller::Role::Impersonator';
use Shutterstock::WWW::Model::Service::Customer::Lightbox;
View gist:7090634
# Failed test 'get: got expected redirect url'
# at t/unit/lib/Shutterstock/WWW/Controller/LightboxShow/basic.t line 40.
# ''
# doesn't match '(?^:\/login\.mhtml\?landing_page\=\/lightboxes\/12345$)'
# Looks like you failed 1 test of 1.
not ok 3 - Ensure that dancer redirects to mason login if no logged in user is found in session
# Failed test 'Ensure that dancer redirects to mason login if no logged in user is found in session'
# at t/unit/lib/Shutterstock/WWW/Controller/LightboxShow/basic.t line 42.
View gist:5724406
equire 'celluloid'
require 'date'
require 'pieces'
class Summer
include Celluloid
attr_reader :result, :status
def initialize
View gist:5719075
require 'parallel'
require 'date'
require './pieces' # adds pieces function to Array objects
@things = []
100_000.times do |i|
@things << { name: i.to_s, value: i }
View gist:5718646
class Array
def pieces( count )
indexes = self.piece_indexes( count ){ |index| self[*index] }
def piece_indexes( pieces_count )
chunk_size = self.size / pieces_count
chunk_size = 1 if chunk_size < 1
View A sinatra block
post '/play_list/?' do
puts params.inspect
id = very_clean( params[:_id] )
# validations
raise "Id cannot be blank" if id.nil?
raise "Id cannot be blank" if id.empty?
raise "Id must be a String" unless id.is_a? String
raise "That play list already exists" if find_play_list( id )
View gist:1555311
hoguej / User.rb
Created Oct 2, 2011 — forked from isaacsanders/User.rb
For Jon Hogue
View User.rb
class User
include ReUser
roles do
role :god, :actions => [ :manage_all, :new_user_session, :destroy_user_session ]
role :registrant, :read_event
role :observer, :read_event
role :admin, :manage_event
mail_actions = [ :show_user, :read_todo, :box_mail, :show_mail ]