Skip to content

Instantly share code, notes, and snippets.

Avatar

Juhamatti Niemelä iiska

View GitHub Profile
@iiska
iiska / db_fixtures_dump.rake
Created Dec 28, 2011
Dump Rails db to fixtures
View db_fixtures_dump.rake
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros
#
# Optimized version which uses to_yaml for content creation and checks
# that models are ActiveRecord::Base models before trying to fetch
# them from database.
namespace :db do
namespace :fixtures do
desc 'Dumps all models into fixtures.'
task :dump => :environment do
models = Dir.glob(RAILS_ROOT + '/app/models/**.rb').map do |s|
@iiska
iiska / .irbrc
Created Oct 8, 2010
Command history, tab completion and Rails SQL logs for script/console
View .irbrc
# -*- mode: ruby -*-
# TAB completion for irb
require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
# Save command history to be used between multiple sessions
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
@iiska
iiska / pre-commit
Created Oct 4, 2010
Refuse commit when there are debug code present.
View pre-commit
#!/bin/sh
#
# Aborts commit if grepping diff encounters JS or Ruby debug lines.
has_console_log=$(git diff --cached | grep '^\+\s*console\.log\(.*\)')
has_console_dir=$(git diff --cached | grep '^\+\s*console\.dir\(.*\)')
has_ruby_debug=$(git diff --cached | grep "^\+\s*\(require \['\"\]ruby-debug\['\"\];\?\)\?\s*debugger")
View notes.rake
require 'source_annotation_extractor'
class SourceAnnotationExtractor
# Override the directories that the SourceAnnotationExtractor
# traverses when you call rake notes
def find(dirs=%w(app lib spec public/javascripts))
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
end
# Override to extract annotations from .haml and .js files
View lastfm-mpd-related.sh
@iiska
iiska / validator.py
Created Oct 22, 2009
Simple XML Schema validator in Python using lxml library
View validator.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# Simple XML validator done while learning the use of lxml library.
# -- Juhamatti Niemelä <iiska AT iki DOT fi>
import lxml
from lxml import etree
if __name__ == "__main__":
@iiska
iiska / Nettiradiot.m3u
Created Jun 6, 2009
Lähes kaikki Suomalaisten radioasemien nettiradiot.
View Nettiradiot.m3u
#EXTM3U
#EXTINF:0,Bassoradio
http://83.145.201.209:8000/
#EXTINF:0,Classic Radio
http://217.30.180.242:8000/clsr.ogg
#EXTINF:0,Groove FM
http://217.30.180.242:8000/gvfm.ogg
@iiska
iiska / wvdial.conf
Created Feb 6, 2009
wvdial.conf to be used with DNA Finland 3G or gprs over bluetooth.
View wvdial.conf
# wvdial.conf to be used with DNA Finland 3G or gprs over bluetooth
[Modem0]
Modem = /dev/rfcomm0
Baud = 115200
SetVolume = 0
Dial Command = ATD
Init1 = AT
Init3 = ATH
FlowControl = CRTSCTS
[Dialer dna]
@iiska
iiska / iiska.theme
Created Jan 23, 2009
My irssi theme with minor changes
View iiska.theme
# default foreground color (%N) - -1 is the "default terminal color"
default_color = "-1";
# print timestamp/servertag at the end of line, not at beginning
info_eol = "false";
# these characters are automatically replaced with specified color
# (dark grey by default)
replaces = { "[]=" = "%K$*%n"; };
View .bashrc
# .bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
[ -z "$PS1" ] && return
# http://en.tldp.org/HOWTO/Bash-Prompt-HOWTO/x869.html
function prompt_command {
hostnam=$(hostname -s)
usernam=$(whoami)
You can’t perform that action at this time.