Skip to content

Instantly share code, notes, and snippets.

View rodrigobaron's full-sized avatar

Rodrigo Baron rodrigobaron

View GitHub Profile
@rodrigobaron
rodrigobaron / docker-compose-run
Last active August 2, 2016 07:04
Windows alternative to 'Interactive mode is not yet supported on Windows.' on docker-compose run issue
#!/bin/bash
function docker-compose-run() {
if [ "$1" = "-f" ] || [ "$1" = "--file" ] ; then
docker exec -i $(docker-compose -f $2 ps $3 |grep -m 1 $3 | cut -d ' ' -f1) "${@:4}"
else
docker exec -i $(docker-compose ps $1 | grep -m 1 $1 | cut -d ' ' -f1) "${@:2}"
fi
}
@rodrigobaron
rodrigobaron / bundle_install
Created May 17, 2016 12:27
Docker, generate Gemfile.lock
#!/bin/bash
docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.2 bundle install
@rodrigobaron
rodrigobaron / install-opencv.sh
Last active April 21, 2023 18:51
Install OpenCV on Ubuntu or Debian
# SOURCE: (milq) https://github.com/milq/scripts-ubuntu-debian/blob/master/install-opencv.sh
# also http://milq.github.io/install-opencv-ubuntu-debian/
# KEEP UBUNTU OR DEBIAN UP TO DATE
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
@rodrigobaron
rodrigobaron / unlock-screen.cmd
Created February 13, 2017 23:43
Unlock screen for steam home streaming
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log
@rodrigobaron
rodrigobaron / oo_python.md
Last active September 8, 2017 16:25
Exemplo em pt-BR de separação de responsabilidade com python

Importa as dependencias

from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship, backref
@rodrigobaron
rodrigobaron / textblob_sentan_pt.py
Last active February 12, 2018 13:59
A simple POC of sentiment analisys using a small portuguese corpus
"""
A simple POC of sentiment analisys using a small portuguese corpus
- The corpus can be downloaded from here http://www.linguateca.pt/Repositorio/ReLi/ReLi-Lex.rar
please visit the page before download http://www.linguateca.pt/Repositorio/ReLi/
"""
from textblob import TextBlob
from textblob.classifiers import NaiveBayesClassifier
import os
import re
@rodrigobaron
rodrigobaron / onchange.sh
Created March 15, 2018 16:39 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@rodrigobaron
rodrigobaron / cuda_install.sh
Created April 21, 2018 00:56
CUDA install ubuntu*
#!/bin/sh
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys \
http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda-9-0
@rodrigobaron
rodrigobaron / google_colab_tricks.txt
Created April 25, 2018 16:32
Google Colab Tricks
#
# access gdrive
#
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
import rpyc
from rpyc.utils.zerodeploy import DeployedServer
from plumbum import SshMachine
mach = SshMachine("rodrigo@server")
server = DeployedServer(mach, python_executable='/home/rodrigo/venv/bin/python')
conn = server.classic_connect()
import sys
conn.modules.sys.stdout = sys.stdout