Skip to content

Instantly share code, notes, and snippets.

View cftang0827's full-sized avatar
🏠
Playing~

Paul Tang cftang0827

🏠
Playing~
View GitHub Profile
@cftang0827
cftang0827 / function_time.py
Last active July 3, 2018 06:31
The simple code that help you to estimate the computing time of the target function and get the same return value compare with origin function
def function_time(func, arg=()):
'''
The simple code that can estimate the computing time of the function and
return the same output of original one
:param func: The reference of the function you may want to estimate time
:param arg: The arguments of function, the default is ()
:return: Return original output of the function
'''
t1 = timeit.default_timer()
@cftang0827
cftang0827 / gist:35b12be7133a36a3cc7d5dabbdc52762
Created July 9, 2018 07:00 — forked from thinkphp/gist:1450738
Binary Search Tree implementation in Python
'''
by Adrian Statescu <adrian@thinkphp.ro>
Twitter: @thinkphp
G+ : http://gplus.to/thinkphp
MIT Style License
'''
'''
Binary Search Tree
------------------
@cftang0827
cftang0827 / rpi_cpu_temp_monitor.py
Created July 26, 2018 04:25
A script that can measure rpi's temperature and clock speed
# coding=UTF-8
'''
Python rpi monitor program
Call vcgencmd in shell and get the temp info and cpu clock info
20180314
'''
import subprocess as sub
import time
{
"protocol": "sftp",
"host": "ip_address",
"port": 22,
"username": "cftang",
"remotePath": "remote_path",
"privateKeyPath": "/Users/cftang/.ssh/id_rsa",
"passphrase": "/Users/cftang/.ssh/id_rsa.pub",
"uploadOnSave": true,
"ignore": [
ffmpeg -i /dev/video0 -c:v libx264 -b:v 1M -preset ultrafast -s 1280x720 -r 30 test.mp4
<html>
<head>
<script>
function show_image() {
document.getElementById("show").setAttribute("src", "data:image/jpeg;base64," + document.getElementById('base64_img').value);
}
</script>
</head>
<h1> Base64 encoding</h1>
import time
import threading
class p:
def __init__(self):
self.flag = True
self.thread = threading.Thread(target=self.show)
self.thread.start()
def show(self):
@cftang0827
cftang0827 / .vimrc
Created November 18, 2018 16:06 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
ffmpeg -f avfoundation -framerate 30 -s 1280x720 -i "1" -b:v 1M -preset ultrafast -s 1280x720 -r 30 test.mp4
@cftang0827
cftang0827 / pppoe.service
Created November 23, 2018 19:24
systemd for pppoe pon network connection
[Unit]
Description=pppoe
[Service]
Type=simple
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/pon dsl-provider
Restart=always
[Install]