Skip to content

Instantly share code, notes, and snippets.

View navono's full-sized avatar
:octocat:
I may be slow to respond.

Darkness navono

:octocat:
I may be slow to respond.
View GitHub Profile
@navono
navono / Makefile-x64.msc
Created November 2, 2020 05:25
sqlcipher: Windows x64 version of Makefile
#
# nmake Makefile for SQLite
#
###############################################################################
############################## START OF OPTIONS ###############################
###############################################################################
# The toplevel directory of the source tree. This is the directory
# that contains this "Makefile.msc".
#
@navono
navono / Makefile.msc
Created November 2, 2020 05:24
sqlcipher: Windows x86 version of Makefile
#
# nmake Makefile for SQLite
#
###############################################################################
############################## START OF OPTIONS ###############################
###############################################################################
# The toplevel directory of the source tree. This is the directory
# that contains this "Makefile.msc".
#
@navono
navono / hmac.java
Created October 5, 2020 02:54
HMAC in Java
package hello;
import javax.crypto.Mac;
import javax.crypto.spec.*;
public class HMAC {
public void hash() {
try {
String secret = "salt";// 加密使用的key
String message = "1";// 需要加密的字符串(本项目是 "{uuid}_{timestamp}" )
@navono
navono / env_bat
Created September 28, 2020 08:38
setup env with bat
@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
set dir=%~dp0
set ligGit2Path=%dir%third_party\libgit2
set pkgConfigPath=%dir%third_party\pkg-config
set zlibPath=%dir%third_party\zlib
set KEY_NAME="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
@navono
navono / utf8-string
Created September 28, 2020 08:35
UTF8 - string in C++
std::string ofDewarServer::string_To_UTF8(const std::string & str)
{
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t * pwBuf = new wchar_t[nwLen + 1];//一定要加1,不然会出现尾巴
ZeroMemory(pwBuf, nwLen * 2 + 2);
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
@navono
navono / zap_jq.md
Last active August 3, 2020 12:06
filter zap json logger with jq

suppose we have a log file named 'log.json' and record some error level info, we want to split the stack trace from the file with some filter(like time) to formatted json, so we can do this :

cat log.json | jq '. | select(.level=="error") | select(.time | contains("xxxxx"))' | jq '.stacktrace | fromjson'
@navono
navono / pull.go
Created June 1, 2020 08:47 — forked from sithembiso/pull.go
git pull using git2go
func (repo *Repo) Pull() error {
branch, err := repo.Branch()
if err != nil {
return err
}
// Get the name
name, err := branch.Name()
if err != nil {
return err
@navono
navono / git2go-merge-local-branch.go
Created June 1, 2020 01:49 — forked from danielfbm/git2go-merge-local-branch.go
how to merge two local branches using git2go
package main
import (
"errors"
"log"
"github.com/libgit2/git2go"
)
func mergeBranches(repo *git.Repository, sourceBranchName string, destinationBranchName string) error {
// Assuming that these two branches are local already
sourceBranch, err := repo.LookupBranch(sourceBranchName, git.BranchLocal)
@navono
navono / main.go
Created May 18, 2020 11:08 — forked from Zenithar/main.go
More secure password storage using HMAC-SHA256 and scrypt
// Inspired by https://blog.filippo.io/salt-and-pepper/
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"encoding/json"
@navono
navono / main.go
Created May 18, 2020 11:08 — forked from Zenithar/main.go
More secure password storage using HMAC-SHA256 and scrypt
// Inspired by https://blog.filippo.io/salt-and-pepper/
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"encoding/json"