Skip to content

Instantly share code, notes, and snippets.

View cpuguy83's full-sized avatar
🐶

Brian Goff cpuguy83

🐶
View GitHub Profile
@cpuguy83
cpuguy83 / partial_docekrfile
Created November 21, 2013 19:51
Docker long string
RUN /bin/echo -e "PassEnv DB_PORT_3306_TCP_ADDR\n\
PassEnv DB_PORT_3306_TCP_DATABASE\n\
PassEnv DB_PORT_3306_TCP_USER\n\
PassEnv DB_PORT_3306_TCP_PASS\n\
PassEnv LDAP_PORT_389_TCP_ADDR\n\
PassEnv LDAP_PORT_689_TCP_ADDR\n\
PassEnv LDAP_BASEDN\n\
PassEnv LDAP_UID\n\
PassEnv LDAP_SEARCH_USER\n\
PassEnv LDAP_SEARCH_PASS\n\
@cpuguy83
cpuguy83 / set_node_name.rb
Created October 28, 2013 16:35
call ohai from chef directly
require 'ohai'
o = Ohai::System.new
o.all_plugins
node_name o[:macaddress].split(":").join
@cpuguy83
cpuguy83 / crash1
Created October 17, 2013 14:05
Rbx 2.0.0 crash with sidekiq
Rubinius Crash Report #rbxcrashreport
Error: signal �SIGSEGV
[[Backtrace]]
ruby[0x81bd52a]
[0x4001d400]
/lib/tls/i686/cmov/libc.so.6(index+0x63)[0x40233db3]
/lib/tls/i686/cmov/libnss_dns.so.2(_nss_dns_gethostbyname3_r+0xb6)[0x43ce6b66]
/lib/tls/i686/cmov/libnss_dns.so.2(_nss_dns_gethostbyname2_r+0x4b)[0x43ce6f2b]
@cpuguy83
cpuguy83 / sidekiqer.rb
Created October 10, 2013 20:33
Run Sidekiq in your main process
require 'sidekiq/cli'
require 'sidekiq/launcher'
module Sidekiqer
Sidekiq = ::Sidekiq.dup
module Sidekiq
CLI = ::Sidekiq::CLI.dup
Launcher = ::Sidekiq::Launcher.dup
::Sidekiq.send(:remove_const, :CLI)
@cpuguy83
cpuguy83 / poller.coffee
Last active December 24, 2015 23:59
Poll returns immediately after the page is loaded for some reason... any ideas?
@Poller =
delay: (ms, func) -> setTimeout func, ms
poll: (url,time)->
@schedulePoll(url, time)
$.getScript(url)
schedulePoll: (url, time=30000) ->
poller = @delay(time, =>@poll(url, time))
$(document).on 'page:fetch', =>
clearTimeout(poller)
@cpuguy83
cpuguy83 / clock.rb
Last active December 24, 2015 10:18
Running clockwork in a separate process is for suckers...
module MyApp
class Clock
include Celluloid
include Clockwork
require_relative '../clockwork'
end
end
@cpuguy83
cpuguy83 / gist:6518667
Created September 11, 2013 02:26
actor crash on terminate
Celluloid::DeadActorError: attempted to call a dead actor
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/proxies/sync_proxy.rb:23:in `method_missing'
/Users/bgoff/dev/monitor/agent/lib/agent/worker.rb:20:in `post_run'
/Users/bgoff/dev/monitor/agent/lib/agent/worker.rb:12:in `perform'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/calls.rb:25:in `public_send'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/calls.rb:25:in `dispatch'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/calls.rb:67:in `dispatch'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/actor.rb:322:in `block in handle_message'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/actor.rb:416:in `block in task'
/Users/bgoff/.gem/ruby/2.0.0/bundler/gems/celluloid-02e3882c1e55/lib/celluloid/tasks.rb:55:in `block in initialize'
# Serializes model for use with pivot.js
# https://github.com/rjackson/pivot.js
require 'csv'
module Concerns::Pivotable
extend ActiveSupport::Concern
included do
attr_reader :pivotable_attrs
@pivotable_field_options ||= []
end
class ApplicationController < ActionController::Base
#... stuff
private
def resource_params
if params[:action] == 'new'
[]
elsif current_user.admin?
params.require(resource_instance_name).permit!
else
params.require(resource_instance_name).permit( *policy_attributes(resource_class) )
@cpuguy83
cpuguy83 / ruby.rb
Created August 19, 2013 19:45
Chef rbenv
include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"
@my_ruby_version = node[:_common_system][:ruby][:version]
rbenv_ruby @my_ruby_version do |rbenv|
rbenv.ruby_version @my_ruby_version
rbenv.global true
end
def gem_install(gem)