Skip to content

Instantly share code, notes, and snippets.

View brunovcosta's full-sized avatar

Bruno Vieira Costa brunovcosta

View GitHub Profile
@brunovcosta
brunovcosta / executor.py
Created September 12, 2022 18:23
receives a python code file and executes statement by statement with checkpoint
import fire
import pdb
import pickle
import sys
import ast
import os
class Executor:
def run(self,
source_path,

Python intro

About this tutorials

This tutorial is aimed for those who have little to no programming knowledge, so I will cover the basic programming principles here.

I will use a unfold approach, so in order to make it easier to understand, I will sometimes give approximated definitions for each concept and try my best to bring the precise definitions until the end of the course.

Basic concepts (as quick as possible)

@brunovcosta
brunovcosta / todo-app.js
Last active November 30, 2021 00:23
Abstra Custom Element
const eventListeners = [];
function define({
name,
initialState,
template,
listeners
}) {
customElements.define(name,
class extends HTMLElement {
$state = initialState();
@brunovcosta
brunovcosta / readExcel.js
Last active May 17, 2021 23:44
Async read Excel file from browser
// SheetJS should be loaded (https://unpkg.com/xlsx/dist/xlsx.full.min.js)
new Promise((resolve, reject) => {
const fileInput = document.createElement("input")
fileInput.type='file'
fileInput.style.display='none'
fileInput.onchange=evt => {
const reader = new FileReader();
reader.readAsBinaryString(evt.target.files[0])
reader.onload = evt2 => {
const workbook = XLSX.read(evt2.target.result, {type: "binary"})
@brunovcosta
brunovcosta / fix.pgsql
Last active June 3, 2020 14:22
Fix all missing indexes in PostgreSQL
-- source: https://www.cybertec-postgresql.com/en/index-your-foreign-key/
WITH missing_indexes AS (
SELECT c.conrelid::regclass AS "table",
/* list of key column names in order */
string_agg(a.attname, ',' ORDER BY x.n) AS columns,
pg_catalog.pg_size_pretty(
pg_catalog.pg_relation_size(c.conrelid)
) AS size,
c.conname AS constraint,
c.confrelid::regclass AS referenced_table
g9 {
r: 200
t: 10,
p: 10,
},(d,c)->
points = 20
sphere = (x,y)->
[d.r*Math.cos(d.p+x*2*Math.PI/points)*Math.sin(y*Math.PI/points),
d.r*Math.sin(d.p+x*2*Math.PI/points)*Math.sin(y*Math.PI/points),