Skip to content

Instantly share code, notes, and snippets.

Avatar
🔁
忙得团团转

Hypercube SmartHypercube

🔁
忙得团团转
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am smarthypercube on github.
  • I am smarthypercube (https://keybase.io/smarthypercube) on keybase.
  • I have a public key ASDs2-Z7Zn2qOs64hT0xxAggROXv-k03QQljn42Mk3NMCAo

To claim this, I am signing this object:

@SmartHypercube
SmartHypercube / .bashrc
Last active Jul 3, 2021
Hypercube's fancy prompt
View .bashrc
# Hypercube's fancy prompt
# + show user, hostname, pwd in ssh format
# + use color
# + use seperate command line
# + set short window title
# + show start time and duration
# + ring bell after long running command
# + show exit code
# + append newline when needed
# - show jobs
View mhtml.js
#!/usr/bin/node
// 作为脚本时需要上面这行
// 用于 AWS Lambda 时不需要
'use strict';
// 用于 AWS Lambda 时需要下面这些库,以及添加 Layer: arn:aws:lambda:eu-west-2:764866452798:layer:chrome-aws-lambda:24
// 这个 Layer 的最新版本见 https://github.com/shelfio/chrome-aws-lambda-layer
const crypto = require('crypto');
const chromium = require('chrome-aws-lambda');
const aws = require('aws-sdk');
@SmartHypercube
SmartHypercube / apt.conf
Last active Dec 8, 2020
Nginx APT proxy for docker builds
View apt.conf
proxy_cache_path /var/lib/nginx/proxy_cache levels=2 keys_zone=apt-cache:10m inactive=7d max_size=10g;
server {
listen 80;
listen [::]:80;
server_name deb.debian.org;
charset utf-8;
tcp_nodelay on;
server_tokens off;
@SmartHypercube
SmartHypercube / pyflow.py
Created Sep 11, 2018
一个 streaming process 的小实验
View pyflow.py
#!/usr/bin/python3
def main():
# 每秒生成一个随机字母并打印
from random import randrange
node = 26 >> Clock(1) >> randrange >> (lambda x: x+ord('A')) >> chr >> print
# 以下是两个有点tricky的例子,展示通过Wait节点连出一个环路
# 注意两个例子是并行运行的
@SmartHypercube
SmartHypercube / email2text.py
Last active Jul 7, 2018
从电子邮件源码中提取文本,依赖于beautifulsoup
View email2text.py
#!/usr/bin/python3
from codecs import getdecoder
from email import message_from_bytes
from bs4 import BeautifulSoup
ATTACHMENT = '<attachment with type %s>'
GARBAGE = '<cannot decode>'