Skip to content

Instantly share code, notes, and snippets.

View yowcow's full-sized avatar
💮
Job well done

Yoko OYAMA yowcow

💮
Job well done
View GitHub Profile
@yowcow
yowcow / restart-spotlight-indexing.sh
Created September 20, 2017 02:31
Stop and start macOS spotlight indexing
# sudo required
# stop indexing
mdutil -a -i off
# start indexing
mdutil -a -i on
@yowcow
yowcow / parse-uri-query-repl.js
Created September 12, 2017 03:04
Parse URI query on Node.js REPL
const url = require('url')
const qs = require('querystring')
const givenURL = 'http://hogefuga.com/?foo=bar&hoge=fuga'
qs.parse(url.parse(givneURL).query)
@yowcow
yowcow / keybase.md
Last active February 8, 2021 01:12
keybase.md

Keybase proof

I hereby claim:

  • I am yowcow on github.
  • I am yowcow (https://keybase.io/yowcow) on keybase.
  • I have a public key whose fingerprint is 4E54 4FA3 A411 C0E2 FA93 346A 1C52 C77C 6A2B 498F

To claim this, I am signing this object:

@yowcow
yowcow / docker-mysql-onetime.sh
Created July 28, 2017 07:18
Create one-time MySQL database
docker run --rm --name test-mysql -e MYSQL_ROOT_PASSWORD=hogehoge -p 3336:3306 -d mysql:5.7
@yowcow
yowcow / vim.mk
Last active August 18, 2017 04:25
Install vim from source
VERSION ?= 8.0.0705
ARCHIVE = v$(VERSION).tar.gz
UNARCHIVED = vim-$(VERSION)
PREFIX = /usr/local/$(UNARCHIVED)
.PHONY: all install current
all: $(UNARCHIVED)
cd $< && \
./configure \
@yowcow
yowcow / vast-client-player.js
Last active June 30, 2017 10:06
Minimalistic VAST Ad Player
var createVideoElement = function (w, h) {
var videoEl = document.createElement('video');
videoEl.setAttribute('width', w);
videoEl.setAttribute('height', h);
videoEl.setAttribute('muted', true);
videoEl.style.cssText = 'cursor: pointer; background-color: #000;';
return videoEl;
};
var createSourceElement = function (src, type) {
@yowcow
yowcow / ssh-port-forwarding.sh
Last active June 19, 2017 05:06
SSH Port Forwarding
# Local Forwarding
# For instance, connect to target mysql from localhost via proxying remote host:
# ssh -L <Local Port>:<Tartet Host>:<Target Host Port> Proxying Remote Host
ssh -L 3307:my-database-server:3306 my-app-server
# Remote Forwarding
# For instance, forwarding remote host port to target host port:
# ssh -R <Target Host Port>:<Target Host>:<Remote Host Port> Remote Host
ssh -R 5001:my-another-app-server:5000 my-app-server
@yowcow
yowcow / list-process-swap.sh
Last active April 24, 2025 10:07
List process swap
for file in $(find /proc -maxdepth 2 -type f -name "status"); do /proc
cat $file | awk '/Name|Swap/ { printf $2 " " $3 "\t" } END { print "" }';
done
@yowcow
yowcow / datetime-vs-posix-strftime.pl
Created April 27, 2017 09:01
DateTime vs. POSIX::strftime()
use strict;
use warnings;
use Benchmark qw(cmpthese);
use DateTime;
use POSIX;
cmpthese(
200_000 => {
'DateTime' => sub {
DateTime->from_epoch(
@yowcow
yowcow / hash-key-access.pl
Created April 25, 2017 08:28
Hash key access
use strict;
use warnings;
use Benchmark qw(cmpthese);
sub hv {
my ($ref, $key, $default) = @_;
defined $ref && exists $ref->{$key} ? $ref->{$key} : $default;
}
my $hash = {