Skip to content

Instantly share code, notes, and snippets.

View gf3's full-sized avatar
🍊
workin' goodly

Gianni Chiappetta gf3

🍊
workin' goodly
View GitHub Profile
@gf3
gf3 / shotweb.rb
Created December 11, 2008 16:51 — forked from anonymous/shotweb.rb
Downloads all releases from Luna-C's website.
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
BASE_URL = "http://www.kniteforcerevolution.com"
PAGE_URL = "#{BASE_URL}/music/"
FILE_URL = "#{BASE_URL}/file_download/"
@gf3
gf3 / shotweb.rb
Created December 11, 2008 17:00 — forked from anonymous/shotweb.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
BASE_URL = "http://www.kniteforcerevolution.com"
PAGE_URL = "#{BASE_URL}/music/"
FILE_URL = "#{BASE_URL}/file_download/"
#!/usr/bin/env ruby -w
def find_caseinsensitive_duplicates(dir)
# INIT
conflicts = {}
# Load file list
files = Dir.entries(dir).collect{|f| f.downcase }
# Do yo thang!
@gf3
gf3 / git-select-add.rb
Created March 12, 2009 16:41
git-select-add
#!/usr/bin/env ruby
# Git - Select Add
# Written by: Gianni Chiappetta <gianni[at]runlevel6[dot]org>
require 'rubygems'
require 'git' # http://github.com/schacon/ruby-git
MODES = {
"M" => "Modified"
@gf3
gf3 / hoverer.js
Created April 9, 2009 16:26 — forked from fermion/hoverer.js
Hover class for Prototype
var Hoverer = {
current: null,
delay: 0.5,
timer: null,
handler: function(event) {
var element = event.findElement('div.nav_menu');
if (!element)
return Hoverer.leave();
if (element == Hoverer.current)
@gf3
gf3 / getScrollbarWidth.js
Created April 15, 2009 14:25
Get the width of the scrollbars on a page.
function getScrollbarWidth() {
if (this.scrollbarWidth) {
return this.scrollbarWidth;
}
var inner = document.createElement('p');
inner.style.width = '100%';
inner.style.height = '200px';
var outer = document.createElement('div');
outer.style.position = 'absolute';
@gf3
gf3 / gist:101164
Created April 24, 2009 15:54 — forked from fermion/gist:101162
Rake task to pack JS files.
require 'packr'
namespace :js do
desc "Pack javascript src for production environment"
task :pack => :environment do
# Files to pack
Dir.glob(File.join("public", "javascripts", "**", "*.js")).each do |filename|
puts "packing #{filename}..."
FileUtils.cp(filename, "#{filename}.orig")
js = ""
@gf3
gf3 / viewable.js
Created May 21, 2009 19:01
Amount of element viewable.
Element.addMethods({
viewable: function(el) {
// INIT
el = $(el);
var scroll = document.viewport.getScrollOffsets();
var viewport = document.viewport.getDimensions();
var offsets = el.cumulativeOffset();
var dimensions = el.getDimensions();
// Sanity check
@gf3
gf3 / abs_phone.rb
Created May 21, 2009 16:20
Get the absolute value of a phone number.
# Get the absolute value of a phone number
def abs_phone(phone)
abs = []
phone = phone.gsub(/[^a-zA-Z0-9]/, '').downcase
phone.each_byte do |b|
case b
when 0..96
abs << (b - 48)
when 122
abs << ((((b-97).to_f/3.0)+1.0).round)
@gf3
gf3 / gist:119382
Created May 28, 2009 15:23
iTerm Automation - Apple Script
tell application "iTerm"
activate
-- Close the first session
terminate the first session of the first terminal
-- New Terminal
set myterm to (make new terminal)
tell myterm
-- Tab 1 (Server)
launch session "Default"