Skip to content

Instantly share code, notes, and snippets.

Avatar

USHITO Hiroyuki iso2022jp

View GitHub Profile
@iso2022jp
iso2022jp / ExcelWriter.php
Created Dec 4, 2020
ZipArchive 依存の単一シート Excel 出力
View ExcelWriter.php
<?php
declare(strict_types=1);
namespace Damn\IO;
use ZipArchive;
class ExcelWriter
{
@iso2022jp
iso2022jp / char-volume-ranking.js
Created Aug 25, 2020
文字の占有率ランキング
View char-volume-ranking.js
document.addEventListener('DOMContentLoaded', _ => {
const x0208 = [ 0x3000,0x3001,0x3002,0xFF0C,0xFF0E,0x30FB,0xFF1A,0xFF1B,0xFF1F,0xFF01,0x309B,0x309C,0x00B4,0xFF40,0x00A8,0xFF3E,0xFFE3,0xFF3F,0x30FD,0x30FE,0x309D,0x309E,0x3003,0x4EDD,0x3005,0x3006,0x3007,0x30FC,0x2015,0x2010,0xFF0F,0x005C,0x301C,0x2016,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,0x201D,0xFF08,0xFF09,0x3014,0x3015,0xFF3B,0xFF3D,0xFF5B,0xFF5D,0x3008,0x3009,0x300A,0x300B,0x300C,0x300D,0x300E,0x300F,0x3010,0x3011,0xFF0B,0x2212,0x00B1,0x00D7,0x00F7,0xFF1D,0x2260,0xFF1C,0xFF1E,0x2266,0x2267,0x221E,0x2234,0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFFE5,0xFF04,0x00A2,0x00A3,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,0x2606,0x2605,0x25CB,0x25CF,0x25CE,0x25C7,0x25C6,0x25A1,0x25A0,0x25B3,0x25B2,0x25BD,0x25BC,0x203B,0x3012,0x2192,0x2190,0x2191,0x2193,0x3013,0x2208,0x220B,0x2286,0x2287,0x2282,0x2283,0x222A,0x2229,0x2227,0x2228,0x00AC,0x21D2,0x21D4,0x2200,0x2203,0x2220,0x22A5,0x2312,0x2202,0x2207,0x2261,0x2252,0x226A,0x226B,0x221A,0x223D,0x221D,0x223
@iso2022jp
iso2022jp / char-box-ranking.js
Created Aug 25, 2020
文字のバウンディングボックスランキング
View char-box-ranking.js
document.addEventListener('DOMContentLoaded', _ => {
const x0208 = [ 0x3000,0x3001,0x3002,0xFF0C,0xFF0E,0x30FB,0xFF1A,0xFF1B,0xFF1F,0xFF01,0x309B,0x309C,0x00B4,0xFF40,0x00A8,0xFF3E,0xFFE3,0xFF3F,0x30FD,0x30FE,0x309D,0x309E,0x3003,0x4EDD,0x3005,0x3006,0x3007,0x30FC,0x2015,0x2010,0xFF0F,0x005C,0x301C,0x2016,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,0x201D,0xFF08,0xFF09,0x3014,0x3015,0xFF3B,0xFF3D,0xFF5B,0xFF5D,0x3008,0x3009,0x300A,0x300B,0x300C,0x300D,0x300E,0x300F,0x3010,0x3011,0xFF0B,0x2212,0x00B1,0x00D7,0x00F7,0xFF1D,0x2260,0xFF1C,0xFF1E,0x2266,0x2267,0x221E,0x2234,0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFFE5,0xFF04,0x00A2,0x00A3,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,0x2606,0x2605,0x25CB,0x25CF,0x25CE,0x25C7,0x25C6,0x25A1,0x25A0,0x25B3,0x25B2,0x25BD,0x25BC,0x203B,0x3012,0x2192,0x2190,0x2191,0x2193,0x3013,0x2208,0x220B,0x2286,0x2287,0x2282,0x2283,0x222A,0x2229,0x2227,0x2228,0x00AC,0x21D2,0x21D4,0x2200,0x2203,0x2220,0x22A5,0x2312,0x2202,0x2207,0x2261,0x2252,0x226A,0x226B,0x221A,0x223D,0x221D,0x223
@iso2022jp
iso2022jp / measure-text-preview.js
Last active Aug 25, 2020
CanvasRenderingContext2D.measureText のテスト
View measure-text-preview.js
document.addEventListener('DOMContentLoaded', _ => {
const canvas = document.querySelector('#canvas')
const context = canvas.getContext('2d')
context.font = '300px "Yu Mincho"'
context.fillStyle = 'white'
context.fillRect(0, 0, canvas.width, canvas.height)
context.textBaseline = 'top'
@iso2022jp
iso2022jp / from_base64.sql
Created Sep 5, 2019
FROM_BASE64 custom function for old MySQL
View from_base64.sql
DROP FUNCTION IF EXISTS FROM_BASE64;
DELIMITER ;;
CREATE FUNCTION FROM_BASE64 (base64 BLOB) RETURNS BLOB DETERMINISTIC SQL SECURITY INVOKER
BEGIN
DECLARE plain BLOB DEFAULT '';
DECLARE o INTEGER DEFAULT 0;
View rdp-ping.sh
exec 3<>/dev/tcp/$server/3389
xxd -r -p <<REQ >&3
03 00 00 2a
25 e0 00 00 00 00 00
43 6f 6f 6b 69 65 3a 20 6d 73 74 73 68 61 73 68 3d 70 69 6e 67 0d 0a
01 00 08 00 00 00 00 00
REQ
xxd -l 11 <&3 > debug.log
@iso2022jp
iso2022jp / date-range-regexp.js
Last active Sep 17, 2019
Make regex for date range (YYYY-MM-DD to YYYY-MM-DD)
View date-range-regexp.js
const makeDateRangeRegexp = (from, to) => {
const indices = Array.from('01235689')
const unders = indices.map(i => {
const digit = from[i]
return digit > 0 ? from.slice(0, i) + `[0-${digit - 1}]` : null
})
const overs = indices.map(i => {
@iso2022jp
iso2022jp / $grep.js
Created Jul 22, 2017
何か探索するアレ
View $grep.js
function $grep(o, v, p = '') {
$grep.known = []
return $grep.find(o, v, p)
}
$grep.match = function (e, v) {
return v instanceof RegExp ? typeof e !== 'object' && typeof e !== 'function' && v.test(String(e)) : e === v
}
$grep.pandora = function (key) {
@iso2022jp
iso2022jp / bootstrap-partial.php
Last active Aug 29, 2015
Code fragments for CakePHP w/ PHP Built-in Web Server
View bootstrap-partial.php
<?php
// for built-in server
if (php_sapi_name() == 'cli-server') {
// log access like a built-in router
register_shutdown_function(function () {
$status = http_response_code();
$escape = '';
@iso2022jp
iso2022jp / sprintf.bas
Created May 28, 2014
sprintf for VB6: 若かりし頃のコード発掘
View sprintf.bas
Option Explicit
Public Declare Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long)
Public Function sprintf(ByRef FormatString As String, ParamArray Arguments() As Variant) As String
Dim h As OLE_HANDLE
Dim hTerm As OLE_HANDLE