Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
@huobazi
huobazi / minio.sh
Created July 6, 2022 07:21 — forked from corbtastik/minio.sh
Bash script to configure, start and stop single node MinIO container instance on Docker
#!/bin/bash
# --------------------------------------------------------------------
# [init] Create run dir, env file if they don't exist, then source env
# --------------------------------------------------------------------
init() {
MINIO_CONTAINER_NAME=$1
MINIO_RUN_DIR=/data1/run/${MINIO_CONTAINER_NAME}
MINIO_DATA=${MINIO_RUN_DIR}/data
MINIO_CERTS=${MINIO_RUN_DIR}/certs
# create run dir for container instance
@huobazi
huobazi / ntpdate.md
Created May 24, 2021 03:26
服务器同步网络时间

同步网络时间

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#!/bin/bash
#同步网络时间
echo “同步网络时间中…”
apt-get install -y ntpdate
ntpdate -u cn.pool.ntp.org
@huobazi
huobazi / Remove password from git commit history.md
Created September 13, 2020 15:04
Remove password from git commit history

在github上传了带密码的文件的删除方法

在 GitHub上Push了带密码的文件,就算删掉文件,commit 历史还是残留的。

怎样删除commit历史呢?

方法:

使用 git filter-branch 可以替换 commit 历史,然后 --force push。

@huobazi
huobazi / SnowflakeIdGenerator.cs
Created September 2, 2020 08:24 — forked from jessejjohnson/SnowflakeIdGenerator.cs
Generate Twitter Snowflake ID's
public class SnowflakeIdGenerator
{
public const byte DefaultMachineIdBits = 6;
public const byte DefaultSequenceBits = 12;
private readonly long _machineId = 0;
private readonly byte _machineIdBits = 0;
private readonly byte _sequenceBits = 0;
private readonly long _maxSequence = 0;
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private readonly object _lockObject = new object();
@huobazi
huobazi / Golang program stdin stdout interaction.md
Created September 1, 2020 09:01 — forked from jamesrr39/Golang program stdin stdout interaction.md
Using stdout and stdin from other programs in Golang

Go program interaction

Example of how to use stdout and stdin from other programs in golang

Requires go

Run

go run parentprocess.go
@huobazi
huobazi / logger.go
Last active March 22, 2023 14:13
golang, logrus, write log to stdout also write to files as the same time with different format
package logging
import (
"time"
"github.com/sirupsen/logrus"
"github.com/snowzach/rotatefilehook"
"github.com/mattn/go-colorable"
)
@huobazi
huobazi / Oracle_Csharp_Type.md
Last active July 24, 2020 10:26
Oracle 的 Numer类型与 C# 数据类型对应关系

[.NET: Int32] = [Oracle:NUMBER(2)..NUMBER(9)*]

[.NET: Int64] = [Oracle:NUMBER(10)..NUMBER(18)*]

[.NET: Double] = [Oracle:NUMBER(x, 0)..NUMBER(x, 15)*]

[.NET: Double] = [Oracle: FLOAT]

[.NET: Decimal] = [Oracle:NUMBER]

@huobazi
huobazi / dirty-magic-on-how-to-convert-bigint-to-int-in-mysql.sql
Created July 20, 2020 10:16
dirty-magic-on-how-to-convert-bigint-to-int-in-mysql
/*
ref: https://stackoverflow.com/questions/11595217/convert-bigint-unsigned-to-int#11595484
*/
/*
CREATE FUNCTION long2int (n BIGINT) RETURNS INT(11) RETURN n;
*/
SET @a:= CAST('111' AS SIGNED );
@huobazi
huobazi / gist:e410bec08320f3ae87bb2dcec8756a8a
Created July 17, 2020 03:11 — forked from imranbaloch/gist:10895917
SqlHelper.cs class with async support
// ===============================================================================
// Microsoft Data Access Application Block for .NET
// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
//
// cs
//
// This file contains the implementations of the SqlHelper and SqlHelperParameterCache
// classes.
//
// For more information see the Data Access Application Block Implementation Overview.
using System;
using System.Collections;
using System.Data;
using MySql.Data.MySqlClient;
using System.Linq;
using System.Xml;
namespace OBALog.Data
{
[System.Diagnostics.DebuggerStepThrough]