Skip to content

Instantly share code, notes, and snippets.

Avatar

Luiz Rocha lsdr

View GitHub Profile
@lsdr
lsdr / passgen.rs
Created Mar 30, 2020
Small password gen in Rust
View passgen.rs
// 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 Sep 4, 2019
Simplest Clojure example script
View teste.clj
(defn square [x] (* x x))
(println (take 25 (map square (range))))
@lsdr
lsdr / asciify.py
Last active Jul 19, 2019
Remove accentuation from a utf-8/latin-1 "string" (which should actually a byte-string) to ascii
View asciify.py
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 Jun 14, 2019
Data Engineering Howto
View data-engineering-howto.md
@lsdr
lsdr / ambulance.js
Created Dec 17, 2018
count IR total among NFL current injuries list
View ambulance.js
// 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 Oct 30, 2018
Fetch RDS logs
View get_the_logs.sh
#!/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 Dec 2, 2019
Docker Cheatsheet for the ages!
View docker_cheatsheet.md

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 Jun 1, 2018
Carregando dados do IBGE no PostGIS
View ibge.sh
# 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 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).lazy.select do |p|
p if p.to_s == p.to_s.reverse
end.first(n.to_i)
end
View Effective_Engineer.md

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?