Skip to content

Instantly share code, notes, and snippets.

View paulsonkoly's full-sized avatar

Paul Sonkoly paulsonkoly

View GitHub Profile
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'gosu'
def linear_map(value, mina, maxa, minb, maxb)
(maxb - minb) * (value - mina) / (maxa - mina) + minb
end
@paulsonkoly
paulsonkoly / x.rb
Created July 11, 2020 16:33
local var assignment
def foo
13
end
2.times do
p foo
foo = 'something else'
p foo
end
@paulsonkoly
paulsonkoly / x.rb
Last active February 6, 2021 19:18
pokemon
describe '#reload' do
# Attributes
let(:id) { 25 }
let(:name) { 'Pikachu' }
let(:new_name) { 'Pika' }
let(:pokemon) { Pokemon.find(id) }
it 'returns an object with the original attributes' do
pokemon.name = new_name
@paulsonkoly
paulsonkoly / x.rb
Created February 8, 2021 12:28
singleton
class Foo
def initialize
singleton_class.class_eval { def foo; :bar; end }
singleton_class.class_eval do
alias_method :f_o_o, :foo
end if respond_to? :foo
end
end