Skip to content

Instantly share code, notes, and snippets.

View kadaliao's full-sized avatar
:octocat:

Kada Liao kadaliao

:octocat:
  • Beijing
View GitHub Profile
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@DIYer22
DIYer22 / addPageNumberToPDF.py
Last active July 24, 2023 19:41
Add Page Number to PDF file with Python(Python 给 PDF 添加 页码)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
helpDoc = '''
Add Page Number to PDF file with Python
Python 给 PDF 添加 页码
usage:
python addPageNumberToPDF.py [PDF path]
require:
@phoemur
phoemur / webshell.py
Created August 6, 2017 23:39
Basic webshell with Python + Flask and WebSockets (Flask-SocketIO)
#!/usr/bin/env python
import subprocess
from flask import Flask, render_template
from flask_socketio import SocketIO, send, emit
HTML = '''
<html>
<head>
<title>WEBSHELL</title>
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active July 15, 2024 19:43 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@dennislwy
dennislwy / rsa.py
Last active April 12, 2023 03:46
Python helper class to perform RSA encryption, decryption, signing, verifying signatures & generate new keys
# RSA helper class for pycrypto
# Copyright (c) Dennis Lee
# Date 21 Mar 2017
# Description:
# Python helper class to perform RSA encryption, decryption,
# signing, verifying signatures & keys generation
# Dependencies Packages:
# pycrypto
@krtx
krtx / imgcat
Created November 27, 2016 02:48
fix imgcat to be able to display images on tmux https://gitlab.com/gnachman/iterm2/issues/3898#note_14097715
#!/bin/bash
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
# only accepts ESC backslash for ST.
function print_osc() {
if [[ -n $TERM ]] ; then
printf "\033Ptmux;\033\033]"
else
printf "\033]"
@alexanderjeurissen
alexanderjeurissen / devicons.py
Created May 5, 2016 16:32
Linemode that shows WebDevIcons in Ranger
#!/usr/bin/python
# coding=UTF-8
import re;
import os;
# all those glyphs will show as weird squares if you don't have the correct patched font
file_node_extensions = {
'.styl' : '',
'.scss' : '',
'.htm' : '',
@subfuzion
subfuzion / curl.md
Last active July 15, 2024 17:14
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mr-pinzhang
mr-pinzhang / Xcode 文件下载.md
Last active August 22, 2023 04:24
Xcode 文件下载

在 Xcode 里下载文件真的是一种折磨, 特别是每次 Xcode 大版本更新都会遇到新的下载内容. 经过一翻周折, 本人找到一个方法可以轻松快速便捷地下载和安装对应的 Simulator 和 Doc 文件

  1. 在 Mac 下, 打开 Xcode, 进入 Preference 中的 Downloads 面板
  2. 点击任意的下载按钮
  3. 打开系统帮助工具 Console
  4. 稍等一会儿, 在 Xcode 里取消下载, 然后你会在 Console 里面看到对应的下载地址 (对应的 Cosnole Message 是 (DVTDownloadable: Download Cancelled. Downloadable: ...) 之类的)
  5. 复制对应的链接地址, 到某雷或者任何比 Xcode 下载快的工具里
  6. 等待下载完成, 进入 /Users/#{Username}/Library/Caches
@vasanthk
vasanthk / System Design.md
Last active July 15, 2024 10:23
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?