毎回検索するのも面倒なので自分のブログにメモ。
.emacsに下記を記載する。
1 2 | (setq make-backup-files nil) (setq auto-save-default nil) |
1 2 | (setq make-backup-files nil) (setq auto-save-default nil) |
auのhtc u11で歩きながら操作するといきなりバイブがなって画面全体に出る「やめましょう歩きスマホ」。
わかるけど邪魔ですよね。
というわけで消し方。
【設定】→【au設定メニュー】→【歩きスマホ注意アプリ】
と進んで、ONになっているトグルをOFFにして下さい。
1 2 3 4 | DB::enableQueryLog(); $table1 = DB::table( 'table1' )->where( 'id' , $no )->first(); // $results = DB::select('select * from table1 where id = ?', [1]); logger()->debug(DB::getQueryLog()); |
[2017-07-12 03:01:50] local.DEBUG: array ( 0 => array ( 'query' => ' select * from table1 where value like \'%\' || \'?\' || \'%\';', 'bindings' => array ( 0 => '1', ), 'time' => 1, ), )
1 | 'log_level' => env( 'APP_LOG_LEVEL' , 'debug' ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | .scrollbars-visible- always { /deep/ ::-webkit-scrollbar { width : 15px ; height : 15px ; &-track { border : 10px ; border-radius: 10px ; background-color : rgba( 100 , 100 , 100 , 1 ) !important ; } &-thumb { background-color : rgba( 200 , 200 , 200 , 0.7 ) !important ; border : 10px ; border-radius: 10px ; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php Route::get( '/' , function () { return view( 'welcome' ); }); // Viewを指定するパターン Route::get( 'test' , function () { //return view('test'); return view( 'test' , [ 'name' => 'Viewを指定' ]); }); // 直接文字列を返すパターン Route::get( 'helloworld' , function () { return 'HelloWorld' ; }); // Controller使用するパターン Route::get( 'user/{id}' , 'TestController@show' ); // Ajax(とりあえず簡単なGetでお試し) Route::get( 'ajaxTest' , 'TestController@ajax' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use DB; class TestController extends Controller { /** * 指定ユーザのプロフィール表示 * * @param int $id * @return Response */ public function show( $id ) { // 下記はMariaDBへの接続サンプル //$table1 = DB::table('table1')->where('id', 2)->first(); //$result = $this->addText($id) . $table1->value; return view( 'test' , [ 'name' => $id ]); } /** * Ajax通信のサンプル * @return [type] [description] */ public function ajax() { // 簡単にやるなら配列返すのでもOK // return ["data" => "Ajax success"]; return response()->json( [ 'data' => 'Ajax success' ], 200,[], JSON_UNESCAPED_UNICODE ); } /** * ローカルメソッドのサンプル * @param [type] $val [description] */ private function addText( $val ) { $val2 = '' ; return $val . '-add string-' ; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <!DOCTYPE HTML> < html lang = "ja" > < html > < head > < meta charset = "UTF-8" > < title >アプリ名 - @yield('title')</ title > <!-- CSS --> < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" > < style type = "text/css" > <!-- hr { border: 0; border-bottom: 1px dashed #ccc; background: #999; } @yield('css') --> </ style > <!-- Scripts --> < script type = "text/javascript" > <!-- @yield('js') --> </ script > </ head > < body > @section('header') < hr > ここがメインのヘッダ < hr > @show < div class = "container" > @yield('content') </ div > @section('footer') < hr > ここがメインのフッター @show </ body > </ html > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | @extends('layouts.app') @section('title', 'これがサブのタイトルになります') @section('css') @endsection @section('js') $(function() { $("#button_a").on("click", function() { alert("aaaaaaaaa"); }); $("#button_b").on("click", function() { $.ajax( '../ajaxTest', { type: 'get', data: { 'no': 'aaaaaaaa' }, dataType: 'json' } ) // 検索成功時にはページに結果を反映 .done(function(data) { alert(data.data); }) // 検索失敗時には、その旨をダイアログ表示 .fail(function() { window.alert('正しい結果を得られませんでした。'); }); }); }); @endsection @section('header') @parent < p >ここはサブのヘッダ</ p > < hr > @endsection @section('content') < p >ここが本文のコンテンツ</ p > @for($i = 1; $i <= 10; $i++) < p >Hello, {{$name}}</ p > @endfor < p > < a id = "button_a" class = "btn btn-lg btn-success" href = "#" role = "button" >Push</ a > < a id = "button_b" class = "btn btn-lg btn-info" href = "#" role = "button" >Push</ a > </ p > @endsection @section('footer') @parent @endsection |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <VirtualHost "laravel.local:80" > #ServerName laravel. local #ServerAdmin webmaster@localhost DocumentRoot "C:/xampp/htdocs/app_laravel/public" ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common <Directory "C:/xampp/htdocs/app_laravel/public" > AllowOverride All </Directory> </VirtualHost> |
コノスル日本語公式サイトより白葡萄品種、人気No.1のシャルドネ。
爽やかなシトラスの香りにトロピカルな果実味が感じられる、
豊かでバランスのよい白ワイン。外観は黄金がかったきれいなイエローで、若々しい印象です。溌剌とした中に、複雑さも感じさせます。フレッシュなシトラスのアロマ、白桃を思わせる果実香に、ミネラルのヒント。ミネラルを感じさせる複雑な果実香が口内に広がります。ヴァラエタル・シリーズのシャルドネは若々しくフレッシュ。バランス良く、きれいな酸が感じられます。
1 2 3 4 5 6 7 8 9 10 11 12 | select a.SID, b.PIECE, a.SQL_ID, b.SQL_TEXT from v$session a, v$sqltext b where a.SQL_ID = b.SQL_ID and a.TYPE = 'USER' order by 3,2 |
アサヒワインコムよりトロピカルフルーツやピーチを想わせる豊かな果実味とコクのある味わいが特徴の、なめらかな飲み口の辛口白ワインです。
熟したグレープフルーツ、アプリコット、トロピカルフルーツ、パイナップル、ナッツ、白桃、クルミ、ミネラル香と若干のスモーク香など、複雑で芳醇なアロマ。リッチな果実味とクリーンな透明感が同居する辛口ワインです。KIRINの公式ホームページより
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // ListView val lv = findViewById(R.id.list_view) as ListView val list_items = listOf("1", "2", "3") // アダプタをセット val adapter = ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list_items) lv.adapter = adapter } } |
Wikipediaより2008年(平成20年)6月14日に運転を開始し、東上本線の有料列車としては特急「フライング東上」号以来約50年ぶりとなる。ただし「TJライナー」は「フライング東上」と異なり、この名称を愛称としてだけではなく、愛称を兼ねた正式な列車種別名としている。シンボルカラー(ロゴマーク)は青を基調とする。停車駅案内・駅時刻表においての色は橙を使用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | public class StringUtil { /** * パラメータを3桁カンマ区切り数字として返す。 * @param number 処理対象文字列 * @return フォーマット後文字列 */ public static String formatComma(String number) { if (!NumberUtils.isCreatable(number)) { return number; } NumberFormat nfNum = NumberFormat.getNumberInstance(); return nfNum.format(Double.parseDouble(number)); } /** * パラメータの文字列を、パラメータの最大文字数で切って返す。 * * nullの場合ブランクを返す。 * 文字数以内の場合文字列をそのまま返す。 * 指定文字数を超える場合は文字数で切った文字列を返す。 * * @param target 処理対象文字列 * @param length 文字数 * @return 処理後文字列 */ public static String split(String target, int length) { String res = null ; if (StringUtils.isEmpty(target)) { res = "" ; } else if (target.length() > length) { res = target.substring( 0 , length); } else { res = target; } return res; } /** * 引数の文字列をSHA-256で暗号化して、16進数エンコードする。 * ※base64でもエンコード出来るが、その場合、文字数が64文字以下になる。 * @param pass * @return */ public static String encode(String pass) { MessageDigest md = null ; try { md = MessageDigest.getInstance( "SHA-256" ); } catch (NoSuchAlgorithmException e) { // 発生しない e.printStackTrace(); } md.update(pass.getBytes()); byte [] digest = md.digest(); // 16 進数文字列として出力 StringBuilder sb = new StringBuilder(); for ( byte b : digest) { String hex = String.format( "%02x" , b); // 16 進数 2 桁として表示 (1byte は 00 ~ ff) sb.append(hex); } String result = sb.toString(); if (result.length() > 64 ) { result = result.substring( 0 , 64 ); } return result; } /** * ランダムな32文字の文字列を生成する。 * CSRF攻撃対策用のトークンとして使用する。 * @return */ public static String getRandomToken() { SecureRandom random = new SecureRandom(); byte bytes[] = new byte [ 32 ]; random.nextBytes(bytes); // 16 進数文字列として出力 StringBuilder sb = new StringBuilder(); for ( byte b : bytes) { String hex = String.format( "%02x" , b); // 16 進数 2 桁として表示 (1byte は 00 ~ ff) sb.append(hex); } String result = sb.toString(); if (result.length() > 32 ) { result = result.substring( 0 , 32 ); } return result; } /** * ランダムな文字列を生成する。 * 文字列に記号を含めるため、base64でエンコードする。 * パスワードを生成するために使用する。 * @param num 文字数 * @return 生成したパスワード */ public static String getRandomPass( int num) { SecureRandom random = new SecureRandom(); byte bytes[] = new byte [ 32 ]; random.nextBytes(bytes); String encoded = Base64.getEncoder().encodeToString(bytes); String result = "" ; if (num <= 32 ) { result = encoded.substring( 0 , num); } else { result = encoded.substring( 0 , 32 ); } return result; } /** * 数値を指定の桁で0埋めする * @param num 処理対象数値 * @param digit 桁数 * @return 0埋め後文字列 */ public static String padZero( int num, int digit) { return String.format( "%0" + digit + "d" , num); } /** * 指定の桁までスペース埋めする * @param str 処理対象文字列 * @param digit 桁数 * @return スペース埋め後文字列 */ public static String padSpace(String str, int digit) { return String.format( "%" + digit + "s" , str); } /** * 数字の頭の0を除去する * @param str 処理対象文字列 * @return 0除去後文字列 */ public static String ltrimZero(String str) { return str.replaceFirst( "^0+" , "" ); } /** * 文字列の頭のスペースを除去する * @param str 処理対象文字列 * @return スペース除去後文字列 */ public static String ltrim(String str) { return str.replaceFirst( "^ +" , "" ); } /** * 文字列の後ろのスペースを除去する * @param str 処理対象文字列 * @return スペース除去後文字列 */ public static String rtrim(String str) { return str.replaceFirst( " +$" , "" ); } /** * JSON文字列からMapを生成 * @param json JSON文字列 * @return Map */ public static Map<String, String> createMapFromJson(String json) { Gson gson = new Gson(); Type listType = new TypeToken<HashMap<String, String>>() { }. getType(); HashMap<String, String> map = gson.fromJson(json, listType); return map; } /** * MapからJSON文字列を生成 * @param map Map * @return JSON文字列 */ public static String createJsonFromMap(Map<String, String> map) { Gson gson = new Gson(); return gson.toJson(map); } /** * パラメータ1がnullの場合はパラメータ2を返す(SQLのNVLと同じ) * @param val1 検査対象文字列 * @param val2 パラメータ1がnullの時に返す文字列 * @return 判定後パラメータ1OR2 */ public static String nvl(String val1, String val2) { if (val1 == null ) { return val2; } else { return val1; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | public class DateUtil { /** * システム日付を返す * @return システム日付 */ public static java.util.Date getToday() { return new java.util.Date(System.currentTimeMillis()); } /** * システム日付を返す(SQL) * @return システム日付 */ public static java.sql.Date getTodaySql() { return new java.sql.Date(System.currentTimeMillis()); } /** * パラメータのDateに日数を加算 * @param date 対象日付 * @param add_days 加算日数 * @return 計算後の日付 */ public static java.util.Date addDay(java.util.Date date, int add_days) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, add_days); return new java.util.Date(cal.getTimeInMillis()); } /** * パラメータのDateに日数を加算(SQL) * @param date 対象日付 * @param add_days 加算日数 * @return 計算後の日付 */ public static java.sql.Date addDaySql(java.sql.Date date, int add_days) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, add_days); return new java.sql.Date(cal.getTimeInMillis()); } /** * パラメータのDateに月を加算 * @param date 対象日付 * @param add_months 加算月数 * @return 計算後の日付 */ public static java.util.Date addMonth(java.util.Date date, int add_months) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.MONTH, add_months); return new java.util.Date(cal.getTimeInMillis()); } /** * パラメータのDateに月を加算(SQL) * @param date 対象日付 * @param add_months 加算月数 * @return 計算後の日付 */ public static java.sql.Date addMonthSql(java.sql.Date date, int add_months) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.MONTH, add_months); return new java.sql.Date(cal.getTimeInMillis()); } /** * パラメータのDateに年を加算 * @param date 対象日付 * @param add_months 加算年数 * @return 計算後の日付 */ public static java.util.Date addYear(java.util.Date date, int add_years) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.YEAR, add_years); return new java.util.Date(cal.getTimeInMillis()); } /** * パラメータのDateに年を加算(SQL) * @param date 対象日付 * @param add_months 加算年数 * @return 計算後の日付 */ public static java.sql.Date addYearSql(java.sql.Date date, int add_years) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.YEAR, add_years); return new java.sql.Date(cal.getTimeInMillis()); } /** * パラメータのDateをYYYY/MM/DDのフォーマットにして返す * @param date 対象日付 * @return 変換後の日付文字列 */ public static String formateYyyyMmDd(java.util.Date date) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); return sdf.format(date); } /** * パラメータのDateをYYYY/MM/DDのフォーマットにして返す(SQL) * @param date 対象日付 * @return 変換後の日付文字列 */ public static String formateYyyyMmDdSql(java.sql.Date date) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); return sdf.format(date); } /** * パラメータのDateをYYYY/MMのフォーマットにして返す * @param date 対象日付 * @return 変換後の日付文字列 */ public static String formateYyyyMm(java.util.Date date) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM" ); return sdf.format(date); } /** * パラメータのDateをYYYY/MMのフォーマットにして返す(SQL) * @param date 対象日付 * @return 変換後の日付文字列 */ public static String formateYyyyMmSql(java.sql.Date date) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM" ); return sdf.format(date); } /** * システム日時をYYYYMMDDHHMMのフォーマットにして返す * @return 変換後の日時文字列 */ public static String getTodayYyyyMmDdHhMm() { SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmm" ); java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis()); return sdf.format(ts); } /** * システム日付をyyyy-MM-dd HH:mm:ssのフォーマットにして返す * @return 変換後の日付文字列 */ public static String getTodayYyyyMmDdHhMmSs() { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis()); return sdf.format(ts); } /** * システム日付をYYYYMMDDのフォーマットにして返す * @return 変換後の日付文字列 */ public static String getTodayYyyyMmDd() { SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd" ); java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis()); return sdf.format(ts); } /** * システム日付をYYYY/MM/DDのフォーマットにして返す * @return 変換後の日付文字列 */ public static String getTodayYyyyMmDdWithSlash() { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis()); return sdf.format(ts); } /** * YYYY-MM-DD(もしくはYYYY/MM/DD)形式の文字列をDateにして返す(java.util.Date 版) * @param str_date * @return */ public static java.util.Date convertStringToDate(String str_date) { // YYYY/MM/DD形式の場合はフォーマットを変更してから処理 if (str_date.indexOf( "/" ) > - 1 ) { str_date = str_date.replaceAll( "/" , "-" ); } SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" ); java.util.Date result = null ; try { result = sdf.parse(str_date); } catch (ParseException e) { e.printStackTrace(); } return result; } /** * YYYY-MM-DD(もしくはYYYY/MM/DD)形式の文字列をDateにして返す(SQL) * @param str_date * @return */ public static java.sql.Date convertStringToDateSql(String str_date) { // YYYY/MM/DD形式の場合はフォーマットを変更してから処理 if (str_date.indexOf( "/" ) > - 1 ) { str_date = str_date.replaceAll( "/" , "-" ); } return java.sql.Date.valueOf(str_date); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | function createDateList() { const START_ROW = 6; const END_ROW=36; var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // 日本の祝日取得 var cal = CalendarApp.getCalendarById( "ja.japanese#holiday@group.v.calendar.google.com" ); var startTime = new Date(2012, 0, 1); var endTime = new Date(2020, 11, 31); var events = cal.getEvents(startTime, endTime); // 標準時間を取得 var nstart = sheet.getRange( "H2" ).getValue(); var nend = sheet.getRange( "I2" ).getValue(); var nrest = sheet.getRange( "J2" ).getValue(); // 色をクリア sheet.getRange( "A" + START_ROW + ":N" + END_ROW).setBackgroundRGB(255, 255, 255); // 時間・作業内容クリア sheet.getRange( "C" + START_ROW + ":E" + END_ROW).setValue( "" ); sheet.getRange( "G" + START_ROW + ":I" + END_ROW).setValue( "" ); sheet.getRange( "K" + START_ROW + ":L" + END_ROW).setValue( "" ); sheet.getRange( "N" + START_ROW + ":N" + END_ROW).setValue( "" ); var yesterday; for (i = START_ROW; i < END_ROW + 1; i++) { var today = sheet.getRange( "A" + i).getValue(); var weekday = sheet.getRange( "B" + i).getValue(); // 不要な日を消す if (i > 30) { valY = yesterday.toString().slice(8, 10); valT = today.toString().slice(8, 10); if (valT != "" && valY > valT) { sheet.getRange( "A" + i + ":I" + i).setValue( "" ); continue ; } } if (weekday == "日" ) { sheet.getRange( "A" + i + ":N" + i).setBackgroundRGB(255, 230, 230); } else if (weekday == "土" ) { sheet.getRange( "A" + i + ":N" + i).setBackgroundRGB(200, 230, 255); } else { sheet.getRange( "C" + i).setValue(nstart); sheet.getRange( "D" + i).setValue(nend); sheet.getRange( "E" + i).setValue(nrest); } // 祝日 for (j = 0; j < events.length; j++) { var holiday = events[j].getAllDayStartDate().toString(); if (today == holiday) { sheet.getRange( "A" + i + ":N" + i).setBackgroundRGB(255, 230, 230); sheet.getRange( "N" + i).setValue(events[j].getTitle()); sheet.getRange( "C" + i).setValue( "" ); sheet.getRange( "D" + i).setValue( "" ); sheet.getRange( "E" + i).setValue( "" ); sheet.getRange( "G" + i).setValue( "" ); sheet.getRange( "H" + i).setValue( "" ); sheet.getRange( "I" + i).setValue( "" ); sheet.getRange( "K" + i).setValue( "" ); sheet.getRange( "L" + i).setValue( "" ); } } yesterday = today; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | fun main(args: Array<String>) { // ←JVM言語ですが、このように一番外枠がClassでなくても大丈夫。Ptyhonのモジュールのような考え方です。 // Javaと相互互換を保証しています。ので、Javaの資産がそのまま使えます。またこのファイルのメソッドなどもJavaから呼び出せます。 println(java.sql.Timestamp.valueOf("2013-10-11 12:13:4")) System.out.println("Javaによるsysout") // (アドレスが)変更できない変数の宣言は「val」(Javaで言う所のfinal) val str: String = "Hello, World!" val num: Int = 5 // プリミティブはない。IntとかLongとか。Javaでいうラッパーを使用する。ここらへんもPythonに近いですね。 // 3項演算子の代わりにこんな文法がある val res = if (num.equals(5)) { "Hi, Tom!" } else { "Hi, Bob!" } println(str + num.toString()) println(res) // (アドレスが)変更できる変数の宣言は「var」。Kotlinでは可能な限り「val」を使うことを推奨 var str2: String = "test" str2 = "test2" println("str2:" + str2) val str3: String = "test" // str3 = "test3" ←これはコンパイルエラー。リテラルはアドレスが別になるため。 // str3 = str3 + str2 ←よってこれもコンパイルエラー。StringBuilderのように使う場合はvarを使用する。 str2 += "abcd" println("文字列の変更。test2 + abcd = " + str2) // 型の変換は変換元のメソッドで行う val int1: Int = "123".toInt() val int2 = int1 * 10 println(int2.toString()) //Int.parseInt("123") ←こんなメソッドはない // Switchはなくて、whenを使う val color: String = "青" val piyo = when (color) { "青" -> "blue" "赤" -> "red" else -> "other" } println(piyo) // (中身を)変更できないリスト。Pythonで言う所のタプル。 // (豆知識)Pythonでも可能な限りリストではなくタプルを推奨してますよね。 println("変更できないリスト") val list: List<String> = listOf("1", "2", "5") // list.add("5") ←変更できないリストなのでaddメソッドは存在しない for (value1 in list) { println(value1) } // (中身を)変更できるリスト。Pythonで言う所のリスト println("変更できるリスト。宣言は「val」なところに注目。この場合はアドレスが変わらないという意味") // JavaでfinalのListにもaddはできますよね val mutableList: MutableList<Int> = mutableListOf(9, 8, 7, 6, 5) mutableList.add(4) for (value1 in mutableList) { println(value1) } // JavaのObjectにあたるクラスはAnyです val any1: Any = "This is Any." val any2: Any = 123 // Javaと違ってプリミティブがないのでこんな書き方になる。Javaなら「Object any2 = new Integer(123);」とか。 println(any1.toString()) println(any2.toString()) // クラスの使い方。Kotlinでは「new」は不要 val carol = Car(price = 1000000, speed = 250, name = "キャロル") println("name:" + carol.name) // ←実はこれはフィールド(値)を直接参照しているのではなく、プロパティ(getter)の呼び出しです // メソッド呼び出し carol.displayInfo() // Try-Catch try { throw Exception("try-catch") } catch (e: Exception) { println("Error Message:" + e.message) } // ラムダ val sum: (Int, Int) -> Int = { x, y -> x + y } println("ラムダの処理結果→" + sum(1, 2)) // 匿名関数 val sum2 = fun(a: Int, b: Int): Int { return a + b } println("匿名関数の処理結果→" + sum2(1, 2)) // 2つの結果を戻してくれる関数。Javaに欲しかったですよね。 val pair = carol.addNumbers(2, 3) println("2つの結果を返してくれる関数 ひとつめ→" + pair.first + " ふたつめ→" + pair.second) // プライマリコンストラクタの動き val cb400sf = Bike("CB400SF", 200, 800000) println("プライマリコンストラクタで設定されたもの→" + cb400sf.name + "," + cb400sf.maxSpeed + ",\\" + cb400sf.price) // filterの使い方。trueの要素だけ返す val filterSample = arrayOf(1, 2, 3).filter { num -> num != 2 } print("filterの使い方→") for (x in filterSample) { print(x.toString() + " ") } println() // filterNotにすると逆になる val filterNotSample = arrayOf(1, 2, 3).filterNot { num -> num != 2 } print("filterNotの使い方→") for (x in filterNotSample) { print(x.toString() + " ") } println() // forEach println("ListのforEachはJava8と同じ雰囲気で。") listOf(1, 2, 3).forEach { x -> println(x + 1) } // リスト系は他にもMaxとかMinとかDistinctとか便利なのがたくさんある。リファレンスは見たほうがいいです。 // Stringの便利な機能やメソッド println("Stringの便利な機能やメソッド") val a = 2 val b = 3 // もうformatメソッドは必要ありません println("$a + $b = ${a + b}") // 2 + 3 = 5 // ヒアドキュメントも使えます val hereDoc = """ <html> <body> $a + $b = ${a + b} </body> </html> """ println(hereDoc) // Kotlinはnull safetyです。 // 基本的にNull Pointer Exceptionは発生しません。(Javaで定義したメソッドの使い方によってはそれでも起こるけど) // 普通の変数にnullを代入しようとするとコンパイルエラーになります // val nullDesu: String = null ←コンパイルエラー // nullが入り得る場合は明示的に下記のようにしなければいけません val nullDesu: String? = null // println(nullDesu.length) ←わざとぬるぽ起こそうとしてもコンパイルエラー。nullが入り得る変数で危険なことはできない仕様です if (nullDesu != null) { println(nullDesu.length) // nullチェックをするとコンパイルが通ります } // 既存のクラスに機能を追加できる「Extension」という機能 // 今回はStringクラスに機能追加しちゃいます fun String.addShimasu(x: Int): String { return this + x.toString() } println("これがExtensionです!!!".addShimasu(123456)) } // クラスの書き方(Javaっぽく) // ちなみにデフォルトだとclassはpublic finalです。 // また、staticの概念はないです class Car { // getterやsetterは記載不要です。 // 変数名がgetter、setterとして外部と連携します。 // 直接に値(フィールド)にアクセスするのではないので、これらは「フィールド」ではなく「プロパティ」と呼びます。 // 要はJavaで言う所のメンバ変数をprivateで宣言してgetter, setterを用意した状態と同じで、メンバ変数名でgetter, setterが使用できるということです。 val price: Int val speed: Int val name: String constructor(price: Int, speed: Int, name: String) { this.price = price this.speed = speed this.name = name } // 何も返さない時はvoidではなくUnit型 fun displayInfo(): Unit { println("クラスのメソッド呼び出し↓") println("Name:" + this.name) println("MaxSpeed:" + this.speed) println("Price:" + this.price) return } // 複数の値を返せる関数 fun addNumbers(a: Int, b: Int): Pair<Int, Int> { return Pair(a + 1, b + 1) } } // クラスのプライマリコンストラクタの書き方(Kotlinっぽい) class Bike(name: String, maxSpeed: Int, price: Int) { val name = name val maxSpeed = maxSpeed val price = price } |