Skip to content

Instantly share code, notes, and snippets.

View bitristan's full-sized avatar
😀
happy coding everyday

Ting Sun bitristan

😀
happy coding everyday
View GitHub Profile
@bitristan
bitristan / RecognitionTaskType.java
Created September 6, 2015 11:53
android aidl enum parameter
public enum RecognitionTaskType implements Parcelable {
HOTWORD,
OFFLINE,
ONLINE,
MIX,
RECORD_ONLY;
@Override
public int describeContents() {
return 0;
@bitristan
bitristan / exists.go
Created September 2, 2015 09:00
Check file exists.
package main
import (
"log"
"os"
)
var (
fileInfo *os.FileInfo
err error
private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
Log.v(TAG, "Connection State Changed: " + (newState == BluetoothProfile.STATE_CONNECTED ? "Connected" : "Disconnected"));
if (newState == BluetoothProfile.STATE_CONNECTED) {
setState(State.CONNECTED);
gatt.discoverServices();
} else {
setState(State.IDLE);
@bitristan
bitristan / BLEPeripheral.java
Created July 15, 2015 11:57
Create a ble peripheral service
package com.example.android.bluetoothleadvertiser;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattServer;
import android.bluetooth.BluetoothGattServerCallback;
import android.bluetooth.BluetoothGattService;
@bitristan
bitristan / api.go
Created July 14, 2015 02:31
Send get and post request by golang
//发送get请求
func get(url string) string {
response, err := http.Get(url)
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
@bitristan
bitristan / ViewController.m
Created June 17, 2015 02:47
IOS autolayout code snippet
//
// ViewController.m
// AutoLayoutDemo
//
// Created by Ting Sun on 6/17/15.
// Copyright (c) 2015 sunting. All rights reserved.
//
#import "ViewController.h"
@bitristan
bitristan / build.gradle
Created June 9, 2015 03:13
use gradle upload library to bintrary
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
//classpath 'com.github.dcendents:android-maven-plugin:1.2'
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version '1.5.0'
android {
@bitristan
bitristan / Ball.java
Created May 14, 2015 04:43
使用OpenGlES2.0绘制球体
import android.opengl.GLES20;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import xyz.sunting.opengles.light.model.TSApplication;
import xyz.sunting.opengles.light.model.util.TSMatrixState;
import xyz.sunting.opengles.light.model.util.TSShaderUtil;
@bitristan
bitristan / TSMatrixState.java
Created May 14, 2015 04:39
OpenGLES2.0 矩阵变换工具类
import android.opengl.Matrix;
import android.util.Log;
/**
* 矩阵变换工具类
*
* @author tinker <[email protected]>
*/
public class TSMatrixState {
private static final int MATRIX_F4V_SIZE = 16;
@bitristan
bitristan / build-jar.gradle
Created March 26, 2015 12:08
build java project with gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
mainClassName = 'hello.HelloWorld'
// tag::repositories[]
repositories {
mavenCentral()
}