Skip to content

Instantly share code, notes, and snippets.

@sharkdeng
sharkdeng / code.tex
Created October 12, 2020 19:13
latex code style
%Source: https://www.overleaf.com/learn/latex/code_listing%
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
@sharkdeng
sharkdeng / is_nan.py
Last active October 9, 2020 11:16
judge if the given value is nan
def is_nan(a):
import math
import numpy as np
if isinstance(a, float):
return math.isnan(a)
elif isinstance(a, np.float64):
return np.isnan(a)
else:
return False
@sharkdeng
sharkdeng / pdf2jpg.py
Created October 2, 2020 08:24
turn pdf pages to jpg (not png, since jpg is smaller than png, website friendly)
# extract pdf to jpg
from pdf2image import convert_from_path
from tqdm import tqdm
import os
import uuid
input_path = 'corridor.pdf'
uid = uuid.uuid4().hex[:4]
output_path = uid + '-' + input_path.split('.')[0]
@sharkdeng
sharkdeng / wodpress2txt.py
Last active October 2, 2020 08:22
turn wordpress xml to txt
## this snippet allows you to fastly convert post from wordpress xml format to txt
from xml.dom.minidom import parse, parseString
import os
dom = parse('jobyme88.xml') # parse an XML file by name
os.path.makedirs('blogs')
items = dom.getElementsByTagName('item')