Skip to content

Instantly share code, notes, and snippets.

View microwaves's full-sized avatar

Stephano Zanzin Ferreira microwaves

View GitHub Profile
find . -type f -name "*.pyc" -exec rm -f {} \;
:%s'replacethis'withthis'gc
#!/usr/bin/env ruby
a = ARGV[0]
i = 1
until i == 256
o = a + i.to_s
puts o
i += 1
end
desc "Run spork"
task :spork do
sh %{bundle exec spork > /dev/null 2>&1 &}
end
@microwaves
microwaves / gist:1158638
Created August 20, 2011 04:00
plan 9 IP routing
minooka; diff -c /n/dump/2010/0930/sys/src/9/ip/ip.c /n/dump/2010/0820/sys/src/9/ip/ip.c
/n/dump/2010/0930/sys/src/9/ip/ip.c:463,469 - /n/dump/2010/0820/sys/src/9/ip/ip.c:463,469
}
/* don't forward to source's network */
- memset(&conv, 0, sizeof conv);
+ conv.r = nil;
r = v4lookup(f, h->dst, &conv);
if(r == nil || r->ifc == ifc){
ip->stats[OutDiscards]++;
#
# RFC822 Email Address Regex
# --------------------------
#
# Originally written by Cal Henderson
# c.f. http://iamcal.com/publish/articles/php/parsing_email/
#
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb.
#
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License
middle_name = case full_name
when /^.*\s(.*)\s.*$/
$1
else
"Peatrice"
end
>> "https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash".match /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/
=> #<MatchData "https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash" 1:"https:/" 2:"https" 3:"www.google.com" 4:"/dir/1/2/" 5:"/2" 6:"search.html" 7:"?arg=0-a&arg1=1-b&arg3-c#hash" 8:nil>
>> "ftp://ftp1.freebsd.org/pub/FreeBSD/ports/i386/packages-8.2-release/All/".match /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/
=> #<MatchData "ftp://ftp1.freebsd.org/pub/FreeBSD/ports/i386/packages-8.2-release/All/" 1:"ftp:/" 2:"ftp" 3:"ftp1.freebsd.org" 4:"/pub/FreeBSD/ports/i386/" 5:"/i386" 6:"packages-8.2-release/All/" 7:"" 8:nil>
>> u = "ftp://ftp1.freebsd.org/pub/FreeBSD/ports/i386/packages-8.2-release/All/".match /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/
=> #<MatchData "ftp://ftp1.freebsd.org/pub/FreeBSD/ports/i386/packages-8.2-release/All/" 1:"ftp:
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
rails_root = File.expand_path('../../', __FILE__)
$LOAD_PATH.unshift(rails_root) unless $LOAD_PATH.include?(rails_root)
require 'bundler/setup'
require 'active_record'
require 'rspec/rails/extensions/active_record/base'
require 'spec/support/require_helper'
require 'spec/support/helpers'
require 'ostruct'
Bundler.require :models