Skip to content

Instantly share code, notes, and snippets.

View hidsh's full-sized avatar

yakshaver hidsh

View GitHub Profile
@hidsh
hidsh / zmk-create-skeleton.v
Last active February 15, 2025 08:36
creates skeleton files for zmk template
// SPDX-License-Identifier: CC0-1.0
//
// zmk-create-skeleton.v
//
// Creates skeleton files for the ZMK template (https://github.com/zmkfirmware/unified-zmk-config-template)
//
// ./boards/shields/KBD_NAME/
// Kconfig.shield
// Kconfig.defconfig
// KBD_NAME.overlay
@hidsh
hidsh / show-path.sh
Created December 17, 2024 01:35
linux: list $PATH env variable
echo $PATH | tr ':' '\n'
@hidsh
hidsh / part-of-sway-config
Created December 17, 2024 01:13
sway: show keybinding via fuzzel
# somewhere like `~/.config/sway/config.d/default`
#
# add a following line to the end of sway config
bindsym $mod+k exec PATH/TO/sway-show-keybindings-fuzzel.sh
@hidsh
hidsh / sway-show-keybindings.sh
Created December 16, 2024 02:27
shell script: cheat sheet for keybindings of sway
#!/bin/zsh
s=$(rg '^ *bindsym +(.+)$' ~/.config/sway/config.d/default | sed -e 's/^ *bindsym *//' | sed 's/ \+/\t/' | sed 's/\+/ /g' | awk '{printf("%25s\t%s\n", $1, $2)}' FS='\t')
w=`expr "$COLUMNS" - 16`
s=$(echo ${s} | cut -c -${w})
echo $s | less
@hidsh
hidsh / part-of-.zshrc
Last active December 24, 2024 01:00
show command help w/ fzf
h() {
local tmp_file=/tmp/h
local cmd=''
if [ "$#" -eq 0 ]; then
cmd=$(echo $PATH | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -executable 2>/dev/nul
l | xargs -n 1 basename | fzf);
elif [ "$#" -eq 1 ]; then
cmd=$1
else
@hidsh
hidsh / sed-example.txt
Last active December 9, 2024 08:15
linux: sed で全置換
$rg --no-heading bat43 # check
rat43.zmk.yml:2:id: bat43
rat43.zmk.yml:5:url: https://kbd.dailycraft.jp/bat43/
Kconfig.shield:5: def_bool $(shields_list_contains,bat43)
$sed -i -e 's/bat43/rat43/' * # replace bat43 --> rat43
$rg --no-heading bat43 # confirm
$rg --no-heading rat43 # confirm
@hidsh
hidsh / rename-example.txt
Last active December 9, 2024 07:14
linux: renameコマンドなんてあったんや…
$ls -1
bat43.keymap
bat43.overlay
bat43.zmk.yml
Kconfig.defconfig
Kconfig.shield
$rename -n -v bat43 rat43 bat43* # dry run
`bat43.keymap' -> `rat43.keymap'
`bat43.overlay' -> `rat43.overlay'
@hidsh
hidsh / log-failed.txt
Last active December 8, 2024 15:38
error log, west build 1key shield
root@feb003495f7a:/workspaces/zmk-modules/zmk-modules/1key-zmk-shield# west build -s /workspaces/zmk/app -p -b seeeduino_xiao -- -DSHIELD=1key -DZMK_CONFIG=$PWD/config
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /workspaces/zmk/app
-- CMake version: 3.30.0
-- Found Python3: /usr/bin/python3 (found suitable version "3.12.3", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /root/.cache/zephyr
-- Zephyr version: 3.5.0 (/workspaces/zmk/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- ZMK Config directory: /workspaces/zmk-modules/zmk-modules/1key-zmk-shield/config
@hidsh
hidsh / PKGBUILD
Last active September 11, 2024 02:07
PKGBUILD for emacs-29.4
##emacs-29.3 Maintainer: Pedro A. López-Valencia <https://aur.archlinux.org/users/toropisco>
################################################################################
# CAVEAT LECTOR: This PKGBUILD is highly opinionated. I give you
# enough rope to hang yourself, but by default it
# only enables the features I use.
#
# TLDR: yaourt users, cry me a river.
#
# Everyone else: do not update blindly this PKGBUILD. At least
@hidsh
hidsh / README.md
Last active July 22, 2024 03:49
arduino example: calling Serial.println() from a C source file

C言語からArduinoのSerialオブジェクトを使うには

  1. C++のソースにSerialオブジェクトを使ったラッパー関数を作る (my_log() @sub.cpp)
  2. Cのソースからそのラッパー関数をコールするラッパー関数を作る (my_log_c() @sub.c)

という、二段構えのラップラップが必要になる。

C++から直接Serialオブジェクトを使うときに比べてめんどいけど、このやり方を覚えるとArduinoだけでなく他の言語でも使えるので応用が効くはず。

元ネタ:https://stackoverflow.com/questions/66632376/how-to-call-serial-print-from-c-file-in-arduino-ide