Skip to content

Instantly share code, notes, and snippets.

@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
@stevenocchipinti
stevenocchipinti / photos.sh
Last active December 10, 2015 15:19
A really simple bash script to move photos from the memory card to the computer
#!/bin/bash
DATE=`date +%Y%m%d`
SDCARD="/media/steve/NIKON D90/DCIM"
mkdir -p $DATE/{jpg,raw}
find "$SDCARD" -name "*.JPG" -exec mv -v {} "$DATE/jpg" \;
find "$SDCARD" -name "*.NEF" -exec mv -v {} "$DATE/raw" \;
notify-send "Finished transferring photos!"
@stevenocchipinti
stevenocchipinti / screen.sh
Last active December 16, 2015 19:39
Screen
#!/bin/bash
################################################################################
# REATTACH or CREATE a session called "bla"
screen -xR bla
# Send "date" to the session called "bla"
screen -S bla -X stuff date
@stevenocchipinti
stevenocchipinti / curses.rb
Created June 4, 2013 03:29
Simple example of using Curses (built in to the ruby stdlib)
#!/usr/local/bin/ruby
require "curses"
include Curses
begin
init_screen
crmode
x = 0
y = 0
@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"