Skip to content

Instantly share code, notes, and snippets.

View cmpute's full-sized avatar
🏠
Working from home

Jacob Zhong cmpute

🏠
Working from home
View GitHub Profile
@cmpute
cmpute / fastio.hpp
Last active August 11, 2023 07:58
Code Snippets for IO Bursting in OJ
/*
* OJ中加速IO常用的代码片段
* Author Jacob C
* THU_ID 2014010812
*/
//OJ中常用的头文件和预编译指令
#ifndef _OJ_
#define DEBUG
#endif
@cmpute
cmpute / PCL_props_generator.py
Created May 11, 2017 12:58
Generate VC++ Properties file (.prop) for PCL projects
import os
import os.path as op
# Paths can be user-defined
pcl_dir = os.environ["PCL_ROOT"]
pcl_ver = pcl_dir.split(' ')[-1]
vctool_ver = list(filter(lambda part: part.startswith('vc'),
os.listdir(op.join(pcl_dir, '3rdParty', 'Boost', 'lib'))[0].split('-')))[0] #vc140
openni_dir = op.sep.join(os.environ['OPENNI2_LIB64'].split(op.sep)[:-2])
@cmpute
cmpute / caltrans.py
Created July 11, 2017 20:09
data path generator for reading Caltrans Travel Survey data
'''
Interface for caltrans data repo
'''
import os
import os.path as osp
_default_data_root = 'E:\\Data\\Caltrans_2010-2012'
class _DirIndexer():
@cmpute
cmpute / PinGoogleDriveFS.ps1
Last active January 14, 2022 22:57
Pin Google Drive File Stream to Explorer Sidebar
# This script only works when Google Drive is mounted at G:\
# Change the encoding to UTF-8-BOM before executing this script
# To run this file: powershell -noprofile -executionpolicy bypass -file ./PinGoogleDriveFS.ps1 [add/remove]
# Settings
$ErrorActionPreference = "Stop"
$clsid = "{81539FE6-33C7-4CE7-90C7-1C7B8F2F2D41}" # CLSID for personal drive namespace
$clsid_i = "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" # CLSID for personal drive instance
$clsid_g = "{FB9411E2-c3F8-4004-BA95-47D459C219D1}" # CLSID for shared drive namespace
$clsid_g_i = "{1A223FF4-D08D-4B38-A051-5D2391FE655C}" # CLSID for shared drive instance
@cmpute
cmpute / dircmp.py
Created January 22, 2019 22:15
Directory Comparar
import filecmp
import os.path as osp
dir_a = "E:/"
dir_b = "F:/"
def print_diff_files(dcur, dcmp):
for name in dcmp.diff_files:
print("[diff_file @ %s ] %s" % (dcur, name))
for name in dcmp.left_only:
@cmpute
cmpute / manual_calib.md
Last active April 17, 2019 06:06
Manual Camera-Lidar Calibrator

This script is a tool to manual calibrate image and lidar point cloud.

Requirements:

numpy, scipy>=1.2.0, cv2 (opencv),

Input/Output

The input is specified by the variable image_in and cloud_in, the value of these two variables have to be either a path to the file, or a path to the folder containing the data. Point cloud should be stored in txt format with points value starting from the second row. (This could be modified in the code) The output contains three translation parameters (x,y,z) and three rotation parameters (roll,pitch,yaw). The calibration output will be printed when the calibration process finishes.

Usage

@cmpute
cmpute / convert_rgbd.py
Last active April 20, 2023 11:40
Convert Realsense ROS bag to TUM format image files
import os, sys
import os.path as osp
import cv2
from cv_bridge import CvBridge
import rosbag
import sensor_msgs
import sensor_msgs.point_cloud2 as pc
import zipfile
import tqdm
@cmpute
cmpute / crawler.py
Last active July 1, 2020 21:36
astost_crawler
'''
Before running the scripts, please set page loading order to descending by post date (instead of reply date)
'''
import browsercookie
import sqlalchemy
import tqdm
from random import uniform
from itertools import count as icount
from time import sleep
@cmpute
cmpute / tar2zip.py
Last active May 7, 2020 16:11
Convert tarballs to zip files
#!/usr/bin/env /usr/bin/python3
import argparse
import os
import signal
import tarfile
import time
import zipfile
from itertools import count
from multiprocessing import Pool, Manager
@cmpute
cmpute / git-cheatsheet.md
Created April 27, 2020 15:27
My cheatsheet of Git

Delete all remote branches

git branch -r | grep <remote> | cut -c 10- | xargs -n 10 git push <remote> --delete

Useful for clean forked repository. 10 in cut -c 10- here represents the length of string <remote>\ 10 in xargs -n 10 represents how many branch to delete at a time, sometimes detele will report error, so less branches a time can reduces number of branched to be deleted manually