Skip to content

Instantly share code, notes, and snippets.

View zhmz1326's full-sized avatar
🤠
look ahead

Zheng Mingzhi (AI码士) zhmz1326

🤠
look ahead
View GitHub Profile
@zhmz1326
zhmz1326 / RSATest.java
Created April 14, 2017 06:59
Show how to create a BCRSAPrivateCrtKey instance by Java Reflect API
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.math.BigInteger;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
import org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPrivateCrtKey;
public class RSATest {
@zhmz1326
zhmz1326 / compress.java
Created March 29, 2017 09:44
Compress a directory to a zip stream using commons-compress and java
public static void compressZipfile(String sourceDir, OutputStream os) throws IOException {
ZipOutputStream zos = new ZipOutputStream(os);
compressDirectoryToZipfile(sourceDir, sourceDir, zos);
IOUtils.closeQuietly(zos);
}
private static void compressDirectoryToZipfile(String rootDir, String sourceDir, ZipOutputStream out) throws IOException, FileNotFoundException {
File[] fileList = new File(sourceDir).listFiles();
if (fileList.length == 0) { // empty directory / empty folder
ZipEntry entry = new ZipEntry(sourceDir.replace(rootDir, "") + "/");
@zhmz1326
zhmz1326 / sigmoid_plot.py
Created November 16, 2015 05:15
Draw sigmoid function by matplotlib
sigmoid = lambda x: 1 / (1 + np.exp(-x))
x=linspace(-10,10,10)
y=linspace(-10,10,100)
plot(x,sigmoid(x),'r', label='linspace(-10,10,10)')
plot(y,sigmoid(y),'b', label='linspace(-10,10,100)')
grid()
xlabel('X Axis')
ylabel('Y Axis')
title('Sigmoid Function')
suptitle('Sigmoid')
@zhmz1326
zhmz1326 / index.html
Created August 9, 2015 08:15
Practice from Dotinstall: Angular v1.4.3 http://dotinstall.com/lessons/basic_angularjs
<!DOCTYPE html>
<html lang="js" ng-app="testApp">
<head>
<meta charset="utf-8">
<title>Angular Practice</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="myscript.js"></script>
<style>
.even {
background: #ccc;
@zhmz1326
zhmz1326 / csvDuplicateCheck.py
Created July 22, 2015 05:57
Check duplicate by key in csv file, and then print the duplicate lines out.
import codecs
filename = 'input.csv'
# fr = open(filename)
fr = codecs.open(filename,"r","shift_jis")
lines = fr.readlines()
lines.sort()
dict = {}