Skip to content

Instantly share code, notes, and snippets.

@afjk
afjk / CSL.v
Last active August 29, 2015 14:02
Defying Gravity - A Minimal Cognitive Sensorimotor Loop Which Makes Robots With Arbitrary Morphologies Stand Up からの引用
reg [17:0] voltage;
reg [16:0] timer;
always @(posedge ADC_CLK)
case (state)
0 : begin // sense -----------------------------------
if (ADC_DAT == 1)
begin
if ($signed(voltage) < $signed(18'h1FFFF))
voltage <= voltage + 1; // if not saturated
end
@afjk
afjk / csl_motor.m
Last active August 29, 2015 14:04
変形CSL関数
- (void) doMonitoring{
// Δφ0(t)=-gi/K*Δφ1(t)+gf*Δφ0(t-1)
const float gi = 0.5f;
const float gf = 1.4f;
const float Kinv = 10.0f;
const float MAX_VOL = 2.0f; //角速度最大値
// 現在の角度
btScalar angle = pHinge->getHingeAngle();
@afjk
afjk / ios_cocos3d_device_camera.m
Created January 25, 2015 03:40
iOS cocos3d cameraを端末の姿勢に合わせて制御する
#import <CoreMotion/CoreMotion.h>
-(void) initMotionManager{
// 1.CMMotionManagereより、端末の姿勢情報を取得
_motionManager = [[CMMotionManager alloc] init];
// 更新の間隔を設定する
_motionManager.deviceMotionUpdateInterval = 1.0f / 30.0f;
// ハンドラを設定する
CMDeviceMotionHandler deviceMotionHandler;
@afjk
afjk / StickyNotesActivity::onNewIntent.java
Last active December 18, 2015 13:39
StickyNotesActivity::onNewIntent
@Override
protected void onNewIntent(Intent intent) {
// NDEF exchange mode
if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
NdefMessage[] msgs = getNdefMessages(intent);
promptForContent(msgs[0]);
}
// Tag writing mode
if (mWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
@afjk
afjk / StickyNotesActivity::onNewIntent2.java
Last active December 18, 2015 13:39
StickyNotesActivity::onNewIntent customize for oob
@Override
protected void onNewIntent(Intent intent) {
// NDEF exchange mode
if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
NdefMessage[] msgs = getNdefMessages(intent);
promptForContent(msgs[0]);
}
// Tag writing mode
if (mWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
@afjk
afjk / GetBTinfo.java
Last active December 18, 2015 18:49
Get Bluetooth device info from BluetoothDevice class
@Override
protected void onNewIntent(Intent intent) {
// NDEF exchange mode
if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
NdefMessage[] msgs = getNdefMessages(intent);
}
// Tag writing mode
if (mWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
@afjk
afjk / dir.py
Created June 21, 2013 14:01
指定フォルダ以下の指定拡張子のファイルリストを表示
# -*- coding: CP932 -*-
# 指定フォルダ以下の指定拡張子のファイルリストを表示
import re
import os
def main():
print os.path.realpath(".")
for root, dirs, files in os.walk(r"D:¥work¥src"):
for fname in files:
if( fname[-4:] == ".cpp" ) or ( fname[-2:] == ".c" ) or ( fname[-2:] == ".h" ):
@afjk
afjk / del_comment.py
Created June 21, 2013 14:03
del comment
# -*- coding: CP932 -*-
# コメントの削除
import re
import codecs
import csv
import os
import string
DIR_NAME = r"D:\src"
MOD_DIR_NAME = r"D:\dest"
@afjk
afjk / command.txt
Created June 22, 2013 03:44
command sample
コマンド
■Android Shell
●Android アプリ名からプロセスを探してKill(ただし、UNIXシェルから実行。WindowsからならMinGWとか使う)
adb shell ps|grep <プロセス名> |awk '{ print $2 }' | xargs adb shell kill
●圧縮ファイル解凍
busybox unzip -x <圧縮ファイル名>.zip
■Linux
@afjk
afjk / autoInput.rb
Last active December 26, 2015 00:49
require 'open3'
#-------------------------------------------------------------------------------
LOG_FILE = 'inputlog.log'
#-------------------------------------------------------------------------------
# Androidでの入力のログファイルへの出力
#-------------------------------------------------------------------------------
def recordToLogFile
Open3.popen3('adb shell') do |stdin,stdout,stderr,thread|