Skip to content

Instantly share code, notes, and snippets.

View dstrelau's full-sized avatar

Dean Strelau dstrelau

View GitHub Profile
#!/bin/bash
#####
# Builds a custom nginx
#
# RELEASE_TAGS="+your+tags+here"
# RELEASE_MAINTAINER="Your Name Here"
# RELEASE_MAINTAINER_EMAIL="hi@example.com"
# RELEASE_MESSAGE="Some message"
#
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@fnichol
fnichol / README.md
Created February 26, 2012 01:23
A Common .ruby-version File For Ruby Projects

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@ngauthier
ngauthier / README.md
Created February 14, 2012 16:50
333% Test Speedup

333% Test Speedup

  1. Normal Rails setup: 30 seconds for rake test
  2. Using 1.9.3-falcon: 22 seconds
  3. Using merged task w/ db reset: 16 seconds
  4. Using merged task w/o db reset: 12 seconds
  5. Using raw ruby execution: 9 seconds

You can run rake test:fast:db to get a merged run that resets your db. However, if you have clean tests that don't pollute the db between runs, you can just run rake test:fast and it will omit db:reset. This means your sequence numbers (under PostgreSQL, at least) may keep increasing, but if you tests against those I have other words for you.

@fujin
fujin / foo.rb
Created January 31, 2012 21:49
template override between cookbooks
template "/tmp/foo.rb"
source "foo.rb.erb"
cookbook "banana"
end
@bradland
bradland / ssh-known-hosts-mgmt.sh
Last active April 4, 2023 21:21
SSH known_hosts tools
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -F github.com
@rtomayko
rtomayko / gist:1202895
Created September 8, 2011 08:11
The Sazerac
You'll need:
- Old Fashioned glasses, two of
- Sugar cubes, two of
- Peychaud's Aromatic Cocktail Bitters, one bottle of
- Ice, enough to fill both glasses
- Water, one oz of
- Rye whisky, two oz of
- St. George Absinthe Verte, 0.333oz of
- Lemon, one twist of
@jamis
jamis / cap-transcriber.rb
Created July 25, 2011 14:57
Capistrano Transcriber: a wrapper script for Capistrano that writes session transcripts to a timestamped file.
#!/usr/bin/env ruby
require 'capistrano/cli'
class TranscriptLogger
module TranscriptLoggerMetadata
attr_accessor :tx_logger_metadata
def self.apply_to(object, options={})
object.extend(self) unless object.respond_to?(:tx_logger_metadata)
@dstrelau
dstrelau / caveatPatchor.js
Created June 23, 2011 15:14 — forked from protocool/caveatPatchor.js
caveatPatchor.js file for use in Propane
var displayAvatars = true;
var displayCloudAppImages = true;
var displayGists = true;
if (displayAvatars) {
Object.extend(Campfire.Message.prototype, {
addAvatar: function() {
if (this.actsLikeTextMessage()) {
var author = this.authorElement();
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb: