Skip to content

Instantly share code, notes, and snippets.

View jackect's full-sized avatar
🎯
Focusing

Hell Jibe jackect

🎯
Focusing
  • Sichuan, China
View GitHub Profile
/* The world's smallest Brainfuck interpreter in C, by Kang Seonghoon
* http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c */
s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;}
@cdown
cdown / gist:1163649
Last active August 10, 2026 06:43
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@nicky-zs
nicky-zs / make_safely_shutdown.py
Created August 22, 2013 09:10
Make the tornado httpserver.HTTPServer to be shutdown safely.
# vim: fileencoding=utf-8
import time, signal
from tornado import web, ioloop, options, httpserver
_SHUTDOWN_TIMEOUT = 30
def make_safely_shutdown(server):
io_loop = server.io_loop or ioloop.IOLoop.instance()
def stop_handler(*args, **keywords):
def shutdown():
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@chrisveness
chrisveness / crypto-pbkdf2.js
Last active August 10, 2026 11:46
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*
@bookfere
bookfere / fix-google-translate-cn.sh
Last active December 22, 2025 01:54
Fix Google Translate CN for macOS
#!/bin/bash
# Copyright (c)2022 https://bookfere.com
# This is a batch script for fixing Google Translate and making it available
# in the Chinese mainland. If you experience any problem, visit the page below:
# https://bookfere.com/post/1020.html
set -e
IPS=(
74.125.137.90
@bookfere
bookfere / fix-google-translate-cn.bat
Last active March 30, 2026 03:41
Fix Google Translate CN for Windows
:: Copyright (c)2022 https://bookfere.com
:: This is a batch script for fixing Google Translate and making it available
:: in the Chinese mainland. If you experience any problem, visit the page below:
:: https://bookfere.com/post/1020.html
@echo off
setlocal enabledelayedexpansion
chcp 437 >NUL
set "ips[0]=74.125.137.90"
@TheCjw
TheCjw / extract_bun.js
Created June 5, 2026 03:34
A standalone Bun/JavaScript CLI tool that parses the .bun section from PE, ELF, and Mach-O executables compiled with bun build --compile, listing and extracting the embedded source files, assets, and native libraries.
#!/usr/bin/env bun
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
const TRAILER = Buffer.from("\n---- Bun! ----\n");
const BUN_SECTION_NAME = ".bun";
const OFFSET_STRUCT_SIZE = 32;
const MODULE_RECORD_SIZE = 52;