Skip to content

Instantly share code, notes, and snippets.

View lucaspg96's full-sized avatar

Lucas Peres lucaspg96

View GitHub Profile
@lucaspg96
lucaspg96 / FibTests.scala
Created March 31, 2023 16:25
An interesting way to use traits to enerate test cases in Scala
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import scala.annotation.tailrec
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import math.{pow, sqrt}
trait FibTest extends AnyFlatSpec with should.Matchers {
@lucaspg96
lucaspg96 / ConfigUtils.py
Created September 15, 2022 18:43
Simple utility config function to read yml files and override them with environment variables
import yaml
import os
from pprint import pprint
config = yaml.safe_load(open("config.yml"))
def path_to_env(path):
return path.upper()\
.replace('.','_')
import rx
from rx import operators as ops
from collections.abc import Iterable
import logging
identity = lambda x: x
def throw(e):
print(e)
logging.exception(e)
# -*- coding: utf-8 -*-
from uuid import uuid4
from telegram.utils.helpers import escape_markdown
from telegram import InlineQueryResultArticle, ParseMode, \
InputTextMessageContent
from telegram.ext import Updater, InlineQueryHandler, CommandHandler
import logging
import telegram
from telegram.ext import Updater, CommandHandler, \
MessageHandler, Filters
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
import requests as req
def get_crypto_coin(name, coin="usd"):
from os import system
import shutil
import telegram
def get_disk_free_space(path):
usage = shutil.disk_usage(path)
free = usage.free/1024/1024/1024
percentage = 100*usage.free/usage.total
return (free,percentage)
from os import system
from pprint import pprint
from telegram import Bot, ParseMode
class Process(dict):
__getattr__ = dict.get
__delattr__ = dict.__delitem__
__setattr__ = dict.__setitem__
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.