Skip to content

Instantly share code, notes, and snippets.

View zhangyangjing's full-sized avatar

Yangjing Zhang zhangyangjing

View GitHub Profile
@zhangyangjing
zhangyangjing / MainView.java
Last active August 29, 2015 06:27
extract points position from image
package com.example.zyj.myapplication;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
@zhangyangjing
zhangyangjing / dtd.py
Last active August 29, 2015 14:03
dtd
#!/usr/bin/python
# -*- coding: utf-8 -*-
dt = ['3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y']
td = {
'3': 0, '4': 1, '5': 2, '6': 3, '7': 4, '8': 5, '9': 6, 'A': 7, 'B': 8,
'C': 9, 'D': 10, 'E': 11, 'F': 12, 'G': 13, 'H': 14, 'J': 15, 'K': 16,
public class SingletonSample {
private static SingletonSample mInstance;
private SingletonSample() {
}
public static SingletonSample getInstance() {
if (null == mInstance) {
synchronized(SingletonSample.class) {
@zhangyangjing
zhangyangjing / clear.sh
Created November 6, 2014 02:14
clear mac ._* bash shell
#!/bin/sh
#find . -name "._*" -exec rm {} \;
function clear() {
for file in `ls -A $1`
do
if [ -d $1/$file ]
then
@zhangyangjing
zhangyangjing / gist:8414811
Created January 14, 2014 08:06
android utils
// 判断是否是中文
private boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
return true;
@zhangyangjing
zhangyangjing / hn.py
Created February 4, 2016 07:30
hack news rss generator
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@zhangyangjing
zhangyangjing / concat.py
Last active October 14, 2016 07:22
subtitles_concat
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
if 2 != len(sys.argv):
print 'bad argument'
exit(1)
@zhangyangjing
zhangyangjing / port_id.txt
Created November 15, 2016 05:54
port id for tide info @ http://ocean.cnss.com.cn
亚洲 中国 辽宁 丹东 1
亚洲 中国 辽宁 丹东新港 2
亚洲 中国 辽宁 石山子 3
亚洲 中国 辽宁 大鹿岛 4
亚洲 中国 辽宁 小长山岛 5
亚洲 中国 辽宁 大窑湾(南大圈) 6
亚洲 中国 辽宁 大连(老虎滩) 7
亚洲 中国 辽宁 旅顺新港 8
亚洲 中国 辽宁 金县 9
亚洲 中国 辽宁 葫芦岛 10
@zhangyangjing
zhangyangjing / FpsMonitor.java
Last active January 18, 2017 03:18
FpsMonitor
public class FpsMonitor {
private static final int SAMPLE_COUNT = 10;
private ArrayBlockingQueue<Long> mQueue;
private long mLastUpdateTime;
public FpsMonitor() {
mQueue = new ArrayBlockingQueue<>(SAMPLE_COUNT);
mLastUpdateTime = System.currentTimeMillis();
}
@zhangyangjing
zhangyangjing / timing.cpp
Created January 18, 2017 14:43
timing_cpp
#include <chrono>
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::nanoseconds ns;
auto start = Time::now();
ns d1 = std::chrono::duration_cast<ns>(Time::now() - start);
ms d2 = std::chrono::duration_cast<ms>(Time::now() - start);