Skip to content

Instantly share code, notes, and snippets.

View omgitsads's full-sized avatar
:shipit:

Adam Holt omgitsads

:shipit:
View GitHub Profile
@omgitsads
omgitsads / error.log
Created November 15, 2011 13:29 — forked from tjl2/error.log
Examining request objects
ActionView::Template::Error (can't dump anonymous class Class):
1: <h3>Rack request env</h3>
2: <h3>Rails request object</h3>
3: <pre><%= h(@request_obj.to_yaml).gsub(" ", "&nbsp;").html_safe %></pre>
app/views/headers/index.html.erb:3:in `_app_views_headers_index_html_erb___1006215901_77896010__270781548'
@omgitsads
omgitsads / shef.rb
Created February 24, 2012 11:45 — forked from cliffdickerson/shef.rb
Shef - chef in irb
$ bin/shef
Loading Node Data
Ohai2u!
chef > recipe
=> :recipe
chef:recipe > file "/tmp/foo"
=> #<Chef::Resource::File:0x1c3cd2c @provider=nil, @not_if=nil, @params={}, @recipe_name=nil, @action="create", @source_line="/Users/danielsdeleo/ruby/shef/(irb) line 2", @actions={}, @ignore_failure=false, @name="/tmp/foo", @cookbook_name=nil, @enclosing_provider=nil, @resource_name=:file, @before=nil, @supports={}, @backup=5, @allowed_actions=[:nothing, :create, :delete, :touch, :create_if_missing], @path="/tmp/foo", @only_if=nil, @noop=nil, @updated=false, @node=eigenstate.local, @collection=#<Chef::ResourceCollection:0x1c4f328 @insert_after_idx=nil, @resources=[#<Chef::Resource::File:0x1c3cd2c ...>], @resources_by_name={"file[/tmp/foo]"=>0}>>
chef:recipe > run_chef
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: Processing file[/tmp/foo]
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: file[/tmp/foo] using Chef::Provider::File
jQuery ->
$('#password_prompt_form').submit (e) ->
$.post(this.action, { passcode: $('#passcode').val() }) ->
$('#passcode_response').html(data)
e.preventDefault()
@omgitsads
omgitsads / gist:3171047
Created July 24, 2012 16:31
Scamp V2 - Final API
Scamp.new do |bot|
bot.adapter :test, TestAdapter, :delay => 1
bot.adapter :another, TestAdapter, :delay => 5
bot.plugin PingPlugin, :on => [:test]
bot.connect!
end
@omgitsads
omgitsads / gist:3171050
Created July 24, 2012 16:31
Scamp V2 Test Adapter
class TestAdapter < Scamp::Adapter
class Context
def say msg
puts msg
end
end
def connect!
EventMachine::PeriodicTimer.new(@opts[:delay]) do
msg = Scamp::Message.new(self, :body => "help")
@omgitsads
omgitsads / gist:3171053
Created July 24, 2012 16:32
Scamp V2 plugin example
require 'scamp/plugin'
class MyPlugin < Scamp::Plugin
match /^ping$/, :say_pong
def say_pong context, msg
context.say "pong"
end
end
@omgitsads
omgitsads / gist:3171063
Created July 24, 2012 16:34
Scamp V2 plugin prototype
class Scamp
def say str
puts "BOT: #{str.inspect}"
end
def behaviour &block
instance_eval(&block)
end
def plugin klass
@omgitsads
omgitsads / gist:3171067
Created July 24, 2012 16:35
Scamp V1 example
require 'scamp'
scamp = Scamp.new(:api_key => "YOUR API KEY", :subdomain => "yoursubdomain", :verbose => true)
scamp.behaviour do
# Simple matching based on regex or string:
match "ping" do
say "pong"
end
end
@omgitsads
omgitsads / before_compile_assets.rb
Created December 3, 2012 13:17 — forked from ilyakatz/before_compile_assets.rb
Selective compilation
last_revision = run "cat #{current_path}/REVISION"
assets_modified = run "git diff --name-only #{last_revision} | grep '/assets/' | wc -l"
if assets_modified.output.to_i > 0
info "#{assets_modified} asset files changed detected. Compiling assets"
cd #{release_path} && PATH=#{release_path}/ey_bundler_binstubs:$PATH #{config.framework_envs} rake assets:precompile RAILS_GROUPS=assets"
else
info "No asset changes detected. Copying assets from previous"
current = shared_path + '/assets'
@omgitsads
omgitsads / rails-check.sh
Last active December 10, 2015 22:38
Look for affected versions of rails, and if they have been patched or not
for i in `find /data -maxdepth 1 -type d ! -name "monit.d" ! -name "nginx" ! -name "lost+found" ! -name "homedirs" ! -name "data"`;
do
appname=`echo ${i} | awk -F/ '{print $3}'`
version=''
if [ -f $i/current/Gemfile.lock ];
then
version=`egrep "^ *rails \([0-9\.]+\)" $i/current/Gemfile.lock | egrep -o "[0-9\.]+"`
else
version=`gem list | egrep -o "^rails \([^,\)]+" | egrep -o "[0-9\.]+"`