Skip to content

Instantly share code, notes, and snippets.

#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]
@bf4
bf4 / keybase.md
Created August 19, 2014 04:18
keybase.md

Keybase proof

I hereby claim:

  • I am bf4 on github.
  • I am bf4 (https://keybase.io/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
bf4 / stream_and_parse_file.rb
Last active August 29, 2015 14:05
streaming file, ripped off of ruby's csv lib
# streaming logic ripped from https://github.com/ruby/ruby/blob/trunk/lib/csv.rb
def raw_encoding(default = Encoding::ASCII_8BIT)
if @io.respond_to? :internal_encoding
@io.internal_encoding || @io.external_encoding
elsif @io.is_a? StringIO
@io.string.encoding
elsif @io.respond_to? :encoding
@io.encoding
else
default

Github Events Analysis with Neo4j

Imgur

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.

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
bf4 / README.md
Created September 14, 2014 19:00
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
/usr/local/rbenv_installer.bash
# cp rbenv.sh /etc/profile.d/rbenv.sh
sudo chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
# cp default-gems /usr/local/rbenv/default-gems
#!/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
#
#
# 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
#

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

Railties:

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

@bf4
bf4 / introrx.md
Last active August 29, 2015 14:10 — forked from staltz/introrx.md

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.