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
# Ref. http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/ | |
def dfs(graph, start, visited=None): | |
if visited is None: | |
visited = set() | |
if start in visited: | |
return | |
yield start | |
visited.add(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
# Ref. http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/ | |
def bfs(graph, queue, visited=None): | |
if visited is None: | |
visited = set() | |
if not queue: | |
return | |
start = queue.pop(0) | |
yield 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
#SingleInstance force | |
Hotkey, *~$LButton, LButtonLabel | |
return | |
LButtonLabel: | |
Loop | |
{ | |
if (!GetKeyState("ScrollLock", "T") or !GetKeyState("LButton", "P")) |
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/bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "You must be root to execute this script" 2>&1 | |
else | |
PID=$(docker inspect --format "{{ .State.Pid }}" "$1") | |
nsenter --target $PID --mount --uts --ipc --net --pid | |
fi |
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 | |
# | |
# Startup / shutdown script for the couchbase sync_gateway | |
# | |
if [ "$(id -u)" != "0" ]; then | |
echo "Must run as root" | |
exit 1 | |
fi |
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
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<fontconfig> | |
<match target="pattern"> | |
<test name="lang"> | |
<string>zh-tw</string> | |
</test> | |
<test name="family"> | |
<string>sans-serif</string> | |
</test> |
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 | |
# -*- coding: utf-8 -*- | |
import locale | |
import shlex | |
import subprocess | |
def _execute(cmd): | |
p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, |
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 | |
# -*- coding: utf-8 -*- | |
import argparse | |
import locale | |
import os | |
import re | |
import shlex | |
import subprocess | |
import sys |
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 asyncio | |
@asyncio.coroutine | |
def hello_world(): | |
while True: | |
yield from asyncio.sleep(1) | |
print('Hello World') | |
@asyncio.coroutine |
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 Api: | |
def __init__(self): | |
self.apis = [] | |
def register(self): | |
s = self | |
class Api: | |
def __init__(self, func): | |
self.func = func |