Skip to content

Instantly share code, notes, and snippets.

View mpyw's full-sized avatar
🏠
Working from home

mpyw mpyw

🏠
Working from home
View GitHub Profile
@mpyw
mpyw / qiita_nonsense_lgtm_button_killer.user.js
Last active March 13, 2020 19:54
qiita_nonsense_lgtm_button_killer.user.js
// ==UserScript==
// @name Qiita Nonsense LGTM Button Killer
// @namespace https://github.com/mpyw
// @version 0.6
// @description Qiita の LGTM を倒す
// @author mpyw
// @match https://qiita.com/*
// @grant none
// ==/UserScript==
@mpyw
mpyw / array_splice_assoc.php
Last active January 6, 2022 02:16
array_splice_assoc.php
<?php
// https://stackoverflow.com/questions/16585502/array-splice-preserving-keys/70576992#70576992
function array_splice_assoc(array &$input, int|string $offset, ?int $length = null, $replacement = []): array
{
// Normalize offset
$offset = match (true) {
is_string($offset) => array_flip(array_keys($input))[$offset] ?? throw new OutOfBoundsException(),
$offset < 0 => count($input) + $offset,