View ar_4_2_bug.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
View post.md

Getting started with Elixir - Part 1

If you have been reading blog posts, hacker news threads, your favorite developers tweets or listening podcasts at this point I'm pretty sure you heard about Elixir programming language. The language was created by José Valim, a well known developer in the open-source world, you probably know him from the Ruby on Rails MVC framework or from the devise and simple_form ruby gems him and his co-workers from the Plataformatec have been working in the last years.

Elixir, a brief history

According the José Valim, the language was born 2011. He had the idea to build the new language due the lack of good tools to solve the concurrency problems in the ruby world. At that time, after spending time studying concurrency and distributed focused languages he found two languages that he likes Erlang and Clojure which runs in the JVM. He liked everything he saw in the Erlang language (Erlang VM) and he hated the things he didn't see, like polymorphism, metaprogramming and languag

View intergration_spec_helper.rb
module IntegrationSpecHelper
def drop_files files, drop_area_id
js_script = "fileList = Array();"
files.count.times do |i|
# Generate a fake input selector
page.execute_script("if ($('#seleniumUpload#{i}').length == 0) { seleniumUpload#{i} = window.$('<input/>').attr({id: 'seleniumUpload#{i}', type:'file'}).appendTo('body'); }")
# Attach file to the fake input selector through Capybara
attach_file("seleniumUpload#{i}", files[i])
# Build up the fake js event
js_script = "#{js_script} fileList.push(seleniumUpload#{i}.get(0).files[0]);"
View data-html-chosen.jquery.js
$ = jQuery;
$.fn.extend({
chosenDataHtml: function(options) {
return this.each(function(input_field) {
var $this = $(this),
formatSelection = options['formatSelection'] || function(e, data) {
var chosen = data.chosen,
View usd2brl.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
View usd2brl.js
var http = require('http'),
request = require('request');
x = '',
port = process.env.PORT || 8080;
http.createServer(function(req, response) {
http.get({
host: 'query.yahooapis.com',
path: "/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%27www.google.com%2Ffinance%2Fconverter%3Fa%3D1%26from%3DUSD%26to%3DBRL%27%20and%20xpath%3D%27%2F%2F*%5B%40id%3D" + '"currency_converter_result"' + "%5D%2Fspan%2Ftext()%27&format=json&callback="
View pac.rb
# [altura, largura, comprimento, peso]
products = [
[28.0, 44.0, 33.0, 4],
[29.0, 44.0, 33.0, 17],
[50.0, 100.0, 50.0, 10],
[106, 40 , 20, 4],
[70, 70, 70, 20],
[66.65, 66.65, 66.65, 6.6],
[10, 1, 1, 7.5]
]
View my-day.sh
autoload -U colors && colors
HOUR=`date +"%k"`
function _is_current_ () {
if [[ $1 =~ ([0-9]{1,2})h([[:space:]]-[[:space:]])?([0-9]{1,2})?h? ]]; then
start=$match[1];
end=$match[3];
if [ -z $end ]; then
if [[ $HOUR -eq $start ]]; then
View worm.rb
#!/usr/bin/env ruby
require 'gosu' # gem install gosu --no-document
include Gosu
$dimension, $splits = 200, 20
$size = $dimension.to_f / $splits.to_f
class Worm
attr_writer :dir
def initialize() reset end