Skip to content

Instantly share code, notes, and snippets.

View alainravet's full-sized avatar

Alain Ravet alainravet

  • Braine l'Alleud, Belgium
View GitHub Profile
###
# This is a demonstration of using SQLite3's Virtual File System API in Ruby.
#
# == Synopsis
#
# This program will store its SQLite database after the __END__ line.
#
# === In Detail
#
# SQLite3 uses the DATABase class as a proxy for our IO object. Upon
#!/bin/bash
if [ -z "$1" ]; then
wdir="."
else
wdir=$1
fi
for f in $( find . -name '*.erb' ); do
out="${f%.erb}.haml"
if [ -e $out ]; then
@JackDanger
JackDanger / forgetful.js
Created June 22, 2010 00:28
forgetful.js
// Forgetful.js is what I use on SSDs to prevent disk wear.
// Because each SSD sector can only be written a set # of times
// it's important not to write huge log files for no reason.
// So my test logs (and some others) are all outputted to this
// node.js instance which keeps track of the throughput
// in simply-named channels.
//
// To use this in, e.g., Rails, put this in environments/test.rb:
//
// class NamedChannelSocket < TCPSocket
module Test
module Unit
TestCase = RSpec::Core::ExampleGroup
end
end
class Test::Unit::TestCase
def self.inherited(host)
host.set_it_up host.name.gsub(/(Spec|Test)/,'')
def host.method_added(name)
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@drnic
drnic / $
Created June 10, 2011 15:20
never fear $ in tutorials again
#!/usr/bin/env bash
"$@"
@jamis
jamis / demo.rb
Created August 3, 2011 21:56
Repairing a unicode string that contains invalid characters
# encoding: utf-8
s = "Blah \xe9 blah 헌글"
puts "BEFORE"
puts "encoding: #{s.encoding}"
puts "valid : #{s.valid_encoding?}"
puts "text : #{s}"
s = s.
Gem::Specification.new do |s|
s.name = 'bang'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jeff Kreeftmeijer'
s.email = 'jeff@kreeftmeijer.nl'
s.summary = 'Bang!'
s.description = 'Bangs existing model methods'
s.files = ['bang.rb']
@henrik
henrik / request_debug_helpers.rb
Created November 25, 2011 12:36
show_page debug helper for RSpec request specs that opens or reloads page in Chrome.
module RequestDebugHelpers
DEBUG_URL = "http://example.dev/debug.html"
def show_page
filename = File.join(Rails.root, 'public', 'debug.html')
File.open(filename, 'w') do |f|
f.puts page.body.gsub("</title>", " (#{ current_path })\\0")
end
system "osascript", "-e", <<-OSASCRIPT
@netmute
netmute / README.md
Last active October 27, 2022 13:22
Game of Life

Game of Life

An implementation of Conway's Game of Life in 140 characters of Ruby.

Author

Created by Simon Ernst (@sier).