Skip to content

Instantly share code, notes, and snippets.

View shi-yan's full-sized avatar
💭
keyboard smashing

Shi Yan shi-yan

💭
keyboard smashing
View GitHub Profile
@shi-yan
shi-yan / gist:dc93b6fb121b89e65ec849e0db68f51e
Last active May 5, 2020 08:28 — forked from yuezhu/gist:47b15b4b8e944221861ccf7d7f5868f5
Generate self-signed certificate for HAProxy
# Generate a unique private key (KEY)
sudo openssl genrsa -out xxx.local.key 2048
# Generating a Certificate Signing Request (CSR)
sudo openssl req -new -key xxx.local.key -out xxx.local.csr
# Creating a Self-Signed Certificate (CRT)
sudo openssl x509 -req -days 365 -in xxx.local.csr -signkey mydomain.key -out xxx.local.crt
# Append KEY and CRT to xxx.local.pem
@shi-yan
shi-yan / gist:db2efe2320065731f56db101fa61ed62
Created July 18, 2019 17:52
check which packaged installed a binary
dpkg -S /usr/bin/passwd
check which binaries are installed by a package:
dpkg -L ddd.deb
@shi-yan
shi-yan / gist:e7ec250792d8b43ed4b29a649a250abc
Created July 11, 2019 17:51
how to print all cmake variables for debugging
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
@shi-yan
shi-yan / gist:d34734cf37f4d3287220c56cc64fe86c
Created November 18, 2018 17:22
save tmux buffer into file
https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file
@shi-yan
shi-yan / gist:eaf177def8bfc81fb617090cda9d28ce
Created November 15, 2018 17:54
ssh Connection reset by xxxx port 22 error solution
run
sudo dpkg-reconfigure openssh-server
@shi-yan
shi-yan / gist:3b2225bd267fcd6114de87d4a7e2c063
Created November 1, 2018 22:07
gdb exit if program succeeds, break if program crashes?
https://stackoverflow.com/questions/8657648/how-to-have-gdb-exit-if-program-succeeds-break-if-program-crashes
If you put the following lines in your ~/.gdbinit file, gdb will exit when your program exits with a status code of 0.
python
def exit_handler ( event ):
if event .exit_code == 0:
gdb .execute ( "quit" )
@shi-yan
shi-yan / node_odbc_ms_odbc_17.md
Last active September 18, 2018 00:02
How to solve node-odbc + Microsoft ODBC driver issue [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]
{ [Error: [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]]
  errors:
   [ { message:
        '[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]',
       state: '08001' },
     { message:
        '[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection',
       state: '08001' } ],
  error: '[node-odbc] SQL_ERROR',
wc `find . -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.c" -o -name "*.hpp" -o -name "*.cc" \)`
@shi-yan
shi-yan / reportip.sh
Last active May 2, 2018 16:57
My work machine changes IP, If I want to ssh into it from home, often I need to know its ip. This is the bash script to report ip change to my slack. Need to set cron job: crontab -e, 0 * * * * /home/xxx/reportip.sh
#!/bin/bash
touch oldIp.txt
md1=$(cat "oldIp.txt");
md2=$(hostname -I);
if [ "$md1" = "$md2" ]; then
echo The same
else
@shi-yan
shi-yan / gist:4f9670b0aad49f3cdab635da29b8c67e
Created June 7, 2017 21:03
count line numbers in a folder recursively
find . -name '*.h' -o -name '*.cpp' | xargs wc -l