Skip to content

Instantly share code, notes, and snippets.

View FiXato's full-sized avatar

Filip H.F. "FiXato" Slagter FiXato

View GitHub Profile
@FiXato
FiXato / openmsx-sha1sum-roms.rb
Created July 11, 2012 23:40
Rather ugly Ruby script to select all needed system roms for openMSX from source directories
#!/usr/bin/env ruby
# encoding: utf-8
ROMDIRS = [File.expand_path("~/.openMSX/share/systemroms/old/*"),File.expand_path("~/.openMSX/share/systemroms/downloaded/**/*")]
TARGETDIR = File.expand_path("~/.openMSX/share/systemroms")
SHAREDIR = "~/Development/openmSX/share/"
require 'fileutils'
sha1s = `grep -hEro '<sha1>([a-f0-9]+)<\/sha1>' #{SHAREDIR}|sed 's/<\\/sha1>//'|sed 's/<sha1>//'|uniq|sort`.split("\n").map{|l|l.strip.downcase}.uniq.sort
copied = []
@FiXato
FiXato / unrealircd_tkl_stats.rb
Created September 20, 2012 22:12
UnrealIRCd TKL Stats
#!/usr/bin/env ruby
# encoding: utf-8
require 'yaml'
THRESHOLD = 5
lines = `grep -E '[A-Z]:[lL]ine added for ' ~/UnrealIRCd/logs/tkl.log`.split("\n");nil
ban_types = []
results = lines.map do |line|
if line.match(/\[([^\]]+)\] - (.+) added for (\S+)@(\S+) on (.+) \(from (\S+)( to expire at (.+))?: (.+)\)/)
puts "1- #{line}" if $2 == '' || $2 == ' '
ban_types << $2
@FiXato
FiXato / youtube-title-for-videoid.py
Created October 14, 2012 23:12
Retrieve page title for YouTube video ID.
# If the url is a youtube URL, make sure we query the api instead of the actual page to prevent triggering captcha requests
if 'v=' in url and ('youtube.com' in url or 'youtu.be' in url):
m = re.search('v=([\w\d_-]+)', url)
if m:
youtube_id = m.group(1)
url = "http://gdata.youtube.com/feeds/api/videos?v=2&q=" + youtube_id + "&max-results=1&fields=entry(title)&prettyprint=false"
weechat.prnt("", url)
@FiXato
FiXato / favicon_grabber.rb
Created October 21, 2012 21:40
Favicon Grabber
#!/usr/bin/env ruby
# encoding: utf-8
# Favicon Grabber by Filip H.F. "FiXato" Slagter
require 'open-uri'
require 'nokogiri'
require 'fileutils'
ICONS_DIR = File.expand_path(File.join("~",'favicons'))
favicon_urls = Hash.new{|h,k|h[k] = []}
urls = {
'wikipedia' => 'http://en.wikipedia.org/wiki/Favicon#HTML5_recommendation_for_icons_in_multiple_sizes',
@FiXato
FiXato / icons_renamer.rb
Created October 21, 2012 21:44
Icons Renamer
#!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
base_dir = File.join("E:","Filip","Development","icons")
suffix = 'fatcow'
size = 32
files = Dir.glob(File.join("E:","Filip","Development","icons","fatcow-hosting-icons-3000",'32x32',"*.png"))
files.each do |filepath|
fn = File.basename(filepath)
@FiXato
FiXato / Satanklaas.txt
Created December 2, 2012 18:50
Quick English translation of Satanklaas lyrics
Quick English translation of http://www.youtube.com/watch?v=ElYwUY60UYw
Goddamnthecunt!
When I was told
that Santa Claus does not really exist,
something snapped in my head.
Man I got so angry.
I started smoking heavy tobacco
and became a Satanist.
@FiXato
FiXato / age.rb
Created January 2, 2013 00:17
A Ruby tool to calculate the amount of years, days or hours+minutes on Earth since a date of birth.
#!/usr/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'chronic'
require 'date'
if ARGV.size > 0
dob = Chronic.parse(ARGV.join(' '))
strings = ['You were', 'you']
else
dob = Chronic.parse('01 january 1970 at 20:12 GMT+1')
# Mousemode alias so the mouse works in WeeChat while running mosh:
alias mousemode="perl -E ' print \"\e[?1005h\e[?1002h\" '"
# Command function to enable mousemode, get the mosh key and port, lookup the ip for the hostname and set up the mosh-client connection
function mosher() {
mousemode
mosh_string=$(ssh $1 -t mosh-server|grep "MOSH CONNECT")
mosh_key=$(echo $mosh_string|cut -d " " -f4)
mosh_port=$(echo $mosh_string|cut -d " " -f3)
mosh_ip=$(ping -n 1 $1 | grep Pinging | cut -d '[' -f 2|cut -d ']' -f 1)
alias weemux='tmux -2u attach -t weemux|| tmux-weemux-setup'
@FiXato
FiXato / alias.conf
Last active December 11, 2015 06:28
2 aliases to test how plain foreground and background colours look in WeeChat.
colours-all-1 = "/input insert ,00 [ ] 00 00 (white) ,01 [ ] 01 01 (black) ,02 [ ] 02 02 (navyblue) ,03 [ ] 03 03 (green)"
colours-all-2 = "/input insert ,04 [ ] 04 04 (red) ,05 [ ] 05 05 (maroonbrown) ,06 [ ] 06 06 (purple) ,07 [ ] 07 07 (oliveorange)"
colours-all-3 = "/input insert ,08 [ ] 08 08 (yellow) ,09 [ ] 09 09 (limegreen) ,10 [ ] 10 10 (teal/greenbluecyan) ,11 [ ] 11 11 (lightcyan/aqua)"
colours-all-4 = "/input insert ,12 [ ] 12 12 (royal/lightblue) ,13 [ ] 13 13 (fuchsia) ,14 [ ] 14 14 (grey) ,15 [ ] 15 15 (lightgrey/silver)"