Skip to content

Instantly share code, notes, and snippets.

class AwsController < ApplicationController
def call
service = AWS.const_get(params[:service]).new(params[:service_params] || {})
result = service.client.send(params[:method].to_sym, params[:options] || {})
respond_to do |format|
format.json { render :json => result.data }
end
end
end
@zwily
zwily / gist:5959853
Last active December 19, 2015 13:09

CPUUtilization Based:

1 week ago 1 week ago
+ 1 hour
Now In 1 hour
(Prediction)
Avg CPU avg_cpu 50% 45% 52%
Num Nodes nodes 2 4 2
See if the present is matching the past
Total CPU
total_cpu = avg_cpu * nodes
100 104
100 and 104 are close enough together to assume that the future will match the past
Calculate total cpu for 1w ago + 1h

programStations is an Ember.ArrayController

  console.log programStations.mapProperty('id')
  programStations.forEach (programStation, index) ->
    console.log "#{index}: #{programStation.get 'id'}

outputs:

@zwily
zwily / gist:5322615
Last active December 15, 2015 20:59
class GraphiteUrl
constructor: (base, attrs = {}) ->
@base = base
@attrs = attrs
@targets = []
attr: (k, v) ->
@attrs[k] = v
target: (target) ->
RUBY_GC_MALLOC_LIMIT=1000000000
RUBY_HEAP_FREE_MIN=500000
RUBY_HEAP_MIN_SLOTS=1000000
RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
RUBY_HEAP_SLOTS_INCREMENT=1000000
@zwily
zwily / straitjacket.md
Last active December 14, 2015 12:39
Straitjacket quickstart.

Getting Started with the StraitJacket AMI

Create a security group:

ec2-create-group straitjacket -d "straitjacket testing"
GROUP	sg-dc1cf8b7	straitjacket	straitjacket testing
<?xml version="1.0" encoding="ISO-8859-1"?>
<xml>
<result>
<ui_conf>
<id>1103</id>
<partnerId>0</partnerId>
<objType>5</objType>
<objTypeAsString>Playlist</objTypeAsString>
<name>kupload 1.0.7</name>
<swfUrl>https://www.instructuremedia.com/flash/kupload/v1.1.7/KUpload.swf</swfUrl>
@zwily
zwily / emoji.coffee
Created February 26, 2013 22:01
emoji (github-flavored) for limechat + limescripts
##
# replaces :blah: with an image with the appropriate emoji
all_emojis = [
'+1', '-1', '100', '1234', '8ball', 'a', 'ab', 'abc', 'abcd', 'accept',
'aerial_tramway', 'airplane', 'alarm_clock', 'alien', 'ambulance', 'anchor',
'angel', 'anger', 'angry', 'anguished', 'ant', 'apple', 'aquarius', 'aries',
'arrow_backward', 'arrow_double_down', 'arrow_double_up', 'arrow_down',
'arrow_down_small', 'arrow_forward', 'arrow_heading_down',
'arrow_heading_up', 'arrow_left', 'arrow_lower_left', 'arrow_lower_right',
@zwily
zwily / gollum-config.rb
Created February 20, 2013 19:26
Add this to your gollum config file to get full GitHub-Flavored Markdown. (including newline behavior)
class GitHub::Markdown
class << self
alias_method :old_render, :render
def render(content)
render_gfm(content)
end
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'highline'
def ask(question)
HighLine.new.ask(question)
end
def ask_secure(question)