Skip to content

Instantly share code, notes, and snippets.

Matheus Vieira Portela matheusportela

Block or report user

Report or block matheusportela

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View raspberry pi backup.md

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

@matheusportela
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
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/virtualenvwrapper.sh
@matheusportela
matheusportela / test.py
Created Mar 31, 2017
How to use simpletable to generate a table given some data
View test.py
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 / merge.py
Created Aug 15, 2016
Naive merge sort implementation
View merge.py
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_sklearn_and_graphlab_split.py
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.
View test_sklearn_and_graphlab_split.py
#!/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']
View Game.js
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);
You can’t perform that action at this time.