Skip to content

Instantly share code, notes, and snippets.

View lazypower's full-sized avatar
💭
Bring back independent blogs, rss feeds, and the small web.

Charles "Chuck" Butler lazypower

💭
Bring back independent blogs, rss feeds, and the small web.
View GitHub Profile
@lazypower
lazypower / call_dumper_archive.rb
Created September 12, 2012 06:34
Call Center Recording Dump - Push to S3
#!/usr/bin/env ruby
#Utility to perform routine backups for CallCenter Recordings
require 'rubygems'
require 'aws/s3'
#Parent of directory tree for recordings
directory = ARGV.shift
#We're shipping the output to S3, so we need to define creds
# Methods bound to Step1 dialog
stepone_submit = ->
$("#stepone").dialog "destroy"
$("#steptwo").dialog
title: "Refine Search"
resizable: false
height: 500
width: 400
modal: true
closeOnEscape: false
@lazypower
lazypower / readme.md
Created October 10, 2012 15:36
Deploy your website using git hooks instead of ssh

server-side:

  • navigate to your user folder /home/username/
  • create a folder for your repo. 'repo'
  • create a folder inside of your repo. call it whatever. 'test'
  • cd into folder.
  • git init --bare

local:

  • navigate to local repo
@lazypower
lazypower / job.rb
Created October 11, 2012 18:18
Sanitizer script
require 'mongoid'
#`Job` _Job Model_ bound to the mongo database. Handles the dynamic properties of the mongo documents.
# Helper data model to define the dynamic properties of jobs which has no standard definition between
# all the aggregated data
class Job
include Mongoid::Document
field :company, :type => String, :default => ""
field :location, :type => String, :default => ""
@lazypower
lazypower / ErrorOutput.txt
Created October 27, 2012 18:01
Problematic Mass Assignment
Can't mass-assign protected attributes: rinkleagues, rinksurfaces, developmentalprograms
app/controllers/rinks_controller.rb:43:in `new'
app/controllers/rinks_controller.rb:43:in `create'
{"utf8"=>"✓",
"authenticity_token"=>"x1fV0Snf9A7f2938b/UplmuVFRvPytZSPlCzxO07KPw=",
"rink"=>{"name"=>"",
"address1"=>"",
"address2"=>"",
@lazypower
lazypower / commands.sh
Created November 11, 2012 02:14
Command line reference to correct Ubuntu 12.10 Nvidia-current failure
$ sudo apt-get purge nvidia-current
$ sudo apt-get install linux-source linux-headers-generic linux-image
$ sudo apt-get install nvidia-current nvidia-preferences
@lazypower
lazypower / chef-rake-command.rb
Created November 11, 2012 02:39
Sample Chef configuration snippet
execute "rake db:setup" do
environment ({'RAILS_ENV' => 'production'})
command "cd #{node[:fatfree][:dir]}; rake db:setup; touch .db-created"
creates "#{node[:fatfree][:dir]}/.db-created"
action :run
end
RESTful HTTP Response Codes
Recently I have been building RESTful APIs in Ruby on Rails so I decided to compile a list of HTTP Status Codes to use. This is just a guideline.
Successful Responses:
200 (OK) – everything is fine
201 (Created)– resource successfully created
202 (Accepted) – the call returned but the request was queued up. Somewhat async behavior. Unclear how to communicate error, possibly through the resource state
204 (No Content) – A successful DELETE
Unsuccessful Responses:
400 (Bad Request) – the request could not be understood
#!/bin/bash
# Log output:
#
# * 51c333e (12 days) <Gary Bernhardt> add vim-eunuch
#
# The time massaging regexes start with ^[^<]* because that ensures that they
# only operate before the first "<". That "<" will be the beginning of the
# author name, ensuring that we don't destroy anything in the commit message
# that looks like time.
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
S3.connect!
objects = []
last_key = nil
begin
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects