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 / useenv.sh
Created October 11, 2024 08:10
简单方便的实现go,node等本机sdk的多版本管理。Simple and easy to realize go, node and other local sdk multi-version management.
#!/usr/bin/env bash
# backup the PATH
pathBak="$PATH"
# echo "$BASH_VERSION"
# 声明关联数组(bash > 4.2 版本)
declare -A env_paths=(
[node20]="/c/Users/inhere/workspace/env/node-sdk/node-v20.16.0-win-x64"
[node16]="/c/Users/inhere/workspace/env/node-sdk/node-v16.16.0-win-x64"
# 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