Skip to content

Instantly share code, notes, and snippets.

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

Inhere inhere

😃
working, learning ...
View GitHub Profile
# link https://github.com/humbug/box/blob/master/Makefile
#SHELL = /bin/sh
# 每行命令之前必须有一个tab键。如果想用其他键,可以用内置变量.RECIPEPREFIX 声明
# mac 下这条声明 没起作用 !!
.RECIPEPREFIX = >
.PHONY: all usage help clean
# 需要注意的是,每行命令在一个单独的shell中执行。这些Shell之间没有继承关系。
# - 解决办法是将两行命令写在一行,中间用分号分隔。
# - 或者在换行符前加反斜杠转义 \
@inhere
inhere / format-mdtable2sql.php
Last active June 2, 2021 02:15
Convert table create SQL to markdown table, Convert markdown table to table create SQL
<?php
function format_mdtable2sql(string $mdStr): string
{
$lines = array_values(
array_filter(
explode("\n", trim($mdStr))
)
);
<?php declare(strict_types=1);
namespace App\Common;
use ReflectionException;
use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Bean\Exception\ContainerException;
use Swoft\Consul\Agent;
use Swoft\Consul\Exception\ClientException;
@inhere
inhere / common-func.sh
Created July 6, 2019 02:46
some common functions for bash script usage
#!/usr/bin/env bash
# some common functions
# Usage:
# user_confirm
# user_confirm "custom question"
function user_confirm() {
local yes=0
local msg="Confirm continue"
@inhere
inhere / add-remotes.sh
Created July 6, 2019 02:44
Add the remote repository address of each component to the local remote
#!/usr/bin/env bash
#set -e
# import common functions
source "$(dirname $0)/common-func.sh"
binName="bash $(basename $0)"
if [[ -z "$1" ]]
@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 / 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;