Skip to content

Instantly share code, notes, and snippets.

View lsdr's full-sized avatar

Luiz Rocha lsdr

  • São Paulo, Brazil
  • 10:43 (UTC -03:00)
View GitHub Profile
@lsdr
lsdr / passgen.rs
Created March 30, 2020 02:23
Small password gen in Rust
// Original code:
// https://github.com/rodolfoghi/learn-rust/tree/master/raspberrypi-projects/password_generator
//
use rand::Rng;
use std::io;
fn main() {
let chars = "abcdefghijklmnopqrstuvxz1234567890!@#$%&*()-+=?;:.><.\\|{}[]";
println!("Password Generator");
@lsdr
lsdr / teste.clj
Created September 4, 2019 13:45
Simplest Clojure example script
(defn square [x] (* x x))
(println (take 25 (map square (range))))
@lsdr
lsdr / asciify.py
Last active July 19, 2019 14:44
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')
'Bau'
>>> asciify('Bau')
'Bau'
@lsdr
lsdr / data-engineering-howto.md
Created June 14, 2019 19:27
Data Engineering Howto
@lsdr
lsdr / ambulance.js
Created December 17, 2018 18:00
count IR total among NFL current injuries list
// Pro Football Reference | Current NFL Injuries
// https://www.pro-football-reference.com/players/injuries.htm
var elements = document.getElementById("div_injuries");
var injuries = elements.querySelectorAll("td[data-stat='injury_class']");
var seasonEnding = Array.prototype.slice.call(classes).filter(el => el.textContent == "I-R");
console.log(injuries.length);
console.log(seasonEnding.length);
@lsdr
lsdr / get_the_logs.sh
Last active October 30, 2018 00:08
Fetch RDS logs
#!/bin/sh
#
# usage:
# $ sh get_the_logs.sh [rds-instance-name]
#
function __describe_logs {
aws rds describe-db-log-files --db-instance-identifier $1
}
@lsdr
lsdr / docker_cheatsheet.md
Last active December 2, 2019 18:27
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
lsdr / ibge.sh
Last active June 1, 2018 13:05
Carregando dados do IBGE no PostGIS
# download dos shapefiles do IBGE
curl -s 'ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2016/Brasil/BR/BR.zip' -o BR.zip
# abrir o pacote
unzip -j BR.zip
# instala o postgresql e o postgis
brew install postgis
# inicia o postgresql
@lsdr
lsdr / palindromic_primes.rb
Created March 3, 2018 20:53
Random code challenge scripts and stuff like that
# Enter your code here. Read input from STDIN. Print output to STDOUT
require 'prime'
def ppn(n)
Prime.each(Float::INFINITY).lazy.select do |p|
p if p.to_s == p.to_s.reverse
end.first(n.to_i)
end

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?