Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# A pre-commit hook script to ensure that no local gem dependencies (gem 'asdf', path: '~/local')
# exist in your Gemfile before commiting.`
# Allows gems to be loaded from source within the current project, but not from outside.
puts 'Checking for local dependencies in your Gemfile.'
ROOT_PATH = File.expand_path('../../..', __FILE__)
begin
require 'rubygems'
gemfile = ENV['BUNDLE_GEMFILE'] || File.join(ROOT_PATH, 'Gemfile')
require 'bundler/setup' if File.exists?(gemfile)
#!/usr/bin/env ruby
require 'logger'
# rotatelogs required...
# http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
logger = Logger.new("|rotatelogs ./foo.log.%Y-%m-%d-%H 3600", 0, 0)
10.times do
logger.error "testing..."
@Telmo
Telmo / integrated_docs.rb
Created November 21, 2012 12:20 — forked from mattwynne/integrated_docs.rb
Integrated documentation for Ruby
# For context, this was inspired by the RubyRogues podcast #79 where they talked about
# documentation in Ruby, and specifically grumbled quite a bit about the failings of RDoc.
#
# http://rubyrogues.com/079-rr-documenting-code/
#
# As someone who's spent a lot of time using an IDE for programming C# and Java, I think
# Ruby could do a lot better at putting documentation at our fingertips as we program.
#
# Maybe making the documentation part of the structure of the code would facilitate this?
#
@Telmo
Telmo / README.md
Created October 21, 2012 06:51 — forked from briangonzalez/README.md
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
@Telmo
Telmo / app.ru
Created June 4, 2012 20:48 — forked from tenderlove/app.ru
An adapter for Rack that makes it look like node
##
# Make Rack look like node.
#
# http://youtu.be/Zp91yUH-zAw
require 'node_adapter'
use Rack::Chunked
run createServer { |req, res|
@Telmo
Telmo / futures.rb
Created April 22, 2012 19:15 — forked from wycats/0_app.rb
Example of using a simple future library for parallel HTTP requests
require "thread"
class Future
attr_reader :exception, :cancelled
def initialize(&block)
@thread = Thread.new(&block)
@thread.abort_on_exception = false
@exception = nil
@cancelled = false
@Telmo
Telmo / fiber.rb
Created April 19, 2012 18:05 — forked from mfdela/fiber.rb
Ruby fiber benchmark
#!/usr/bin/ruby1.9
require 'fiber'
require 'benchmark'
class Ring
attr_reader :id
attr_accessor :attach
def initialize(id)
@Telmo
Telmo / personality.rb
Created April 18, 2012 19:48 — forked from wycats/personality.rb
More technical details about the discussion at last nights meetup
# Just wanted to clarify my points at the meetup last night.
#
# There were two different issues intertwined:
# (1) Whether to use extend or "include as extend"
# (2) When using "include as extend", what is the simplest way to achieve the goal?
#
# My personal opinion is that the answer to (1) is "extend", not "include as extend", but that
# is just my personal opinion. My answer to (2) is a more empirical question.
# Using the "extend" approach. Again, I personally prefer the simplicity of this approach, but
@Telmo
Telmo / 1_let.rb
Created April 14, 2012 13:51 — forked from ryanb/1_let.rb
let vs def
desc "A user's comment" do
let(:user) { User.create! name: "John" }
let(:comment) { user.comments.create! }
it "delegates to user's name" do
comment.name.should eq(user.name)
end
end
@Telmo
Telmo / hack.sh
Created April 1, 2012 03:18 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#