Skip to content

Instantly share code, notes, and snippets.

@amoslanka
amoslanka / README.md
Last active December 23, 2015 20:39 — forked from eric1234/README.md
@amoslanka
amoslanka / Berksfile
Last active September 9, 2016 19:59
StatsD/Graphite server on AWS/EC2 using Vagrant, Chef Solo, and Berkshelf
site :opscode
cookbook 'apt'
cookbook 'statsd', git: 'https://github.com/librato/statsd-cookbook.git'
cookbook 'graphite', git: 'https://github.com/hw-cookbooks/graphite.git'
@amoslanka
amoslanka / graphite_install.sh
Last active February 2, 2024 00:17
Install StatsD on an Ubuntu box, including creating an upstart service and the option to build a graphite box or configure Librato as a backend.
#
# Assumes an independent box (we'll call this one "graphite")
#
# Stay up to date
sudo apt-get update
sudo apt-get upgrade
# Install git
sudo apt-get install g++ curl libssl-dev -y
@amoslanka
amoslanka / .gitignore
Last active January 15, 2018 01:42
Simple session-stored auth on Node.js
*node_modules/
.DS_Store
@amoslanka
amoslanka / JSON Root Nodes.md
Last active December 19, 2018 09:27
JSON Root Nodes

Some json configurations will emit a single root node named after the object's type or an abstractable name for the object depending on context. This document outlines the differences and examples of both included and discluded root nodes in JSON responses.

Single Record Requests

Nodes of this type, for request GET foos will respond with this body:

{
  "foo": {
    "bar": "baz"

}

@amoslanka
amoslanka / Gemfile
Created December 13, 2012 21:19
Sprite Generation and Application in Rails
# etc ...
group :development do
# etc ...
# Sprites:
gem 'sprite-factory'
gem 'rmagick'
gem 'piet' # image optimization
end
// DEBUG Styles:
#time_of_day_debug {
position: fixed;
padding: .25em;
bottom: 0;
right: 0;
font-size: 10px;
> a {
display:block;
margin: .5em .5em .5em 1.1em;
@amoslanka
amoslanka / fail
Created October 25, 2012 21:33
ActiveResource 422 responses must send errors as full_messages
# If sent as normal errors:
# Response: {"errors": { "email": ["Email address is invalid","Email address can't be blank"]} }
>> NewsletterSubscriber.new(:email_address => "").save
ArgumentError: wrong number of arguments(2 for 1)
from /Users/amoslanka/.rvm/gems/ruby-1.9.3-p194/gems/activeresource-3.2.8/lib/active_resource/validations.rb:19:in `[]'
from /Users/amoslanka/.rvm/gems/ruby-1.9.3-p194/gems/activeresource-3.2.8/lib/active_resource/validations.rb:19:in `block (2 levels) in from_array'
from /Users/amoslanka/.rvm/gems/ruby-1.9.3-p194/gems/activeresource-3.2.8/lib/active_resource/validations.rb:18:in `each'
from /Users/amoslanka/.rvm/gems/ruby-1.9.3-p194/gems/activeresource-3.2.8/lib/active_resource/validations.rb:18:in `detect'
from /Users/amoslanka/.rvm/gems/ruby-1.9.3-p194/gems/activeresource-3.2.8/lib/active_resource/validations.rb:18:in `block in from_array'
PG::Error: ERROR: relation "chores" does not exist
LINE 4: WHERE a.attrelid = '"chores"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"chores"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
/Users/amoslanka/.rvm/gems/ruby-1.9.3-p194@jitb_cms/gems/activerecord-3.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `async_exec'
@amoslanka
amoslanka / struck-postgres.md
Created August 3, 2012 15:43
Postgres in Struck Development

Postgres in Struck Development

Installation

Option 1: Postgres.app (recommended):

http://postgresapp.com/

Option 2: Install it yourself: