Skip to content

Instantly share code, notes, and snippets.

View zhengxiaowai's full-sized avatar
🎯
Focusing

zxy zhengxiaowai

🎯
Focusing
View GitHub Profile
#!/bin/sh
set -o nounset # error when referencing undefined variable
set -o errexit # exit when command fails
# Install latest nodejs
if ! command -v node > /dev/null; then
curl --fail -L https://install-node.now.sh/latest | sh
# Or use apt-get
# sudo apt-get install nodejs
@zhengxiaowai
zhengxiaowai / geektime.user.js
Created December 7, 2018 09:44 — forked from Rand01ph/geektime.user.js
让极客时间的内容可以复制
// ==UserScript==
// @name geektime copy
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 让极客时间的内容可以复制!
// @author Rand01ph
// @match https://time.geekbang.org/column/*
// @grant none
// @require http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
// ==/UserScript==
apt update
apt install -y supervisor lrzsz curl
wget --no-check-certificate -P ~ -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
bash ~/shadowsocks-all.sh
/etc/init.d/shadowsocks-r stop
cat > /etc/supervisor/conf.d/ssr.conf << EOF
[program:ssr]
command=python /usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json --log-file /var/log/shadowsocks.log --workers 2
[loggers]
keys=root
[logger_root]
level=DEBUG
handlers=console,rotating
[handlers]
keys=console,rotating
# coding: u8
import json
from requests_html import HTMLSession
session = HTMLSession()
def get_name(html):
name = html.find('body > div.container > div > div:nth-child(1) > div > div > div.col-md-8 > div > div.book-title > h2', first=True).text
/*
* Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This mode will double the cache usage, and double the single thread performance. It will
* consume much less power (as less cores are working), but will max out at around 80-85% of
* the maximum performance.
*
* no_prefetch - Some sytems can gain up to extra 5% here, but sometimes it will have no difference or make
* things slower.
*
* affine_to_cpu - This can be either false (no affinity), or the CPU core number. Note that on hyperthreading
  1. 进入项目文件夹
  2. 创建远程仓库 $NEW_REPO
  3. git push $NEW_REPO +$BRANCH:master
  • $NEW_REPO: 远程仓库地址
  • $BRANCH:本地分支名

可以保存完整的提交记录

import decimal
import json
# This is a workaround for: http://bugs.python.org/issue16535
class DecimalEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, decimal.Decimal):
return int(obj)
return super(DecimalEncoder, self).default(obj)
class MagicDict(object):
def __init__(self, default=None):
if isinstance(default, (type(None), type(dict))):
raise TypeError('default must dict or None')
self.store = {}
if default is not None:
for k, v in default.items():
self.set(k, v)
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt update
sudo apt install python3.6