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
@inap-bannai
inap-bannai / set-value.md
Created June 23, 2021 05:42 — forked from JeffreyWay/set-value.md
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');
@inap-bannai
inap-bannai / AuthServiceProvider.php
Created April 22, 2021 05:40 — forked from paulofreitas/AuthServiceProvider.php
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
{
/**
@inap-bannai
inap-bannai / BaseThreading
Created March 25, 2021 03:16 — forked from amirasaran/BaseThreading
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