Skip to content

Instantly share code, notes, and snippets.

View easyforgood's full-sized avatar
🎯
Focusing

Sip easyforgood

🎯
Focusing
  • Freelancer
  • Singapore
View GitHub Profile
@easyforgood
easyforgood / main.go
Created July 3, 2020 02:39
Golang http detect file type
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
@easyforgood
easyforgood / airdrop_hack.sol
Last active October 14, 2018 09:21
airdrop_hack
// 实现 Hacker 合约并薅走全部的羊毛。
// 注意 gas 控制。
contract Attack{
function Attack(address _game, uint count) public {
Airdrop a = Airdrop(b);
for (uint i=0; i< count; i++) {
a.airDrop();
}
pragma solidity ^0.4.18;
contract Gate {
bytes8 private password;
address public entrant;
address private mainContract;
uint public tryLimit=0;
struct User {
bytes8 username;
@easyforgood
easyforgood / jinja2_path.py
Created April 25, 2018 06:17
Jinja 的路径导入
from jinja2 import Environment, FileSystemLoader
import os
env = Environment(loader=FileSystemLoader(
os.path.join(os.path.split(os.path.realpath(__file__))[0], ".")))
template = env.get_template("template.html")
@easyforgood
easyforgood / interact.py
Created April 25, 2018 06:16
python 交互的命令行并导入locals变量
import code
code.interact(local=locals())
@easyforgood
easyforgood / 0_reuse_code.js
Created September 4, 2016 09:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import math
def dataInput():
(N,P,W,H)=(int(x) for x in raw_input().split())
initData=[int(x) for x in raw_input().split()]
return N,P,W,H,initData
def getResult():
N,P,W,H,initData=dataInput()
max=1
def getMax(max):
while True:
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"deviceName":"emulator-5554","platformName":"Android","platformVersion":"18","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\JAVAWORKSPACE\\TestforAppium\\bin\\TestforAppium.apk","appPackage":"com.example.testforappium","appActivity":".MainActivity","platformVersion":"4.3.1","automationName":"Selendroid","platformName":"Android","deviceName":"emulator-5554"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
> info: [debug] Using local app from desired caps: D:\JAVAWORKSPACE\TestforAppium\bin\TestforAppium.apk
> info: [debug] Creating new appium session 517975c1-90e4-4391-923b-b4a2a1034ed3
> info: [debug] Starting selendroid server
> info: [debug] Getting Java version
@easyforgood
easyforgood / complier_bjhua_hw1
Last active August 29, 2015 14:21
Mooc_编译工程_保健哥_Homework1
//补全了TODO部分的代码
//实现了Constant folding
#include <stdio.h>
#include <stdlib.h>
#define TODO() \
do{ \
printf ("\nAdd your code here: file \"%s\", line %d\n", \
__FILE__, __LINE__); \
}while(0)

ZeroRPC简介 - 轻量级分布式通信框架

概述

分布式系统的核心是分布式通信,而传统上开发一套支持上千台规模集群,可靠性非常高的分布式通信框架,需要不少的精力投入。而在多数情景下,我们(特别是时间宝贵的OP)并不是非常关注技术实现的细节,而是希望有一套成熟、轻量、可靠性高、使用方便而且易于调试的分布式通信框架,可以直接使用,从而把时间放在具体业务逻辑上。

在PyCon 2012大会上,dotcloud公司开源了一套基于ZeroMQ和MessagePack的分布式通信框架(或者说是协议+Python实现)。该框架因为基于ZeroMQ,使用方法是RPC,所以被命名为ZeroRPC。ZeroRPC的特点在其官网的介绍中一目了然[1]:

ZeroRPC is a light-weight, reliable and language-agnostic library for distributed communication between server-side processes.