Skip to content

Instantly share code, notes, and snippets.

John Feminella fj

Block or report user

Report or block fj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fj
fj / bf.rb
Created Mar 18, 2014
Brainfuck interpreter in Ruby
View bf.rb
$_=$$/$$;@_=$_+$_;$-_=$_-@_
$__=->_{_==[]||_==''?$.:$_+$__[_[$_..$-_]]}
@__=->_,&__{_==[]?[]:[__[_[$.]]]+@__[_[$_..$-_],&__]}
$_____=->_{@__[[*_],&->__{__[$.]}]}
@_____=->_{@__[[*_],&->__{__[$-_]}]}
$______=->_{___,______=$_____[_],@_____[_];_____=$__[___];____={};__=$.;(_=->{
____[______[__]]=___[__];(__+=$_)==_____ ?____:_[]})[]}
@______=->_,__{_=[*_]+[*__];____=$__[_];___={};__=$.;(_____=->{
___[_[__][$.]]=_[__][$_];(__+=$_)==____ ?___:_____[]})[]}
$_______=->_{$___=[];@___=$__[_];__=___=____=$.;$____,@____={},[]
@fj
fj / gist:9691518
Last active Aug 29, 2015
"Your Mission", by Ellen M. H. Gates (1865)
View gist:9691518
If you cannot, on the ocean, sail among the swiftest fleet,
Rocking on the highest billows, laughing at the storms you meet,
You can stand among the sailors, anchored yet within the bay,
You can lend a hand to help them, as they launch their boats away.
If you are too weak to journey up the mountain steep and high,
You can stand within the valley, while the multitudes go by;
You can chant in happy measure, as they slowly pass along;
Though they may forget the singer, they will not forget the song.
View gist:11259853
def outer(&b)
foo = 1
block.call
end
def inner(v)
puts foo + v
end
# Is there a way to make 'foo' available in the scope of `inner`?
View gist:11260367
def with_model(m, &block)
w = Object.new
w.define_singleton_method :model do
m
end
w.instance_eval &block
end
def property(name)
puts model.to_s + name.to_s
View gist:11384481
require 'spec/environment_spec_helper'
describe 'UsersController' do
describe 'GET /new' do
it { expect(:get => '/users/new').to be_routable }
it {
get '/users/new'
expect(last_response.status).to eq 200
}
@fj
fj / game.rb
Created Jul 10, 2014
My work on the Uncle Bob bowling kata.
View game.rb
class Game
def roll(*pins)
(@rolls ||= []).push *pins
end
def score
scores.inject(:+)
end
def scores
View gist:62953162c079eeca30bb
Loaded in 1.3 seconds
/home/polytope/.local/share/Steam/SteamApps/common/Star Ruler 2/scripts/server/empire.as:
Compiling void markDesignObsolete(Player&inout, const Design@, bool)
Error (302:5): Expression must be of boolean type
ERROR: Failed to build module 'empire' in manager 'server' (code -1).
ERROR: 'cheats': Cannot import function 'void setInstantColonize(bool)': module 'planets.SurfaceComponent' does not exist.
ERROR: 'empire_ai.EmpireAI': Cannot import function 'AIController@ createBasicAI()': module 'empire_ai.BasicAI' does not exist.
ERROR: 'orbitals': Cannot import function 'SystemDesc@ getSystem(Region@)': module 'game_start' does not exist.
ERROR: 'system_pathing': Cannot import function 'SystemDesc@ getSystem(uint)': module 'game_start' does not exist.
ERROR: 'system_pathing': Cannot import function 'SystemDesc@ getSystem(Region@)': module 'game_start' does not exist.
@fj
fj / gist:2900f29c6dc77d0e7c00
Last active Aug 29, 2015 — forked from cammckinnon/gist:2369233
fizzbuzz-in-brainfuck
View gist:2900f29c6dc77d0e7c00
[-]>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<<<<<
>>>>>>
[-]>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<<<<<
>>>>>>
>
[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@fj
fj / time.rb
Created Oct 31, 2014
perplexing round-trip Time instance behavior
View time.rb
t1 = Time.now
# => 2014-10-31 13:48:12 -0400
t2 = Time.at(t1.to_i)
# => 2014-10-31 13:48:12 -0400
t1.to_a
# => [12, 48, 13, 31, 10, 2014, 5, 304, true, "EDT"]
t2.to_a
@fj
fj / .rubocop.yml
Created Nov 5, 2014
UpHex's Rubocop and Rakefile
View .rubocop.yml
Metrics/LineLength:
Max: 125
You can’t perform that action at this time.