Skip to content

Instantly share code, notes, and snippets.

View theharveyz's full-sized avatar
🕶️
NOOP

HarveyZ theharveyz

🕶️
NOOP
View GitHub Profile
@theharveyz
theharveyz / string_splice.go
Created April 5, 2017 12:59
GoLang字符串拼接
package main
import (
"bytes"
"fmt"
"log"
"strings"
)
# 1. list => dict
arr1,arr2 = ['a', 'b'],[1,2]
dic = dict(zip(arr1, arr2)) # {'a':1, 'b':2}
@theharveyz
theharveyz / python_sort.py
Last active March 8, 2017 18:35
python 排序
# 字典排序:
# 1. 根据key排序
items = dict.items()
items.sort() # list 的sort属性
for key,value in items:
print key,value
'''or'''
print key, dict[key] for key in sorted(dict.keys()) # sorted方法:从小到大排列
<?php
function is_json_str($str) {
json_decode($str);
return json_last_error() === JSON_ERROR_NONE;
}
@theharveyz
theharveyz / 编程词汇与简写.md
Last active March 16, 2017 17:23
编程词汇与简写

Constants

  • NL: new line 一般指\r\n
  • CR: 回车carriage return \r
  • LF: 换行line feed \n

Terms

  • ESB: Enterprise Service Bus 服务总线(SOA)
  • RFC: Requests For Comments 征求意见稿
  • SOA: service-oriented architecture 面向服务体系架构
@theharveyz
theharveyz / py.h.sublime-snippet
Created February 17, 2017 06:16
Sublime Text snippets
<snippet>
<content><![CDATA[
# -*- coding: utf-8 -*-
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>py.h</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@theharveyz
theharveyz / decorator_test.py
Last active December 22, 2016 19:17
python decorator装饰器测试: 装饰器在代码加载时就会执行! 最简单的装饰器就是将函数直接返回(dummyDecorator)
# -*- coding: utf-8 -*-
def dummy_decorator(injection):
print 'dummy'
return injection
def test_decorator(injection):
print 'foooo'
def wrapper(params):
print 'barrrr'
# -*- coding: utf-8 -*-
class A(object):
def foo(self):
print 'hello A'
@classmethod
def demo(cls):
s = cls()
s.foo()
@theharveyz
theharveyz / php-stream-and-stream-filter-demo.php
Created December 13, 2016 17:56
php stream流操作相关知识点
<?php
/**
* stream解释: 将数据从开始位置传送到目的位置, 可以是大流量文件传输
* 1. stream的过程:
* 开始通信
* 读取数据
* 写入数据
* 结束通信
* ## 可以说stream是这一过程的抽象
*
@theharveyz
theharveyz / node_cluster_http_server.js
Last active December 6, 2016 07:24
使用cluster模块实现负载均衡,和多进程监听同一端口
import http from 'http';
import cluster from 'cluster';
import os from 'os';
const port = 3001;
// cpu核数
const numCpus = os.cpus().length;
console.log(`The num of cpu: ` + numCpus);
// 实现Load balancer