Skip to content

Instantly share code, notes, and snippets.

View mintisan's full-sized avatar

Jinhui-Lin mintisan

View GitHub Profile
@mintisan
mintisan / copy_bin_2_nucleo.py
Last active August 28, 2016 07:29
copy bin from Downloads directory to board(like Nucleo) automatically for mbed
import os
from shutil import copyfile
# `sudo pip install walkdir` if you don't install walkdir
import walkdir as wd
import time
src_dir = os.environ['HOME']+'/Downloads/'
dst_dir = '/Volumes/NUCLEO/'
pattern = "*_NUCLEO_F401RE.bin"
@mintisan
mintisan / raw2bmp.m
Created August 6, 2016 11:22
read a raw image, convert to bmp image format
fp = fopen('0016.raw','r');
[a,count]=fread(fp);
a = reshape(a,row,col)';
figure,imshow(uint8(a))
imwrite(uint8(a),'0016.bmp','bmp');
@mintisan
mintisan / raw2bmp.py
Created August 4, 2016 11:54
convert all raw images in current directory recursively to bmp(or png/jpg) image files
# -*- coding: utf-8 -*-
# @author linjinhui
# @time 2016/04/01
# @version 1.0
# How can I save an image with PIL?
# http://stackoverflow.com/questions/14452824/how-can-i-save-an-image-with-pil
import numpy as np
from PIL import Image
import os
import re
@mintisan
mintisan / bmp2raw.py
Created August 4, 2016 11:53
convert all bmp(or png, jpg) image in current direcory recursively to raw image Raw
# -*- coding: utf-8 -*-
# @author linjinhui
# @time 2016/08/04
# @version 1.0
import numpy as np
from PIL import Image
import os
import re
from tqdm import tqdm
@mintisan
mintisan / file_name_modify.py
Last active June 25, 2016 07:54
modify file name: prefix, suffix, split and specific keywords
#-*- coding: utf-8 -*-
import os
import numpy as np
import walkdir as wd
file_info_type = np.dtype({
'names': ['dir','name'],
'formats':['S100','S100']
})
@mintisan
mintisan / file_name_suffix_modify.py
Created June 25, 2016 07:04
modify file's suffix
#-*- coding: utf-8 -*-
import os
import numpy as np
import walkdir as wd
file_info_type = np.dtype({
'names': ['dir','name'],
'formats':['S100','S100']
})
@mintisan
mintisan / file_name_strip_modify.py
Created June 25, 2016 06:39
modify split in file_name
#-*- coding: utf-8 -*-
import os
import numpy as np
import walkdir as wd
file_info_type = np.dtype({
'names': ['dir','name'],
'formats':['S100','S100']
})
@mintisan
mintisan / file_name_prefix_add.py
Last active June 25, 2016 06:38
add a specific prefix for all files within current directory
#-*- coding: utf-8 -*-
import os
import numpy as np
import walkdir as wd
prefix = 'pre-'
file_info_type = np.dtype({
'names': ['dir','name'],
@mintisan
mintisan / buttondown.css
Created February 18, 2016 16:50 — forked from ryangray/buttondown.css
A clean, minimal CSS stylesheet for Markdown, Pandoc and MultiMarkdown HTML output.
/*
Buttondown
A Markdown/MultiMarkdown/Pandoc HTML output CSS stylesheet
Author: Ryan Gray
Date: 15 Feb 2011
Revised: 21 Feb 2012
General style is clean, with minimal re-definition of the defaults or
overrides of user font settings. The body text and header styles are
left alone except title, author and date classes are centered. A Pandoc TOC
@mintisan
mintisan / classify_file_type_in_current_dir.py
Created January 25, 2016 16:05
classify specific file type into a txt within current directory
# -*- coding: utf-8 -*-
import os
import re
def classify_file_type_in_current_dir(file_name, file_type):
f = open(file_name,'wb')
for root, dirs, files in os.walk(os.getcwd(), topdown=True):
for name in files: