Skip to content

Instantly share code, notes, and snippets.

View keijidosha's full-sized avatar

keijidosha

  • Kyoto, Japan
View GitHub Profile

エミュレータ

  • SDカードイメージを指定してAVDを作成
    パス指定
  • android create avd -n <AVD名> -t 2 -c <SDイメージファイルパス>
    サイズ指定
  • android create avd -n <AVD名> -t 2 -c 512M
  • エミュレータ起動
    emulator -avd <AVD名>
  • エミュレータに接続
@keijidosha
keijidosha / bash.md
Last active February 10, 2018 06:04

日付

日付を取得する

  • 今日の日付
    date +%Y%m%d
  • 現在の日付時刻
    date +%Y%m%d%H%M%S
  • 昨日の日付
    date -v-1d +%Y%m%d
@keijidosha
keijidosha / Markdown of GitHub.md
Last active November 17, 2017 05:50
Markdown of Git

見出し

# 見出し1
## 見出し2
### 見出し3
#### 見出し4

見出し1

見出し2

見出し3

読み込み

全読み込み

PHP

<?php
echo file_get_contents( "read.txt" );
?>

操作

起動/停止

  • 起動
    cd /usr/local/mysql; sudo ./bin/safe_mysqld –user=mysql &
    
  • 停止

Tips

一定時間経過すると自動的にログアウトする。

環境変数 TMOUT を設定。
(例) /etc/profile に

export TMOUT=300

を指定すると、5分間操作がなかった時に自動ログアウトされます。

ネットワークの問題(NATテーブルのタイムアウトなど)により、一定時間操作しないと切断されてしまう。

ゲストOS構築

  1. mkdir ~/vagrant
  2. cd ~/vagrant
  3. mkdir centos7
  4. cd centos7
  5. vagrant init bento/centos-7.2
  6. 必要に応じて Vagrantfile 編集
  7. vagrant up
  8. vagrant ssh

高階関数

2つの関数を渡す

fun main( args: Array<String> ) {
    // 丸括弧の中に 2つのラムダ式を記述する
    run( { println( "hoge" ) }, { println( "fuga" ) } )
    // 名前付き引数を使って渡す
    run( act2 = { println( "hoge" ) }, act1 = { println( "fuga" ) } )
}

概要

関数名 渡し方 参照 戻り値 例(val str = "hoge")
apply 関数 this this val strApply = str?.apply{ println( toUpperCase()) }
run 関数 this 結果の値 val upperStr = str?.run{ toUppserCase() }
let 関数 it 結果の値 val upperStr = str?.let{ it.toUppserCase() }
also 関数 it this val strAlso = str?.also{ println( it.toUpperCase()) }
with 引数 this 結果の値 val upperStr = with(str){ toUpperCase() }

apply