Skip to content

Instantly share code, notes, and snippets.

View felix021's full-sized avatar

Felix021 felix021

View GitHub Profile
@felix021
felix021 / zabbix-agent-setup.sh
Created February 28, 2018 03:50
Ubuntu 16.04 - Zabbix Agent 部署脚本:脚本里设置了 ServerActive ,会主动尝试到zabbix server注册,但需要先在zabbix frontend的 configuration->actions->auto registration 配置好 add host 动作,这样才会自动添加。
#!/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
@felix021
felix021 / sign-offline.js
Last active February 8, 2018 12:30
Ethereum: Sign Transactions Offline in NodeJS | 用NodeJS对以太坊交易离线签名
#!/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');
@felix021
felix021 / ethereum-key-address.js
Last active November 3, 2022 10:13
以太坊的私钥、公钥、地址
/*
* 安装nvm和相应npm包
* $ nvm install v8.9.4
* $ npm install keccakjs secp256k1
*/
const { randomBytes } = require('crypto')
const secp256k1 = require('secp256k1')
const SHA3 = require('keccakjs')
@felix021
felix021 / Exmail.php
Created October 24, 2017 13:37
basic sdk for exmail.qq.com
<?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);
@felix021
felix021 / sql_splitter.py
Created September 18, 2016 11:41
建表:分离主键、索引、外键、AUTO_INCREMENT (separate primary key, index, foreign key, auto_increment from table creation sql exported by mysqldump)
#!/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
@felix021
felix021 / cloud_db_test.sh
Created July 27, 2016 14:31
Cloud Database Test
#!/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 \
import urllib
print len(urllib.urlopen('http://106.75.28.160/UCloud.txt#rd?n').read().split('UCanUup')) - 1 #728
@felix021
felix021 / multiprocess.py
Last active April 12, 2016 12:51
Python多进程库multiprocessing的封装
#!/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)
@felix021
felix021 / basic permutation
Created June 3, 2015 06:13
递归回溯法生成数字排列。
#include <stdio.h>
int visit[1024] = {0};
void perm_rec(int *a, int n, int i)
{
int j;
if (i == n) {
for (j = 0; j < n; j++)
printf("%d ", a[j]);
@felix021
felix021 / pyinterpreter.py
Created October 28, 2014 09:16
扔这里存档吧,侵入式的调试工具:D 用法:pyinterpreter.thread_interpreter(globals(), locals())
#!/usr/bin/env python
#coding:utf-8
import sys
import compiler
import thread
def thread_interpreter(globals_dict, locals_dict):
thread.start_new_thread(interpreter, (globals_dict, locals_dict))