Skip to content

Instantly share code, notes, and snippets.

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

SmokingGoats smokinggoats

:octocat:
Batata é bom
View GitHub Profile
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
currentPage: 0,
pageCount: 10,
}
}
handlePageClick = (data) => {
@smokinggoats
smokinggoats / 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):
@smokinggoats
smokinggoats / 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] != '/'):
@smokinggoats
smokinggoats / 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
'''
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);
};
@smokinggoats
smokinggoats / 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('./')
@smokinggoats
smokinggoats / 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)
@smokinggoats
smokinggoats / nestedArrayAndObject.js
Created August 22, 2019 13:12
nestedArrayAndObject.js
function nestedArrayAndObject() {
// refactor this to a single line of destructuring...
const info = {
title: "Once Upon a Time",
protagonist: {
name: "Emma Swan",
enemies: [
{ name: "Regina Mills", title: "Evil Queen" },
{ name: "Cora Mills", title: "Queen of Hearts" },
{ name: "Peter Pan", title: `The boy who wouldn't grow up` },
@smokinggoats
smokinggoats / 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("");