Skip to content

Instantly share code, notes, and snippets.

View kaizhu256's full-sized avatar

kai zhu kaizhu256

View GitHub Profile
@t1mofe1
t1mofe1 / pkce.ts
Last active March 7, 2024 08:49
PKCE Generator in nodejs which generates `code_challenge` and `code_verifier` using sha256. Implemented custom length feature.
import * as crypto from 'crypto';
export type PkcePayload = {
code_verifier: string;
code_challenge: string;
code_challenge_method: 'S256';
};
export default function generatePKCE(length = 128): PkcePayload {
if (length < 43) length = 43;
@blluv
blluv / decrypt.py
Last active November 4, 2023 06:39
HighFleet seria_enc decrypt
f = open("./english.seria_enc", "rb")
data = list(f.read())
a = 0
b = 2531011
while a < len(data):
data[a] = (b ^ (b >> 15) ^ data[a]) & 0xff
b += 214013
@kaizhu256
kaizhu256 / electron.onload.test.js
Last active September 1, 2017 05:50
electron script to measure onload-time for a given url
/*
electron.onload.test.js
this function will test the onload performance of the given url
# example usage 1:
mkdir -p node_modules
npm install electron-lite --electron-version=v1.0.1
url=https://www.google.com node_modules/.bin/electron electron.onload.test.js
@domenic
domenic / redirecting-github-pages.md
Created February 10, 2017 19:28
Redirecting GitHub pages after a repository move

Redirecting GitHub Pages after a repository move

The problem

You have a repository, call it alice/repo. You would like to transfer it to the user bob, so it will become bob/repo.

However, you make heavy use of the GitHub Pages feature, so that people are often accessing https://alice.github.io/repo/. GitHub will helpfully redirect all of your repository stuff hosted on github.com after the move, but will not redirect the GitHub Pages hosted on github.io.

The solution

@baumandm
baumandm / GIF-Screencast-OSX.md
Last active September 20, 2024 10:23 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to Animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime and ffmpeg.

Forked from https://gist.github.com/dergachev/4627207. Updated to use a palette to improve quality and skip gifsicle.

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@tvlooy
tvlooy / unit.sh
Last active September 20, 2024 20:53
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@kaizhu256
kaizhu256 / example.js
Last active December 2, 2018 21:52
nodejs - standalone code to upload data to amazon s3
/*
this standalone nodejs code requires the following env variables to be set:
process.env.AWS_ACCESS_KEY_ID
process.env.AWS_S3_BUCKET
process.env.AWS_SECRET_ACCESS_KEY
*/
/*jslint
bitwise: true, browser: true,
indent: 2,
maxerr: 8,
@kaizhu256
kaizhu256 / travis-encrypt.sh
Last active August 29, 2015 14:02
travis encrypt secrets using shell commands
#!/bin/sh
function shTravisEncrypt () {
## this shell function travis encrypts the secret $2 for github repo $1
## tested to work on linux and osx (mountain lion)
local GITHUB_REPO="$1"
local SECRET="$2"
printf "fetching public rsa key from https://api.travis-ci.org/repos/$GITHUB_REPO/key ...\n"
curl -3Ls https://api.travis-ci.org/repos/$GITHUB_REPO/key\
| perl -ne 's/[^-]*//; s/"[^"]*$//; s/\\n/\n/g; s/ RSA / /g; print'\
@nehaljwani
nehaljwani / AVLTree.c
Created February 28, 2014 07:11
AVLTree
#include <stdio.h>
#include <stdlib.h>
typedef struct _node node;
struct _node {
node *head;
node *left;
node *right;
int value;
int height;
@wang-bin
wang-bin / base64_buffer
Created November 6, 2013 07:36
js base64 to ArrayBuffer
decode64: function decodeBase64(en) {
var de = new Uint8Array(en.length); //3/4
var u = 0, q = '', x = '', c;
var map64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (var r=0; c=en[x++]; ~c&&(u=q%4?u*64+c:c,q++%4)?de[r++]=(255&u>>(-2*q&6)):0)
c = map64.indexOf(c);
var sub = de.subarray||de.subset||de.slice;
return sub.call(de, 0, r);
},