Skip to content

Instantly share code, notes, and snippets.

View capoferro's full-sized avatar

Josiah Kiehl capoferro

View GitHub Profile
osiah@claymore-ubuntu:~/Projects/berkshelf$ irb
irb(main):001:0> class A
irb(main):002:1> attr_accessor :a
irb(main):003:1> def x
irb(main):004:2> a ||= 'blue'
irb(main):005:2> puts a
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0> z = A.new
josiah@claymore-ubuntu:~/Projects/rusp$ ./bin/rusp execute test.rusp
abc
josiah@claymore-ubuntu:~/Projects/rusp$ cat test.rusp
(define print_abc
(lambda
(print (quote abc))))
(print_abc)
content = Content.find_by_name("home_main")
@content_home_main = content.nil? ? content.content : "home_main not found"
## My app has 1 rails application and several goliath applications all deployed by the same cookbook.
default[:service_name][:sites_proxied] = [:app_name', :app_name2, :app_name3]
default[:service_name][:app_name][:unicorn][:worker_timeout] = 300
default[:service_name][:app_name][:unicorn][:worker_processes] = (node[:cpu][:total].to_i * 4)
default[:service_name][:app_name][:unicorn][:listen_sock] = "path/to/someth.sock"
default[:service_name][:app_name][:unicorn][:listen_options] = { :backlog => 64 }
default[:service_name][:app_name][:nginx_proxy][:listen_port] = 443
execute "npm install" do
action :nothing
end
application "my_app" do
# ...
notifies "execute[npm install]", :run
end
@capoferro
capoferro / ERB_test.rb
Created October 31, 2012 00:51 — forked from anonymous/ERB_test.rb
Struggling ruby loop.
# I am attempting to read all files in an input/ directory
# (index.html.erb, style.css.erb & script.js.erb) and
# compile them into their corresponding files in the
# output/ directory (index.html, style.css & script.js)
# Currently, only one file is rendering correctly and
# the following error is being thrown:
# ERB_test.rb:12:in `read': No such file or directory - script.js (Errno::ENOENT)
# from single_loop.rb:12:in `block in <main>'
class << "abc"
  class << self
    self  # => #<Class:#<Class:#<String:0x33552c>>>
  end
end
Perrotta. Metaprogramming Ruby (Josiah Kiehl) (Kindle Locations 2989-2993). The Pragmatic Bookshelf (376834).
diff --git a/app/models/pusher.rb b/app/models/pusher.rb
index f24b3d7..291bcd4 100644
--- a/app/models/pusher.rb
+++ b/app/models/pusher.rb
@@ -1,5 +1,5 @@
class Pusher
- attr_reader :user, :spec, :message, :code, :rubygem, :body, :version, :version_id
+ attr_reader :user, :spec, :message, :code, :rubygem, :body, :version, :version_id, :indexer
def initialize(user, body, host_with_port=nil)
[Fri, 19 Oct 2012 20:55:10 +0000] INFO: *** Chef 10.12.0 ***
...
*** LOCAL GEMS ***
chef (10.14.4)
irb(main):001:0> class A
irb(main):002:1> attr_accessor :a, :b, :c
irb(main):003:1> end
=> nil
irb(main):004:0> a = A.new
=> #<A:0x007fbdf390e7d8>
irb(main):005:0> a.a = 1
=> 1
irb(main):006:0> a.b = 2
=> 2