Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

andyl

🎯
Focusing
View GitHub Profile
@andyl
andyl / rm_auto_display_formatter.rb
Created Jul 29, 2012
Rspec Formatter for RubyMine
View rm_auto_display_formatter.rb
require 'rubygems'
require 'rspec/core/example'
require 'rspec/core/formatters/progress_formatter'
require 'colored'
class RSpec::Core::Example
attr_reader :example_block
end
# Custom formatter for Rspec - intended for use with RubyMine
@andyl
andyl / 30lines1.rb
Created May 1, 2012 — forked from isa/gist:2571012
Convert in less than 30 lines
View 30lines1.rb
#!/usr/bin/env ruby
DATA = <<-EOF
A, B, C
A, C, E
E, F, D
D, A, J
E, D, J
EOF
View foreman.md

Overview

I love Foreman, but need some additional capabilities:

  • upstart/init script with different options than foreman supports (dependencies)
  • monit config files
  • separate export templates per app-type
  • separate start and stop commands for some app-types

Inspiration for Enhanced Foreman

View init.pp
# this Define just ensures that app and configuration
# directories have been created for the deploy user.
#
# production apps are always stored in "/home/<user>/a".
# nginx configuration for the app is stored in "/home/<user>/a/_conf"
# the configuration directory is referenced in nginx.conf
define ngusr($duser = $title) {
sysuser { $duser : }
View asdf.txt
asdf
asdf
asdf
asdf
asdfL
View carrier.rb
# The mail servers of many SMS gateways treat email as spam if the mails
# arrive too frequently. This has happened using the SMS-gateways managed
# by Verizon and Sprint.
#
# Maintains a queue of delivery addresses for a given carrier.
# Limits the sending frequency, to reduce the chance of being rejected as spam.
#
class CarrierQueue
View code.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'spreadsheet'
book = Spreadsheet.open 'input.xls'
sheet = book.worksheet 0
sheet[0,0] = "Changed Cell"
book.write 'output.xls'
View code.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'spreadsheet'
book = Spreadsheet.open 'input.xls'
sheet = book.worksheet 0
sheet[0,0] = "Changed Cell"
book.write 'output.xls'
View faye_chat.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'faye'
abort "Usage: #{$0} <url> <channel> <nick>" if ARGV.length != 3
$url, $channel, $nick = ARGV
$client = Faye::Client.new($url)
View application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
def current_ability
@current_ability ||= Ability.new(current_member)
end
rescue_from CanCan::AccessDenied do |exception|
flash[:alert] = "Access Denied."
redirect_to root_url