Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Giuliano Oliveira giuliano-oliveira

🏠
Working from home
  • Brazil
View GitHub Profile
@giuliano-oliveira
giuliano-oliveira / random_particles.py
Last active Aug 31, 2020
Generate n random particles with random velocity vectors in python using curses
View random_particles.py
import curses
from time import time,sleep
from random import randrange,random
from math import cos,sin,pi
import argparse
class TUI:
FPS=60
def __init__(self,screen,no_particles):
@giuliano-oliveira
giuliano-oliveira / modes.json
Last active Aug 31, 2020
Workout timer written in python using curses
View modes.json
[
{
"name":"REP",
"time_seconds":60
},
{
"name":"SWITCH",
"time_minutes":3
}
]
@giuliano-oliveira
giuliano-oliveira / wpp_video_splitter.py
Last active Jul 9, 2020
Split video using ffmpeg to fit WhatsApp status
View wpp_video_splitter.py
from subprocess import getstatusoutput as shell
from subprocess import Popen,PIPE,STDOUT
import shlex
import re
import argparse
import os
from tqdm import tqdm
from math import ceil,log10
def get_video_length(fname):
@giuliano-oliveira
giuliano-oliveira / focus_node_mem_leak_test.dart
Created Jun 2, 2020
FocusScope.of(context).requestFocus(new MyFocusNode()) memleak test
View focus_node_mem_leak_test.dart
import 'package:flutter/material.dart';
class MyFocusNode extends FocusNode {
MyFocusNode() : super() {
print("constructor");
}
@override
void dispose() {
print("dispose");
@giuliano-oliveira
giuliano-oliveira / file_picker_form_field.dart
Last active Jun 1, 2020
A String path form field for the file_picker package.
View file_picker_form_field.dart
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
class FilePickerFormField extends StatelessWidget {
final Function(String) validator;
final Function(String) onSaved;
final String labelText;
final String hintText;
@giuliano-oliveira
giuliano-oliveira / paladins_elo.py
Last active Jan 8, 2020
script to get players elo using paladins-tracker.de
View paladins_elo.py
import requests
from bs4 import BeautifulSoup as BS
from multiprocessing.dummy import Pool
def get_elo(nickname):
sess=requests.Session()
r=sess.get(f"https://paladins-tracker.de/search/player/{nickname}")
soup=BS(r.text,"html.parser")
link=soup.select_one(".player-meta.clearfix a")
if link==None:
@giuliano-oliveira
giuliano-oliveira / paladins.py
Created Dec 30, 2019
helper script to get how many matches i have to do so i can get "Variety is the Spice of Life", "The Dedicated" and "The Insane" achievements by scraping paladins-tracker.de for the updated stats
View paladins.py
import requests
from bs4 import BeautifulSoup as BS
from collections import namedtuple
from math import ceil
#config
lvs=[10,15,20]
mean_exp=32000
#----
table=[20000,60000,120000,200000,300000,420000,560000,720000,900000,1100000,1320000,1560000,1820000,2100000,2400000,2720000,3060000,3420000,3800000,4200000]
def fix_exp(exp,lvl):
@giuliano-oliveira
giuliano-oliveira / simpleroutertopo.py
Last active Sep 2, 2021
simple mininet custom topology with static routing
View simpleroutertopo.py
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Node
from mininet.log import setLogLevel, info
from mininet.cli import CLI
class LinuxRouter( Node ):
"""A Node with IP forwarding enabled.
Means that every packet that is in this node, comunicate freely with its interfaces."""
@giuliano-oliveira
giuliano-oliveira / hu_moments.tex
Last active Sep 28, 2019
Hu moments in Latex
View hu_moments.tex
$
M_{ij}=\sum\limits_{x}\sum\limits_{y}x^iy^iI(x,y)\\
\eta_{pq}=\sum\limits_{x}\sum\limits_{y}(x-\bar x)^p(y- \bar y)^qI(x,y)\\
\bar x=\frac{M_{10}}{M_{00}}, \bar y=\frac{M_{01}}{M_{00}}\\
\mu_{pq}=\frac{\eta_{pq}}{\eta_{00}^\gamma},\gamma=\frac{p+q}{2}\\
H_{1} = \mu_{20} + \mu_{02}\\
H_{2} = (\mu_{20} - \mu_{02})^2 + 4(\mu_{11})^2\\
H_{3} = (\mu_{30} - 3\mu_{12})^2 + (\mu_{03} - 3\mu_{21})^2\\
H_{4} = (\mu_{30} + \mu_{12})^2 + (\mu_{03} + \mu_{21})^2\\
H_{5} = (\mu_{30} - 3\mu_{12})(\mu_{30} + \mu_{12})((\mu_{30} + \mu_{12})^2 - 3(\mu_{21} + \mu_{03})^2) + (3\mu_{21} - \mu_{03})(\mu_{21} + \mu_{03})(3(\mu_{30} + \mu_{12})^2 - (\mu_{03} + \mu_{21})^2)\\
@giuliano-oliveira
giuliano-oliveira / tex.py
Last active Aug 16, 2020
Move tex files and compiles them in a temp dir, then move pdf file to root. Works on linux and requires nodemon and latexmk
View tex.py
#!/usr/bin/env python3
import argparse
import os
from tempfile import mkdtemp
parser=argparse.ArgumentParser()
parser.add_argument("input",type=str)
args=parser.parse_args()
pwd=os.path.realpath(os.getcwd())