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 / 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 / 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 / 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 / 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 / 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()
}
public void attachBaseContext(Context paramContext) {
// Byte code:
// 0: aconst_null
// 1: astore_2
// 2: ldc 0
// 4: istore_3
// 5: aload_0
// 6: getfield mLauncherApplication : Lcom/x/mobile/y/LauncherApplication;
// 9: getfield mCurrentProcessStartupTime : J
// 12: lstore #4
@stefanJi
stefanJi / animator_cancel.java
Last active April 17, 2020 15:28
animator_cancel_android_8
public void cancel() {
if (isStarted()) {
ArrayList<AnimatorListener> tmpListeners = null;
if (mListeners != null) {
tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
int size = tmpListeners.size();
for (int i = 0; i < size; i++) {
tmpListeners.get(i).onAnimationCancel(this);
}
}
@stefanJi
stefanJi / animator_cancel_7.java
Created April 17, 2020 15:28
animator_cancel_7
public void cancel() {
if (isStarted()) {
ArrayList<AnimatorListener> tmpListeners = null;
if (mListeners != null) {
tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
int size = tmpListeners.size();
for (int i = 0; i < size; i++) {
tmpListeners.get(i).onAnimationCancel(this);
}
}
@stefanJi
stefanJi / application.js
Created May 3, 2020 00:58
hugo post image process. Resize, Center, FancyBox
let images = document.querySelectorAll('.article-entry img');
images.forEach(function (i) {
i.style.maxHeight = '450px'
i.style.maxWidth = '600px';
i.style.boxShadow = '2px 2px 8px 0px #888888';
i.style.borderRadius = '8px';
let a = document.createElement("a");
a.setAttribute("data-fancybox", "gallery");
a.setAttribute("href", i.getAttribute("src"));
a.setAttribute("data-caption", i.alt);
@stefanJi
stefanJi / application.js
Created May 3, 2020 00:58
hugo post image process. Resize, Center, FancyBox
let images = document.querySelectorAll('.article-entry img');
images.forEach(function (i) {
i.style.maxHeight = '450px'
i.style.maxWidth = '600px';
i.style.boxShadow = '2px 2px 8px 0px #888888';
i.style.borderRadius = '8px';
let a = document.createElement("a");
a.setAttribute("data-fancybox", "gallery");
a.setAttribute("href", i.getAttribute("src"));
a.setAttribute("data-caption", i.alt);