Skip to content

Instantly share code, notes, and snippets.

@zzak
zzak / config.yml
Last active August 24, 2018 23:59 — forked from pamo/config.yml
CircleCI 2.0 Workflows
references:
defaults: &defaults
working_directory: ~/app
docker:
- image: circleci/node:8.1.4-browsers
npm_permissions: &npm_permissions
run:
name: set-user-permissions
unless ARGV[0] && ARGV[1]
puts "Usage: set_password.rb username password"
exit 1
end
require 'chef'
require 'chef/config'
require 'chef/webui_user'
Chef::Config.from_file(File.expand_path("~/.chef/knife.rb"))
http = require 'http'
server = http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end 'Hello World\n'
server.listen 8124, "127.0.0.1", () ->
console.log 'Server running at http://127.0.0.1:8124/'
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
@zzak
zzak / gist:635606
Created October 20, 2010 01:51 — forked from defunkt/gist:206253
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end
@zzak
zzak / gist:580042
Created September 15, 2010 00:38 — forked from cmelbye/gist:580039
def restrict_to_owner(application, error = false, &block)
return unless logged_in?
if application.is_owner? current_user
p &block
p &block.call
&block.call
elsif error
flash[:error] = 'You must be an owner of this application to do that.'
redirect_to(application)
# =====================
# Spell: Argument Array
# =====================
# Collapse a list of arguments into an array.
def my_method(*args)
args.map {|arg| arg.reverse }
end
# ===================
# Spell: Around Alias
# ===================
# Call the previous, aliased version of a method from a redefined method.
class String
alias :old_reverse :reverse
def reverse
@zzak
zzak / blank_slate.rb
Created September 13, 2010 16:54 — forked from nusco/blank_slate.rb
# ===================
# Spell: Blank Slate
# ===================
# Remove methods from an object to turn them into Ghost Methods (http://gist.github.com/534776).
class C
def method_missing(name, *args)
"a Ghost Method"
end