$ sudo npm install -g hexo-cli
$ hexo -v
hexo-cli: 0.1.9
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
%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} |
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
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 |
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
# 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] |
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
## 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') |
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
model.zero_grad() # Reset gradients tensors | |
for i, (inputs, labels) in enumerate(training_set): | |
predictions = model(inputs) # Forward pass | |
loss = loss_function(predictions, labels) # Compute loss function | |
loss = loss / accumulation_steps # Normalize our loss (if averaged) | |
loss.backward() # Backward pass | |
if (i+1) % accumulation_steps == 0: # Wait for several backward steps | |
optimizer.step() # Now we can do an optimizer step | |
model.zero_grad() # Reset gradients tensors | |
if (i+1) % evaluation_steps == 0: # Evaluate the model when we... |
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
import React from "react"; | |
/* | |
Read a text file and out put the content. | |
Example Usage: | |
var myTxt = require("./myTxt.txt"); | |
... |
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
"""Create a notebook containing code from a script. | |
Run as: python make_nb.py my_script.py | |
""" | |
import sys | |
import nbformat | |
from nbformat.v4 import new_notebook, new_code_cell | |
nb = new_notebook() |
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
def get_abs_paths_for_immediate_children (tree, input_paths_string): | |
input_paths = input_paths_string.strip().split(".") | |
tmp_tree = tree | |
for input_path in input_paths: | |
tmp_tree = tmp_tree.n(input_path) | |
output_paths = [] | |
children = list(tmp_tree.children.keys()) |
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
<html> | |
<script type="text/javascript"> | |
function d2xy(n, d) { | |
var rx, ry, s, t, x, y; | |
t = d; | |
x = y = 0; | |
for (s = 1; s < n; s *= 2) { | |
rx = 1 & (t / 2); |
NewerOlder