Skip to content

Instantly share code, notes, and snippets.


Matheus Vieira Portela matheusportela

View GitHub Profile
View raspberry pi


diskutil list # Find out your Raspberry Pi drive
diskutil unmountDisk /dev/disk2 # Unmount disk
sudo dd if=/dev/disk2 of=raspberry_pi_backup.img # Create backup image
gzip -c raspberry_pi_backup.img > raspberry_pi_backup.img.gz # Compress image


matheusportela / supress_warning.rb
Created May 15, 2018
Suppress OpenSSL warnings in Ruby (e.g. WARNING: OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE)
View supress_warning.rb
require 'openssl'
$VERBOSE = nil
matheusportela / .zshrc or .bash_profile
Created Jan 6, 2018
Environment variables for virtualenvwrapper in Mac OS X with Python 3
View .zshrc or .bash_profile
$ brew install python3
$ pip3 install virtualenv virtualenvwrapper
$ vim .bash_profile # or .zshrc
# Virtualenv variables
export WORKON_HOME=/Users/portela/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source /usr/local/bin/
matheusportela /
Created Mar 31, 2017
How to use simpletable to generate a table given some data
import simpletable
def main():
data = '''basesystem-10.0-7.el7.centos.noarch
checksum_data = 0280ee16df09be0cebf62695706598caed8ff5cba47de1fed625068a90a9ef68
checksum_type = sha256
from_repo = anaconda
from_repo_revision = 1489513119
from_repo_timestamp = 1489513374
matheusportela /
Created Aug 15, 2016
Naive merge sort implementation
def merg(a, b):
# This method takes care of merging two lists while maintaining it sorted.
# Hence, it must only return the resulting merged list, not the indices i
# and j.
c = [None] * int(len(a) + len(b))
i = 0
j = 0
k = 0 # This will take care of where we are placing the new elements
# i and j must be strictly less than the lengths, otherwise they'll overflow
matheusportela /
Last active Jan 14, 2016
This script splits data loaded via GraphLab with two methods: SFrame.random_split and sklearn.cross_validation.train_test_split. In the end, present the number of different rows between each divided array.
import graphlab
import numpy as np
from sklearn.cross_validation import train_test_split
def main():
sales = graphlab.SFrame('')
train_data_graphlab, test_data_graphlab = sales.random_split(0.8, seed=0)
input_graphlab = train_data_graphlab['sqft_living']
View Game.js
function printControls(){
var controls = $('<div></div>')
.attr('id', 'controls')
$('<button></button>').text( 'rodar uma geração' ).attr( 'id', 'ciclo' )
.click( function(){
$( cfg.screen ).append(controls);