Skip to content

Instantly share code, notes, and snippets.

View cadwallion's full-sized avatar
⚒️
Building all the things

Andrew Nordman cadwallion

⚒️
Building all the things
View GitHub Profile
@cadwallion
cadwallion / ball.rb
Created November 24, 2011 14:17
Gosu Bouncing ball
require 'zorder'
class Ball
attr_accessor :x, :y, :velocity_x, :velocity_y
def initialize(window)
@x = rand(window.width)
@y = rand(window.height)
@velocity_x = 2.0
@velocity_y = 2.0
@cadwallion
cadwallion / console output
Created November 28, 2011 15:55
portal commandline script
1.9.3-p0 in portal/
› ./bin/portal
Manages SSH portals as easy hosts
usage: portal command [command options]
Version: 0.0.1
Commands:
add - Adds a portal to the list
@cadwallion
cadwallion / gist:1409963
Created November 30, 2011 17:41
Writing custom warden strategies
# For more information on Warden strategies, read this: https://github.com/hassox/warden/wiki/Strategies
class SuperCoolWardenStrategy
def valid?
# you have access to env and request
# return true/false if this is strategy should run or not
# if it returns false, it will move onto the next strategy in the list
# defaults to true if you don't write this method
end
def authenticate!
@cadwallion
cadwallion / gist:1423557
Created December 2, 2011 15:05
Boot times of Rails apps in various circumstances
DevNull:research cadwallion$ rails new blank_app -O -T > /dev/null
DevNull:research cadwallion$ cd blank_app/
DevNull:blank_app cadwallion$ date && rails s
Fri Dec 2 09:02:48 CST 2011
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-02 09:02:49] INFO WEBrick 1.3.1
[2011-12-02 09:02:49] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.1.0]
@cadwallion
cadwallion / segfault_test.rb
Created December 5, 2011 14:29
Gosu Segmentation Fault Details
require 'gosu'
require 'minitest/autorun'
class TestWindow < Gosu::Window
def initialize
super(640, 480, false)
end
def draw ; end
def update ; end
@cadwallion
cadwallion / segfault_test2.rb
Created December 5, 2011 14:36
Gosu Segfault - Repro #2
require 'gosu'
require 'minitest/autorun'
class TestWindow < Gosu::Window
def initialize
super(640, 480, false)
end
def draw ; end
def update ; end
1.9.3-p0@profile_service_application in profile-service/ on major_renovations
› gb
authorize_with_oauth_tokens
avatars
bnet_debug
config_cleanup
continuous_bnet_parsing
header_versioning
jasmine_conversion
* major_renovations
@cadwallion
cadwallion / refactored_troll.rb
Created December 7, 2011 15:18
Read-only Detection in Ruby for Java Developers
class File
def self.read_only?(file)
s = File.stat(file)
mode = sprintf("%o", s.mode)
if s.owned?
return true if mode[3].to_i == 4
end
if s.grpowned?
return true if mode[4].to_i == 4
@cadwallion
cadwallion / gist:1482967
Created December 15, 2011 21:24
`which rvm`
› which rvm
rvm () {
local result current_result
if [[ -n "${BASH_VERSION:-}" ]]
then
trap '__rvm_teardown_final' 0 1 2 3 15
fi
next_token="$1"
[[ $# -eq 0 ]] || shift
__rvm_initialize
@cadwallion
cadwallion / ball.rb
Created December 17, 2011 14:35
Peter Cooper's jRuby Pong, Refactored
require 'java'
require 'lwjgl.jar'
require 'slick.jar'
java_import org.newdawn.slick.Image
require 'pong/image_context'
require 'pong/collidable_attributes'
module Pong