Skip to content

Instantly share code, notes, and snippets.

View stungeye's full-sized avatar

Kyle Geske stungeye

View GitHub Profile
stungeye / ruby_read_file_by_line.rb
Created March 29, 2010 14:36
Ruby Read File By Line
# Ruby Read File By Line
WORKING_DIR = File.dirname(__FILE__)
File.foreach(WORKING_DIR + '/filename.txt') do |line|
puts line
# The file can be online too
require 'open-uri'
stungeye / Handy SQLite3 Commands
Created May 14, 2010 00:37
Handy SQLite3 Commands
Describe Table:
PRAGMA table_info(tablename);
Show Tables:
stungeye / Using Jeweler to Build a Gem
Created May 29, 2010 20:35
Using Jeweler to Build a Gem
sudo apt-get install jeweler
jeweler gem_name --testunit
cd gem_name
touch lib/gem_name.rb <unless you already have code, in which case move it to /lib>
rake version:write
stungeye / Automated Scraping with Heroku and Sinatra
Created July 9, 2010 04:30
Automated Scraping with Heroku and Sinatra
mkdir wpgskeeter
cd wpgskeeter
git init
heroku create wpgskeeter
git add .
git commit -m 'Initial commit'
Create a .gems file:
stungeye / Suppress IRB Return Echoes
Created August 6, 2010 14:27
Suppress Irb/Console Return Echoes
conf.return_format = ''
rails new httpdocs --database=mysql
Config the db in config/database.yaml
Create subversion repos location:
svnadmin create /var/svn/n3repos
Import the rails project.
stungeye /
Last active June 21, 2018 15:32
Improving my VIM

Setting up Pathogen

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim

Ensure that pathogen.vim ends up in ~/.vim/autoload

Colour Scheme

mkdir ~/.vim/colors

stungeye / rbc_mechanize.rb
Created May 11, 2011 15:37
Mechanize Example
# Example of using Mechanize to login to the RBC online banking.
# RBC has since changed the structure of their HTML, so I doubt this script still works.
require 'rubygems'
require 'hpricot'
require 'mechanize'
WWW::Mechanize.html_parser = Hpricot
agent =
page = agent.get('')
stungeye / cipher.rb
Created May 26, 2011 17:19
Obfuscated Caesar Cipher Solver
s ='code.txt')
shift = ('e'.ord - ('a'..'z').reduce(['',0]) do |m, l|
s.count(l) > m[1] ? [l, s.count(l)] : m
end[0].ord) % 26
puts'a-z', (('a'..'z').to_a*2)[shift...shift+26].join)
# Assumptions:
# - The plaintext is written in a language that uses Roman characters.
# - The plaintext is written in a language where 'e' is the most common letter.
stungeye / cipher.txt
Created May 26, 2011 20:08
Cipher Text
rwpeitg x. sdlc iwt gpqqxi-wdat
paxrt lph qtvxccxcv id vti ktgn ixgts du hxiixcv qn wtg hxhitg dc iwt
qpcz, pcs du wpkxcv cdiwxcv id sd: dcrt dg ilxrt hwt wps ettets xcid iwt
qddz wtg hxhitg lph gtpsxcv, qji xi wps cd exrijgth dg rdcktghpixdch xc
xi, 'pcs lwpi xh iwt jht du p qddz,' iwdjvwi paxrt 'lxiwdji exrijgth dg
hd hwt lph rdchxstgxcv xc wtg dlc bxcs (ph ltaa ph hwt rdjas, udg iwt
wdi spn bpst wtg utta ktgn hatten pcs hijexs), lwtiwtg iwt eatphjgt