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
| #!/bin/sh | |
| function install_packages { | |
| sudo apt-get install -y nginx build-essential python3-dev libssl-dev openssl python3-pip fail2ban git mysql-server | |
| sudo pip3 install -r requirements.txt | |
| } |
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
| #!/bin/sh | |
| function install_packages(){ | |
| sudo apt-get install -y nginx build-essential python3-dev libssl-dev openssl python3-pip fail2ban git mysql-server | |
| sudo pip3 install -r requirements.txt | |
| } |
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
| class count_limiter(object): | |
| def __init__(self, count_limit): | |
| pass | |
| def __call__(self, func): | |
| def wrapper(*args, **kwargs): | |
| res = func(*args, **kwargs) | |
| return res |
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
| @count_limiter(3) | |
| def hello(person): | |
| print("hi there {}".format(person)) | |
| if __name__ == '__main__': | |
| hello("fred") | |
| hello("george") | |
| hello("jane") | |
| hello("jim") # exception thrown here because it's the 4th call |
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 threading import Thread | |
| from random import random, seed | |
| from time import time, sleep | |
| from functools import wraps | |
| def concurrent(func): | |
| @wraps(func) | |
| def wrapper(*args, **kwargs): | |
| Thread(target=func, args=args).start() |
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
| for soup, file_name in soup_line("sources"): | |
| print(file_name, soup("title")) |
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
| def soup_line(dir_name, *exclusions): | |
| """ | |
| Pair up soups with the files they're based on. | |
| :param dir_name: Directory with the html files needed. | |
| :param exclusions: Don't include these files. | |
| :return: A tuple of soup file name pairs. | |
| """ | |
| import os | |
| from collections import namedtuple |
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 bpy | |
| import _bpy | |
| from collections import defaultdict | |
| def make_operator_dict(): | |
| submod_op_pairs = [entry.split("_OT_") for entry in _bpy.ops.dir()] | |
| submod_op_pairs = [(k.lower(), v) for k,v in submod_op_pairs] | |
| op_dict = defaultdict(list) | |
| for key, val in submod_op_pairs: |
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
| # meta_troll.py | |
| # This is me messing around with Python type constructors just for fun. | |
| # Try and see what happens if you uncomment the __metaclass__ line in Foo. | |
| class TrollType(type): | |
| def __new__(meta, classname, bases, clssDict): | |
| class MyTroll(object): | |
| def say_stuff(self): | |
| print("you mad bro?") | |
| return MyTroll |
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
| #worlds_worst_fizzbuzz.py | |
| print(type("",(),{"__call__": | |
| lambda self, start, end: | |
| [(n, (lambda x: ("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else ""))(n)) | |
| for n in range(start,end+1)] | |
| })()(1,50) | |
| ) |