Skip to content

Instantly share code, notes, and snippets.

View tjyuyao's full-sized avatar
🎯
Focusing

Yuyao Huang tjyuyao

🎯
Focusing
View GitHub Profile
@tjyuyao
tjyuyao / pandoc.template.zh.tex
Created January 8, 2018 02:23 — forked from farawayboat/pandoc.template.zh.tex
Chinese LaTeX template (using Ctex) for pandoc.
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{euler}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use microtype if available
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
@tjyuyao
tjyuyao / gist:e351acc69b3dcda5eb4f216347c94b83
Created June 5, 2018 14:10 — forked from dsc/gist:3855240
Python argparse Cheatsheet
Arg Name or Optional Flags:
positional : str = "foo"
options : str = "-f", "--foo"
Standard:
action : str = [store], append, store_true, store_false, store_const, append_const, version
default : * = [None]
type : callable = [str], argparse.FileType(mode='wb', bufsize=0)
Exotic:
@tjyuyao
tjyuyao / CMakeLists.txt
Last active May 14, 2023 15:23
cmake architecture detect
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") # for desktop
message("1")
ELSE(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") # for tx2
message("2")
ELSE()
message(FATAL_ERROR "Unknown System Architecture: ${CMAKE_SYSTEM_PROCESSOR}")
ENDIF()
@tjyuyao
tjyuyao / Eigen Cheat sheet
Created October 21, 2019 05:36 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@tjyuyao
tjyuyao / quaternion_multiply.py
Created February 8, 2020 07:47
Quaternion Multiplication
# !pip install PyGeometry
from geometry import *
import numpy as np
def quaternion_multiply(p, q):
assert isinstance(p, np.ndarray) and p.shape == (4,)
assert isinstance(q, np.ndarray) and q.shape == (4,)
p0, p1, p2, p3, q0, q1, q2, q3 = p[0], p[1], p[2], p[3], q[0], q[1], q[2], q[3]
r0 = + p0 * q0 - p1 * q1 - p2 * q2 - p3 * q3
r1 = + p0 * q1 + p1 * q0 + p2 * q3 - p3 * q2
@tjyuyao
tjyuyao / Bing-Image-Scraper
Last active May 8, 2020 00:59 — forked from stephenhouser/Bing-Image-Scraper
Bing-Image-Scraper
Bing image scraper example using Python to query and scrape Microsoft Bing image search.
@tjyuyao
tjyuyao / recgif
Last active June 3, 2020 13:21
An easy script to record GIF based on [ffcast](https://github.com/lolilolicon/FFcast), with default options, you draw a region to start recording, press 'q' to stop, and a `screenshot.gif` file will be saved to current directory. Read the [WIKI](https://github.com/lolilolicon/FFcast/wiki/GIF-Howto) and this script to learn more details.
#!/bin/bash
# An easy script to record GIF based on [ffcast](https://github.com/lolilolicon/FFcast).
# With default options, you draw a region to start recording, press 'q' to stop, and a `screenshot.gif` file will be saved to current directory.
# Read the [WIKI](https://github.com/lolilolicon/FFcast/wiki/GIF-Howto) and this script to learn more details.
# Author of this script: huangyuyao@outlook.com
STEP1=YES
STEP2=YES
FPS=10
@tjyuyao
tjyuyao / rmlast
Last active June 14, 2020 11:07
remove latest file/subfolder in the given folder.
#!/usr/bin/python3
"""
remove latest file/subfolder in the given folder.
Author: huangyuyao@outlook.com
"""
import sys
import os
import time
import sys
python3 -m pip install --extra-index-url https://rospypi.github.io/simple/ rospy rosbag sensor_msgs --user
import os
import hashlib
def escape(s):
allowed = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVQXYZ0123456789_'
s = ''.join(i for i in s if i in allowed)
return s
def make_cache(value_creator, cache_name, cache_dir='__pycache__/'):
cache_name = escape(cache_name)