Skip to content

Instantly share code, notes, and snippets.

Felix021 felix021

View GitHub Profile
View schedule.py
MINUTES_OF_DAY = 1440
# [begin, end)
class TimeRange(object):
def __init__(self, begin, end):
self.begin = begin
self.end = end
def getMinutes(schedule):
minutes = [0] * MINUTES_OF_DAY
@felix021
felix021 / skiplist.py
Created Sep 18, 2018
A Basic Skip List Implementation
View skiplist.py
#coding:utf-8
import random
class Node(object):
def __init__(self, height, key=None):
self.key = key
self.next = [None] * height
def height(self):
@felix021
felix021 / IdNumChecksum
Last active Sep 14, 2018
中国身份证号校验码计算
View IdNumChecksum
def IdNumChecksum(id_num):
return '10X98765432'[sum([int(num) * (2 ** (17 - idx) % 11) for idx, num in enumerate(id_num[:17])]) % 11]
@felix021
felix021 / Ethereum.md
Last active Aug 25, 2018
以太坊区块链长什么样? —— 自建 ethereum 私有链指南
View Ethereum.md

之前接触以太坊的时候,确实能搜到很多资料,还有一个看起来很丰富的 Homestead Documentation,但这些材料都太不接地气了,看完还是不知道以太坊区块链到底长什么样,因此整理了这篇说明,希望能够在一定程度上解决这个问题吧。

1. 安装 ethereum (@ubuntu)

参考 官方说明:

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
@felix021
felix021 / zabbix-agent-setup.sh
Created Feb 28, 2018
Ubuntu 16.04 - Zabbix Agent 部署脚本:脚本里设置了 ServerActive ,会主动尝试到zabbix server注册,但需要先在zabbix frontend的 configuration->actions->auto registration 配置好 add host 动作,这样才会自动添加。
View zabbix-agent-setup.sh
#!/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 Feb 8, 2018
Ethereum: Sign Transactions Offline in NodeJS | 用NodeJS对以太坊交易离线签名
View sign-offline.js
#!/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 Apr 12, 2020
以太坊的私钥、公钥、地址
View ethereum-key-address.js
/*
* 安装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 Oct 24, 2017
basic sdk for exmail.qq.com
View Exmail.php
<?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 Sep 18, 2016
建表:分离主键、索引、外键、AUTO_INCREMENT (separate primary key, index, foreign key, auto_increment from table creation sql exported by mysqldump)
View sql_splitter.py
#!/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 Jul 27, 2016
Cloud Database Test
View cloud_db_test.sh
#!/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 \
You can’t perform that action at this time.