Skip to content

Instantly share code, notes, and snippets.

View berinhard's full-sized avatar
👾
let's play that

berin berinhard

👾
let's play that
View GitHub Profile
@berinhard
berinhard / save_frames.py
Last active November 4, 2018 15:01
Function to save Processing frames
#####
# Author: Berin
# Sketches repo: https://github.com/berinhard/sketches
#
# The save_video_frames function saves sketches' frames to be used by `ffmpeg` command to generate videos.
# For example, if we call the method with the following parameters:
#
# save_video_frames(25, 60 * 10)
#
# The ffmpeg commands to generate the video would be:
@berinhard
berinhard / processing_gcode_generator.pde
Last active March 30, 2019 18:51
Simple processing Sketch to generate .gcode files for all SVGs in a directory
/*
This sketch is an adaptation from Sighack's Gcode Export
Blog post: https://sighack.com/post/processing-boilerplate-with-gcode-export
*/
import geomerative.*;
/*
* Gcode-generation settings. Edit these as per your needs.
* CONFIG_SVGS_DIR : Directory containing the SVG files
* CONFIG_PRINT_WIDTH_MM : The width of paper in mm
@berinhard
berinhard / exemplo_003.py
Created March 18, 2019 20:37
Exemplo 003
class Posicao():
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
@property
def lat(self):
return self._lat
@lat.setter
@berinhard
berinhard / exemplo_002a.py
Last active March 18, 2019 20:42
Exemplo 002
class Posicao():
def __init__(self, lat, lng):
self.set_lat(lat)
self.set_lng(lng)
def get_lat(self):
return self.__lat
def set_lat(self, value):
@berinhard
berinhard / exemplo_001.py
Created March 18, 2019 20:40
Exemplo 001
class Posicao():
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
def distancia(pos_1, pos_2):
#### implementação do cálculo de distância
def direcao(pos_1, pos_2):
#### implementação do cálculo de direção
@berinhard
berinhard / exemplo_002.py
Created March 18, 2019 20:42
Exemplo 002 pythônico
class Posicao():
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
@property
def lat(self):
return self._lat
@lat.setter
@berinhard
berinhard / exemplo_004.py
Created March 18, 2019 20:47
Exemplo 004
import math
class Posicao():
PLANA, ESFERICA, ELIPTICA = 'plana', 'esferica', 'eliptica'
KM, M, MILHAS = 'kms', 'm', 'miles'
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
self.geometria = self.PLANA
self.unidade = self.KM
@berinhard
berinhard / exemplo_005.py
Created March 18, 2019 20:49
Exemplo 005
import math
class Posicao():
def __init__(self, lat, lng):
self.lat, self.lng = lat, lng
self.geometria = GeometriaPlana()
self.unidade = UnidadeQuilometro()
@property
@berinhard
berinhard / paperboy_001.py
Created March 21, 2019 19:53
Paperboy 001
class Wallet:
def __init__(self, money):
self.money = money
def subtract(self, amount):
self.money -= amount
def add(self, amount):
self.money += amount
@berinhard
berinhard / paperboy_002.py
Last active March 22, 2019 19:14
Paperboy 002
class Wallet:
def __init__(self, money):
self.money = money
def subtract(self, amount):
self.money -= amount
def add(self, amount):
self.money += amount