Skip to content

Instantly share code, notes, and snippets.

@chaomai
chaomai / check_time_and_mv.sh
Created November 12, 2020 03:05
check google takeout images, set a time for those without timestamp, and move them to destination directory
#!/usr/bin/env bash
function set_ts() {
local f=$1
dto=$($GNUBIN_COREUTILS/date -d "$dir_t" "+%Y:%m:%d 00:00:00")
echo exiftool -datetimeoriginal="$dto" "$f"
exiftool -datetimeoriginal="$dto" "$f"
local dest_path=$dest_dir/$dir_d
#!/usr/bin/env bash
dir=$1
function process() {
local final_dir="/Users/chaomai/Downloads/final_imgs"
local dest_dir="/Users/chaomai/Downloads/dest_imgs"
local f=$1
echo $f
class SparseTensorFactory[Shape](sv: ShapeValue[Shape]) {
def *[D <: Dimension](dv: DimValue[D]): SparseTensorFactory[Shape ~ D] =
new SparseTensorFactory[Shape ~ D](sv.append(dv))
def &(sc: SparkContext): SparseTensor[Shape] =
new SparseTensor[Shape](sc, sv)
}
object SparseTensorFactory {
def >[D <: Dimension](dv: DimValue[D]): SparseTensorFactory[RNil ~ D] =

Building lldb on Mac

Create Codesign Certificate

First we need to create a certificate. The llvm provided a way to do that, but I found this way to work slightly better for me. Just substitute lldb_codesign for the certificate name, instead of gdb-cert.

Install swig dependency

@chaomai
chaomai / read_bin.cc
Created October 26, 2016 14:17
read file as binary format
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("%s\n", "wrong number of parameters");
exit(-1);
}
@chaomai
chaomai / cpu_reordering_results.txt
Created March 6, 2016 13:07
cpu_reordering_results
1 reorders detected after 11199 iterations
2 reorders detected after 12680 iterations
3 reorders detected after 58064 iterations
4 reorders detected after 69153 iterations
5 reorders detected after 72177 iterations
6 reorders detected after 72555 iterations
7 reorders detected after 75906 iterations
8 reorders detected after 95847 iterations
9 reorders detected after 98174 iterations
10 reorders detected after 103919 iterations
import os
import os.path
import fnmatch
import logging
import ycm_core
BASE_FLAGS = [
'-Wall',
'-Wextra',
'-Werror',
@chaomai
chaomai / convert_files_to_UTF8.py
Created September 8, 2012 09:19
Python 3: convert files to UTF8
#convert files to UTF8 encoding
#tested under Python3
from chardet.universaldetector import UniversalDetector
import os
import os.path
def convert_to_uft8(filename, filetype, out_enc='utf-8'):
(filepath, name) = os.path.split(filename)
if filetype == os.path.splitext(name)[1]:
try:
@chaomai
chaomai / get_specific_type_files.py
Created September 8, 2012 09:15
Python 3:get specific type files
#scan a directory iteratively and get specific type files
#tested under Python3
import os
import os.path
def print_filename(item, sou_dir, type):
(filepath, filename) = os.path.split(item)
if type == os.path.splitext(filename)[1]:
sourcefile = os.path.join(sou_dir, item)
print(sourcefile)
@chaomai
chaomai / copy_to_target_location_2.py
Created September 8, 2012 09:19
Python 3: copy to target location 2
#scan a directory iteratively, copy particular file to a new directory
#each file in new directory has is own new directory that name is same as the file
#tested under Python3
import os
import os.path
import shutil
def copy_file(item, sou_dir, des_dir, type):
(filepath, filename) = os.path.split(item)
if type == os.path.splitext(filename)[1]: