Skip to content

Instantly share code, notes, and snippets.

View canassa's full-sized avatar
🎯
Focusing

Cesar Canassa canassa

🎯
Focusing
View GitHub Profile
@canassa
canassa / gist:1771645
Created February 8, 2012 17:56
Utilizando Leiningen

Comandos

lein new NAME  # Cria um novo projeto
lein deps      # Baixa as dependências
lein repl      # Iniciar o REPL
lein compile   # Gera o war

Exemplo de project.clj para o Google App Engine

@canassa
canassa / install.markdown
Created November 1, 2012 02:06
Installing Graphite on OS X with virtualenv

Virtualenv setup

cd /opt
sudo mkdir graphite
sudo chown `logname` graphite
virtualenv --distribute graphite
cd /opt/graphite
source bin/activate
@canassa
canassa / gist:7458174
Created November 13, 2013 23:08
Clojure LZW compression and decompression
(defn make-dict []
(let [vals (range 256)]
(zipmap (map vector vals) vals)))
(defn compress- [{:keys [dict index w out] :as a} b]
(let [buffer (conj w b)]
(if (contains? dict buffer)
(assoc a :w buffer)
{:dict (assoc dict buffer index)
#!/usr/bin/env ruby
#
# Runs during git flow hotfix start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
# version is necessary
#
@canassa
canassa / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package recfun
import common._
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
for (col <- 0 to row)
print(pascal(col, row) + " ")
println()
@canassa
canassa / portoseguro.js
Last active August 29, 2015 14:06
Exporta os dados de rede referenciada do site da Porto Seguro Saúde.
// Nao esqueca de mudar o iframe no console do Chrome antes de rodar.
// Com os dados impressos pelo console.log, importe eles no
// http://batchgeo.com/
console.log("City\tState\tAddress\tZip\tName\tPhone Number");
$('#pnResult').find('table.tabela_dados').each(function() {
var a = {
"address": $(this).find('th:contains("Endereço")').next().text(),
"name": $(this).find('th:contains("Razão Social")').next().text(),
@canassa
canassa / fix_pytest.py
Last active December 8, 2015 08:59
Converts self.assertEquals to assert
"""
Replaces unittest style asserts (e.g.: self.assertEqual) with py.test style asserts
Usage:
from lib2to3.refactor import RefactoringTool
refactoring_tool = RefactoringTool(['fix_pytest'])
refactoring_tool.refactor(['input.py'], write=True)
"""
### Keybase proof
I hereby claim:
* I am canassa on github.
* I am canassa (https://keybase.io/canassa) on keybase.
* I have a public key whose fingerprint is 45B8 8E66 CE7F FB3D E5A2 531B 003D 4D74 F252 5084
To claim this, I am signing this object:
local display = {
{1, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 1},