Skip to content

Instantly share code, notes, and snippets.

View fcgomes92's full-sized avatar
:octocat:
Batata é bom

Fernando fcgomes92

:octocat:
Batata é bom
View GitHub Profile
@fcgomes92
fcgomes92 / envdir-migrate-to-dot-env.py
Last active May 10, 2017 18:56
A Gist to migrate from envdir to .env ( like Python Decouple )
from glob import glob
import os
import sys
import argparse
class AbsPathAction(argparse.Action):
def __init__(self, option_strings, dest, nargs=None, **kwargs):
super().__init__(option_strings, dest, **kwargs)
def __call__(self, parser, namespace, values, option_string=None):
@fcgomes92
fcgomes92 / py-thumb.py
Created May 11, 2017 14:40
Generate thumb images
from PIL import Image
import sys
import os
import glob
thumb_size = (256, 256)
def main(path):
if (path[0] != '/'):
@fcgomes92
fcgomes92 / RFID-readSerial.py
Created May 11, 2017 14:50
Read / Write some serial data
import serial
import json
import sys
ser = serial.Serial(
port='/dev/ttyUSB0',\
baudrate=9600,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
'''
result:
books
books / nl
books / nl / sf
books / nl / ff
books / il / sf
books / il / ff
'''
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
currentPage: 0,
pageCount: 10,
}
}
handlePageClick = (data) => {
const WALTER_PRICE = 0.53,
TARE_PRICE = 0.08;
const tareMoney = (bottles) => {
return TARE_PRICE * bottles;
};
const round = (f) => {
return Math.round(f * Math.pow(10, 2)) / Math.pow(10, 2);
};
@fcgomes92
fcgomes92 / speedtest-cli-analysis.py
Last active December 17, 2017 14:20
speedtest-cli csv data analysis collected during a year
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import os
import datetime
% matplotlib inline
dir_name = os.path.abspath('./')
@fcgomes92
fcgomes92 / isort_changed_files.py
Created March 8, 2018 12:17
iSort changed files using git diff
import os
import sys
from subprocess import call, check_output
from isort import SortImports
def isort_all():
path = sys.argv[1]
abs_path = os.path.abspath(path)
@fcgomes92
fcgomes92 / currencyFormat.js
Created February 4, 2020 18:38
Simple currency formatter
function formatCurrency(number) {
const [integerPart, decimalPart] = `${number}`.split(".");
const chunkSize = 3;
const integerPartArray = integerPart.split("").reverse();
const chunks = Math.ceil(integerPartArray.length / chunkSize);
const formatedInteger = Array.from(new Array(chunks), (_, idx) => {
return integerPartArray
.slice(idx * chunkSize, idx * chunkSize + chunkSize)
.reverse()
.join("");
@fcgomes92
fcgomes92 / reference.js
Created April 5, 2020 15:21
some this reference for js
function GroceryList(items){
this.items = items;
this.mapItems = (fn) => {
let newItems = [];
// could use map but it would not fit for this example
for (let i = 0; i < this.items.length ; i++){
newItems = [...newItems, fn(this.items[i])];
}
this.items = newItems;
return this;