Skip to content

Instantly share code, notes, and snippets.

View comzyh's full-sized avatar
🏢
Thinking about Ops

Comzyh comzyh

🏢
Thinking about Ops
View GitHub Profile
@comzyh
comzyh / ProjectOxford-video.py
Last active January 28, 2016 18:41
ProjectOxford-video.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Comzyh
# @Date: 2016-01-29 01:12:22
# @Last Modified by: Comzyh
# @Last Modified time: 2016-01-29 02:29:15
import requests
import json
import time
@comzyh
comzyh / aioamqp_0.7_heartbeat_bug_reproduce.py
Last active May 7, 2016 19:21
aioamqp 0.7 heartbeat bug reproduce
# -*- coding: utf-8 -*-
# @Author: Comzyh
# @Date: 2016-05-07 22:46:41
# @Last Modified by: Comzyh
# @Last Modified time: 2016-05-08 03:12:27
import aioamqp
import asyncio
import logging
import sys
import datetime
@comzyh
comzyh / configure.sh
Created August 16, 2016 14:26
openresty with openssl
sudo yum install libxslt-devel gd gd2 gd-devel gd2-devel perl-devel perl-ExtUtils-Embed geoip-devel
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_mod
@comzyh
comzyh / weibo_login.py
Created October 20, 2016 18:01
weibo_login.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Thanks @xianhu
# referer: https://github.com/xianhu/LearnPython/blob/master/python_weibo.py
import requests
import urllib
import base64
import time
import json
import logging
@comzyh
comzyh / bits-i7-7700HQ.s
Last active April 19, 2018 14:55
Bit Count test
.file "a.cpp"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC10:
.string "a.cpp"
.section .rodata.str1.8,"aMS",@progbits,1
.align 8
.LC11:
.string "bits1(arr[i]) == bits2(arr[i])"
.section .rodata.str1.1
@comzyh
comzyh / addbom.py
Created December 27, 2017 06:35
Add BOM to .h file
import os
import os.path
import sys
import codecs
def main():
print(sys.argv[1])
for root, dirs, files in os.walk(sys.argv[1]):
for file in files:
if file.endswith('.h'):
@comzyh
comzyh / ubuntu.json
Created November 22, 2018 07:04
Ubuntu theme colors for tilix
{
"name": "Ubuntu",
"comment": "Ubuntu default/theme terminal colors for tilix",
"use-theme-colors": false,
"foreground-color": "#ffffff",
"background-color": "#300a24",
"palette": [
"#2e3436",
"#cc0000",
"#4e9a06",
@comzyh
comzyh / bold_max.py
Created February 25, 2019 13:32
[Latex] Highlight maximum value in line
import re
import sys
def main():
for line in sys.stdin.readlines():
line = re.sub(r'\\textbf\{(?P<value>(\d+)?\.\d+)\}', lambda g: g.group('value'), line)
maxval = 0.0
for v in re.finditer(r'(?P<value>(\d+)?\.\d+)', line):
maxval = max(maxval, float(v.group('value')))
def rep_func(group):
# print(float(group.group('value')) == maxval)
@comzyh
comzyh / partial_random_shuffle.cpp
Created March 28, 2019 05:42
partial_random_shuffle.cpp
#include <algorithm>
#include <random>
#include <iostream>
using namespace std;
template< class RandomIt>
void partial_random_shuffle( RandomIt first, RandomIt last, RandomIt part) {
typename std::iterator_traits<RandomIt>::difference_type i, n, p;
p = part - first;
n = last - first;
@comzyh
comzyh / rand_k_in_n.cpp
Created March 28, 2019 07:58
rand_k_in_n.cpp
#include <algorithm>
#include <random>
#include <iostream>
#include <vector>
using namespace std;
vector<int> random_k_in_n(size_t k, int n) { // generate k distinct number in [0..n-1]
vector<int> ans;
ans.reserve(k);
std::random_device rd;