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 time | |
from watchdog.observers import Observer | |
from watchdog.events import PatternMatchingEventHandler | |
class ScriptModifiedHandler(PatternMatchingEventHandler): | |
patterns = ['*.py'] | |
def __init__(self): | |
super(ScriptModifiedHandler, self).__init__() |
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
# in block server | |
location / { | |
root D:/project/www; | |
try_files $uri $uri/ /index.php; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
location ~ \.php$ { | |
root D:/project/www; | |
fastcgi_pass 127.0.0.1:9000; |
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 logging | |
def setup_logging(): | |
log = logging.getLogger(__name__) | |
log.setLevel(logging.DEBUG) | |
log.propagate = False | |
formatter = logging.Formatter('%(asctime)s :: line %(lineno)d, %(module)s [%(levelname)s] %(message)s') | |
formatter.datefmt = '%H:%M:%S %d/%m/%y' | |
handler = logging.StreamHandler() | |
file_handler = logging.FileHandler('file.log') |
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
# -*- coding: utf-8 -*- | |
import os | |
from fabric.api import env, run, put, cd, local | |
env.user = '' | |
env.password = '' | |
env.hosts = ['127.0.0.1'] | |
env.shell = "bash -c" |
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
class LinkedList(object): | |
def __init__(self): | |
self.head = None | |
self.tail = None | |
def add(self, node): | |
if self.tail is not None: | |
self.tail.next = node | |
self.tail = node | |
else: |
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 os | |
import time | |
import psutil | |
import humanfriendly | |
now = time.time() | |
pid = os.getgid() | |
ppid = os.getppid() |
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
timetable = ( | |
('10:30', '11:30'), | |
('10:00', '11:00'), | |
('11:00', '12:00'), | |
('09:33', '12:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), |
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 math | |
from collections import defaultdict | |
words = ('the', 'quisck', 'brown', 'fox', 'quick') | |
class WordDistanceFinder(object): | |
def __init__(self, words): |
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
# Setup docs: http://boto3.readthedocs.org/en/latest/guide/quickstart.html | |
import boto3 | |
# List all regions | |
client = boto3.client('ec2') | |
regions = client.describe_regions()['Regions'] | |
for region in regions: | |
print('Name: %s. Endpoint: %s' % (region['RegionName'], region['Endpoint'])) |
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
from collections import Counter | |
def find_letter_distance(string, other): | |
string_counter = Counter(string) | |
other_counter = Counter(other) | |
unique_symbols = set(string + other) | |
distance = 0 | |
for char in unique_symbols: |
OlderNewer