Skip to content

Instantly share code, notes, and snippets.

table="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
def base64_encode64(str):
add=3-len(str)%3
if(add!=3):
str+=add*'\x00'
bits="".join(format(x,'08b') for x in bytearray(str))
list=[]
for i in xrange(0,len(bits),6):
@hzshang
hzshang / rename.sh
Last active November 1, 2017 12:43
i=1
for file in $(find . -name "*.jpg")
do
mv $file face-set/face$i.jpg;
i=$((i+1));
done
for file in $(ls -p | grep -v / | tail -5000)
do
@hzshang
hzshang / mod_inverse
Created November 14, 2017 15:04
mod inverse for RSA
def ext_Euclid(n,m):
if (m == 0):
return 1, 0
else:
x, y = ext_Euclid(m, n%m)
x, y = y, (x -(n//m)*y)
return x, y
def mod_inverse(e,n):
@hzshang
hzshang / pwnable-kr.md
Last active November 25, 2017 14:56
pwnable.kr writeup
@hzshang
hzshang / build-caffe.md
Created December 27, 2017 09:51 — forked from kylemcdonald/build-caffe.md
How to build Caffe for OS X.

Theory of Building Caffe on OS X

Introduction

Our goal is to run python -c "import caffe" without crashing. For anyone who doesn't spend most of their time with build systems, getting to this point can be extremely difficult on OS X. Instead of providing a list of steps to follow, I'll try to explain why each step happens.

This page has OS X specific install instructions.

I assume:

#!/usr/bin/env python
# coding=utf8
import urllib2
import time
from lxml import etree
import urllib
import csv
import traceback
BASE = "https://www.wunderground.com/history/airport/ZSSS/%s/DailyHistory.html"
from random import uniform
#calculate intergral
def integral(fun,a,b,N=10000):
sum=0
for i in range(N):
sum=sum+fun(uniform(a,b))
return sum/N*(b-a)
# test
print integral(lambda x : x + 1,0,1)
#!/bin/bash
# complie cross tool, only passed for i386-pc-elf
# before you start, make sure you have installed gmp mpfr isl zlib mpc m4 makeinfo to your system path
# download i386-pc-elf binary from https://drive.google.com/file/d/1VuKflnxlq934tImeO06ulqsilgIzzcc9/view?usp=sharing
export TARGET=i386-pc-elf
export PREFIX=$HOME/cross/usr
export SRC=$HOME/cross/src
export BUILD=$HOME/cross/build
export BINUTILS=binutils-2.29
export GCC=gcc-7.2.0
docker rmi $(docker images | grep "none" | awk '{print $3}')
export CFLAGS="-g -O1 -Wuninitialized"
/dbg64/src/glibc-2.23/configure --prefix=/dbg64
make -j8
make install