Skip to content

Instantly share code, notes, and snippets.

View dagezi's full-sized avatar

Takeshi Sasaki dagezi

View GitHub Profile
@dagezi
dagezi / file0.txt
Last active August 29, 2015 14:15
ぐだぐだな branchを gitを駆使して綺麗にする。 ref: http://qiita.com/dagezi/items/2b73743c237f5f4901f7
- A [*] (master trunk)
\- B0 - B1 - B2 (messy_branch)
@dagezi
dagezi / BankAccount.groovy
Created April 13, 2015 01:42
Groovy has real closure!
def bank(int amount) {
[withdraw: {n -> amount -= n},
deposit: {n -> amount += n},
check: {amount}]
}
account = bank(1000)
println account.check()
@dagezi
dagezi / ThumbRemap.hk
Created May 27, 2015 00:57
ThumbRemap supports "Tap"+g,h
ThumbRemap_Init:
;1.有効にしたい方のコメントを削除
;#Include %A_ScriptDir%\Thumb_ALPS.ahk
#Include %A_ScriptDir%\Thumb_Synaptics.ahk
;2.タッチパッドに触れているときのみ有効化したいリマップを列挙
Thumb_Remap =
(
# returns list of reasons
def check_section(section)
case section.output_type
when 'text'
if section.content.match /.{0,10}<.{0,10}/ then
return $&
end
end
end
@dagezi
dagezi / UrlTest.java
Created June 2, 2015 12:54
http://java.net .URL#equals resolves domain name!
import java.net.URL;
public class UrlTest {
public static void main(String argv[]) throws Exception {
URL url1 = new URL("http://squiare.github.io/");
URL url2 = new URL("http://google.github.io/");
System.out.println(
String.format("\"%s\".equals(\"%s\") = %b",
url1.toString(),
@dagezi
dagezi / c.svg
Last active October 29, 2015 02:24
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dagezi
dagezi / file0.txt
Last active December 8, 2015 02:51
9patchの異常な仕様、あるいはなぜ私はドットを打つのをやめて scriptを書くようになったか ref: http://qiita.com/dagezi/items/be73212e12fea1e4e545
ninepatch {
round_rect {
vStretch 8, 32
hStretch 8, -8
vPadding 7, 33
hPadding 7, -7
}
}
#!/bin/sh
if [ -z "$ANDROID_HOME" ] ; then
echo Please set ANDROID_HOME >&2
fi
for jar in "${ANDROID_HOME}"/platforms/android-*/android.jar ; do
sdkVer=`expr "${jar}" : '.*/\(android-[0-9]*\)/android.jar'`
jar tf "$jar" | sed -n '/^java.*\.class/{s/\.class$//; s,/,.,g; p;}' |sort > sdk-${sdkVer}
done
def waitForEmulatorReady() {
def bootanim = ''
def failCounter = 0
while (!(bootanim =~ /stopped/)) {
def adbProcess = 'adb -e shell getprop init.svc.bootanim'.execute()
def errCode = adbProcess.waitFor()
if (errCode != 0) {
failCounter += 1
if (failCounter > 3) {
throw new RuntimeException('failed to start emulator')
import com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask
import com.android.builder.testing.api.DeviceConnector
def isDeviceReady(DeviceConnector device) {
def res = device.getSystemProperty('init.svc.bootanim').get()
return res == 'stopped'
}
def waitForAllDevicesReady(DeviceProviderInstrumentTestTask testTaks) {
// Add time out?