This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* RuntimeInit.java | |
* My favorite initialization code for Android applications. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* HexDump.java | |
* Yet another HexDump. It prints bytes in human readable text. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IOUtil.java | |
* The class has some static methods to use streams easily. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* JSONEntity.java | |
* An utility class to POST json(optionally gzipped) with Apache HttpClient. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* EuclideanAlgorithm.java | |
* An implementation of the method for computing the greatest common divisor. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hex_dump.rb | |
# print hex dump of a string | |
module HexDump | |
module_function | |
def hex_dump(str) | |
cs = str.unpack 'C*' | |
puts "[#{cs.size} bytes]" | |
addr = 0 | |
loop do | |
cs16 = cs.shift 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* MarkerFilter.java | |
* Logback NON-turbo filter checks whether the marker in the event matches the marker. | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bookmarklet: qrcode | |
// | |
// javascript:void((function(d){var s=BOOKMARKLETSCRIPT=d.createElement('script');s.type='text/javascript';s.src='https://raw.github.com/gist/1266971/b5e0748c51dd0ffdf4a1abb00d14409a8220b7c2/qrcode.js';d.getElementsByTagName('head')[0].appendChild(s);})(document)); | |
// | |
try { | |
(function(d){ | |
var body = d.getElementsByTagName('body')[0]; | |
var add = function(args) { | |
var target = args.target || body; | |
var elem = d.createElement(args.tag || 'div'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// is_array():bool | |
// "JavaScript: The Good Parts by Douglas Crockford. Copyright 2008 Yahoo! Inc., 978-0-596-51774-8." | |
function is_array(value) { | |
return value && | |
typeof value === 'object' && | |
typeof value.length === 'number' && | |
typeof value.splice === 'function' && | |
!(value.propertyIsEnumerable('length')); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* TProcessors.java | |
* Create an instance of org.apache.thrift.TProcessor bound to the classes at run time. | |
* TProcessor processor = TProcessors.newInstance(Class.forName(className), Class.forName(serviceName)); | |
* | |
* Copyright (C) 2011 TAKUMAKei | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* |
OlderNewer