Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo "🚿 Starting CleanMyMac Lite (Safe Version)"
confirm() {
read -p "$1 [y/N]: " response
[[ "$response" == "y" || "$response" == "Y" ]]
}
safe_rm() {
@wasikarn
wasikarn / .ideavimrc
Last active June 17, 2025 14:19
The Essential IdeaVim Remaps & Plugins
""" ------------------------------------------
""" The Essential IdeaVim Remaps
""" https://towardsdatascience.com/the-essential-ideavim-remaps-291d4cd3971b
""" ------------------------------------------
""" Editing and Reloading the Config
set clipboard+=unnamed
set clipboard+=ideaput
nnoremap \e :e ~/.ideavimrc<CR>
nnoremap \r :action IdeaVim.ReloadVimRc.reload<CR>
@wasikarn
wasikarn / .php-cs-fixer.php
Last active April 27, 2022 16:19
Use PHP-CS-FIXER for git hook pre commit
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@wasikarn
wasikarn / bump-version.sh
Created November 8, 2021 08:43
Bump version for release
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"
<?php
use App\Models\PointTransaction;
$maxAtOneTime = 30;
$transactionCount = 38490;
$pages = ceil($transactionCount / $maxAtOneTime);
$transactions = collect();
for ($i = 1; $i < $pages + 1; $i++) {
@wasikarn
wasikarn / randomTabeinRod.php
Last active February 8, 2021 17:25
สุ่มตัวเลขป้ายทะเบียนรถและตัดเลขที่ไม่ต้องการออก
<?php
$categoryCharactors = [
1 => ['ก', 'ด', 'ถ', 'ท', 'ภ'],
2 => ['ข', 'บ', 'ป', 'ง', 'ช'],
3 => ['ต', 'ฒ', 'ฆ'],
4 => ['ค', 'ธ', 'ร', 'ญ', 'ษ'],
5 => ['ฉ', 'ณ', 'ฌ', 'น', 'ม', 'ห', 'ฮ', 'ฎ', 'ฬ'],
6 => ['จ', 'ล', 'ว', 'อ'],
7 => ['ศ', 'ส'],
@wasikarn
wasikarn / random-string.php
Last active May 7, 2020 14:33
Generate random string very much at a time and ignore character.
<?php
$startTime = microtime(true);
function generateRange(int $range = 1, int $length = 10)
{
for ($i = 0; $i < $range; $i++) {
yield generateCode($length);
}
}
@wasikarn
wasikarn / prepend-ticket-number.py
Created July 17, 2019 16:09
Automatically Prefixing Git Commit Messages with an Issue Number From the Current Branch Name
#!/usr/bin/env python
from __future__ import print_function
import sys
import os
import re
regex = re.compile(r"^[A-Za-z]+-[0-9]+")
regex_formatted = re.compile(r"^[\[][A-Za-z]+-[0-9]+[\]][:]")
def main():
@wasikarn
wasikarn / countries.json
Created April 6, 2019 15:29
Countries with calling code
[
{
"name": "Afghanistan",
"calling_code": "+93",
"code": "AFG",
"native_common": "افغانستان"
},
{
"name": "Albania",
"calling_code": "+355",
@wasikarn
wasikarn / AuthenticatesUsers.php
Last active October 10, 2018 18:32
Example for register and login by Laravel Passport
<?php
namespace App\Http\Controllers\Traits;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
trait AuthenticatesUsers