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 / tab_controller_with_on_change.dart
Last active Dec 29, 2021
Flutter TabController with onChange callback
View tab_controller_with_on_change.dart
import 'package:flutter/material.dart';
class TabControllerWithOnChange extends TabController {
TabControllerWithOnChange({
int initialIndex = 0,
required int length,
required TickerProvider vsync,
required void Function(int) onChange,
}) : super(initialIndex: initialIndex, length: length, vsync: vsync) {
addListener(() {
@giuliano-oliveira
giuliano-oliveira / scanner.dart
Created Dec 17, 2021
QrCode/Barcode scanner using qr_code_scanner in flutter
View scanner.dart
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
class ScannerWidget extends StatefulWidget {
final BarcodeFormat format;
final void Function(String?) onScan;
ScannerWidget({
@giuliano-oliveira
giuliano-oliveira / cubic_bezier.rs
Last active Nov 15, 2021
Cubic bézier function in rust (not the most performant, focused in readability)
View cubic_bezier.rs
use std::fmt;
#[derive(Debug, Clone, Copy)]
struct Point {
x: f64,
y: f64,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@giuliano-oliveira
giuliano-oliveira / quadratic_bezier.rs
Last active Nov 18, 2021
Quadratic bézier function in rust (not the most performant, focused in readability)
View quadratic_bezier.rs
use std::fmt;
#[derive(Debug, Clone, Copy)]
struct Point {
x: f64,
y: f64,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
View print_json.go
package main
import (
"encoding/json"
"fmt"
)
func printJson(data interface{}) {
bs, err := json.MarshalIndent(data, "", " ")
if err != nil {
@giuliano-oliveira
giuliano-oliveira / download_file.rs
Last active Jun 29, 2022
Download large files in rust with progress bar using reqwest, future_util and indicatif
View download_file.rs
// you need this in your cargo.toml
// reqwest = { version = "0.11.3", features = ["stream"] }
// futures-util = "0.3.14"
// indicatif = "0.15.0"
use std::cmp::min;
use std::fs::File;
use std::io::Write;
use reqwest::Client;
use indicatif::{ProgressBar, ProgressStyle};
@giuliano-oliveira
giuliano-oliveira / custom_commands.sh
Created Nov 2, 2020
some common custom shell commands i use, you can add to your home directory and add "source custom_commands.sh" on your .bashrc file to add them.
View custom_commands.sh
function notify_when_online(){
host=$1
while true; do
ping -c1 $host > /dev/null && break;
done && notify-send --icon=dialog-information "$host is online"
}
View download_folder.py
from .download import download
from bs4 import BeautifulSoup
import json
import re
import requests
import sys
if sys.version_info.major < 3:
from pathlib2 import Path
else:
@giuliano-oliveira
giuliano-oliveira / gdown_folder_regex.py
Last active Oct 25, 2020
Shallow download files from Google Drive folder with requests,bs4 and regex
View gdown_folder_regex.py
import re
from bs4 import BeautifulSoup
import requests
import gdown
import json
import argparse
parser=argparse.ArgumentParser()
parser.add_argument("url")
@giuliano-oliveira
giuliano-oliveira / gdown_folder.py
Created Oct 25, 2020
Shallow download files from Google drive folder using gdown and selenium
View gdown_folder.py
from bs4 import BeautifulSoup
from selenium import webdriver
import gdown
import argparse
parser=argparse.ArgumentParser()
parser.add_argument("url")
args=parser.parse_args()