Skip to content

Instantly share code, notes, and snippets.

View vayn's full-sized avatar

Vayne Tsai vayn

View GitHub Profile
@vayn
vayn / decrypt.py
Last active October 9, 2017 22:16
Example of PyCrypto AES decryption
import base64
import hashlib
import hmac
from Crypto.Cipher import AES
key = base64.decodebytes(b'v4QC6l4ttEogiBYvjLyvbA==')
nonce = base64.decodebytes(b'3iNVHJXuCfYoU9QP49DGqw==')
ct = base64.decodebytes(b'x9WM3Qy15Xw/2Z6pGVKXVA==')
import sys
import subprocess
from time import sleep
cmd = ['top', '-l 0']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
from sys import stdout
from time import sleep
for i in range(1,20):
stdout.write("\r%d" % i)
stdout.flush()
sleep(1)
stdout.write("\n") # move the cursor to the next line
######################################
# Format Options
######################################
# The date_format variable followed by a space, specifies
# the log format date containing any combination of regular
# characters and special format specifiers. They all begin with a
# percentage (%) sign. See `man strftime`
#
#Any Apache log date format
@vayn
vayn / cvimrc.vim
Last active April 11, 2019 06:11
Vayn's cVim setting
let blacklists = ["https://mail.google.com/* gi gt x r f"]
map H scrollLeft
map L scrollRight
map h previousTab
map l nextTab
map r reloadTabUncached
map u lastClosedTab
map R :restore<Space>
map , goBack
@vayn
vayn / cli-gojuon-exercise.py
Last active April 18, 2019 05:58
CLI Gojūon Exercise
#!/usr/bin/env python3
import random
import signal
import sys
"""帮助
输入 ? 显示正确答案
"""
TEST_COUNT = 0
function textToHTML(text) {
return ((text || "") + "") // make sure it's a string;
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/\t/g, " ")
.replace(/ /g, "&#8203;&nbsp;&#8203;")
.replace(/\r\n|\r|\n/g, "<br />");
}
/* Smoke system for pipe --------------------------------------------------------*/
var NUM_PARTICLES = 100
var EMITTER_X = 155
var EMITTER_Y = 120
var MIN_SIZE = 0.1
var MAX_SIZE = 0.3
var MIN_VELOCITY_Y = 0.2
var MAX_VELOCITY_Y = 0.8
var VELOCITY_X = 0
import time
class Marsaglia:
"""Pseduo-random generator
http://www.math.uni-bielefeld.de/~sillke/ALGORITHMS/random/marsaglia-c
"""
def __init__(self, i1=0, i2=0):
self.z = i1 or 362436069
@vayn
vayn / incrementString.py
Created August 17, 2013 17:07
An interesting exercise from __Rapid GUI Programming with Python and Qt__
# vim: set fileencoding=utf-8:
def incrementString(char):
if char.isalpha():
char = char.upper()
else:
raise ValueError
char_len = len(char)
ord_list = [ord(s) for s in reversed(char)]