Skip to content

Instantly share code, notes, and snippets.

View stefanJi's full-sized avatar
🎯
Focusing

Yang Ji stefanJi

🎯
Focusing
View GitHub Profile
@stefanJi
stefanJi / TlsHandshake.kt
Created March 10, 2020 02:25
TLS Handshake by Kotlin
import java.net.Inet4Address
import java.net.InetSocketAddress
import java.net.Socket
import java.nio.ByteBuffer
import kotlin.random.Random
fun main() {
tlsHandshake()
}
@stefanJi
stefanJi / BytecodeParser.java
Created January 18, 2020 15:56
Implement a parser for JVM Byte Code.
/**
* <pre>
* ClassFile {
* u4 magic;
* u2 minor_version;
* u2 major_version;
* u2 constant_pool_count;
* cp_info constant_pool[constant_pool_count-1];
* u2 access_flags;
* u2 this_class;
@stefanJi
stefanJi / gitconfig.md
Created January 12, 2020 07:08
condition git-config for multiple git account

~/.gitconfig

[includeIf "gitdir:/"]
  path = .gitconfig_person


[includeIf "gitdir:~/work-a/"]
  path = .gitconfig_work_a
@stefanJi
stefanJi / pre-commit
Created December 15, 2019 14:39
send hexo source to git repo hook
#!/bin/sh
echo "Push source to repo"
echo "Cur: `pwd`"
cd ../source/_posts
git add .
git commit -m "feat: update or create post"
git push
cd ../../.deploy_git
@stefanJi
stefanJi / apk_size_diff.py
Last active November 6, 2019 10:57
两个 Apk 文件大小对比
# coding=utf-8
#
# Usage: result = Differ(old_apk_path, new_apk_path).diff()
#
import os
from argparse import ArgumentParser
from zipfile import ZipFile
KB = 1024.0
@stefanJi
stefanJi / steps.txt
Created October 26, 2019 02:50
为博客配置使用 acme 协议的 SSL 证书
acme.sh --issue -d blog.jiyang.site --webroot /home/jy/stefanji.github.io/
acme.sh --installcert -d blog.jiyang.site \
--key-file /home/jy/ssl/blog.jiyang.site.key \
--fullchain-file /home/jy/ssl/fullchain.cer
## nginx config
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
@stefanJi
stefanJi / android_dump_java_heap.sh
Last active October 22, 2019 08:10 — forked from LanderlYoung/android_dump_java_heap.sh
script to dump android java heap and convert use hprof-conv
ADB=${ANDROID_HOME}/platform-tools/adb
HPROF_CONV=${ANDROID_HOME}/platform-tools/hprof-conv
# customized functions
# dump droid heap
function droid_hd() {
PACKAGE_NAME=$1
TIME=$(date +"%Y%m%d_%H%M%S")
FILE_NAME="${PACKAGE_NAME}-${TIME}-heap.hprof"

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@stefanJi
stefanJi / pausable_coroutines_dispatcher.kt
Created June 26, 2019 07:06
pausable dispatcher for kotlin coroutines
import kotlinx.coroutines.*
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.atomic.AtomicInteger
import kotlin.coroutines.CoroutineContext
fun main() {
val dispatcherMgr = PauseDispatcherMgr()
GlobalScope.launch {
withContext(dispatcherMgr.pausableDispatcher(Dispatchers.IO)) {
abstract class IntervalProgressPainter extends CustomPainter {
final int max;
final int progress;
final int intervalSize;
final Color highlightColor;
final Color defaultColor;
final Color intervalColor;
final Color intervalHighlightColor;
final double radius;