Skip to content

Instantly share code, notes, and snippets.

View extralam's full-sized avatar
🎯
Focusing

Alan Lam extralam

🎯
Focusing
View GitHub Profile
@extralam
extralam / tailclasshelper.php
Created December 21, 2022 02:23
A simple helper function for TailwindCss, responsive Tailwindcss
<?php
if (! function_exists('tailclass')) {
function tailclass($key, $default = null) {
$default = $classArr['default'] ?? [];
unset($classArr['default']);
$result = $default;
foreach($classArr as $key => $value) {
@extralam
extralam / SimpleBrowserNotification.php
Created October 9, 2021 15:22
Laravel Livewire - Simple Browser Notification ( toastr like popup )
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class SimpleBrowserNotification extends Component
{
public string $title;
@extralam
extralam / gist:944ed5000c390865eb002b4ac03e1b12
Created June 25, 2021 18:19
MySQL FULL TEXT SEARCH 中文字 要加ngram
ALTER TABLE bu_translates ADD FULLTEXT (`content`) WITH PARSER ngram;
@extralam
extralam / BaseModel.php
Last active April 24, 2020 06:00
Laravel BaseModel class - This is wrapped BaseModel for quickly write findOne{FieldName}("value") or findBy{FieldName}And{FieldName}
<?php
/**
* Created by PhpStorm.
* User: alan
* Date: 24/12/2018
* Time: 5:47 PM
*/
namespace App\Models;
@extralam
extralam / eps.js
Last active August 31, 2019 08:02
Hong Kong EPS Checksum
function eps_checksum(accNumber) {
return 10 - (accNumber.split("").map((digit, index) => digit*( Number((index+1)%2==0)+1) ).reduce((a,b)=> a+(b%10)+Number(b>10)) % 10 );
}
<?php
$zh_hk = [
"一" => "yat",
"丁" => "ding",
"七" => "chat",
"万" => "waan",
"丈" => "jeung",
"三" => "sham",
"上" => "seung",
@extralam
extralam / login.blade.php
Created August 1, 2019 05:40
Laravel-admin Custom Login view
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{config('admin.title')}} | {{ trans('admin.login') }}</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
@if(!is_null($favicon = Admin::favicon()))
@extralam
extralam / ApiLogController.php
Last active March 26, 2019 09:52
Base Grid Controller on Laravel-admin
<?php
namespace App\Admin\Controllers\Lam;
use App\Models\ApiLog;
class ApiLogController extends BaseGridController
{
public function __construct()
@extralam
extralam / BaseModel.php
Last active December 25, 2018 11:07
Laravel Eloquent Model Enhancement.
<?php
/**
* User: extralam
* Date: 24/12/2018
* Time: 5:47 PM
*/
namespace App\Models;
@extralam
extralam / README.md
Created December 13, 2018 09:55 — forked from FokkeZB/README.md
URL schemes for iOS and Android (2/2)