Skip to content

Instantly share code, notes, and snippets.

@lackac
lackac / .irbrc.rb
Created August 12, 2008 21:07
My .irbrc file
# load libraries
require 'rubygems'
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
# which from http://programmingishard.com/code/507
module Kernel

Quacks

I created this simple script to play a random audio file from my ~/quacks directory. Then mapped this script to ⌃⌥Q with QuickSilver. This is like one free interaction just for me. I placed the default Adium sounds into this directory for a start.

The script creates a log from the numbers the audio files were played. If you don't need this just delete the file contents from line 9 to the end of file.

// ==UserScript==
// @name Jira improvements
// @namespace http://lackac.hu
// @include http://crm.virgo.hu/*
// ==/UserScript==
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// ==UserScript==
// @name Piacter improvements
// @namespace http://lackac.hu
// @description Normalisabb kepkezeles piacteren
// @include http://piacter.bikemag.hu/showproduct.php*
// ==/UserScript==
var GM_jQuery = document.createElement('script');
GM_jQuery.src = 'http://jquery.com/src/jquery-latest.js';
GM_jQuery.type = 'text/javascript';
def how_to_make_pizza( components, pizza_size )
components.each do |component|
angle = rand * 2 * Math::PI
dist = rand(pizza_size) / 2.0
Fan << component.move_to( Position.new( dist * Math.cos( angle ), dist * Math.sin ( angle )).release
end
end
#!/usr/bin/env ruby -rrubygems
require 'activesupport'
require 'ostruct'
bprb = [
{:date => Date.new(2008, 9, 17), :attendees => 52},
{:date => Date.new(2008, 10, 16), :attendees => 30},
{:date => Date.new(2008, 11, 20), :attendees => 25},
{:date => Date.new(2008, 12, 17), :attendees => 8},
> This is a Shortwave configuration file
> http://shortwaveapp.com/
>
> Urls may contain the following replacement tokens:
>
> %s → search terms
> %r → URL of current page
> %d → domain part of the current URL
> %t → current page title
>
@lackac
lackac / gist:216060
Created October 22, 2009 16:14
A primitive way to ensure that your Passenger processes don't eat up your machine completely. It will kill any Rack app process that starts to eat more than 300MB RAM. I used this to find a leak in a Sinatra application.
#!/bin/bash
while :; do
stats=$(passenger-memory-stats | grep Rack)
if [ "$stats" != "" ]; then
echo $stats
echo $stats | egrep --color=always 'MB ([12][0-9]|[3-9])..\.. MB'
pid=$(echo $stats | egrep 'MB ([12][0-9]|[3-9])..\.. MB' | awk '{ print $1 }')
if [ "$pid" != "" ]; then
ps aux | grep $pid
@lackac
lackac / pptwit.rb
Created November 16, 2009 15:46
Some old code where the script would monitor a newsstream called "Percről percre" and tweet any new items through a specific twitter account.
#!/usr/bin/env ruby
$KCODE = 'u'
require 'jcode'
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'twitter'
@lackac
lackac / typo2jekyll.rb
Created November 19, 2009 16:15
Migrates a blog's contents from the Typo blog engine to Jekyll
# Author: Toby DiPasquale <toby@cbcg.net>
# Modified by: László Bácsi <lackac@lackac.hu>
require 'fileutils'
require 'rubygems'
require 'sequel'
require 'htmlentities'
begin
require 'ya2yaml'
$KCODE = 'u'