Skip to content

Instantly share code, notes, and snippets.

@chen206
chen206 / mkdocs-chinese-search.md
Created January 18, 2017 11:02
mkdocs支持中文搜索
  1. 替换支持中文的lunr.min.js文件
  2. 下载 https://github.com/codepiano/lunr.js/blob/37680a339bfec3785e507bb3c07e362cae66ac26/lunr.min.js
  3. 复制到 /usr/local/Cellar/mkdocs/0.16.1_1/libexec/lib/python2.7/site-packages/mkdocs/assets/search/mkdocs/js/
  4. 修改生成索引文件的函数
  5. 找到文件 /usr/local/Cellar/mkdocs/0.16.1_1/libexec/lib/python2.7/site-packages/mkdocs/search.py
  6. 修改函数generate_search_index,在json.dumps中添加一个参数:ensure_ascii=False
    def generate_search_index(self):
        """python to json conversion"""
 page_dicts = {
@chen206
chen206 / ip
Last active September 14, 2016 07:32
公司IP
#google
74.125.58.0/24
104.132.0.0-104.133.127.255
63.243.168.0/22
209.62.176.0/20
1.1.1.0/24
8.15.202.0/24
23.251.128.0/19
66.102.0.0/20
74.114.24.0/21
@chen206
chen206 / awk.sh
Created September 13, 2016 03:35
Shell scripts
0000ABC1111ABC2222,"id": "1001", "name": "Jack"
0000ABC1111ABC2222ABC3333,"id": "1002", "name": "Michael"
0000ABC1111ABC3333,"id": "1003", "name": "David"
0000ABC2222ABC3333,"id": "1001", "name": "Jack"
1111ABC2222ABC3333,"id": "1002", "name": "Michael"
0000ABC2222ABC3333,"id": "1003", "name": "David"
0000ABC1111,"id": "1003", "name": "David"
# 按id统计ABC出现的总次数,文件如上例
less infile | awk -F"profile_image_url" '{first=match($0, "\"gsid\": \"");last=match($0, "\", \"s\"");s=substr($0, first+9, last-first-9)}{print NF-1,s}' | awk '{Counter[$2]+=$1;} END {for(key in Counter)print key, Counter[key];}' | sort -nr
@chen206
chen206 / memo.md
Last active December 5, 2023 18:10
Logrotate and upload Nginx logfile to S3

安装awscli

sudo apt-get install -y awscli

测试

sudo logrotate -d -f /etc/logrotate.d/nginx

触发logrotate

sudo logrotate -f /etc/logrotate.d/nginx

@chen206
chen206 / mytime.sql
Created March 18, 2016 05:19
MySQL日期时间时区
CREATE TABLE `tbl_test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
SELECT @@session.time_zone;
SELECT @@global.time_zone;
SET @@session.time_zone='+08:00';
@chen206
chen206 / wechat_getappmsgext.py
Last active July 6, 2024 10:30
微信公众号文章抓取阅读数和点赞数
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import json
from urlparse import urlparse, parse_qs
import requests
@chen206
chen206 / pyenv_install_pypy_offline.md
Last active March 18, 2016 04:32
pyenv install pypy offline

pyenv安装pypy时因为下载困难,可以先通过其它方式下载pypy,然后离线安装

  1. 下载

http://www.pypy.org/download.html 比如 pypy-5.0.0-osx64.tar.bz2

文件校验 shasum -a 256 pypy-5.0.0-osx64.tar.bz2

  1. 复制到目录
@chen206
chen206 / gradle.md
Last active July 4, 2018 03:14
gradle project
brew install gradle

echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.bash_profile

echo 'export GRADLE_HOME=/usr/local/opt/gradle/libexec' >> ~/.bash_profile

echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bash_profile
@chen206
chen206 / time.py
Last active July 4, 2018 03:10
Python日期时间函数库arrow
"""
pip install arrow
https://github.com/crsmithdev/arrow
"""
import arrow
utcnow = arrow.utcnow()
@chen206
chen206 / aws-kinesis-agent
Last active June 4, 2016 02:01
init script for aws-kinesis-agent 1.0.2 on ubuntu 14.04
#! /bin/sh
#
. /lib/lsb/init-functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/start-aws-kinesis-agent
NAME=aws-kinesis-agent
DESC=aws-kinesis-agent