Skip to content

Instantly share code, notes, and snippets.

View rdenadai's full-sized avatar
🐍
But still haven't found what I'm looking for...

⟠ Rodolfo De Nadai rdenadai

🐍
But still haven't found what I'm looking for...
View GitHub Profile
@rdenadai
rdenadai / edge_detection_and_polygon_exporter.py
Last active November 4, 2015 22:24
This gist uses Pillow to get the boundary edges of an image and generate the polygon position of the draw inside. Im using this script to get the polygon of my games sprites to create the collisions mechanics using libgdx!
from PIL import Image, ImageFilter
filename = "dship1"
image = Image.open(filename + ".png")
image = image.filter(ImageFilter.FIND_EDGES)
image.save(filename + "_edge.png")
cols = image.width
rows = image.height
points = []
@rdenadai
rdenadai / crop_image.py
Last active November 25, 2015 15:06
A simple command line python script which convert to grayscale and crop some image multiple times with the same size.
import sys, getopt
import argparse
from PIL import Image
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--image')
parser.add_argument('-o', '--output')
parser.add_argument('-d', '--divisor')
args = parser.parse_args()
@rdenadai
rdenadai / MyTelescopeSpeaks.py
Last active December 20, 2015 22:08
This is a small program i made using python to get an image from my telescope, using a webcam connected to the usb port, and post that on the twitter account i made!Was a really cool saturday afternoon project! hahahahahahahahahaha!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from SimpleCV import *
from StringIO import *
from time import sleep
# I have to make a little alter on the default script api.py from tweepy since the guys didn't commit yet the update_with_media function
import tweepy
if __name__ == '__main__':
Install docker
wget -qO- https://get.docker.com/ | sh
Create a 'Dockerfile'
Inside the folder where the docker file is, create a image
docker build -t <img name> .
@rdenadai
rdenadai / esp826612e+micropython+commands
Created July 22, 2017 22:51
Simple explanation and usage of ESP8266 12E and MicroPython
# ESP8266 12E + MicroPython
## Install tools to connect to the board
pip install esptool ampy
apt install picocom
## Erase | Flash the firmware
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin
@rdenadai
rdenadai / ffmpeg.md
Created July 29, 2017 16:55
Using ffmpeg to extract audio from video files (this a copy of https://gist.github.com/protrolium/e0dbd4bb0f1a396fcb55)

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

abcde

A Better CD Encoder

Grab an entire CD and compress it to Ogg/Vorbis, MP3, FLAC, AAC, Ogg/Speex and/or MPP/MP+(Musepack) format.

Why abcde?

Ordinarily, the process of grabbing the data off a CD and encoding it, then tagging or commenting it, is very involved. abcde is designed to automate this. It will take an entire CD and convert it into a compressed audio format - Ogg/Vorbis, MPEG Audio Layer III, Free Lossless Audio Codec (FLAC), Ogg/Speex, MPP/MP+(Musepack), M4A (AAC) or Opus format(s). With one command, it will:

  • Do a CDDB or Musicbrainz query over the Internet to look up your CD or use a locally stored CDDB entry, or read CD-TEXT from your CD as a fallback for track information
@rdenadai
rdenadai / opencl.sh
Created August 5, 2019 20:31
OpenCL
sudo apt-get install clinfo ocl-icd-opencl-dev mesa-opencl-icd
@rdenadai
rdenadai / jupyter_commands.md
Last active July 22, 2020 14:03
essentials jupyter commands

Jupyter Commands

Install jupyter

$> pip install ipython[all]

$> jupyter notebook --no-browser
@rdenadai
rdenadai / python_update.md
Last active September 29, 2021 19:25
Update python on debian
$> apt-get update && sudo apt-get upgrade

$> apt-get install -y make build-essential libssl-dev zlib1g-dev

$> apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm

$> apt-get install -y libncurses5-dev  libncursesw5-dev xz-utils tk-dev

$&gt; wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tgz