Skip to content

Instantly share code, notes, and snippets.

View theharveyz's full-sized avatar
🕶️
NOOP

HarveyZ theharveyz

🕶️
NOOP
View GitHub Profile
@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 面向服务体系架构
<?php
function is_json_str($str) {
json_decode($str);
return json_last_error() === JSON_ERROR_NONE;
}
@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方法:从小到大排列
# 1. list => dict
arr1,arr2 = ['a', 'b'],[1,2]
dic = dict(zip(arr1, arr2)) # {'a':1, 'b':2}
@theharveyz
theharveyz / string_splice.go
Created April 5, 2017 12:59
GoLang字符串拼接
package main
import (
"bytes"
"fmt"
"log"
"strings"
)
@theharveyz
theharveyz / curl_multi.php
Last active April 7, 2017 10:55
curl_multi 批处理
<?php
function rolling_curl($curl_multi_data = [])
{
$queue = curl_multi_init();
$map = array();
foreach ($curl_multi_data as $curl_data) {
$ch = curl_init();
$data = $curl_data['data'];
if($curl_data['is_post'])
@theharveyz
theharveyz / func-method.js
Created April 16, 2017 18:00
js函数的方法(跟Go的任何类型都可以有method,非常像)
const func = func = (...args) => {func.info(...args)};
func.info = (...args) => {console.info.apply(this, args)};
// test
func(1,2,3,4);
// out put:
// ø 1 2 3
@theharveyz
theharveyz / slice_remove.go
Last active May 14, 2017 18:42
slice remove node
package main
import (
"fmt"
)
func main() {
s := []int{1,2,3,4,5}
nodes := append(s[:index], s[(index+1):]...)
@theharveyz
theharveyz / ticker.js
Created July 22, 2017 21:16
js测试例子
setTimeout(function(){
console.log("timeout")
}, 0);
setImmediate(function(){
console.log("immediate")
});
process.nextTick(function(){
console.log('next tick')
@theharveyz
theharveyz / CurlRoll.php
Created August 16, 2017 06:29 — forked from luxixing/CurlRoll.php
php-curl-multi 使用php curl多进程请求url,抓取页面的类
<?php
/**
* Use php curl multi, rolling request url.
*
* @author [email protected]
*/
class CurlRoll
{
/**