Skip to content

Instantly share code, notes, and snippets.

@caarlos0
caarlos0 / alemanha.txt
Created August 21, 2016 15:25
Escalações Brasil X Alemanha - Idade dos jogadores - Final Olimpiadas 2016
19 Max Christiansen
20 Julian Brandt
20 Lukas Klostermann
20 Max Meyer
20 Niklas Süle
21 Davie Selke
21 Grischa Prömel
21 Leon Goretzka
21 Robert Bauer
21 Serge Gnabry
#!/bin/sh
go get -u -v github.com/alecthomas/gometalinter
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-outline
go get -u -v github.com/mitchellh/gox
go get -u -v github.com/motemen/gore
go get -u -v github.com/newhook/go-symbols
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/tpng/gopkgs
@caarlos0
caarlos0 / MyClassTest.java
Last active June 4, 2016 13:02
An example of how to use JUnit `@Rule` to test methods who are expected to thrown an exception.
package sample;
import org.junit.*;
import org.junit.rules.ExpectedException;
import sample.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class MyClassTest {
@caarlos0
caarlos0 / elections.rb
Last active June 4, 2016 13:00
My Ruby script to list the top-3 president candidates in Brazilian 2014 elections. Updated with second round data as well. http://carlosbecker.com/posts/elections/
require 'net/http'
require 'uri'
require 'json'
uri = URI('http://divulga.tse.jus.br/2014/divulgacao/oficial/143/dadosdivweb/br/br-0001-e001431-w.js')
class String; def percent_of(n) "#{(self.to_f / n.to_f * 100.0).round(2)}%"; end; end
begin
data = JSON(Net::HTTP.get_response(uri).body)
system('clear')
puts "\n\n----\n#{data['ht']} - #{data['ea'].percent_of(data['e'])} dos votos apurados\n----"
data['cand'].take(3).each do |candidate|
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f
alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"

Setup Mac OS X Mountain Lion

I just replaced the hard drive of my mbp and decided to do a clean install of Mountain Lion (10.8.5) since I was still using Snow Leopard (10.6.8).

I kinda regret for not using Boxen to automate the process, but TBH I have this laptop for almost 3yrs and this is the first time I needed to reinstall everything, maybe the next time...

@caarlos0
caarlos0 / nginx.conf
Last active December 25, 2015 21:29
Config that I'm using right now with Puma + nginx
upstream puma {
server unix://tmp/wealcash.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name wealcash.com;
root /var/www/wealcash/current/public;
location ^~ /assets/ {

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables