Skip to content

Instantly share code, notes, and snippets.

View bil-bas's full-sized avatar

Bil Bas bil-bas

View GitHub Profile
@bil-bas
bil-bas / bacon.rb
Created October 26, 2010 16:06 — forked from banister/bacon.rb
require 'rubygems'
require '../lib/remix'
require 'bacon'
describe 'Test basic remix functionality' do
before :each do
class Module
public :include
end
require 'ray'
ImageWidth = 640
ImageHeight = 480
image = Ray::Image.new [ImageWidth, ImageHeight]
Ray::ImageTarget.new image do |target|
target.shader.compile(:frag => StringIO.new(<<eof))
#version 110
@bil-bas
bil-bas / gist:2907195
Created June 10, 2012 20:18
generator
require 'thor'
require 'thor/actions'
class App < Thor
include Thor::Actions
end
@run = App.new
class Table < ActiveRecord::Base
self.table_name = "magi.tables"
has_many :headers
#--------------------------------------------------------------------------------------------------#
def self.generate
@tables = Table.select([:id, :source_database, :current_name, :magi_name])
@headers = Header.select([:id, :table_id, :current_name, :magi_name]) #refactor to call this in the loop
@bil-bas
bil-bas / gist:3049003
Created July 4, 2012 19:12
programatically define a method that accepts a block
class Test
def self.define_me_a_method(name)
self.send(:define_method, name, proc { |&block|
block.call
})
end
define_me_a_method 'awesome'
end
translate -@camera_x, -@camera_y do
@map.draw
@player.draw
end
translate 10, 10 do
score_text = "Collected: #{@player.items}"
score_width = @score_font.text_width score_text
draw_quad 0, 0, 0xaa000000,
class RawDataController < ApplicationController
helper_method :sort_column, :sort_direction
def index
end
protected
def sort_column
logger.debug self.class::SORT_MODEL.inspect
@bil-bas
bil-bas / gist:3419649
Created August 21, 2012 21:38 — forked from anonymous/gist:3419574
Traffic CSV for nullsign
require 'csv'
# Read the list of hosts.
hosts = {}
CSV.open('./datafile.csv', 'r') do |fields|
hosts[fields[0]] = { :location => fields[1], :device_type => fields[3] }
end
# Find out the date to report on.
report_file = './report.csv'
@bil-bas
bil-bas / wrap_module.rb
Created August 22, 2012 00:46 — forked from drewdeponte/gist:3420790
Require inside module try #1
# code.rb contains:
# class Frog
# end
module MyModule
class_eval File.read("./code.rb"), "code.rb", 1
end
p MyModule::Frog # Will succeed.
p Frog # Will fail.