I hereby claim:
- I am ytkhs on github.
- I am ytkhs (https://keybase.io/ytkhs) on keybase.
- I have a public key whose fingerprint is 9BAF 6EEF DBD6 6336 47EC ACC1 6416 6A09 1572 E0EC
To claim this, I am signing this object:
<?php | |
define('LOGIN', 'xxxxx'); | |
define('API_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); | |
define('END_POINT', 'http://api.bit.ly/v3'); | |
function getShortUrl($longUrl) | |
{ | |
$query = http_build_query( | |
array( | |
'login' => LOGIN, |
<?php | |
if (!function_exists('http_post_contents')) { | |
function http_post_contents($url, $params) { | |
$content = http_build_query($params, '', '&'); | |
$header = array( | |
"Content-Type: application/x-www-form-urlencoded", | |
"Content-Length: ".strlen($content) | |
); | |
$options = array( |
I hereby claim:
To claim this, I am signing this object:
$ adb shell | |
#sample | |
am start -a android.intent.action.CALL -d tel://000-0000 | |
am start -a android.intent.action.SEND -d "some message" -t text/plain | |
am start -a android.intent.action.VIEW -d geo:0,0?q=Tokyo | |
am start -n com.android.browser/.BrowserActivity |
var resultFiles = []; | |
// 再帰的にファイルを探す | |
function getAllFiles(folder, path) { | |
// まずこの階層のファイル | |
var files = folder.getFiles(); | |
while(files.hasNext()){ | |
var file = files.next(); |
$arr = ['a' => 'Alice', 'b' => 'Bob']; | |
# 今まで(ポインタが移動しちゃう) | |
end($arr); | |
# => "Bob" | |
# 存在チェックが必要なのでこれはこれで長い。いい方法あるかな? | |
$lastkey = array_key_last($arr); | |
array_key_exists($lastkey, $arr) ? $arr[$lastkey] : null | |
# => "Bob" |
-- 読み取り専用にする | |
FLUSH TABLES WITH READ LOCK; | |
SET GLOBAL read_only = ON; | |
-- バックアップとかDBサーバの移設作業とか -- | |
-- 元に戻す | |
SET GLOBAL read_only = OFF; | |
UNLOCK TABLES; |
# start emulator shell | |
$ adb shell | |
# on emelator | |
setprop net.dns1 8.8.8.8 | |
setprop net.dns2 8.8.4.4 |
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
fmt.Println(IsPremiumFriday("2017-02-24")) // true | |
fmt.Println(IsPremiumFriday("2017-02-25")) // false |
<?php | |
function is_premium_friday(Datetime $date) { | |
return $date->diff(new DateTime(sprintf('last Fri of %s', $date->format('Y-m'))))->format('%d') == 0; | |
} | |
var_dump(is_premium_friday(new Datetime('2017-02-23'))); // false | |
var_dump(is_premium_friday(new Datetime('2017-02-24'))); // true | |
var_dump(is_premium_friday(new Datetime('2017-02-25'))); // false | |
var_dump(is_premium_friday(new Datetime('2017-03-31'))); // true |