Skip to content

Instantly share code, notes, and snippets.

View jiahut's full-sized avatar
🎯
Focusing

zhijia,.zhang jiahut

🎯
Focusing
View GitHub Profile
// https://ppt.geekbang.org/list/qconbj2019?from=timeline&isappinstalled=0
JSON.stringify(jQuery.map(jQuery(".last-line > a"), e => jQuery(e).attr('href') ))
@jiahut
jiahut / time_cached.py
Last active June 4, 2018 07:46
基于过期时间的LRU缓存
from datetime import datetime, timedelta
from functools import lru_cache, wraps
def time_cached(maxsize=None, **timedelta_kwargs):
"""
基于时间过期的LRU缓存
`timedelta_kwargs`:
days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0
"""
apps = hs.application.runningApplications()
for key, value in pairs(apps) do
print(key)
print(value)
end
@jiahut
jiahut / dropall.js
Last active April 4, 2018 07:02 — forked from cschlyter/dropall.js
MongoDB: Drop all mongodb databases
// Usage: $ mongo dropAll.js
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
}
print("done.")
buildscript {
repositories {
// maven { url 'http://repo.spring.io/plugins-release' }
// maven { url 'https://plugins.gradle.org/m2/'}
jcenter()
}
dependencies {
classpath 'io.github.lukehutch:fast-classpath-scanner:2.4.5'
}
function compile(template){
var evalExpr = /<%=(.+?)%>/g;
var expr = /<%([\s\S]+?)%>/g;
template = template
.replace(evalExpr, '`);\n echo( $1 );\n echo(`')
.replace(expr, '`);\n $1 \n echo(`');
template = 'echo(` ' + template + '`);';
var script = `
#!/bin/sh
#
# /etc/rc.d/init.d/docker
#
# Daemon for docker.com
#
# chkconfig: 2345 95 05
# description: Daemon for docker.com
### BEGIN INIT INFO
#生成 RSA 私钥(传统格式的)
openssl genrsa -out rsa_private_key.pem 1024
#将传统格式的私钥转换成 PKCS#8 格式的
openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
#生成 RSA 公钥
yum install build-essential autoconf libtool openssl-devel gcc git -y
cd /tmp/
git clone --depth=1 https://github.com/madeye/shadowsocks-libev.git
cd shadowsocks-libev
./configure --disable-documentation
make && make install
mkdir -p ~/bin
@jiahut
jiahut / gist:d29dd29b62fe30b2e699
Last active August 29, 2015 14:07
stylus usage demo
$title-color
color red
.a
@extends $title-color
.title-color2
color red
.b
@extends .title-color2