Skip to content

Instantly share code, notes, and snippets.

View inap-bannai's full-sized avatar
🌴
Working from distance.

Ryota Bannai inap-bannai

🌴
Working from distance.
  • Asia
View GitHub Profile
@paulofreitas
paulofreitas / AuthServiceProvider.php
Last active July 7, 2023 13:15
Extending the default Eloquent User Provider (Laravel 5.4+)
<?php
namespace App\Providers;
use App\Auth\UserProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
@heyalexej
heyalexej / pytz-time-zones.py
Created November 16, 2016 09:14
list of pytz time zones
>>> import pytz
>>>
>>> for tz in pytz.all_timezones:
... print tz
...
...
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
@amirasaran
amirasaran / BaseThreading
Created October 27, 2016 06:36
Python threading with callback function (callback function run after thread is finished)
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
@TooTallNate
TooTallNate / http-error.js
Created August 3, 2016 00:48
HTTPError class for JavaScript HTTP errors
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);
}
@naokazuterada
naokazuterada / reset_rebase.sh
Last active May 15, 2024 05:40
git rebaseを間違えた時に元に戻す
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}'
# のように数字を指定すると元に戻る!
@yo-iida
yo-iida / gist:9734838
Created March 24, 2014 05:50
PHP:CLIでの対話インターフェース
//================確認用処理待ちロジック================
while(1){
echo "処理続行しますか?\nyes or no: ";
// 標準入力から入力待ち
$line = trim(fgets(STDIN));
if ($line == "yes") {
echo "処理を続行します\n";
break; // 無限ループを抜ける
}elseif($line == "no"){
echo "処理を終了します\n";
@JeffreyWay
JeffreyWay / set-value.md
Created July 28, 2012 19:09
PHP: Set value if not exist

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');