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
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} |
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
""" xor.py | |
My attempt to complete the challenge at: | |
https://www.geeksforgeeks.org/calculate-xor-1-n/ | |
""" | |
import timeit | |
from functools import reduce | |
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
#!/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""" |
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
""" | |
traffic_lights.py | |
100DaysOfCode Traffic Light challenge | |
""" | |
from collections import namedtuple | |
from itertools import cycle | |
from os import platform, system | |
from time import sleep |
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
from functools import lru_cache | |
from random import choice | |
import requests | |
from apistar import App, Route | |
@lru_cache(maxsize=1) | |
def get_questions(): |
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 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'}) |
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
#!/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 |
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
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): |
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
""" | |
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 |
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
"""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. |