Skip to content

Instantly share code, notes, and snippets.

View ericoporto's full-sized avatar
🎮
making

Érico Porto ericoporto

🎮
making
View GitHub Profile
@ericoporto
ericoporto / cropimgs.bat
Created March 3, 2016 18:38
Just so I can remember how I batch cropped a lot of images
@echo off
for %%f in (*.png) do (
echo %%~nf
convert.exe "%%~nf.png" -gravity center -crop 2592x1458+0-84 +repage "..\out3\%%~nf.png"
)
@ericoporto
ericoporto / magnetpimission.sh
Last active March 17, 2016 00:41
Script to download Magnets I click on my browser, remotely, on my Raspberry Pi
#!/bin/bash
# This script assumes you have a Raspberry Pi (or other always on server) running
# a Transmission-Daemon. It allows you to download you Magnet torrents on it, from
# yours PC browser (Firefox on Linux) on it, remotely. Save it as executable on
# your script folder, such as /usr/local/sbin .
# Open Firefox and in the address bar type:
# about:config
# There, right click anywhere to create a new boolean entry (New->Boolean) called:
# network.protocol-handler.expose.magnet
# Set it's value as false.
@ericoporto
ericoporto / playmusic.desktop
Created March 27, 2016 22:51
Ubuntu shortcut to load ncmpcpp connected to mpd on my local server.
[Desktop Entry]
Version=0.1
Name=MPDC
Comment=Connect to MPD Server
Exec=gnome-terminal --geometry=48x16 -e "bash -c \"/usr/bin/ncmpcpp -h 192.168.0.3; exec bash\""
Terminal=true
Type=Application
Categories=Application;
@ericoporto
ericoporto / checkinternet.sh
Created April 12, 2016 22:51
Let your computer tell you when your internet is back on. Bash script that requires cron and espeak.
#!/bin/bash
# Requires: espeak, crontab, mktemp.
#
# Script for checking if this computer is connected to internet.
# If you copy it to $installdir, give this script execution permission.
# And remember to set proper ownership (using chown).
# Use Example:
#
# sudo chmod +x checkinternet.sh
# sudo cp checkinternet.sh /usr/local/sbin/
@ericoporto
ericoporto / statcolormap.m
Created April 22, 2016 17:32
Nice colormap for octave (that matches Statistica)
shading flat#
map = [[0, 110, 49]/255,
[0, 152, 19]/255,
[0, 212, 0]/255,
[49, 255, 0]/255,
[203, 255, 0]/255,
[255, 239, 0]/255,
[255, 121, 0]/255,
[255, 1, 0]/255,
[197, 0, 0]/255,
@ericoporto
ericoporto / virtualboxubuntu.md
Created May 6, 2016 13:47
Reminder on how to activate USB devices on Virtualbox, in Ubuntu.

If you ever need to use Virtual Box with USB and VT-d on Ubuntu, I recommend installing Users and Groups.

sudo apt-get install gnome-system-tools

Than open it

Select the user which will run Virtual Box.

@ericoporto
ericoporto / getmelogs.sh
Created May 15, 2016 15:45
Get logs and anonimize them to send to someone friendly.
#!/bin/bash
grep --recursive "error" /var/log/ 2>&1 | sed "s/$HOSTNAME/HoStNaMe/g" | sed "s/$USER/uSeRnAmE/g" > ~/allerrors.log
@ericoporto
ericoporto / pyqtUbuntuMime.md
Created June 17, 2016 23:22
How to open a file from Nautilus (in Ubuntu) with your PyQt app

I created a file mymime.xml

<?xml version='1.0' encoding='utf-8'?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/myapp">
        <comment>my format</comment>
        <glob pattern="*.myformat"/>
    </mime-type>
</mime-info>
@ericoporto
ericoporto / AsusEEEPC701Lubuntu.md
Created June 19, 2016 18:28
A writing on booting Lubuntu 16.04 on ASUS EEEPC 701 with nonpae cpu

I have an old Asus EEE PC 701 (4GB SSD 2GB RAM) with Crunchbang and since Crunchbang development stopped, decided to try Lubuntu in it. So I made a Lubuntu 16.04 i386 bootable flash using unetbootin and a 8GB pen drive under Ubuntu.

At the system start, selecting the option Try Lubuntu without installing gives me a non-pae cpu error. Using tab I see that this option is made like this.

/casper/vmlinuz initrd=/casper/initrd.lz file=/cdrom/preseed/lubuntu.seed boot=casper quiet splash --- persistent 

So I try forcepae option to boot. This will boot, but error on [ OK ] Started Update UTMP about System Runlevel Changes. To fix, we need to boot twice, first let's add nomodeset.

/casper/vmlinuz initrd=/casper/initrd.lz file=/cdrom/preseed/lubuntu.seed boot=casper quiet splash nomodeset forcepae -- forcepae --- persistent 
@ericoporto
ericoporto / check_newest.py
Created August 28, 2016 23:19
how to check if version is latest
from distutils.version import StrictVersion
from fgmk import __version__
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
def is_this_newest():
try:
pypi = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')