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
#!/usr/bin/env python | |
import re | |
text = u'This dog \U0001f602' | |
print(text) # with emoji | |
emoji_pattern = re.compile("[" | |
u"\U0001F600-\U0001F64F" # emoticons | |
u"\U0001F300-\U0001F5FF" # symbols & pictographs | |
u"\U0001F680-\U0001F6FF" # transport & map symbols | |
u"\U0001F1E0-\U0001F1FF" # flags (iOS) | |
"]+", flags=re.UNICODE) |
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
#encoding=utf8 | |
import threading | |
import time | |
#这里使用方法__new__来实现单例模式 | |
class Singleton(object):#抽象单例 | |
def __new__(cls, *args, **kw): | |
if not hasattr(cls, '_instance'): | |
orig = super(Singleton, cls) | |
cls._instance = orig.__new__(cls, *args, **kw) | |
return cls._instance |
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 AsyncCursor(object): | |
def __init__(self, event, sql, params, timeout): | |
self._event = event # Used to signal when results are ready. | |
self.sql = sql | |
self.params = params | |
self.timeout = timeout | |
self._cursor = None | |
self._rows = None | |
self._ready = False |
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
# config file | |
# vim ~/.config/fish/config.fish | |
# reload the config | |
# source ~/.config/fish/config.fish | |
# set the workspace path | |
set -x GOPATH /users/my-username/go | |
# add the go bin path to be able to execute our programs |
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 threading import Thread | |
ThreadStop = Thread._Thread__stop | |
class TimeoutException(Exception): | |
pass | |
def timelimited(timeout): |
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 sys | |
import time | |
import atexit | |
class Daemon(object): | |
def __init__(self, pidfile="/dev/null", stdin="/dev/null", stdout="/dev/null", stderr="/dev/null"): |
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 walk_up(bottom): | |
"""mimic os.walk, but walk 'up' instead of down the directory tree. | |
From: https://gist.github.com/zdavkeos/1098474 | |
""" | |
bottom = os.path.realpath(bottom) | |
# get files in current dir | |
try: | |
names = os.listdir(bottom) |
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
# | |
# rules.before | |
# | |
# Rules that should be run before the ufw command line added rules. Custom | |
# rules should be added to one of these chains: | |
# ufw-before-input | |
# ufw-before-output | |
# ufw-before-forward | |
# |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# FileName : aes_python.py | |
# must install the pycrypto at frist, cmd: pip install pycrypto | |
import hashlib | |
from Crypto.Cipher import AES | |
import base64 |
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
@startuml Basic Sample | |
!include <awslib/AWSCommon> | |
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/release/1-0/C4_Container.puml | |
' Uncomment the following line to create simplified view | |
' !include <awslib/AWSSimplified> | |
!include <awslib/General/all> | |
!include <awslib/NetworkingAndContentDelivery/all> |