Skip to content

Instantly share code, notes, and snippets.

@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
alias dewip="sed -E -i '' -e '/^[[:blank:]]*@wip$/d;s/,[[:blank:]]*@wip//g;s/@wip,[[:blank:]]*//g' features/**/*.feature"
namespace :tags do
task :generate do
puts 'Generating tags...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
@zunda
zunda / wol.rb
Last active February 14, 2020 07:41
A ruby script which sends out a magic packet to wake up your PC
#!/usr/bin/ruby
# wol.rb: sends out a magic packet to wake up your PC
#
# Copyright (c) 2004 zunda <zunda at freeshell.org>
#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms of ruby itself ---
# Ruby Distribution License or GNU General Public License.
#
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
@pixelmatrix
pixelmatrix / Rakefile
Created July 22, 2010 19:34
Creating a prompt in a Rake Task
require "rake"
task :say_hi do
puts "What's your name?"
name = $stdin.gets.chomp
puts "Hi #{name}!"
end
@JEG2
JEG2 / bot
Created August 19, 2010 18:58
#!/usr/bin/env ruby -wKU
def program_moves(map, moves, modes)
%w[L L R R balance] # FIXME: replace with bot logic
end
require "socket"
# USAGE: bot [-r] [BOT_NAME [BOT_PASSWORD [HOST]]]
register = ARGV.delete("-r")
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@floehopper
floehopper / wem.rb
Created November 24, 2010 18:23
Use httparty to connect using SSL mutual authentication
require "rubygems"
require "httparty"
class Wem
include HTTParty
debug_output $stderr
ssl_ca_file '/Users/jamesmead/Sites/ssltest/demoCA/ca.crt'
pem File.read('/Users/jamesmead/Sites/ssltest/user/hashblue.pem')
base_uri "https://127.0.0.1/"
def self.wem