Skip to content

Instantly share code, notes, and snippets.

@bbtfr
bbtfr / glob2.py
Last active November 17, 2017 13:54
import os
import platform
import re
from functools import lru_cache, wraps
GLOBBING_SPECIAL_CHARS = '{}[],?*'
def yield_once(iterator):
"""
Decorator to make an iterator returned by a method yield each result only
import numpy as np
ITEMS_COUNT = 100
MAX_SIMILARITY = 100
CLUSTER_THRESHOLD = 80
SPLIT_THRESHOLD = 50
# 随机生成一个相似度矩阵
# 相似度(0-100),数值越大越相似
@bbtfr
bbtfr / bootstrap.sh
Last active May 31, 2017 07:12
VM Bootstrap
sudo apt update
# setup zsh
sudo apt install -y zsh curl git tmux realpath
curl -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
chsh `whoami` -s /bin/zsh
# customize zsh
mkdir -p $ZSH_CUSTOM/themes
curl -L https://raw.githubusercontent.com/bbtfr/dotfiles/master/zsh/themes/bira.zsh-theme -o $ZSH_CUSTOM/themes/bira.zsh-theme
require 'pycall/import'
include PyCall::Import
pyfrom 'tensorflow.examples.tutorials.mnist', import: :input_data
pyimport 'tensorflow', as: :tf
DATA_DIR = '/tmp/tensorflow/mnist/input_data'
# Import data
mnist = input_data.read_data_sets.(DATA_DIR, one_hot: true)
05-25 23:39:36.555 29138-29138/com.sensetime.example.idcardscan D/Instrumentation: wdf startActivityForResult perm:null
[ 05-25 23:39:36.555 362: 362 W/ ]
read_meminfo() mem_free=147800
[ 05-25 23:39:36.555 362: 362 W/ ]
create_subproc ret_fd=57 pid=29337
01-10 07:35:17.417 12158-12158/com.sensetime.liveness D/Instrumentation: wdf startActivityForResult perm:null
01-10 07:35:17.425 12158-12158/com.sensetime.liveness D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{2b6d9e3a token=android.os.BinderProxy@3ebe3aeb {com.sensetime.liveness/com.sensetime.liveness.ui.MainActivity}}
01-10 07:35:17.429 12158-12158/com.sensetime.liveness D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@3ebe3aeb
01-10 07:35:17.430 12158-12158/com.sensetime.liveness V/ActivityThread: Handling launch of ActivityRecord{22ff6e50 token=android.os.BinderProxy@1c3e8849 {com.sensetime.liveness/com.sensetime.stlivenesslibrary.ui.LivenessActivity}}
01-10 07:35:17.432 12158-12158/com.sensetime.liveness V/ActivityThread: ActivityRecord{22ff6e50 token=android.os.BinderProxy@1c3e8849 {com.sensetime.liveness/com.sensetime.stlivenesslibrary.ui.LivenessActivity}}: app=android.app.Application@1e099ee1, appName=com.sensetime.liveness, pkg=com.sensetime.liveness, comp={com.sen
@bbtfr
bbtfr / image_spider.rb
Created February 16, 2015 02:21
梅露可爬虫
# 除Ruby和对应包之外,还需要安装imagemagick和disunity
require 'open-uri'
require 'fileutils'
require 'mini_magick'
RANGE = (1..580)
BASEURL = "http://dbcj6kgtik9tl.cloudfront.net/toto_image_s3/jp_v2/unit/unit_square_#INDEX#.Android.unity3d"
FileUtils.mkdir_p "tmp"
@bbtfr
bbtfr / android.rb
Created December 25, 2014 04:46
RubyMotion Patch
# encoding: utf-8
# Copyright (c) 2012, HipByte SPRL and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
@bbtfr
bbtfr / setup.sh
Last active August 29, 2015 14:11
Android OpenSSL
# http://wiki.openssl.org/index.php/Android
# From the 'root' directory
$ . ./setenv-android.sh
$ cd openssl-*/
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
$ ./config -no-shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=$ANDROID_NDK_SYSROOT/usr
$ make depend
$ make all
@bbtfr
bbtfr / JniTest.java
Last active August 29, 2015 14:10
JniTest for RubyMotion
// This file has been generated automatically. Do not edit.
package com.bbtfr.hello;
public class JniTest extends java.lang.Object {
public native String stringFromJNI();
}