Skip to content

Instantly share code, notes, and snippets.

View inhere's full-sized avatar
😃
working, learning ...

Inhere inhere

😃
working, learning ...
View GitHub Profile
@inhere
inhere / release-tag.sh
Created July 1, 2019 11:34
release tag for an subtree project
#!/usr/bin/env bash
#
# TODO with release message
set -e
binName="bash $(basename $0)"
if [[ -z "$1" ]]
then
@inhere
inhere / html-table2json.js
Created June 27, 2019 10:40
convert html table to json data
// var temp2 = $0.children
var temp2 = document.getElementsByTagName('tbody')[0].children
var arr1 = []
for (t in temp2) {
if (t == 0) {
continue
}
@inhere
inhere / autoloader.php
Last active June 27, 2019 10:41
quick add an pacakge autoloader for php
<?php
$libDir = __DIR__ . '/';
$npMap = [
'SwoftTool\\' => $libDir,
// 'Inhere\\ValidateTest\\' => $libDir . '/test/',
];
spl_autoload_register(function ($class) use ($npMap) {
foreach ($npMap as $np => $dir) {
if (strpos($class, $np) !== 0) {
@inhere
inhere / .editorconfig
Created January 1, 2019 05:44
my simple .editorconfig
root = true
# 对所有文件生效
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@inhere
inhere / build-go-app.Dockerfile
Created July 2, 2018 07:31
dockerfile for build golang application
#
# @build-example build . -f Dockerfile -t myapp:test
#
################################################################################
### builder image
################################################################################
FROM golang:1.10-alpine as Builder
# Recompile the standard library without CGO
@inhere
inhere / websocket-nginx.conf
Created April 28, 2018 05:32
Nginx configuration for websocket server
upstream io_nodes {
ip_hash;
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
server 127.0.0.1:6004;
}
server {
listen 3000;
@inhere
inhere / compare_speed.php
Last active April 26, 2018 15:03
比较两个不同的php语句或者函数的执行速度
<?php
function compare_speed(callable $sample1, callable $sample2, int $times = 1000, array $args = [])
{
if ($times < 1000) {
$times = 1000;
}
$start1 = microtime(1);
@inhere
inhere / nginx_proxy.conf
Created March 24, 2018 12:42
nginx 配置反向代理
upstream frontends {
server 127.0.0.1:8088; # server 监听的ip:port
}
server {
listen 80;
server_name xxx.com www.xxx.com;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
@inhere
inhere / method1.js
Last active April 17, 2018 09:01
js 时间转换到日期
// 对Date的扩展,将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子:
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
@inhere
inhere / swoole-nginx.conf
Created March 7, 2018 04:00
swoole 应用的nginx配置参考
server {
listen 80;
server_name www.site.dev site.dev;
root /webroot/static;
index index.html index.htm;
error_log logs/site.dev.error.log;
access_log logs/site.dev.access.log;
##### 第一个必选规则: 匹配首页