Skip to content

Instantly share code, notes, and snippets.

@janv
janv / gsgrabber.rb
Created August 31, 2009 14:05
Gamespot Grabber
#!/bin/env ruby
url = 'www.gamespot.com/games.html?type=games&mode=all&sort=score&dlx_type=all&sortdir=asc&sortdir=asc&page='
re = /<td class="tac"><a href="[\d\w\/]*index.html">(\d\d?.\d)<\/a><\/td>/im
# Init Scores
scores = {}
(0..10).each do |t|
(0..9).each do |o|
scores["#{t}.#{o}"] = 0
end
@janv
janv / synergy.conf
Created August 31, 2009 14:08
Config file for Synergy2
section: options
screenSaverSync = true
end
section: screens
jan:
switchCorners = none
switchCornerSize = 0
jan-note:
switchCorners = none
switchCornerSize = 0
@janv
janv / gist:184586
Created September 10, 2009 14:44 — forked from clemens/gist:2843
Permalinks mit Umlauten
ActionController::Base.logger.info "[Base] Loading config/initializers/" + File.basename(__FILE__)
class String
def to_permalink
text = self.dup
replacements = {
# replacement special character(s) to be replaced
"A" => [ "À", "Á", "Â", "Ã", "Å"],
"Ae" => [ "Ä", "Æ" ],
"C" => [ "Ç" ],
@janv
janv / add_attachment_data_to_wrapper.rb
Created November 2, 2009 16:30 — forked from Traz/add_attachment_data_to_wrapper.rb
Small tips for building a polymorphic usage of Paperclip, with video to flv, video thumbnail, mp3 tag extraction, zip file listing processors.
class AddAttachmentsDataToWrapper < ActiveRecord::Migration
def self.up
add_column :wrappers, :data_file_name, :string
add_column :wrappers, :data_content_type, :string
add_column :wrappers, :data_file_size, :integer
add_column :wrappers, :data_updated_at, :datetime
end
def self.down
remove_column :wrappers, :data_file_name
@janv
janv / My .gemrc
Created December 30, 2009 15:31
My .gemrc
cat > ~/.gemrc
---
:benchmark: false
:update_sources: true
gem: --no-rdoc --no-ri
:backtrace: false
:bulk_threshold: 1000
:verbose: true
:sources:
- http://gems.rubyforge.org/
@janv
janv / php_dyld.patch
Created February 17, 2010 22:50
Some Bugfix for PHP4 on Mac? dunno
--- Zend/zend.h 2007-09-05 00:16:02.000000000 +0200
+++ Zend/zend.h
@@ -80,18 +80,7 @@
# include <dlfcn.h>
#endif
-#if HAVE_MACH_O_DYLD_H
-#include <mach-o/dyld.h>
-
-/* MH_BUNDLE loading functions for Mac OS X / Darwin */
@janv
janv / dummymail.rb
Created March 17, 2010 11:19
A dummy mailserver implemented in Ruby, running on the commandline. It just spits out whatever it receives.
require 'socket'
class SMTPSession
@@timeout = 25
def initialize (session)
@session = session
puts "## SESSION STARTED ##"
end
def write (s)
@janv
janv / nokogiri_example.rb
Created November 9, 2010 12:30
Example for using the nokogiri reader
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::XML.fragment(<<-eoxml)
<bla>
<bing/>
<bong/>
</bla>
<blubb>asdasd</blubb>
eoxml
@janv
janv / gist:703924
Created November 17, 2010 19:41 — forked from tisba/gist:703646
#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
require "rubygems"
require 'active_support/inflector'
current_word = ENV['TM_CURRENT_WORD'] || ""
def gem_exists?(name)
function time_select(time_str) {
time_str = time_str.match(/(\d+):(\d+)/)
if(time_str) {
var h = time_str[1]
var m = time_str[2]
}
var buf = '<select class="time_h">'
for (var i=0; i < 24; i++) {
var is = i < 10 ? "0"+i : i;
buf += '<option' + (i == h ? ' selected' : '' ) + '>' + is + '</option>'