Skip to content

Instantly share code, notes, and snippets.

View foowaa's full-sized avatar
:octocat:
thinking

Chunlin TIAN foowaa

:octocat:
thinking
View GitHub Profile
@foowaa
foowaa / avframe_mat.hpp
Last active August 23, 2023 01:53
ffmpeg avframe and opencv mat
/*!
* \file format_converter.h
*
* \author cltian
* \date 11 2020
*
*
*/
extern "C" {
#include "libavcodec/avcodec.h"
@foowaa
foowaa / png2icns.sh
Created December 5, 2019 08:34
生成icns文件
#! /bin/bash
baseDir=$(cd `dirname "$0"`;pwd)
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
mkdir $baseDir/icons.iconset
sips -z 16 16 pic.png --out $baseDir/icons.iconset/icon_16x16.png
sips -z 32 32 pic.png --out $baseDir/icons.iconset/icon_16x16@2x.png
sips -z 32 32 pic.png --out $baseDir/icons.iconset/icon_32x32.png
sips -z 64 64 pic.png --out $baseDir/icons.iconset/icon_32x32@2x.png
sips -z 64 64 pic.png --out $baseDir/icons.iconset/icon_64x64.png
sips -z 128 128 pic.png --out $baseDir/icons.iconset/icon_64x64@2x.png
#!/bin/bash
## get files in current dir
path=$(dirname·$0)
files=$(ls·$path)
for·filename·in·$files
do
echo $filename >> abc
done
## remove
@foowaa
foowaa / gist:ab0bb1a21039a0ea24cffcf83a0d3ab1
Last active November 26, 2021 05:16 — forked from tayvano/gist:6e2d456a9897f55025e25035478a3a50
complete list of ffmpeg flags / commands
ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
//asynchronous
function logWord(word) {
setTimeout(
function() {
console.log(word);
},
Math.floor(Math.random() * 100) + 1
// return value between 1 ~ 100
);
}
@foowaa
foowaa / redis_queue.py
Created July 16, 2019 08:49
redis queue
import redis
class RedisQueue(object):
"""Simple Queue with Redis Backend"""
def __init__(self, name, namespace='queue', **redis_kwargs):
"""The default connection parameters are: host='localhost', port=6379, db=0"""
self.__db = redis.Redis(**redis_kwargs)
self.key = '%s:%s' % (namespace, name)
@foowaa
foowaa / dir_natural.m
Last active May 28, 2019 10:00
read all files in natural order by dir in MATLAB
function file=dir_natural(path)
%%% Example:
% file=sortObj('./img/*.bmp*');
file=dir(path);
for i=1:length(file)
A{i}=file(i).name;
end
[~, ind]=natsort(A);
for j=1:length(file)
files(j)=file(ind(j));
@foowaa
foowaa / dot_example.dot
Last active May 18, 2019 14:42
graphviz dot file example
digraph G {
rankdir="LR";
subgraph cluster_3{
subgraph cluster_2 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
VS -> "top-K"->"sequential \n embeding"
label = "CWSE";
@foowaa
foowaa / common.sh
Created April 26, 2019 06:28
一般的 shell 脚本
#! /bin/bash
# constants definition
baseDir=$(cd `dirname "$0"`;pwd) #返回文件当路径
home=$baseDir/..
registry=abc.com
name=$registry/dev
# functions
funWithReturn(){
@foowaa
foowaa / position_encoding_transformer.py
Last active May 3, 2023 18:46
position encoding of Transformer on numpy
'''
numpy sinusoid position encoding of Transformer model.
params:
n_position(n):number of positions
d_hid(m): dimension of embedding vector
padding_idx:set 0 dimension
return:
sinusoid_table(n*m):numpy array