Skip to content

Instantly share code, notes, and snippets.

@sunliang711
sunliang711 / pre-commit.md
Created April 30, 2024 08:27 — forked from robertranjan/pre-commit.md
pre-commit hook to prevent binary check-ins

Navigate to hooks folder and make pre-commit script

cd ${GIT_REOP}/.git/hooks
cp pre-commit.sample pre-commit 

Add below code to pre-comit script

function checkForBinaries() {
    binaryFilesCount=0

echo "PWD: ${PWD}"

@sunliang711
sunliang711 / 1-dnsmasq-dnscrypt-proxy-setup.md
Created June 29, 2023 03:12 — forked from irazasyed/1-dnsmasq-dnscrypt-proxy-setup.md
How to Setup dnsmasq with dnscrypt-proxy and Cloudflare DNS on macOS

How to Setup dnsmasq with dnscrypt-proxy and Cloudflare DNS on macOS

Using Laravel Valet for localhost development, So it installs dnsmasq with it. dnsmasq runs on port 53, The default DNS port. So we setup dnscrypt-proxy on port 5300 with the default config files in this gist.

dnscrypt-proxy Installation

brew install dnscrypt-proxy
@sunliang711
sunliang711 / vim-surround使用指南.MD
Created March 24, 2023 05:37 — forked from wilon/vim-surround使用指南.MD
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" => {     Hello world! }
@sunliang711
sunliang711 / string-conversion.rs
Created August 26, 2022 15:58 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@sunliang711
sunliang711 / init.vim
Created July 13, 2021 03:12 — forked from mengwangk/init.vim
Full Neovim init.vim
"---- vim-plug setup ----
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
if has('win32')&&!has('win64')
let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
else
let curl_exists=expand('curl')
endif
if !filereadable(vimplug_exists)
if !executable(curl_exists)
@sunliang711
sunliang711 / comments.lex
Created February 29, 2020 07:41 — forked from fay59/comments.lex
Tiny Flex lexer that skips C-style block comments
%option noyywrap
%x C_COMMENT
%%
"/*" { BEGIN(C_COMMENT); }
<C_COMMENT>"*/" { BEGIN(INITIAL); }
<C_COMMENT>. { }
<C_COMMENT>\n { }
@sunliang711
sunliang711 / string.md
Created February 26, 2020 15:50 — forked from helinwang/string.md
How to call go from c with string (char *) as the parameter without making a copy

Here is the gist for showing how to send string from c to go without a copy, for sending an float32 array from c to go without copy, please see here

Below is the documentation for converting between a c string and a go string:

// From https://golang.org/cmd/cgo/
// A few special functions convert between Go and C types by making copies of the data. 
// Go string to C string
// The C string is allocated in the C heap using malloc.
// It is the caller's responsibility to arrange for it to be
// freed, such as by calling C.free (be sure to include stdlib.h
@sunliang711
sunliang711 / tmux-cheatsheet.markdown
Created August 4, 2019 11:44 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话: