Skip to content

Instantly share code, notes, and snippets.

View mumumu's full-sized avatar

Yoshinari Takaoka mumumu

View GitHub Profile
@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,
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 / 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)
@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 / tcp_client.pl
Created December 24, 2012 10:52
tcp client by perl, using low-level socket API.
#!/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 / stripInvalidXMLChars.java
Created February 21, 2013 08:26
jdom claims "....." is not legal for a JDOM character content: 0x... is not a legal XML character. for workaround, i used the following method. From http://blog.mark-mclaren.info/2007/02/invalid-xml-characters-when-valid-utf8_5873.html
/**
* This method ensures that the output String has only
* valid XML unicode characters as specified by the
* XML 1.0 standard. For reference, please see
* <a href="http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">the
* standard</a>. This method will return an empty
* String if the input is null or empty.
*
* @param in The String whose non-valid characters we want to remove.
* @return The in String, stripped of non-valid characters.
@mumumu
mumumu / Smarty2.6.26_to_2.6.27.patch
Created March 10, 2013 13:16
Smarty 2.6.26 to 2.6.27 change by possible XSS
Index: ChangeLog
===================================================================
--- ChangeLog (リビジョン 3764)
+++ ChangeLog (リビジョン 4660)
@@ -1,3 +1,8 @@
+2012-09-24 Uwe Tews
+
+ * Fixed escape Smarty error messages to avoid possible script execution
+
+
@mumumu
mumumu / difference_of_keyword_args.txt
Last active December 16, 2015 16:49
difference of keyword arguments between Ruby 2.0.0 and Python.
mumumu@www 17:12:11$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def test(a = []):
... a.append(10)
... print a
...
>>> test()
[10]
@mumumu
mumumu / addTargetBlankattrToAnchor.js
Last active January 25, 2019 10:47
ページ内 a タグを target="_blank" に変えるブックマークレット。今時の # な URL だったら意味無いけどね。
javascript:var elms=document.getElementsByTagName('a');for(var i=0;i<elms.length;i++){elms[i].setAttribute('target','_blank');}
@mumumu
mumumu / ImageRotateUtil.java
Last active April 8, 2022 11:03
Automatically corrects the orientation of image by interpreting exif:Orientation value. This class depends on JMagick and apache-sanselan.
package org.mumumu.test;
import java.io.ByteArrayOutputStream;
import magick.ImageInfo;
import magick.MagickImage;
import org.apache.sanselan.Sanselan;
import org.apache.sanselan.common.IImageMetadata;
import org.apache.sanselan.formats.jpeg.JpegImageMetadata;