Skip to content

Instantly share code, notes, and snippets.

View app.ts
app.get(function(req, res) => {
post.findById(req.params.postId) {
res.json(post);
}
});
app.get( "/posts/:postId", ( req: any, res ) => {
post.findById(req.params.postId) {
res.json(post);
}
@hoguej
hoguej / gist:dc09550137b71ba698b7
Created Dec 30, 2014
example pundit policy file
View gist:dc09550137b71ba698b7
class MessagePolicy < ApplicationPolicy
def create?
return true if user.admin?
user.rooms.inlcude?(record.room)
end
def show?
return true if user.admin?
user.rooms.inlcude?(record.room)
end
View Controller_LightboxShow.pm
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.
# 'http://www.jonathan.dev.shutterstock.com/login.mhtml?landing_page=%2Flightboxes%2F%3Alightbox_id'
# 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.
1..1
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 }
end
View gist:5718646
class Array
def pieces( count )
indexes = self.piece_indexes( count )
indexes.map{ |index| self[*index] }
end
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
message_type=ORDER_CREATED&message_description=New%20order%20created&timestamp=2011-12-30%2014%3a20%3a18&message_id=8573&vendor_id=1637811&invoice_id=4601636788&recurring=0&invoice_status=pending&invoice_list_amount=84.00&invoice_usd_amount=84.00&invoice_cust_amount=84.00&auth_exp=2012-01-05&list_currency=USD&cust_currency=USD&payment_type=paypal%20ec&sale_id=4601636779&sale_date_placed=2011-12-29%2011%3a06%3a12&customer_ip=115.132.61.12&customer_ip_country=Malaysia&customer_first_name=Maryam&customer_last_name=Bello&customer_name=Maryam%20%20Bello&customer_email=maryamsecured%40yahoo.com&customer_phone=0142601872&ship_status=shipped&ship_name=&ship_street_address=&ship_city=&ship_state=&ship_postal_code=&bill_street_address=statiestraat%2028&bill_city=Nijlen&bill_state=XX&bill_postal_code=2560&bill_country=BEL&item_count=0&md5_hash=DE5F23CC881E0370A9EFF9EA3A8AF849&key_count=44
@hoguej
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 ]