You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
<?php | |
namespace App\Providers; | |
use App\Auth\UserProvider; | |
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | |
class AuthServiceProvider extends ServiceProvider | |
{ | |
/** |
>>> import pytz | |
>>> | |
>>> for tz in pytz.all_timezones: | |
... print tz | |
... | |
... | |
Africa/Abidjan | |
Africa/Accra | |
Africa/Addis_Ababa | |
Africa/Algiers |
import time | |
import threading | |
class BaseThread(threading.Thread): | |
def __init__(self, callback=None, callback_args=None, *args, **kwargs): | |
target = kwargs.pop('target') | |
super(BaseThread, self).__init__(target=self.target_with_callback, *args, **kwargs) | |
self.callback = callback | |
self.method = target |
import { format } from 'url'; | |
import { STATUS_CODES } from 'http'; | |
import uppercamelcase from 'uppercamelcase'; | |
class HTTPError extends Error { | |
constructor(code, message, extras) { | |
super(message || STATUS_CODES[code]); | |
if (arguments.length >= 3 && extras) { | |
Object.assign(this, extras); | |
} |
git reflog | |
# これで、以下の様なのが参照できる | |
2be6f11 HEAD@{0}: xxxxxxxxxxxx | |
18389ad HEAD@{1}: xxxxxxxxxxxxx | |
0c485c8 HEAD@{2}: xxxxxxxxxxxxxx | |
b751438 HEAD@{3}: xxxxxxxxxxxxxxx # ここに戻したいので一つ前の数字を指定↓ | |
hc8a0s8 HEAD@{4}: xxxxxx | |
# 「q」で戻って・・・ | |
git reset --hard 'HEAD@{4}' | |
# のように数字を指定すると元に戻る! |
//================確認用処理待ちロジック================ | |
while(1){ | |
echo "処理続行しますか?\nyes or no: "; | |
// 標準入力から入力待ち | |
$line = trim(fgets(STDIN)); | |
if ($line == "yes") { | |
echo "処理を続行します\n"; | |
break; // 無限ループを抜ける | |
}elseif($line == "no"){ | |
echo "処理を終了します\n"; |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');