Skip to content

Instantly share code, notes, and snippets.

PuTTY Session Manager

Installation

Make sure putty.exe is in your PATH (or put it in C:Windows)

Install dependencies:

C:\ gem install sinatra haml win32-open3
@beccasaurus
beccasaurus / member-only-twitter-site.rb
Created November 4, 2009 06:03
Sinatra-based "member-only" Twitter site
#! /usr/bin/env ruby
%w( rubygems sinatra haml sass rack/oauth json ).each {|lib| require lib }
use Rack::Session::Cookie
use Rack::OAuth, :site => 'http://twitter.com',
:key => 'bKtzVmvJoCYjyK1mUYaUQ',
:secret => 'CmOM0APjvmT8z86DA0cXPQWXGZGfLKTpmdTUGzxqnU',
:redirect => '/'
configure do

Not Vark.com

Prototype for asking questions on a site, having it go out to an external messaging system, and getting the responses back to the user who asked the question.

Video demo: www.viddler.com/explore/remitaylor/videos/32/

NOTE: This isn’t 100% working, as Jabber::Simple doesn’t like to support multiple connections to the same GTalk server. If the code were ported to use xmpp4r, it should work fine.

This uses GTalk as the externam messaging system.

@beccasaurus
beccasaurus / spec_helper.rb
Created December 31, 2009 20:29
Transactional specs with ActiveRecord (without Rails)
# ActiveRecord transactional specs (without Rails)
Spec::Runner.configure do |config|
config.before do
ActiveRecord::Base.connection.begin_db_transaction
ActiveRecord::Base.connection.increment_open_transactions
end
config.after do
if ActiveRecord::Base.connection.open_transactions != 0
ActiveRecord::Base.connection.rollback_db_transaction
ActiveRecord::Base.connection.decrement_open_transactions
@beccasaurus
beccasaurus / Output
Created January 24, 2010 04:32
Example of using Forwardable with def_delegators
$ ./UsingForwardable.rb
0
2
Thing
Another Thing
# You might want to do this in your before blocks in RSpec ...
before do
AuxCode.create_root_code!
AuxCode.load_from :colors => %w( red blue ), :genders => %w( male female )
AuxCode.create_classes!
end
# create_root_code! will create an AuxCode with ID=0 (if one doesn't already exist)
# load_from will load up some data
require 'rubygems'
require 'spec'
require 'extlib'
module SomeNamespace; end
describe 'Extlib#assert_kind_of' do
include Extlib::Assertions
it 'should handle constant reloading' do
require "rubygems"
require "dm-core"
class Word
include DataMapper::Resource
property :id, Serial
property :text, String
has n, :translations #, :model => 'Word', :foreign_key => [:word_id]
body {
#content {
.post {
ul {
li.foo {
border: 1px solid black;
}
}
}
}
module Foo
module Bar
class Something
def foo
if hi
if there
# ...
end
end
end