Skip to content

Instantly share code, notes, and snippets.

Avatar

Miopas Miopas

View GitHub Profile
@Miopas
Miopas / read_zst.py
Created May 20, 2020
read zst files using stream
View read_zst.py
# python 3.6
import zstandard
import pathlib
import shutil
import os
import math
import pandas as pd
import sys
def decompress_zstandard_to_folder(input_file, destination_dir):
@Miopas
Miopas / latex.txt
Last active Feb 5, 2020
LaTex tips.
View latex.txt
# fix the order of citations
\bibliographystyle{unsrtnat}
\usepackage[numbers,sort&compress]{natbib}
# figures layout
# credit: https://tex.stackexchange.com/questions/129077/figure-in-beamer
\begin{tabular}{p{.3\textwidth} p{.7\textwidth}}
\adjincludegraphics[width=.8\linewidth,valign=t]{example-image}
&
@Miopas
Miopas / awk.sh
Last active Jun 8, 2020
awk quick notes
View awk.sh
# word count
cat result | awk -F"\t" '{key=$1"\t"$2; c[key]++} END {for (i in c) print c[i],i}'
# sum, count, mean, median, min, max
# credit:https://unix.stackexchange.com/questions/13731/is-there-a-way-to-get-the-min-max-median-and-average-of-a-list-of-numbers-in
#!/bin/sh
cat test.txt | sort -n | awk '
BEGIN {
c = 0;
sum = 0;
View my_iTerm2.json
{
"Ansi 5 Color" : {
"Green Component" : 0.10802463442087173,
"Red Component" : 0.77738940715789795,
"Blue Component" : 0.43516635894775391
},
"Tags" : [
],
"Ansi 12 Color" : {
View html_entity_convert.py
# reference: https://stackoverflow.com/questions/2087370/decode-html-entities-in-python-string
from bs4 import BeautifulSoup
BeautifulSoup("<p>&pound;682m</p>")
# output is like:
# <html><body><p>£682m</p></body></html>
@Miopas
Miopas / shell.sh
Last active Feb 27, 2019
shell commands collection.
View shell.sh
# !! All for CentOS
# clear contents of files
truncate -s 0 test.txt
# clear cache
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
@Miopas
Miopas / gensim.py
Created Feb 27, 2019
train word2vector model with gensim
View gensim.py
# train
import logging
import os
from gensim.models import word2vec
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
sentences = word2vec.LineSentence('/path/to/your/data')
model = word2vec.Word2Vec(sentences,
@Miopas
Miopas / neo4j.sh
Created Feb 25, 2019
command for neo4j
View neo4j.sh
./cypher-shell -a bolt://localhost:1688 -u neo4j -p work "match(n)-[r]->(m) return n, r, m limit 10;" >/tmp/a.txt
@Miopas
Miopas / git.sh
Created Feb 25, 2019
git command
View git.sh
# store account info
git config --global credential.helper store
@Miopas
Miopas / mvn.sh
Last active Feb 13, 2019
mvn command
View mvn.sh
# run specific test case
mvn -Dtest=TestCircle test
# mvn spring boot
mvn clean install && cd ./xx-web && mvn spring-boot:run
# run with specific setting file
mvn clean intall --settings mysetting.xml
You can’t perform that action at this time.