Skip to content

Instantly share code, notes, and snippets.

View oldratlee's full-sized avatar
🐥
Hello world!

李鼎 oldratlee

🐥
Hello world!
View GitHub Profile
@oldratlee
oldratlee / error-trap.sh
Last active February 15, 2024 05:27
error trap in bash
#!/bin/bash
set -eEuo pipefail
# https://stackoverflow.com/questions/6928946/mysterious-lineno-in-bash-trap-err
# https://stackoverflow.com/questions/64786/error-handling-in-bash
# https://stackoverflow.com/questions/24398691/how-to-get-the-real-line-number-of-a-failing-bash-command
# https://unix.stackexchange.com/questions/39623/trap-err-and-echoing-the-error-line
# https://unix.stackexchange.com/questions/462156/how-do-i-find-the-line-number-in-bash-when-an-error-occured
# https://unix.stackexchange.com/questions/365113/how-to-avoid-error-message-during-the-execution-of-a-bash-script
# https://shapeshed.com/unix-exit-codes/#how-to-suppress-exit-statuses
@oldratlee
oldratlee / developer-reading-list.md
Last active August 12, 2023 17:03
关于我的“程序员必读书单”

@peng_gong程序员必读书单不错,核对了一下自己。

“读完”指从头到尾读完的;“读过”是指有读但中途放下了。
当然有些书是在自己年轻时读完的,当时阅历尚浅理解吸收有限,要再读! 😊

PS:
这里个人强调于区分“读完” vs. “读过”,是因为对于编程了解原则还远远不够,循环往复的理解操练是标配,按这个节奏打穿一本书的体系是开始也是过程。
个人觉得如果连“读完”好书建立书中的体系这样级别的磨练都不行,那路是不是走得着急了! 😄

PPS: 📚我的豆瓣读书

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
public class HttpServerTest {
@oldratlee
oldratlee / DisableSslVerification.java
Created April 28, 2015 06:29
Disable Ssl Verification
static boolean sslVerificationDisabled = false;
public static synchronized void disableSslVerification() {
if (sslVerificationDisabled) return;
try {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@oldratlee
oldratlee / memBiterStat.sh
Last active June 18, 2019 06:39
对内存使用超过10%进程,执行内存dump和pstack
#!/bin/bash
PROG=`basename $0`
timestamp=`date "+%Y%m%d_%H%M%S"`
TMP=/tmp/${PROG}_${timestamp}
ge() {
[ $(echo "$1 >= $2" | bc) == 1 ]
}
dumpMemBiter() {
@oldratlee
oldratlee / ssh-break-while-loop.md
Created May 10, 2013 06:46
solve the problem that ssh break the while read loop

Description

ssh break the while loop.

0</dev/null or -n option of ssh can resolve this problem.

Sample Code

@oldratlee
oldratlee / comment-coverage-report.sh
Last active December 7, 2018 13:31
Generate comment coverage report for java of maven project, markdown table format
#!/bin/bash
# comment-coverage-report.sh
# generate comment coverage report, markdown table format
#
# NOTE:
# 1. run at project root dir
# 2. install ohcount: https://github.com/blackducksw/ohcount
# if you use mac install by brew: brew install ohcount
set -euo pipefail
@oldratlee
oldratlee / log-config.md
Last active October 15, 2018 11:37
log dependencies config
@oldratlee
oldratlee / gcor.sh
Last active July 24, 2017 05:42
checkout most recent modified branch
gcor() {
# http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
# --sort=-committerdate : sort branch by commit date in descending order
# --sort=committerdate : sort branch by commit date in ascending order
git branch -a --sort=committerdate "$@" |
awk -F'remotes/origin/' '/remotes\/origin\//{print $2}' |
tail -1 |
xargs git checkout
}
@oldratlee
oldratlee / ScalaLinearization.scala
Last active March 16, 2017 17:16
ScalaLinearization demo implementation by scala, based on https://gist.github.com/zavakid/05e18507ec3a311edcc87a4013b7d057
import scala.collection.immutable.ListSet
object ScalaLinearization {
case class Clazz(className: Symbol, superClasses: ListSet[Clazz])
// Ignore Any, AnyRef. Simplify demo implementation
val animal = Clazz('Animal, ListSet())
val furry = Clazz('Furry, ListSet(animal))
val hasLegs = Clazz('HasLegs, ListSet(animal))