Skip to content

Instantly share code, notes, and snippets.

View bgkittrell's full-sized avatar

Ben Kittrell bgkittrell

View GitHub Profile
@bgkittrell
bgkittrell / aws-transcode.rb
Created June 11, 2013 13:57
Uploads a directory of files to s3 and creates elastic transcoder jobs. Requires the aws-sdk gem. Usage ruby aws-transcode.rb /path/to/videos
require 'aws'
AWS.config(:access_key_id => 'XXXXX', :secret_access_key => 'XXXXX')
pipeline_id = 'XXXXXXX'
preset_id = 'XXXXXX'
s3 = AWS::S3.new
bin = s3.buckets['XXXXXX-in']
bout = s3.buckets['XXXXXX-out']
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
node[:applications].each do |app_name, data|
user = node[:users].first
case node[:instance_role]
when "solo", "app", "app_master"
require 'rubygems'
require 'fog'
require 'find'
require 'set'
# create a connection
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => 'XXXXX',
:aws_secret_access_key => 'XXXXX'
@bgkittrell
bgkittrell / new
Created June 22, 2012 16:51 — forked from creich/new
<%= form_for @time_tracker, :url => {:action => :stop},
:html => {:class => "time-tracker-form",
:onchange => "updateForm()" }do |f| %>
<!-- TODO localize placeholders / add labels -->
<%= f.label l(:time_tracker_label_current_task) %>
<script>
updateForm = function() {
// prototype ajax request
new Ajax.Request(....
module DoodlekitExtensions
module ContentFilter extend ActiveSupport::Concern
module ClassMethods
def content_filter(field, options = {})
before_save { |r| r.apply_filter(field)}
include DoodlekitExtensions::ContentFilter::InstanceMethods
end
end
@bgkittrell
bgkittrell / svnmv.rb
Created April 6, 2012 13:35
Ruby Script to Rename Files in Subversion
#!/usr/bin/ruby
require 'find'
Find.find('.') do |path|
if path =~ /#{ARGV[0]}/
puts path
new_path = path.gsub /#{ARGV[1]}/, ARGV[2]
puts new_path
http = require 'http'
fs = require 'fs'
util = require 'util'
connect = require 'connect'
uuid = require 'node-uuid'
require 'coffee-script'
UploadController = require './controllers/upload'
app = {}
<html>
<head>
<!-- Skin CSS file -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/assets/skins/sam/skin.css">
<!-- Utility Dependencies -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script src="http://yui.yahooapis.com/2.8.2r1/build/element/element-min.js"></script>
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/container/container_core-min.js"></script>
@bgkittrell
bgkittrell / gist:704674
Created November 18, 2010 05:53
Reorder Multiple Elements ala Netflix
images = @album.image_assignments
changed = Array.new
# Get the images that changed order
for image in images
order = params["order_#{image.image_id}".to_sym]
if !order.blank? && order =~ /^\d+$/ && image.position.to_i != order.to_i
image.position = order.to_i
changed << image
var Person = function(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var thomas = new Person('thomas');
var amy = new Person('amy');