This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
inline int left(int idx) { | |
return (idx << 1) + 1; | |
} | |
inline int right(int idx) { | |
return (idx << 1) + 2; | |
} | |
void max_heapify(vector<int>& nums, int idx) { | |
int largest = idx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. sort an array by the nth column | |
Z = np.random.randint(0,10,(3,3)) | |
print(Z) | |
print(Z[Z[:,1].argsort()]) | |
2. Find the nearest value from a given value in an array | |
m = Z.flat[np.abs(Z - z).argmin()] | |
3. accumulate elements of a vector (X) to an array (F) based on an index list (I) | |
X = [1,2,3,4,5,6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. go to letsencrypt homepage to download and use some client tool like certbot to auto manage CA from letsencrypt. | |
2. get and renew CA: | |
2.1 certbot certonly --webroot -w /var/www/example -d example.com | |
2.2 certbot renew --dry-run | |
if you have already configure before,you need to delete entry in jks:(eg $keystoredir=MyDSKeyStore.jks) | |
keytool -delete -alias root -storepass changeit -keystore $keystoredir | |
keytool -delete -alias tomcat -storepass changeit -keystore $keystoredir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Next few examples show how to work with text data in Pandas. | |
# Full list of .str functions: http://pandas.pydata.org/pandas-docs/stable/text.html | |
# Slice values in a DataFrame column (aka Series) | |
df.column.str[0:2] | |
# Lower-case everything in a DataFrame column | |
df.column_name = df.column_name.str.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//although it is hard job to convert pdf to text, tika tool is cool for this. it can auto detect pdf format and choose parser to parse the pdf. | |
package june; | |
import java.io.BufferedInputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. before use this script, you need to get a customed ttf font file, maybe you have only ttc file ,you can convert it to ttf in | |
# this awesome web: http://www.zhuan-huan.com/file-convert/ | |
# 2. then edit the matplotlibrc file(for env most in envs/py3/lib/python3.5/site-packages/matplotlib/mpl-data ), uncomment two lines: | |
# font.family : sans-serif | |
# font.sans-serif :WenQuanYi Zen Hei,Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid... | |
# if your ttf font is sans-serif,you need only to add your new font name to the head of font.sans-serif. | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
import matplotlib.font_manager as font_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |