Skip to content

Instantly share code, notes, and snippets.

View ecordell's full-sized avatar

Evan Cordell ecordell

  • authzed
  • New York
View GitHub Profile
@ecordell
ecordell / machine.js
Created April 1, 2021 21:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ecordell
ecordell / test
Created March 2, 2016 15:47
Wrapper script for Dredd
#!/usr/bin/env bash
set -e
export BASE_URL=${BASE_URL:-http://example.com}
babel hooks --out-dir compiled-hooks --source-maps inline
# Handle passing in specific file patterns
if [[ $# == 0 ]] || [[ $1 == -* ]]; then

Keybase proof

I hereby claim:

  • I am ecordell on github.
  • I am ecordell (https://keybase.io/ecordell) on keybase.
  • I have a public key whose fingerprint is 9ECB B4A7 D86D 628C C643 4131 4630 B401 B328 E6FD

To claim this, I am signing this object:

class AddCitierViewsToLandscape < ActiveRecord::Migration
def self.up
remove_column :landscapes, :created_at
remove_column :landscapes, :updated_at
rename_column(:photos, :inheritance_column_name, :type)
create_citier_view(Landscape)
end
def self.down
add_column :landscapes, :updated_at, :timestamp
Started POST "/landscapes" for 127.0.0.1 at 2011-07-22 11:07:18 -0500
Processing by LandscapesController#create as JSON
Parameters: {"landscape"=>{"id"=>0, "name"=>"Newscape", "city"=>"Fun city", "state"=>"LA", "zip"=>"71457", "images_attributes"=>[{"id"=>0, "image_data"=>"Im a bunch of image data image data image data", "is_thumbnail"=>1}], "address1"=>"Cool place"}}
SQL (61.9ms) SHOW TABLES[
Image Load (0.3ms) SELECT `images`.* FROM `images` WHERE `images`.`id` IN (0) AND (`images`.imageable_id = 0 AND `images`.imageable_type = 'Landscape')
Completed in 242ms
ActiveRecord::RecordNotFound (Couldn't find Image with ID=0 for Landscape with ID=0):
app/controllers/landscapes_controller.rb:44:in `new'
app/controllers/landscapes_controller.rb:44:in `create'
class ImagesController < ApplicationController
# GET /images
# GET /images.json
def index
@imageable = find_imageable
@images = @imageable.images
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @images }
end
class Subscription < Base
def self.find_by_customer_reference(reference)
customer = Customer.find_by_reference(reference)
find(:first, :params => {:customer_id => customer.id})
end
# Strip off nested attributes of associations before saving, or type-mismatch errors will occur
def save
self.attributes.delete('customer')
self.attributes.delete('product')
@ecordell
ecordell / encrypted_caveats.py
Last active August 29, 2015 14:19
Encrypted first party caveats
from pymacaroons import Macaroon, Verifier
from pymacaroons.field_encryptors import SecretBoxEncryptor
# Create a macaroon
m = Macaroon(
location='http://mybank/',
identifier='we used our secret key',
key='this is our super secret key; only we should know it'
)