Skip to content

Instantly share code, notes, and snippets.

View niusounds's full-sized avatar
🤘

Yuya Matsuo niusounds

🤘
View GitHub Profile
@niusounds
niusounds / 01-audioContext.js
Last active August 29, 2015 14:05
WebAudio input to MIDI note number. AngularJS & jQuery is required.
angular.module('myApp').factory('audioContext', function() {
return new AudioContext();
});
@niusounds
niusounds / MyFaceDetectionListener.java
Last active August 29, 2015 14:06
Camera.FaceDetectionListener
public class MyFaceDetectionListener implements Camera.FaceDetectionListener {
private Matrix m = new Matrix();
private RectF rect = new RectF();
// Call this before startFaceDetection().
// targetWidth and targetHeight are usually size of view which shows camera preview.
public void setup(boolean useFrontCamera, int displayOrientation, float targetWidth, float targetHeight) {
m.setScale(useFrontCamera ? -1 : 1, 1);
m.postRotate(displayOrientation);
m.postTranslate(1000, 1000);
@niusounds
niusounds / Simple Mongoose example.js
Last active August 29, 2015 14:06
Simple Mongoose example
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/myapp');
var schema = new mongoose.Schema({
name: String
});
var model = mongoose.model('MyModel', schema);
new model({
@niusounds
niusounds / JS Array funcs.js
Last active August 29, 2015 14:06
JavaScriptの配列操作
var a = [1, 2, 3, 4, 5];
// shift は先頭を取り出す
a.shift(); // -> 1
console.log(a); // -> [2, 3, 4, 5]
// push は末尾に入れる
a.push(111);
console.log(a); // -> [2, 3, 4, 5, 111]
@niusounds
niusounds / QueuedRequest.js
Created September 25, 2014 04:55
QueuedRequest
var request = require('request'),
Promise = require('promise'),
extend = require('extend');
module.exports = QueuedRequest;
function QueuedRequest(interval) {
this.interval = interval;
this.queue = [];
this.loop = loop.bind(this);
@niusounds
niusounds / gist:a1ea63d99aad3782ce96
Created October 2, 2014 04:25
某AWSプレミアコンサルの人に聞いたけどおしえてくれなかったお(´・ω・`)
{
    "Version": "2012-10-17",
    "Statement": [{
        "Action": [
            "sns:CreatePlatformEndpoint"
        ],
        "Effect": "Allow",
        "Resource": "arn:aws:sns:****"
 }, {
@niusounds
niusounds / gist:dc28a4beadf94c7b300c
Last active August 29, 2015 14:15
AndroidのMatrixクラスから、平行移動、拡縮、回転それぞれの成分を取り出す処理。射影変換の行列はサポート対象外です。
import android.graphics.Matrix;
public class MatrixUtils {
public static Info decomposition(Matrix matrix, boolean reverseOrder) {
double dx, dy, sx, sy, theta;
float[] values = new float[9];
matrix.getValues(values);
@niusounds
niusounds / RenderScriptTest.java
Last active October 29, 2015 15:59
Generate content with RenderScript and show result to TextureView.
import android.app.Activity;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.Type;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
@niusounds
niusounds / Gear VRデモ用端末のセットアップ手順.md
Last active December 2, 2015 05:12
開発したGear VRアプリをOculus Storeを使わず独自に配布する場合、イベントで展示する場合などにすること。

Gear VRを使えるようにするための設定

  1. 電源を入れる。
  2. 適当に初期設定をする。アカウント作成などはしない。Googleアカウントも不要。
  3. Wi-Fiに接続する。
  4. 端末をGear VRに接続する。そしてすぐ外す。
  5. Gear VRセットアップを行う。適当に同意しつつ必要なアプリをインストールする。Oculusアカウントのセットアップまで来たら、終了して良い

Gear VR用アプリをビルドする

@niusounds
niusounds / RotateGestureDetector.java
Last active December 29, 2015 15:09
Simple RotateGestureDetector can be used in the same way as GestureDetector and ScaleGestureDetector.
import android.content.Context;
import android.view.MotionEvent;
public class RotateGestureDetector {
public static interface OnRotateListener {
boolean onRotate(float degrees, float focusX, float focusY);
}
public static class SimpleOnRotateGestureDetector implements OnRotateListener {
@Override