View deep_defaultdict.py
from collections import defaultdict | |
def deep_defaultdict(): | |
return defaultdict(deep_defaultdict) | |
d = deep_defaultdict() | |
d['x']['y']['z'] = 'foo' |
View lazy_module_variable.py
normal_variable = "hello I'm a normal variable" | |
def lazy_variable(): | |
from random import randint | |
return "hello I'm a lazy variable and my favorite number is {}".format(randint(0, 1000)) | |
import sys |
View uploaded.py
#!/usr/bin/env python3 | |
import argparse | |
import asyncio | |
import requests | |
import os | |
import sys | |
import re | |
import time | |
import signal | |
import configparser |
View asyncio_download_queue.py
import asyncio | |
import requests | |
import os | |
import re | |
import time | |
progress = {} | |
chunk_size = 4096 | |
workers = 2 | |
running = 0 |
View learnpython_001.py
import subprocess | |
for line in subprocess.check_output('dd if=/dev/urandom of=output.dat bs=1M count=10', shell=True, stderr=subprocess.STDOUT): | |
print line.split(" ") |
View inject command into console prompt.py
import fcntl | |
import termios | |
import sys | |
fd = sys.stdin.fileno() | |
old = termios.tcgetattr(fd) | |
new = termios.tcgetattr(fd) | |
new[3] = new[3] & ~termios.ECHO # disable echo | |
termios.tcsetattr(fd, termios.TCSANOW, new) |
View wifisensor.ino
#include <SoftwareSerial.h> | |
#include <DHT.h> | |
#define DHTTYPE DHT22 | |
#define DHTPIN 12 | |
#define LED_PIN 13 | |
DHT dht(DHTPIN, DHTTYPE); | |
SoftwareSerial dbgSerial(2, 3); // RX, TX |
View lsusb.py
#!/usr/bin/env python | |
# lsusb.py | |
# Displays your USB devices in reasonable form. | |
# (c) Kurt Garloff <garloff@suse.de>, 2/2009, GPL v2 or v3. | |
# (c) Kurt Garloff <kurt@garloff.de>, 9/2013, GPL v2 or v3. | |
# Usage: See usage() | |
from __future__ import print_function | |
import os |
View round_to_minutes.py
import datetime | |
def floor_to_minute(time, minutes): | |
time = time - datetime.timedelta( | |
minutes=time.minute % minutes, | |
seconds=time.second, | |
microseconds=time.microsecond) | |
return time |
View colortimeit.py
from __future__ import print_function | |
import time | |
print_func = print | |
def format_sec(milliseconds): | |
return '{:>8.3f} sec.'.format(milliseconds / 1000.0) | |
current_milli_time = lambda: int(round(time.time() * 1000)) |