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]

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?
#!/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
#
@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.

@bf4
bf4 / 42-things.md
Last active August 29, 2015 14:12 — forked from SabretWoW/42-things.md

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|