Skip to content

Instantly share code, notes, and snippets.

View FiXato's full-sized avatar

Filip H.F. "FiXato" Slagter FiXato

View GitHub Profile
alias weemux='tmux -2u attach -t weemux|| tmux-weemux-setup'
# 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)
@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')
@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 / 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 / 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 / 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 / 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 / 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 / missing_openmsx_roms.txt
Created July 11, 2012 22:39
List of SHA1 sums and filenames that I'm missing for openMSX. Mostly variants though.
Found 12 unique SHA1 sums missing:
05e9f40bb7bdc46b557d445c717cb84ad75252f6
2c359c979fbfe5c7c3cce90b4593dba4b7cbcd92
383de340910981bc1e8a2acaec8663b020804ba1
47c78981b5ffbb9e8d9c2145f9c2e642ff0e8193
4a55eb07e1ab8b847e230854e2e26e48983982a6
51a1467d73d26c91aab7923e3be66490daaffdee
5fa3aa79aeba2c0441f349e78e9a16d9d64422ea
8625c6b633d9cca2875e4dc33404fb98653379d7
b43a4be5c754f68dc3ee64eee29d64f30fac2aff