Skip to content

Instantly share code, notes, and snippets.

@woooha
woooha / append_when_not_found.sh
Created May 31, 2018 02:41
Linux shell function append string when not found string in file
append_when_not_found() {
line=$1
file=$2
dry_run=$3
if [ x"$dry_run" = x"true" ]
then
(grep -q -F "$line" $file) || ((echo "Append [$line] to [$file]") && (echo "$line"))
else
(grep -q -F "$line" $file) || ((echo "Append [$line] to [$file]") && (echo "$line" >> $file))
@woooha
woooha / CVPixelBuffer2UIImage.swift
Created June 21, 2017 12:32
Convert between CVPixelBuffer and UIImage
extension UIImage {
func buffer() -> CVPixelBuffer? {
let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue, kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferIOSurfacePropertiesKey: NSDictionary()] as CFDictionary
var pixelBuffer : CVPixelBuffer?
let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(self.size.width), Int(self.size.height), kCVPixelFormatType_32ARGB, attrs, &pixelBuffer)
guard (status == kCVReturnSuccess) else {
return nil
}
@woooha
woooha / fast-rcnn_test.prototxt
Created February 21, 2017 15:13
Fast-RCNN Caffe prototxt
name: "VGG_ILSVRC_16_layers"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 224
dim: 224
}
@woooha
woooha / use_xilinx_in_ubuntu_linux.md
Last active April 9, 2019 04:12
Ubuntu Linux 下使用 Xilinx SDK 开发

Ubuntu Linux 下使用 Xilinx SDK 开发

1. 下载 Vivado Design Suite for Linux

下载地址是 http://www.xilinx.com/support/download.html . 挺大的,慢慢下.

2. 安装 Vivado Design Suite

解压后, 执行 setup (需要切换到 Terminal 中执行).

@woooha
woooha / unittest.h
Created February 11, 2015 08:49
A simplest unittest snippet for bare metal devleopment.
#include <iostream>
#include <map>
#include <vector>
#include <string>
namespace zerozero{
namespace unittest{
typedef void (*Test_func)(bool &test_result);
@woooha
woooha / clip
Created January 2, 2015 02:53
在 Mac 下复制命令行结果到剪切板, 同时在命令行输出
#!/bin/sh
# usage: clip pwd
# clip ls -l
RESULT=`$*` && echo $RESULT && echo $RESULT | pbcopy
//
// MP4Atom.h
// Encoder Demo
//
// Created by Geraint Davies on 15/01/2013.
// Copyright (c) 2013 GDCL http://www.gdcl.co.uk/license.htm
//
#import <Foundation/Foundation.h>
@woooha
woooha / Closure
Last active December 10, 2015 03:18
$doms = $('input')
$doms.onclick = function(){
this.value = 123
}
$doms = $('.imgs')
var Human = function(){
this.getAge = function(){
return 1
}
this.getSex = function(){
return "I don't know"
}
}