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
const main = async () => {
try {
const ret = await new Promise(() => {
setTimeout(() => {
throw new Error('error in setTimeout');
}, 1);
});
console.log(`promise succeeded: ${ret}`);
} catch (err: unknown) {
console.error(`promise failed: ${err}`);
Regexp Lookaround Memo
======================
Lookahead
---------
```
❯ echo "hoge\nfuga\nhoge1\nfuga11\nhoge111\nfuga1111" | grep -P 'hoge(?=\d+)'
hoge1
hoge111
CN := test.x28.co
all: test.key test.crt
%.key:
openssl genrsa \
-out $@ \
2048
%.crt: %.key
@yowcow
yowcow / myproc.erl
Last active October 30, 2022 09:22
-module(myproc).
-include_lib("kernel/include/logger.hrl").
-export([
start_link/0
]).
%%
%% {ok, Pid} = myproc:start_link()
<?php
interface RandomGeneratorInterface
{
public function getString(int $length): string;
public function getBytes(int $length): string;
}
class RandomFileReader implements RandomGeneratorInterface
{
@yowcow
yowcow / random-hex.sh
Created May 19, 2022 07:55
Print random hex string
head -c 4 /dev/urandom | perl -Mfeature=say -ne 'say unpack("h*", $_);'
@yowcow
yowcow / Makefile
Last active February 1, 2022 10:00
Install/Uninstall Google Chrome (to run headless Chrome on CLI)
PKG := google-chrome-stable
DEB := $(PKG)_current_amd64.deb
all: $(DEB)
$(DEB):
curl -L https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o $@
info: $(DEB)
dpkg -I $<
@yowcow
yowcow / xmllint-format.sh
Created June 21, 2021 04:51
Prettify XML command line
cat input.xml | xmllint --format -
@yowcow
yowcow / kensington-slimblade.sh
Last active April 9, 2021 23:42
X11 Kensington Slimblade Trackball button mapping
#!/bin/sh
#
# Reference: https://unix.stackexchange.com/questions/453069/configuring-kensington-slimblade-in-linux
#
# Kensington Slimblade Trackball Button IDs:
#
# .------+------.
# | 2 | 8 |
# | .--+--. |
# +---+ 4/5 +---+
@yowcow
yowcow / xrandr.sh
Last active April 7, 2021 23:35
Xrandr
# list available outputs
xrandr
xrandr --query
# set HDMI-2 output as 3840x2160, to the left of eDP-1
xrandr --output HDMI-2 --mode 3840x2160 --left-of eDP-1
# set HDMI-2 output as 3840x2160, to mirror eDP-1
xrandr --output HDMI-2 --mode 3840x2160 --same-as eDP-1