Skip to content

Instantly share code, notes, and snippets.

View clamytoe's full-sized avatar
💭
Striving to learn something new each day.

Martin Uribe clamytoe

💭
Striving to learn something new each day.
View GitHub Profile
@clamytoe
clamytoe / poker.py
Created June 6, 2019 19:07
Quick little generic card game demo
from dataclasses import dataclass, field
from random import shuffle
from secrets import choice
from typing import Dict, Generator, List
NUMBERS: List[str] = list(map(str, range(1, 11)))
FACES: List[str] = "J Q K A".split()
SUITS: List[str] = "♠ ♥ ♦ ♣".split()
FACE_SCORES: Dict[str, int] = {"J": 11, "Q": 12, "K": 13, "A": 14}
@clamytoe
clamytoe / xor.py
Created October 11, 2018 13:26
xor.py
""" xor.py
My attempt to complete the challenge at:
https://www.geeksforgeeks.org/calculate-xor-1-n/
"""
import timeit
from functools import reduce
@clamytoe
clamytoe / extract_audio.py
Created September 13, 2018 16:00
Utility to extract the audio from a video file.
#!/usr/bin/env python
import argparse
from os import path, system
# specify the location of your ffmpeg binary
ffmpeg = "/home/mohh/anaconda3/pkgs/ffmpeg-4.0-h04d0a96_0/bin/ffmpeg"
def parser():
"""Argument parser"""
@clamytoe
clamytoe / traffic_lights.py
Created September 5, 2018 18:31
100DaysOfCode Traffic Light challenge
"""
traffic_lights.py
100DaysOfCode Traffic Light challenge
"""
from collections import namedtuple
from itertools import cycle
from os import platform, system
from time import sleep
@clamytoe
clamytoe / app.py
Created July 24, 2018 13:43
Quick proof of concept with using API Star to generate random questions.
from functools import lru_cache
from random import choice
import requests
from apistar import App, Route
@lru_cache(maxsize=1)
def get_questions():
@clamytoe
clamytoe / emoji.py
Created July 15, 2018 17:23
emoji.py
import requests
from bs4 import BeautifulSoup
def get_soup():
url = 'https://www.webpagefx.com/tools/emoji-cheat-sheet/'
page = requests.get(url)
if page.ok:
soup = BeautifulSoup(page.content, 'html.parser')
spans = soup.find_all('span', {'class': 'name'})
@clamytoe
clamytoe / buildOpenCV.zsh
Last active September 19, 2023 09:50
Script to build OpenCV 3.4.2 from source into an Anaconda virtual environment on a Linux Mint 19 machine.
#!/usr/bin/zsh
###############################################################################
# buildOpenCV.zsh - #
# #
# Script to build OpenCV 3.4.2 from source into an Anaconda virtual #
# environment on a Linux Mint 19 machine. #
###############################################################################
# Install requirements
sudo apt-get update
@clamytoe
clamytoe / tools.py
Last active May 31, 2018 12:56
tools.py
from re import sub
def explore(object):
"""Lists all methods and properties for the given object"""
_class = str(object.__class__).split()[1]
_class = sub('>', '', _class)
print(f'\nExplore -> {_class}\n')
for inner in dir(object):
@clamytoe
clamytoe / beam.py
Created May 29, 2018 11:56
beam.py
"""
Beam calculations
My attempt at converting mathematical formulas
into Python code.
Mu =1.35 G + 1.5 Q =1.35*0.5+1.5*0.15=0.9
µ=Mu / ( bw x d² x Fcd )=0.9/(0.3*(0.9*0.65)²*20)=0.438
Fcd=30/1.5=20
α =1.25 x ( 1 - ( 1 - ( 2 x µ ))^ 1/2)= 1.25 x ( 1 - ( 1 - ( 2 x0.438 ))^ 1/2)=0.81
@clamytoe
clamytoe / pins.py
Last active April 15, 2023 14:54
Small script that generates all possible 4 number pin combinations.
"""pins.py
Small script that generates all possible 4 number
pin combinations. Inspired by @ThePracticalDev's tweet challenge:
https://twitter.com/thepracticaldev/status/1000191076106465281?s=21
Challenge Alert!!
Write a script that produces all possible 4-digit numbers (0000...9999),
then put them into a random order and save the output into a text file.