Skip to content

Instantly share code, notes, and snippets.

View matheusportela's full-sized avatar

Matheus Portela matheusportela

View GitHub Profile
function printControls(){
var controls = $('<div></div>')
.attr('id', 'controls')
.append(
$('<button></button>').text( 'rodar uma geração' ).attr( 'id', 'ciclo' )
)
.click( function(){
cycle();
});
$( cfg.screen ).append(controls);
@matheusportela
matheusportela / test_sklearn_and_graphlab_split.py
Last active January 14, 2016 18:05
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.
#!/usr/bin/python
import graphlab
import numpy as np
from sklearn.cross_validation import train_test_split
def main():
sales = graphlab.SFrame('kc_house_data.gl')
train_data_graphlab, test_data_graphlab = sales.random_split(0.8, seed=0)
input_graphlab = train_data_graphlab['sqft_living']
@matheusportela
matheusportela / merge.py
Created August 15, 2016 10:57
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
matheusportela / test.py
Created March 31, 2017 12:06
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
matheusportela / supress_warning.rb
Created May 15, 2018 18:59
Suppress OpenSSL warnings in Ruby (e.g. WARNING: OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE)
require 'openssl'
$VERBOSE = nil
@matheusportela
matheusportela / .zshrc or .bash_profile
Created January 6, 2018 20:53
Environment variables for virtualenvwrapper in Mac OS X with Python 3
$ 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/virtualenvwrapper.sh

Backup

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

Restore