Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
stevenocchipinti / config.ru
Created August 26, 2015 04:06
Rack hello world
run ->(env) {
[ 200, { 'Content-Type' => 'text/plain' }, [ "Hello World" ] ]
}
@stevenocchipinti
stevenocchipinti / .vimrc
Last active August 29, 2015 13:57
Introduction to Vim for IDE Users
" A simplified vimrc
" Full version available here:
" https://github.com/stevenocchipinti/dotvim/blob/master/vimrc
" Use Vundle to manage plugins
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
@stevenocchipinti
stevenocchipinti / troll.sh
Last active August 29, 2015 14:00
Troll
export PS1="\$(osascript -e 'set Volume 10' && say 'jerk')$PS1"
@stevenocchipinti
stevenocchipinti / ifconfig.rb
Created September 2, 2014 07:17
Parse ifconfig
`ifconfig`.split(/^(?=\w)/).flat_map{|x| x.scan(/^(\w+).*inet ([0-9.]+)/m)}
#=> [["lo0", "127.0.0.1"], ["en0", "10.112.202.44"], ["vboxnet0", "192.168.59.3"], ["en4", "10.112.197.80"]]
@stevenocchipinti
stevenocchipinti / contentscript.js
Created December 3, 2014 12:43
Simple "Content Script" Google Chrome extension
(function(d, script) {
script = d.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = function(){
// remote script has loaded
};
script.src = '//hi.kickassapp.com/kickass.js';
d.getElementsByTagName('head')[0].appendChild(script);
}(document));
@stevenocchipinti
stevenocchipinti / rss_to_ical.rb
Created July 27, 2011 03:00
This parses an rss feed for dates that could be used to form an ical
# rss_to_ical.rb
#
# This parses a (specific) rss feed for dates that could be used to form an ical
require 'nokogiri'
require 'open-uri'
require 'time'
# Configuration
url = "http://melbournepatterns.org/feed/"
@stevenocchipinti
stevenocchipinti / collect.rb
Created September 12, 2011 03:15
Creating a years <select> element: Is there a better way to do this?
#
# ERB
#
# <% years = (Date.today.year..Date.today.year + 12).collect %>
# <%= f.select(
# 'ccexpy',
# years.zip(years.collect {|y| y.to_s[-2,2]}),
# {},
# { :class => "expirydate" }
# ) %>
@stevenocchipinti
stevenocchipinti / leds.rb
Created October 10, 2011 03:00
Control LEDs with a parallel port
p = open('/dev/port', 'w')
p.sync = true
sequence = [
0b00000000,
0b00000010, 0b00001010, 0b00101010,
0b10101010,
0b00101010, 0b00001010, 0b00000010,
0b00000000,
0b00000001, 0b00000101, 0b00010101,
#!/usr/bin/env ruby
require 'open-uri'
unless ARGV[0]
puts "Usage: #{$0} <stop-id>"
exit 0
end
# Configuration
url = "http://www.tramtracker.com.au/?id=#{ARGV[0]}"
@stevenocchipinti
stevenocchipinti / test.html
Created February 15, 2012 03:40
Nested HTML list browser corrections example
<html>
<head>
<title>Nested HTML list browser corrections example</title>
</head>
<body>
<!--
This page shows that the browser will correct nested <li> elements to be