🏳️🌈
This file contains 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
""" | |
file_ext_fixer.py - https://gist.github.com/imsofi/dad85324d47b73fd7997d4e5673de645/edit | |
Usage: | |
Create a "photos" folder where the python file is located. Put all files | |
you want to try to fix into the "photos" folder. | |
Open a terminal window in the folder where this python file is located | |
and run: `python3 file_ext_fixer.py` or `python file_ext_finder.py` | |
(without the `) |
This file contains 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
fizzbuzz_dict = {'Fizz': 3, 'Buzz': 5} | |
def fizzbuzz_gen(num: int) -> str: | |
"""Can easily change the values used at runtime from a dict.""" | |
return ''.join(key * (num % value == 0) for key, value in fizzbuzz_dict.items()) or str(num) | |
def fizzbuzz_str(num: int) -> str: | |
"""About 3x faster than fizzbuzz_gen(), but no flexibility at runtime.""" | |
return "Fizz" * (num % 3 == 0) + "Buzz" * (num % 5 == 0) or str(num) |
This file contains 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 click | |
from decimal import Decimal, getcontext | |
@click.command() | |
@click.argument('a', type=click.FLOAT) | |
@click.argument('b', type=click.FLOAT) | |
@click.argument('c', type=click.FLOAT) | |
@click.option('--precision', '-p', type=click.INT, help='Decimal precision by number') | |
def main(a,b,c,precision): | |
"""Quadratic formula solver""" |
This file contains 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
def baby_shark_lyrics(): | |
a,o=[],'' | |
for s in 'Baby Mommy Daddy Grandma Grandpa'.split(): | |
a+=[s+" shark"] | |
a+=["Let's go hunt"] | |
for i in a: | |
o+=(i+","+" doo"*6+"\n")*3+i+"!\n" | |
return o+'Run away,…' | |
print(baby_shark_lyrics()) |