(results in milliseconds per call, operating on a image/texture of size 1022x1022)
PixelCache#to_image 32.61720
PixelCache#refresh 1.83594
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' |
require 'fastercsv' # Gem I'm assuming is beign used, but there are others. | |
hash = {} # So apeiros_ doesn't murder me | |
FasterCSV.foreach("path/to/file.csv") do |line| | |
hash[line[0].to_sym] = { :location => line[1], :device_type => line[3] } | |
end | |
# then you can reference with |
class RawDataController < ApplicationController | |
helper_method :sort_column, :sort_direction | |
def index | |
end | |
protected | |
def sort_column | |
logger.debug self.class::SORT_MODEL.inspect |
heftig: | |
first, do target = rand(a.inject(0){|m,h| m + h[:prob]}) | |
to get a value between 0 and (sum of all probs - 1) | |
then just a.find { |h| target -= h[:prob]; target < 0 } | |
steps through the array, reducing target by prob until it's < 0 |
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, |
# Failing case of Window#gl used with shaders. | |
require "opengl" # Gem must be "opengl" gem, not "ruby-opengl" gem | |
require 'gosu' | |
def media_path(file); File.expand_path "media/#{file}", File.dirname(__FILE__) end | |
class TestWindow < Gosu::Window | |
def initialize | |
super 640, 480, false |
#version 110 | |
attribute vec2 in_TexCoord; | |
varying vec2 var_TexCoord; | |
void main() | |
{ | |
gl_Position = ftransform(); | |
var_TexCoord = in_TexCoord; |
/framebuffer.png | |
/framebuffer_section.png |
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 |