Skip to content

Instantly share code, notes, and snippets.

View dagezi's full-sized avatar

Takeshi Sasaki dagezi

View GitHub Profile
@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?
@dagezi
dagezi / git-latest-branches
Last active December 13, 2019 16:35
The small shell script to show git branches in recently-used order.
#!/bin/sh -e
function show_latest_branches () {
git branch | \
sed 's/[* ]//g; s/.*/printf "& "; git show --format="%at" -s &/'| \
sh | \
sort -k2nr
}
@dagezi
dagezi / SubscribeLater.java
Created January 16, 2017 07:00
Why can "sub2" retrieve the first item of "src1"?
package hoge;
import rx.*;
import rx.schedulers.*;
import java.util.concurrent.TimeUnit;
// See the items in backpressure bufffer will be genereated
// for the observer who subscribed later?
public class SubscribeLater {
@dagezi
dagezi / file0.txt
Last active April 17, 2017 10:13
VectorDrawableの穴を塞がないようにする ref: http://qiita.com/dagezi/items/3fd71a4c4c1cfd9cfcc0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="40px" height="40px" viewBox="0 0 40 40" version="1.1" >
<path
d="M10,10 30,10 30,30 10,30 Z M15,15 25,15 25,25 15,25 Z"
fill="#ff0000" fill-rule="evenOdd" />
</svg>
# Trivial example: 2017-01-01 is part of the last week of 2016 because ISO week starts with the Monday.
irb(main):004:0> fd2017 = Date.new(2017,1,1)
=> #<Date: 2017-01-01 ((2457755j,0s,0n),+0s,2299161j)>
irb(main):005:0> fd2017.cweek
=> 52
irb(main):006:0> fd2017.cwday
=> 7 # Sunday
irb(main):007:0> fd2017.cwyear
=> 2016
@dagezi
dagezi / Www.java
Last active September 14, 2017 06:33
Create WeakReferece out of the inner class!
import java.lang.ref.WeakReference;
public class Www {
public static void main(String args[]) {
Runnable r0 = create0();
Runnable r1 = create1();
System.gc();
r0.run();
r1.run();