Skip to content

Instantly share code, notes, and snippets.

Regex for matching ALL Japanese common & uncommon Kanji (4e00 โ€“ 9fcf) ~ The Big Kahuna!
([ไธ€-้พฏ])
Regex for matching Hirgana or Katakana
([ใ-ใ‚“ใ‚ก-ใƒณ])
Regex for matching Non-Hirgana or Non-Katakana
([^ใ-ใ‚“ใ‚ก-ใƒณ])
Regex for matching Hirgana or Katakana or basic punctuation (ใ€ใ€‚โ€™)
import { useOutsideClick } from './useOutsideClick';
export const MyComponent = () => {
const ref = useOutsideClick(() => {
console.log('Clicked outside of MyComponent');
});
return (
<div ref={ref}>
My Component
@sprobejames
sprobejames / clone-template.sh
Created March 19, 2024 23:33
Bash script to clone a template and merging the commit history into one.
#!/bin/bash
# Create Empty Directory
mkdir -p FOLDER_NAME
cd FOLDER_NAME
git init
git fetch --depth=1 -n REPO_REMOTE_ORIGIN
git reset --hard $(git commit-tree FETCH_HEAD^{tree} -m "Initial Commit")
@sprobejames
sprobejames / SetLocale.md
Created February 6, 2024 01:46 — forked from xarmengol/SetLocale.md
Set locale for authenticated users in laravel

Intro

What we want to do is to set the locales of a laravel 5.6 application, by depending of the language of the authenticated user. We store the language preferences of a user on the database, in the users table.

Steps

Create a new Middleware:

php artisan make:middleware AuthUserSetLocale
@sprobejames
sprobejames / filesize.sh
Last active January 26, 2024 07:26
Linux find largest file in directory recursively
# @see https://www.cyberciti.biz/faq/linux-find-largest-file-in-directory-recursively-using-find-du/
# Linux find a biggest files in /
sudo du -a /dir/ | sort -n -r | head -n 20
sudo du -a / 2>/dev/null | sort -n -r | head -n 20
# Linux find large files quickly with bash alias
## shell alias ##
alias ducks='du -cks * | sort -rn | head'
### run it ###
ducks
@sprobejames
sprobejames / Dockerfile
Created September 22, 2023 00:51 — forked from ptflp/Dockerfile
docker php install imagemagick alpine 3.8
FROM php:7.0-fpm-alpine3.8
RUN apk add --no-cache --virtual .build-deps \
libxml2-dev \
shadow \
autoconf \
g++ \
make \
&& apk add --no-cache imagemagick-dev imagemagick \
&& pecl install imagick-beta \
const url = `https://zipcloud.ibsnet.co.jp/api/search`;
const jpPostalToAddress = async (postalCode) => {
return await fetch(`${url}?zipcode=${postalCode}`)
.then(r => r.json())
.then(({ data }) => data);
};
module.exports = jpPostalToAddress;
const fs = require("fs");
const iconv = require("iconv-lite");
const detectCharacterEncoding = require('detect-character-encoding');
const convertCsvFile = async (sourceFilePath, outputFilePath, outputEncoding = 'UTF8') => {
return await new Promise(resolve => {
const fileBuffer = fs.readFileSync(sourceFilePath);
const { encoding } = detectCharacterEncoding(fileBuffer);
const streamReader = fs.createReadStream(sourceFilePath)
const streamWriter = fs.createWriteStream(outputFilePath)
FROM node:slim
# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
@sprobejames
sprobejames / gist:0ff98370b0a0092a3346cce9610aafbe
Created October 13, 2022 07:45 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: ๐Ÿ˜„ :smile: ๐Ÿ˜† :laughing:
๐Ÿ˜Š :blush: ๐Ÿ˜ƒ :smiley: โ˜บ๏ธ :relaxed:
๐Ÿ˜ :smirk: ๐Ÿ˜ :heart_eyes: ๐Ÿ˜˜ :kissing_heart:
๐Ÿ˜š :kissing_closed_eyes: ๐Ÿ˜ณ :flushed: ๐Ÿ˜Œ :relieved:
๐Ÿ˜† :satisfied: ๐Ÿ˜ :grin: ๐Ÿ˜‰ :wink:
๐Ÿ˜œ :stuck_out_tongue_winking_eye: ๐Ÿ˜ :stuck_out_tongue_closed_eyes: ๐Ÿ˜€ :grinning:
๐Ÿ˜— :kissing: ๐Ÿ˜™ :kissing_smiling_eyes: ๐Ÿ˜› :stuck_out_tongue: