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 list2tuple(l): | |
"""This function takes a list and recursively changes all lists to tuples""" | |
rlist = [] | |
for i in l: | |
if type(i) in (list, tuple, set): | |
rlist.append(l2t(i)) | |
else: | |
rlist.append(i) | |
return tuple(rlist) |
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 wemos import * | |
from machine import Pin, PWM | |
import machine | |
import time | |
import urequests | |
import urandom | |
red = PWM(Pin(D8), freq=512, duty=0) | |
green = PWM(Pin(D7), freq=512, duty=0) | |
blue = PWM(Pin(D6), freq=512, duty=0) |
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 namedtuple_with_defaults(typename, args=None, kwargs=None, verbose=False, rename=False): | |
""" | |
Factory for creating namedtuples with keyword arguments. | |
:type typename: str | |
:type args: tuple | |
:type kwargs: tuple | |
:type verbose: bool | |
:type rename: bool | |
:rtype: 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
from django_extensions.management.shells import import_objects | |
from django.core.management.color import no_style | |
globals().update(import_objects({"dont_load":[], "quiet_load":False},no_style())) |
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 nested_itemgetter: | |
def __init__(self, item, *items): | |
if not items: | |
def func(obj): | |
steps = item.split(".") | |
for step in steps: | |
obj = obj[step] | |
return obj | |
self._call = func | |
else: |
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 socket | |
def listen(): | |
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
connection.bind(('0.0.0.0', 5555)) | |
connection.listen(10) | |
while True: | |
current_connection, address = connection.accept() |
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 readnlines(filehandler, n=4): | |
line_groups = [] | |
while True: | |
nlines = [] | |
for i in range(n): | |
line = filehandler.readline() | |
if line: | |
nlines.append(line.strip()) | |
else: | |
if nlines: |
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 textwrap | |
from sqlalchemy.ext.compiler import compiles | |
from sqlalchemy.sql.ddl import CreateTable | |
@compiles(CreateTable, "postgresql") | |
def pg10_partition_compiler(element, compiler, **kw): | |
""" | |
Simple helper that enables Postgresql 10's declarative partitioning features. | |
partition_by : str = Plain sql string that defines partition rules for the parent table. |
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 python3 | |
""" | |
Bu script İçişleri Bakanlığının yayınladığı il/ilçe listesini okuyup size bir sözlük olarak geri verir, aslında başka şeyler de yapabilir, ben yapmadım üşendim, siz isterseniz yapın. | |
""" | |
__author__ = "Umut Karcı" | |
__license__ = "MIT" | |
from tablib import Dataset |
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 json | |
import pathlib | |
import sys | |
import time | |
import datetime | |
from copy import deepcopy | |
from typing import List, Dict, Any | |
from urllib.parse import urljoin | |
import appdirs |