Skip to content

Instantly share code, notes, and snippets.

View cirops's full-sized avatar
🏠
Working from home

Ciro Plá cirops

🏠
Working from home
View GitHub Profile
@cirops
cirops / settings.json
Last active April 26, 2022 13:30 — forked from diego3g/settings.json
VSCode Settings (Updated)
{
"emmet.syntaxProfiles" : {
"javascript" : "jsx"
},
"workbench.startupEditor" : "newUntitledFile",
"editor.fontSize" : 16,
"javascript.suggest.autoImports" : true,
"javascript.updateImportsOnFileMove.enabled" : "always",
"editor.rulers" : [
80,
import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
import dash_bootstrap_components as dbc
import plotly_express as px
import plotly.graph_objects as go
import numpy as np
@cirops
cirops / quickstart-editorconfig-eslint-prettier-react.md
Created October 4, 2020 18:36
Quickstart for editorconfig, eslint and prettier for ReactJS development

Boilerplate Typescript React with Eslint and Prettier

Create-react-app

  1. Create a react app with typescript template
npx create-react-app . --template typescript

EditorConfig

  1. Create .editorconfig on the root folder:
@cirops
cirops / cnpj_sample_query.py
Created May 29, 2019 17:13
Sample query for the CNPJ sqlite3 database
import sqlite3
import csv
import pandas as pd
def main():
database_file = "CNPJ_full.db"
conn = conn = sqlite3.connect(database_file)
df = pd.read_sql_query("SELECT * FROM empresas WHERE municipio='PELOTAS'", conn)
import os
def split(filehandler, delimiter=',', row_limit=10000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
"""
Splits a CSV file into multiple pieces.
A quick bastardization of the Python CSV library.
Arguments:
`row_limit`: The number of rows you want in each output file. 10,000 by default.
# Silly code to generate all combinations of species, background and gods that spell english words (according to NLTK)
# for Dungeon Crawl Stone Soup (as of 0.23)
from nltk.corpus import words
species = [
"Ba",
"Ce",
"DD",
"DE",
# Calculates geometric distances between all given points
# coordinates are passed as arguments, as in the following sample:
# ruby geodistance.rb 62.425,52.424 42.0,90.5256 0.0,0.0 90.0,-180.0
# returns the distance in kilometers
##
# Haversine Distance Calculation Function
#
# by https://gist.github.com/timols/5268103
# Accepts two coordinates in the form
@cirops
cirops / miojoproblem.rb
Created May 24, 2018 08:13
Calculates Ideal Miojo Cooking time with two hourglasses
# Solves the "Miojo with 2 hourglasses" problem
# cooking time and both hourglass times are passed as arguments, as in the following sample:
# ruby miojoproblem.rb 3 5 7
# returns the minimum total time to cook the miojo accurately, or a fail message if not possible
# Solution is ad-hoc, can probably be optimized a lot
raise "Must specify 3 inputs: Miojo cooking time, hourglass 1 time, hourglass 2 time." if ARGV.length != 3
cook_time = ARGV[0].to_i
hg_1 = ARGV[1].to_i
@cirops
cirops / fetch-using-xmlhttp-cheerio.js
Created November 16, 2017 23:59
Simple example script to grab data from a paginated website using xmlhttprequest and cheerio
var cheerio = require('cheerio');
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
function httpGet(theUrl) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
@cirops
cirops / Exercises for Emmet
Last active July 26, 2022 15:38
Exercises for adapting with Emmet (Ex Zen-coding) CSS-style selector
1) Look up on the internet the simple code for generating the base html5 structure;
2) What would be the code for generating the following structure:
<div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>