Skip to content

Instantly share code, notes, and snippets.

View mrjohannchang's full-sized avatar

Johann Chang mrjohannchang

View GitHub Profile
def solve(s: str, n: int, iseven: bool):
if n <= 0:
print(s)
return
i: int
for i in range(10) if iseven else range(9, -1, -1):
solve(s + chr(ord('0') + i), n - 1, i % 2 == 0 if iseven else i % 2 == 1)
solve('', int(input()), True)
U-Boot 1.1.3 (Nov 15 2013 - 16:45:31)
Board: Ralink APSoC DRAM: 64 MB
relocate_code Pointer at: 83fb4000
enable ephy clock...done. rf reg 29 = 5
SSC disabled.
******************************
Software System Reset Occurred
******************************
spi_wait_nsec: 29
@mrjohannchang
mrjohannchang / build.log
Created November 5, 2015 10:45
Cross Compiling Python 3.4.3 for MIPSel with SSL and SQLite3
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _dbm _gdbm
_lzma _tkinter nis
readline
class Solution:
# @param {TreeNode} root
# @return {TreeNode}
def invertTree(self, root):
if root:
root.left, root.right = self.invertTree(root.right), self.invertTree(root.left)
return root
@mrjohannchang
mrjohannchang / api.py
Last active August 29, 2015 14:21
Python preprocessed decorator
class Api:
def __init__(self):
self.apis = []
def register(self):
s = self
class Api:
def __init__(self, func):
self.func = func
@mrjohannchang
mrjohannchang / coroutine.py
Last active August 29, 2015 14:21
Infinite event loop
import asyncio
@asyncio.coroutine
def hello_world():
while True:
yield from asyncio.sleep(1)
print('Hello World')
@asyncio.coroutine
@mrjohannchang
mrjohannchang / find-not-repoed
Created February 2, 2015 06:07
find-not-repoed
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import locale
import os
import re
import shlex
import subprocess
import sys
@mrjohannchang
mrjohannchang / find-not-gitted-dir
Created February 2, 2015 06:06
find-not-gitted-dir
#!/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,
@mrjohannchang
mrjohannchang / 20-noto-cjk.conf
Created November 15, 2014 17:41
.config/fontconfig/conf.d/20-noto-cjk.conf
<?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>
#!/bin/sh
#
# Startup / shutdown script for the couchbase sync_gateway
#
if [ "$(id -u)" != "0" ]; then
echo "Must run as root"
exit 1
fi