Skip to content

Instantly share code, notes, and snippets.

View k-khr's full-sized avatar

Kenta Kihara k-khr

View GitHub Profile
@k-khr
k-khr / concat_ipynb_output.bash
Last active September 12, 2022 05:45
jqを使ってipynbの長すぎてバラバラになった出力を結合するスクリプト on macOS
# .cells[123] は出力したいセルの番号に変える
jq '.cells[123] | reduce .outputs[] as $e ([]; . + $e.text) | join("")' < foo.ipynb | perl -pe "s/%/%%/g" | xargs printf

Keybase proof

I hereby claim:

  • I am k-khr on github.
  • I am kihara (https://keybase.io/kihara) on keybase.
  • I have a public key ASCY2PnvMS_Iqm940fwsWaQW1blb3AzPPtN1CZpBcrTvVAo

To claim this, I am signing this object:

#!/bin/bash
PID=$1
while [ ! -z "`ps aux | awk '{print $2}' | grep -o $PID`" ]; do
sleep 5
done
echo -e $'\e]9;Process '${PID}' finished\007'
@k-khr
k-khr / show_svgz.py
Last active January 10, 2021 19:43
open a .svgz file in a web browser
#!/usr/bin/env python3
"""
show_svgz.py
open a .svgz file in a web browser
Usage:
$ show_svgz.py foo.svgz
"""
@k-khr
k-khr / firefox_clean_history.py
Last active December 25, 2020 01:24
Remove firefox history with keywords
#!/usr/bin/env python3
import sqlite3
# Edit here
PLACES_SQLITE_PATH = '/Users/$USER/Library/Application Support/Firefox/Profiles/.../places.sqlite' # find path at about:profiles
DEL_KEYWORDS = [
"youtube",
"youtu.be",
"twitter",
@k-khr
k-khr / optpng.py
Last active November 26, 2020 09:00
#!/usr/bin/env python3
#
# Usage:
# optpng [-h] [-i] [-vf filter] [-s scale] file [file ...]
#
import argparse
import os
import subprocess
def exec(infile, in_place = False, vf = None, scale = None):
PROGRAM main
IMPLICIT NONE
INTEGER, PARAMETER :: slen = 1024
CHARACTER(LEN=slen) :: a
a = "./foo/bar/baz.qux"
WRITE(*, *) TRIM(get_basename(a, ext=.TRUE.))
WRITE(*, *) TRIM(get_basename(a))
@k-khr
k-khr / gp_np.py
Last active June 1, 2020 14:46
gnuplot と numpy 連携
#!/usr/bin/env python3
# USAGE
# $ ./gp_np.py
#
# +----------------------------------------------------------------------+
# 16 |-+ + + + + + + B +-|
# | y=2x (w linespoints) ***A*** |
# 14 |-+ y=4x (w points) B +-|
# | |
#!/usr/bin/env ruby
palette_path = "#{File.basename(ARGV[0])}_palette.png"
outfile = "#{File.basename(ARGV[0])}.gif"
ffmpeg_command = "ffmpeg -i #{ARGV[0]} -vf 'palettegen' #{palette_path} && ffmpeg -i #{ARGV[0]} -i #{palette_path} -filter_complex 'paletteuse' -r 7 #{outfile}"
%x(#{ffmpeg_command})
%x(rm #{palette_path})
@k-khr
k-khr / 90-custom-keyboard.hwdb
Created October 31, 2018 14:07
[Linux] Caps Lock を全角半角にするやつ (udev)
# /etc/udev/hwdb.d/90-custom-keyboard.hwdb
# https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes
# for USB keyboard
# `lsusb` to fill id
evdev:input:b0003v<vendor_id>p<product_id>e<version_id>
KEYBOARD_KEY_70039=zenkakuhankaku
# for note PC
evdev:atkbd:dmi:*