Skip to content

Instantly share code, notes, and snippets.

View enjoylife's full-sized avatar
📖

Matthew Clemens enjoylife

📖
View GitHub Profile
@enjoylife
enjoylife / rename.sh
Created March 21, 2024 12:06
Rename all files recursively (Git aware)
#!/bin/bash
# Get the substring to replace and the replacement string
read -p "Enter substring to replace: " old_string
read -p "Enter replacement string: " new_string
# Function to rename files recursively
rename_files () {
for filename in *; do
# Check if filename contains the old string
@enjoylife
enjoylife / convert.sh
Created January 22, 2021 18:15
input to gif
ffmpeg -i my-movie.mov -ss 00:00:00 -filter_complex "[0:v] fps=12,scale=1024:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif
func withTimeout(ctx context.Context, f func(context.Context) error) error {
c := make(chan error, 1)
go func() { c <- f(ctx) }()
select {
case <-ctx.Done():
return ctx.Err()
case err := <-c:
return err
}
@enjoylife
enjoylife / template.sh
Last active June 23, 2020 21:02
A stereotypical bash template with simple example patterns. Useful when creating scripts....
#!/bin/bash
# Exit immediately for non zero status
set -e
# Check unset variables
set -u
# Print commands
set -x
# Prevent acciedently running as root
@enjoylife
enjoylife / triangulation.py
Created June 10, 2020 22:59 — forked from davegreenwood/triangulation.py
Triangulate image points to world points comparing openCV to pure python.
from __future__ import print_function
import numpy as np
import cv2
import time
np.set_printoptions(formatter={'float': '{: 0.3f}'.format})
def triangulate_nviews(P, ip):
"""
@enjoylife
enjoylife / quickdemo.py
Created June 9, 2020 05:00 — forked from horverno/quickdemo.py
Aruco marker-based OpenCV distance measurement
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import sys
import numpy as np
sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')
import cv2
import cv2.aruco as aruco
import numpy as np
import rectangleArea as ra
@enjoylife
enjoylife / simple_triangulation.cc
Created June 9, 2020 04:59 — forked from cashiwamochi/simple_triangulation.cc
This code is used for simple triangulation. It uses findEssentialMat, recoverPose, triangulatePoints in OpenCV. For viewer, PCL is used. You can watch 3D points and 2 camera poses. I checked alcatraz2.jpg and alcatraz1.jpg in pcv_data.zip (https://www.oreilly.co.jp/pub/9784873116075/). Perhaps there is something wrong ( actually it looks working…
#include <opencv2/opencv.hpp>
#include <pcl/common/common_headers.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <Eigen/Core>
#include <Eigen/LU>
@enjoylife
enjoylife / enumMap.js
Created January 10, 2020 00:25
enumMap flow util
export type EnumNames = 'A' | 'B' | 'C';
export type EnumMap<K: string, V, O: Object = *> = O & {
[K]: V & $ElementType<O, K>,
};
export type SpecificMap = EnumMap<EnumNames, any>;
const cbNames: EnumMap<EnumNames, (any) => void> = {
A: v => v,
B: v => v.prop,
@enjoylife
enjoylife / this.txt
Created November 4, 2019 16:53
TIL Python Zen
$ python
Python 2.7.16 (default, Apr 12 2019, 15:32:40)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
const useForceRender = () => {
const [, forceRender] = useReducer((oldVal) => oldVal + 1, 0)
return forceRender
}