Skip to content

Instantly share code, notes, and snippets.

View isanwenyu's full-sized avatar
🏠
Working from home

Paul Zhu isanwenyu

🏠
Working from home
  • Shanghai,China
View GitHub Profile
@ninehills
ninehills / chatglm-openai-api.ipynb
Last active April 16, 2024 01:15
chatglm-openai-api.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.

@stoensin
stoensin / ThreadLocal
Created March 12, 2019 13:49
线程:每个线程都有他自己的一组CPU寄存器,称为线程的上下文,该上下文反映了线程上次运行该线程的CPU寄存器的状态。 指令指针和堆栈指针寄存器是线程上下文中两个最重要的寄存器,线程总是在进程得到上下文中运行的,这些地址都用于标志拥有线程的进程地址空间中的内存。 线程可以被抢占(中断)。 在其他线程正在运行时,线程可以暂时搁置(也称为睡眠) -- 这就是线程的退让。 线程可以分为: 内核线程:由操作系统内核创建和撤销。 用户线程:不需要内核支持而在用户程序中实现的线程。
import threading
# 创建全局ThreadLocal对象:
local_school = threading.local()
def process_student():
# 获取当前线程关联的student:
std = local_school.student
print('Hello, %s (in %s)' % (std, threading.current_thread().name))
def process_thread(name):
# 绑定ThreadLocal的student:
local_school.student = name
#!/usr/bin/env bash
set -eo pipefail
# hello-world latest ef872312fe1b 3 months ago 910 B
# hello-world latest ef872312fe1bbc5e05aae626791a47ee9b032efa8f3bda39cc0be7b56bfe59b9 3 months ago 910 B
# debian latest f6fab3b798be 10 weeks ago 85.1 MB
# debian latest f6fab3b798be3174f45aa1eb731f8182705555f89c9026d8c1ef230cbf8301dd 10 weeks ago 85.1 MB
if ! command -v curl &> /dev/null; then
echo >&2 'error: "curl" not found!'
@magneticflux-
magneticflux- / LiveDataUtils.kt
Last active February 3, 2023 19:08
Helpful Android-Kotlin LiveData utilities
//--------------------------------
// CHECK THE COMMENTS FOR UPDATES!
//--------------------------------
/*
* Copyright (C) 2017 Mitchell Skaggs, Keturah Gadson, Ethan Holtgrieve, Nathan Skelton, Pattonville School District
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@lanfon72
lanfon72 / export.py
Created June 8, 2017 03:39
export word images via python win32com
from pathlib import Path
from win32com.client import Dispatch
xls = Dispatch("Excel.Application")
doc = Dispatch("Word.Application")
def export_images(fp, prefix="img_", suffix="png"):
""" export all of images(inlineShapes) in the word file.
@Kovrinic
Kovrinic / .gitconfig
Last active July 15, 2024 04:45
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github
@nepsilon
nepsilon / git-change-commit-messages.md
Last active June 2, 2024 23:31
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@tabrindle
tabrindle / webp-convert-directory.sh
Last active June 15, 2024 07:55
Convert all files in directory to webp, with default params, or standard cwebp params passed from command
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
@erickok
erickok / SelfSignedCrtCertificate.java
Last active May 11, 2023 14:25
Loading a self-signed SSL certificate .crt file and packaging it into a SSLSocketFactory for use with a HttpsURLConnection.
// Usage example...
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://someurl.com").openConnection();
connection.setSSLSocketFactory(buildSslSocketFactory());
private static SSLSocketFactory buildSslSocketFactory(Context context) {
// Add support for self-signed (local) SSL certificates
// Based on http://developer.android.com/training/articles/security-ssl.html#UnknownCa
try {