This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def IdNumChecksum(id_num): | |
return '10X98765432'[sum([int(num) * (2 ** (17 - idx) % 11) for idx, num in enumerate(id_num[:17])]) % 11] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
ZABBIX_SERVER=192.168.1.100 | |
wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.2-1+xenial_all.deb | |
dpkg -i zabbix-release_3.2-1+xenial_all.deb | |
apt update | |
apt -y install zabbix-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
// ethereum: generate signed transactions | |
// source: https://gist.github.com/neuhaus/7387edf411513a9f11f1242dcec8d62e | |
const fs = require('fs'); | |
const rls = require('readline-sync'); | |
const Accounts = require('web3-eth-accounts'); | |
const web3utils = require('web3-utils'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Exmail | |
{ | |
protected $token = null; | |
public function __construct($corpId, $corpSecret, $debug = false) | |
{ | |
$url = sprintf('https://api.exmail.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s', $corpId, $corpSecret); | |
$resp = self::getJson($url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding:utf-8 | |
import os | |
import sys | |
import re | |
# Usage: | |
# mysqldump -u$user -p$pass --no-data --databases $database > db.sql | |
# ./sql_splitter.py db.sql create.sql modify.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# simplified from msocks5.py @ https://github.com/felix021/ssocks5 | |
import sys | |
import signal | |
try: | |
import gevent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#注:很多发行版自带SysBench的是0.4.12,但有些参数(如oltp-tables-count)是0.5才支持的,建议从官方源获取源码编译运行 | |
cmd="sysbench --test=/root/src/sysbench-0.5/sysbench/tests/db/oltp.lua \ | |
--oltp-table-size=2000000 \ | |
--oltp-tables-count=20 \ | |
--oltp-range-size=100 \ | |
--oltp-point-selects=10 \ | |
--oltp-simple-ranges=6 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
print len(urllib.urlopen('http://106.75.28.160/UCloud.txt#rd?n').read().split('UCanUup')) - 1 #728 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding: utf-8 | |
""" | |
Usage: | |
import multiprocess | |
slices = multiprocess.split_list(filelist, 8) #分成8份 | |
processes = map(lambda slice: multiprocess.spawn(file_processor, slice), slices) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding:utf-8 | |
#problem description: https://www.v2ex.com/t/98224 | |
start_node = dict(state='2011001100110011', row=0, col=0, prev=None); | |
target_state = '2101101001011010' | |
def swap(state, r1, c1, r2, c2): | |
m, n = list(sorted([r1 * 4 + c1, r2 * 4 + c2])) | |
return state[:m] + state[n] + state[m+1:n] + state[m] + state[n+1:] |