Skip to content

Instantly share code, notes, and snippets.


Benjamin Fleischer bf4

View GitHub Profile
View deploy.rake
#Deploy and rollback on Heroku in staging, production, dev and qa environments
require 'pty'
%w[dev qa production staging].each do |app|
desc "Deploy to #{app}"
task "deploy:#{app}" => %W[deploy:set_#{app}_app deploy:push deploy:restart deploy:tag]
desc "Deploy #{app} with migrations"
task "deploy:#{app}:migrations" => %W[deploy:set_#{app}_app deploy:push deploy:off deploy:migrate deploy:restart deploy:on deploy:tag]

Keybase proof

I hereby claim:

  • I am bf4 on github.
  • I am bf4 ( on keybase.
  • I have a public key whose fingerprint is 4B5F 8D75 02A0 8180 CCD5 59D1 3985 4667 DEB1 0286

To claim this, I am signing this object:

bf4 / stream_and_parse_file.rb
Last active Aug 29, 2015
streaming file, ripped off of ruby's csv lib
View stream_and_parse_file.rb
# streaming logic ripped from
def raw_encoding(default = Encoding::ASCII_8BIT)
if @io.respond_to? :internal_encoding
@io.internal_encoding || @io.external_encoding
elsif @io.is_a? StringIO
elsif @io.respond_to? :encoding
View GithubEventAnalysisWithNeo4j.markdown

Github Events Analysis with Neo4j


On July 22, Github announced the 3rd Annual Github Data Challenge presenting multiple sources of data available.

This sounded to me a good opportunity to use their available data and import it in Neo4j in order to have a lot of fun at analyzing the data that fits naturally in a graph.

As I work mainly offline or behind military proxies that do not permit me to use the ReST API, I decided to go for the Github Archive available here, you can then download json files representing Github Events on a daily/hour basis.

View email_address_validator.rb
require 'mail'
require 'resolv'
require 'net/telnet'
class EmailAddressValidator < ActiveModel::EachValidator
attr_reader :mail
def validate_each(record, attribute, value)
return if options[:allow_nil] && value.nil?
bf4 /
Created Sep 14, 2014
RBenv binaries download
sudo apt-get install libssl-dev zlib1g zlib1g-dev libreadline-dev bison
# cp rbenv_install.bash /usr/local/rbenv_installer.bash
sudo chgrp sudo /usr/local/rbenv_installer.bash
sudo chmod g+rwxXs /usr/local/rbenv_installer.bash
# cp /etc/profile.d/
sudo chmod +x /etc/profile.d/
source /etc/profile.d/
# cp default-gems /usr/local/rbenv/default-gems
View vaportrails.rb
#!/usr/bin/env ruby
# Print the vaportrail of a ruby file in a git repo, i.e.,
# the complexity level at each commit.
# Requires: >= bash ?.?
# >= git 1.7.1
# >= ruby 1.9.2
# >= flog 2.5.0

Based on the 'successful' build, I think this PR is sufficient as is. I'll create new PR's for specific JRuby issues.

Travis results summary


test/railties/railtie_test.rb Run options: --seed 40836 Running: ...............

View ruby_queues_are_essentially_go_channels.rb
# Apparently this has been in Ruby since 1.9.3... who knew?
# Also check out sized queue class
require 'thread'
# Create a new thread that blocks on queue pop
# Create an "exit" channel to send "stop" message when total of 100 is reached

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

You can’t perform that action at this time.