Skip to content

Instantly share code, notes, and snippets.

View lsdr's full-sized avatar

Luiz Rocha lsdr

  • São Paulo, Brazil
  • 09:48 (UTC -03:00)
View GitHub Profile
@lsdr
lsdr / data-engineering-howto.md
Created June 14, 2019 19:27
Data Engineering Howto
@lsdr
lsdr / my_python_env.sh
Last active September 28, 2021 21:40
requirements.txt and a quick sh script to bootstrap my core virtualenv
#!/bin/sh
# assumptions:
# * virtualenv is avaliable and working
# * virtualenvs go to ~/.pvm
export PIP_REQUIRE_VIRTUALENV=true
export PIP_RESPECT_VIRTUALENV=true
export VIRTUALENV_DISTRIBUTE=true
cd ~; mkdir -p ~/.pvm/core
virtualenv --python=/usr/bin/python --clear --no-site-packages --distribute ~/.pvm/core
@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 / 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 / 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 / ccat
Last active April 22, 2019 12:57
stuff I keep on ~/bin
#!/bin/bash
# Font: http://scott.sherrillmix.com/blog/programmer/syntax-highlighting-in-terminal/
if [ ! -t 0 ]; then
file=/dev/stdin
elif [ -f $1 ]; then
file=$1
else
echo "Usage: $0 code.c"
echo "or e.g. head code.c|$0"
exit 1
@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 / NEATEvolve.lua
Last active August 11, 2018 12:52
MarI/O: the script that learns how to play Mario Bros/Mario Kart
-- MarI/O by SethBling
-- Feel free to use this code, but please do not redistribute it.
-- Intended for use with the BizHawk emulator and Super Mario World or Super Mario Bros. ROM.
-- For SMW, make sure you have a save state named "DP1.state" at the beginning of a level,
-- and put a copy in both the Lua folder and the root directory of BizHawk.
if gameinfo.getromname() == "Super Mario World (USA)" then
Filename = "DP1.state"
ButtonNames = {
"A",