Skip to content

Instantly share code, notes, and snippets.


Luiz Rocha lsdr

View GitHub Profile
lsdr /
Created Mar 30, 2020
Small password gen in Rust
// Original code:
use rand::Rng;
use std::io;
fn main() {
let chars = "abcdefghijklmnopqrstuvxz1234567890!@#$%&*()-+=?;:.><.\\|{}[]";
println!("Password Generator");
lsdr / teste.clj
Created Sep 4, 2019
Simplest Clojure example script
View teste.clj
(defn square [x] (* x x))
(println (take 25 (map square (range))))
lsdr /
Last active Jul 19, 2019
Remove accentuation from a utf-8/latin-1 "string" (which should actually a byte-string) to ascii
import unicodedata
def asciify(string, encoding='latin-1'):
"""Given an string with bytes coming from a DB or other ill-developed data
extraction, cleanup and return an ASCII string free of accentuations.
>>> asciify('Ba\xc3\xba')
>>> asciify('Bau')
lsdr /
Created Jun 14, 2019
Data Engineering Howto
lsdr / ambulance.js
Created Dec 17, 2018
count IR total among NFL current injuries list
View ambulance.js
// Pro Football Reference | Current NFL Injuries
var elements = document.getElementById("div_injuries");
var injuries = elements.querySelectorAll("td[data-stat='injury_class']");
var seasonEnding = => el.textContent == "I-R");
lsdr /
Last active Oct 30, 2018
Fetch RDS logs
# usage:
# $ sh [rds-instance-name]
function __describe_logs {
aws rds describe-db-log-files --db-instance-identifier $1
lsdr /
Last active Dec 2, 2019
Docker Cheatsheet for the ages!

stop all running containers

docker ps | awk 'NR>1 {print $1}' | xargs docker stop

Brute force; list all and try to stop everything

docker ps -aq | xargs docker stop
lsdr /
Last active Jun 1, 2018
Carregando dados do IBGE no PostGIS
# download dos shapefiles do IBGE
curl -s '' -o
# abrir o pacote
unzip -j
# instala o postgresql e o postgis
brew install postgis
# inicia o postgresql
lsdr / palindromic_primes.rb
Created Mar 3, 2018
Random code challenge scripts and stuff like that
View palindromic_primes.rb
# Enter your code here. Read input from STDIN. Print output to STDOUT
require 'prime'
def ppn(n)
Prime.each(Float::INFINITY) do |p|
p if p.to_s == p.to_s.reverse

FWIW: I didn't produce the content present here. I've just copy-pasted it from somewhere over the Internet, but I cannot remember exactly the original source. I was also not able to find the author's name, so I cannot give him/her the proper credit.

Effective Engineer - Notes

What's an Effective Engineer?