Skip to content

Instantly share code, notes, and snippets.

View johnroyer's full-sized avatar

Zero Huang johnroyer

View GitHub Profile
// neutral family
// U+1F46A
// length: 2
> 👪
// ZWJ sequence: family (man, woman, boy)
// U+1F468 + U+200D + U+1F469 + U+200D + U+1F466
// 👨‍ + U+200D + 👩‍ + U+200D + 👦
// length: 8
> ‍👨‍👩‍👦
// ZWJ sequence: family (woman, woman, girl)
@johnroyer
johnroyer / PHPStorm-Darcula-customized.icls
Created February 18, 2022 13:43
Jetbrains IDE syntax highlight scheme without italic
<scheme name="Darcula" version="142" parent_scheme="Darcula">
<metaInfo>
<property name="created">2022-02-18T21:35:09</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2021.3.2.0.0</property>
<property name="modified">2022-02-18T21:35:29</property>
<property name="originalScheme">_@user_Darcula</property>
</metaInfo>
<attributes>
<option name="DEFAULT_DOC_COMMENT">
@johnroyer
johnroyer / Sitemap.php
Last active February 17, 2022 06:17
Sitemap Middleware for Laravel
<?php
/**
* This file is orginzed from @FDisk from StackOverflow
* @see https://stackoverflow.com/a/28608156/8681141
*/
namespace App\Http\Middleware;
use Closure;
@johnroyer
johnroyer / raidchecker.sh
Created January 11, 2022 15:39
alert via Mailgun if RAID failed
#!/usr/bin/env bash
DEVICE="/dev/md/mdX"
API_KEY="mailgun-api-key"
FROM='user@your.domain'
TO='user@gmail.com'
SUB="在 HOSTNAME 上偵測到 RAID 發生問題"
TEXT="偵測到 HOSTNAME 上的 RAID $DEVICE 異常<br><br>"
@johnroyer
johnroyer / readme.md
Last active December 7, 2021 05:03
Simple PHP script to convert jpeg / gif / png to webp

Introduction

Using PHP GD library to covert common type images to webp format.

Guide

Download script:

sudo wget https://gist.githubusercontent.com/johnroyer/85d0631d175b85a7befa3714855f4ab9/raw/3d70527b4c66279eaa97d997f84f1e42a51ccf18/webp.php -O /bin/webp
@johnroyer
johnroyer / getIp.php
Created June 8, 2021 05:03
get user IP
<?php
function getServerKey(string $key): string
{
if (array_key_exists($key, $_SERVER)) {
return $_SERVER[$key];
}
return '';
}
$orderedKey = [
@import url(../../../stylesheets/application.css);
/* A1 theme version 2.0.0 by Kirill Bezrukov www.redmineup.com */
#header {
background: #394956;
min-height: 5em;
padding: 0px;
min-height: initial;
#!/usr/bin/env bash
function alert() {
# mail notification
curl -v -s --user 'api:MAILGUN_API_KEY' \
https://api.mailgun.net/v3/YOUR_DOMAIN/messages \
-F from='Monitor <you@gmail.com>' \
-F to=your@gmail.com \
-F subject="low momey allert - monitor" \
--form-string html="<span style=\"font-size: 1.5em;\">memory left: $1 MB <br> SWAP left: $2 MB</span>"
@johnroyer
johnroyer / main.js
Created November 28, 2019 10:50
try to new Pin object
var webduino = require('webduino-js');
board = new webduino.WebArduino('Ge8pn');
board.on('ready', function (board) {
var pin = new webduino.core.Pin(board, 10, Pin.DOUT);
board.systemReset();
board.samplingInterval = 250;
var replay = new webduino.module.Relay(board, 10);
@johnroyer
johnroyer / php-info.log
Created September 25, 2019 07:20
PHP segment fault, ENV dump
feature/controller-shipping-refactor
027d43e6f1ddb261cb0021695af6bca42a73a9c0 is the first bad commit
commit 027d43e6f1ddb261cb0021695af6bca42a73a9c0
Author: Zero <john.royer@gmail.com>
Date: Mon Sep 23 10:14:43 2019 +0800
Catch exception from SplitShipmentService
app/Http/Controllers/ApiShipmentController.php | 6 +++++-