This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use comfy_table::{Table,ContentArrangement,Cell,Color,Attribute}; | |
| //use comfy_table::TableComponent; | |
| const COMFY_TABLE_CUSTOM_PRESET: &str = "││━─┡━╇┩│ ┳┴┏┓└┘"; //exportado usando .current_style_as_preset() | |
| pub fn print_table() { | |
| let headers = vec!["SKU","Descrição","ML P", "ML C", "ML P (Promo)", "ML C (Promo)","SH","SH (Promo)"]; | |
| let row = vec!["ISA59228","Pneu Pirelli Phantom Street 29x1.95 Preto","8.06","15.17","9.96","8.15","15.45","13.21"]; | |
| let headers: Vec<Cell> = headers.iter().map(|f|Cell::new(f).add_attribute(Attribute::Bold)).collect(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import shutil | |
| import re | |
| import PySimpleGUI as sg | |
| def config_file_deserializer(file_path: str) -> dict: | |
| variables = {} | |
| with open(file_path,"rb") as f: | |
| for line in f.readlines(): | |
| key,val = line.decode().strip().split("=",1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #python mean.py <desired_mean> <samples_n> | |
| #An simple script to calculate random values that add up to some mean | |
| #Changing the play paramenter (#10) will dictate how wild the numbers will vary from each other | |
| import random | |
| import sys | |
| mean = float(sys.argv[1]) | |
| samples = int(sys.argv[2]) | |
| play = 5.0 #5 good num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::fs::read_dir; | |
| use std::io::{stdin,stdout}; | |
| use std::path::Path; | |
| use std::fs::File; | |
| use std::io::prelude::*; | |
| use std::env; | |
| use colored::*; | |
| const VIDEO_EXTENSIONS: [&str;11] = ["mp4","mkv","mov","webm","vob","wmv","avi","ogg","ogv","m4v","3gp"]; | |
| const IMAGE_EXTENSIONS: [&str;5] = ["png","jpg","jpeg","webp","bmp"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Probably broken fuzzy score made by me alone | |
| fn fuzzy_score(search: &str, test: &str) -> i32 { | |
| let s_chars: Vec<char> = search.chars().collect(); | |
| let t_chars: Vec<char> = test.chars().collect(); | |
| let mut found_idx = Vec::new(); //keep track of match indexes to not mess up with repeated chars | |
| let mut score: i32 = 100; | |
| for (i,c) in s_chars.iter().enumerate() { | |
| if let Some(pos) = t_chars.iter().enumerate().position(|(i,p)|p == c && !found_idx.contains(&i)) { | |
| score -= ((pos.max(i)-pos.min(i))*4) as i32; //measure the distance betwen match chars and multipy by 4 to punish char misplacement more |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import zlib | |
| import lzma | |
| import bz2 | |
| file = sys.argv[1] | |
| bytes_buf = open(file,"rb").read() | |
| zlib_compressed_data = zlib.compress(bytes_buf,9) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Returns the Some(index) of x if it exists, else returns None | |
| fn binary_search(x: usize, vector: &Vec<usize>) -> Option<usize> { | |
| let mut high: usize = vector.len() - 1; | |
| let mut low: usize = 0; | |
| while low <= high { | |
| let mid = (high + low) / 2; | |
| if vector[mid] < x { | |
| low = mid - 1; | |
| } else if vector[mid] > x { | |
| high = mid + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A simple TeamSpeak 3 installer for linux, will work on most distros | |
| # Files will be installed under /opt/ | |
| # .desktop file is automatically created, so it shows up on your distro's start menu | |
| # Credit: https://gist.github.com/srtopster | |
| # Usage: sudo python3 ts3_installer.py | |
| import os | |
| import getpass | |
| import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Prime finder using Sieve of Eratosthenes algorithm | |
| //https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes | |
| // | |
| //-> Cargo.toml | |
| //[dependencies] | |
| //bitvec = "1" | |
| use bitvec::prelude::*; | |
| fn fast_aprox_u128_sqrt(val: u128) -> u128 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::stdout; | |
| use std::io::prelude::*; | |
| use std::{thread,time}; | |
| use std::env; | |
| fn typewrite(msg: &str) { | |
| let letters: Vec<char> = msg.chars().collect(); | |
| for letter in letters { | |
| print!("{}",letter); | |
| stdout().flush().unwrap(); |
NewerOlder