Skip to content

Instantly share code, notes, and snippets.

View mumumu's full-sized avatar

Yoshinari Takaoka mumumu

View GitHub Profile
@mumumu
mumumu / invalid_tcp_client.pl
Created December 24, 2012 10:37
this code gets "Bad arg length for Socket::pack_sockaddr_in" error. we can fix this error by changing 2nd parameter of pack_sockaddr_in function.
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::Socket;
use Data::Dumper;
my $socket = IO::Socket::INET->new(
Proto => 'tcp',
Type => SOCK_STREAM
@mumumu
mumumu / TibarModule.m.diff
Created August 27, 2012 14:43
tibar image overlay module patch
Index: Classes/TibarModule.m
===================================================================
--- Classes/TibarModule.m (revision 17)
+++ Classes/TibarModule.m (working copy)
@@ -257,6 +257,36 @@
[pickerCancelCallback retain];
}
+ // overlay view
+ if ([args objectForKey:@"overlay"] != nil)
if (Ti.Platform.name == "android") {
var speechModule = require('org.mumumu.ti.android.speech');
var voiceRecognitionProxy = speechModule.createVoiceRecognition();
voiceRecognitionProxy.callback = function (e) {
var voice_recognition_enabled = e.voice_enabled;
var voice_results = e.voice_results;
if (e.voice_canceled) {
alert("voice recognition canceled");
} else {
if (!voice_recognition_enabled) {
@mumumu
mumumu / FirstView.js
Created May 3, 2012 09:04
Voice Recognition sample for Titanium Mobile
//Add behavior for UI
label.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
action: "android.speech.action.RECOGNIZE_SPEECH"
});
intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "free_form");
intent.putExtra("android.speech.extra.PROMPT","VoiceRecognitionTest");
//intent発行&音声認識結果受け取り
Ti.Android.currentActivity.startActivityForResult(
intent,
package com.example.ini;
import java.io.File;
import java.io.IOException;
import java.util.Set;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import org.ini4j.Ini;
import org.ini4j.IniPreferences;
import java.io.StringWriter;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.MethodInvocationException;
import java.util.Vector;
/**
#!/bin/sh
export LANG=C
testURLContentsChange()
{
sysctl xen.independent_wallclock=1
TEST_URL="http://www.example.com/"
TODAY_START_DATE=`date +'%Y-%m-%d 00:00:00'`
#include <stdio.h>
/*
* int を2進表記にして出力する
* int を 32bit と仮定している
*/
int binary(int num)
{
//
// - 以下のルーチンでint の範囲に収まる値は扱うことができるが
#include <stdio.h>
/*
* param の num 乗を出力する関数(二進累乗法の実装)
*
* TODO: オーバーフロー/アンダーフローのチェックをしていない
* TODO: num が負の時に対応していない
*/
static void power(double param, long long int num)
{
/**
* 標準入力を1文字ずつ受け取り、それらを繋ぎ合わせて
* 整数として出力するプログラム 実行例は以下のとおり。
*
* $ gcc convert_stdin_tointeger.c -o input2int
* $ ./input2int
* input one number (space to exit):- <= 最初の桁は + と - の入力可(数値でもよい)
* input one number (space to exit):1
* input one number (space to exit):2
* input one number (space to exit): <= input space