Skip to content

Instantly share code, notes, and snippets.

@insaneyilin
insaneyilin / hconcat_images.py
Created July 2, 2020 09:58
Concatenate images with python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import argparse
import cv2
@insaneyilin
insaneyilin / alias.sh
Last active November 19, 2020 13:12
bash alias
# /etc/profile.d/alias.sh
# https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
## ls command
alias ls='ls --color=auto'
alias wl='ls | wc -l'
alias l='ls -l --color=auto'
alias lh='ls -lh --color=auto'
alias ll='ls -la --color=auto' # use a long listing format
@insaneyilin
insaneyilin / unix_ts_to_str.cc
Created May 11, 2020 07:26
format unix timestamp to string
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
// e.g. 1584773265.928826
std::stringstream oss;
oss << std::setfill('0') << std::setw(17) << std::fixed
<< std::setprecision(6) << timestamp << ".png";
std::string filename = oss.str();
@insaneyilin
insaneyilin / load_kitti_lidar_bin_file.cpp
Last active April 29, 2025 16:53
A C++ example showing how to load lidar points from .bin file of KITTI dataset.
#include <iostream>
#include <fstream>
#include <string>
// e.g. ./main data_tracking_velodyne/testing/velodyne/0000/000000.bin
int main(int argc, char **argv) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <filepath>\n";
return 1;
}
@insaneyilin
insaneyilin / print_eigen_mat.cpp
Created March 17, 2020 03:11
Print Eigen's Matrix
void PrintEigenMat(const Eigen::Ref<const Eigen::MatrixXd> &x,
const std::string mat_name) {
if (!mat_name.empty()) {
std::cout << mat_name << " =\n";
}
const int rows = x.rows();
const int cols = x.cols();
char buf[200];
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
@insaneyilin
insaneyilin / today.py
Last active March 8, 2020 07:27
print today's date
#!/usr/bin/env python3
import time
import datetime
# change your birthday here
my_birthday = datetime.datetime(2000, 1, 1, 00, 00, 00)
dt_now = datetime.datetime.now()
print(dt_now)
print('UNIX timestamp: {}'.format(dt_now.timestamp()))
@insaneyilin
insaneyilin / convert_timestamp.js
Last active February 25, 2020 09:45
Convert timestamp to date string in JavaScript
function timestampToDateStr(timestamp) {
var format = 'Y/M/D h:m:s';
var formatArr = ['Y','M','D','h','m','s'];
var returnArr = [];
var formatNumber = function(n) {
n = n.toString();
return n[1] ? n : '0' + n;
};
var date = new Date(timestamp * 1000);
@insaneyilin
insaneyilin / utm2latlon.py
Created January 9, 2020 08:47
convert UTM coordinates to Lat/Lon (WGS84)
# https://stackoverflow.com/questions/343865
def utm_to_lat_lon(zone, easting, northing, northern_hemisphere=True):
if not northern_hemisphere:
northing = 10000000 - northing
a = 6378137
e = 0.081819191
e1sq = 0.006739497
k0 = 0.9996
@insaneyilin
insaneyilin / load_big_ply.cc
Last active January 8, 2020 07:29
load big binary point cloud (.ply) file
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <sstream>
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "Usage: ./load_big_ply <filename>\n";
return 1;
@insaneyilin
insaneyilin / cxx11_elapsed_time.cc
Created December 5, 2019 06:03
C++ 11 measure elapsed time
#include <iostream>
#include <thread>
#include <chrono>
void foo() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
int main(int argc, char **argv) {
auto start_time = std::chrono::high_resolution_clock::now();