Skip to content

Instantly share code, notes, and snippets.

View theharveyz's full-sized avatar
🕶️
NOOP

HarveyZ theharveyz

🕶️
NOOP
View GitHub Profile
@theharveyz
theharveyz / gen-custom.sh
Created September 28, 2018 06:42 — forked from ArthurHlt/gen-custom.sh
Generate json schema for intellij terraform plugin on a community provider
#!/usr/bin/env bash
# Run `./gen-custom.sh github.com/myorg/myprovider provider-name version`
# e.g.: `./gen-custom.sh github.com/mevansam/terraform-provider-cf cloudfoundry v1.0.0`
# This will place a provider-name.json directly in $HOME/.terraform.d/schemas
CUR="$(pwd)"
out="$CUR/schemas"
mkdir -p "$out"
@theharveyz
theharveyz / ios-identifier.md
Last active May 21, 2018 06:43
iPhone手机标识符
/**
 *  取设备型号标识符,e.g. iPhone8,1
 *
 *  @return 设备型号标识符
 */
- (NSString *_Nonnull)identifier {
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
SELECT count(SCHEMA_NAME) as SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='xxx';
@theharveyz
theharveyz / wrapper.js
Last active November 7, 2017 17:59
express async wrapper
/**
* @param fn fn是 async fn...修饰的函数, 本身已经是个Promise对象!!
*/
export const wrapper = (fn) => (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next)
@theharveyz
theharveyz / go-build.sh
Created August 17, 2017 09:24
go build
#!/bin/bash
RUN_MODE=develop
APP_NAME=wawazu-machine-server
SVC_NAME=$APP_NAME-$RUN_MODE
PRJ_PATH=/data/projects/$RUN_MODE/$APP_NAME
BIN_NAME=$APP_NAME-$RUN_MODE
RUN_PATH=/data/GORUN/$RUN_MODE/$APP_NAME
BUILDNO=`date '+%Y%m%d%H%M%S'`
@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 liwanghui@dratio.com
*/
class CurlRoll
{
/**
@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 / 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 / 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 / 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'])