Skip to content

Instantly share code, notes, and snippets.

@imekachi
imekachi / line-copy-username.js
Last active March 2, 2021 07:46
Custom JS, add a button to copy username in Line 1-on-1 chat
function getName() {
return getNameElement().textContent
}
function getNameElement() {
return document.querySelector('#_chat_header_area h1')
}
function copyText(text) {
const inputId = 'copy-input'
@imekachi
imekachi / partial-pure.zsh
Created November 27, 2020 07:27
Add node version, yarn version to pure prompt
# add before prompt_pure_preprompt_render
prompt_node_npm() {
local nodeVersion=`node --version | sed -e "s/v//g"`
local yarnVersion=`yarn --version`
preprompt_parts+="%F{green}⬢%f $nodeVersion 📦 $yarnVersion"
}
## add below
## Git pull/push arrows.
# if [[ -n $prompt_pure_git_arrows ]]; then
for aptx:
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
for AAC:
sudo defaults write bluetoothaudiod "Enable AAC codec" -bool true
for verification:
sudo defaults read bluetoothaudiod
@imekachi
imekachi / air75-vim-arrows.json
Last active October 29, 2021 16:24
NuPhy Air75 fn + h j k l to arrow keys with Karabiner element complex modifications.
{
"title": "VIM arrows",
"rules": [
{
"description": "fn + h j k l to arrow keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "h",
@imekachi
imekachi / alfred-iterm
Created April 20, 2022 15:12
Run terminal commands on iTerms via Alfred
-- This is v0.7 of the custom script for AlfredApp for iTerm 3.1.1+
-- created by Sinan Eldem www.sinaneldem.com.tr
on alfred_script(q)
if application "iTerm2" is running or application "iTerm" is running then
run script "
on run {q}
tell application \"iTerm\"
activate
try
@imekachi
imekachi / trackpad-pairing-toggle.md
Created May 30, 2022 15:01
Switch magic trackpad to pair with another mac.
  1. install blueutil
    brew install blueutil
  2. Find your trackpad address by running
    blueutil --paired
    
    # address: 3c-a6-f6-b9-c6-c7, connected (master, 0 dBm), not favourite, paired, name: "Magic Trackpad", recent access date: 2022-05-30 2:41:17 PM +0000
@imekachi
imekachi / .ideavimrc
Created June 27, 2022 02:48
Ideavim config and key mapping to make multi cursor work like default keymaps
set number relativenumber
set multiple-cursors
set easymotion
set surround
set sneak
set ideajoin
set ReplaceWithRegister
set commentary
" Remap multiple-cursors shortcuts to match terryma/vim-multiple-cursors
export type RequireAtLeastOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Omit<T, K>>
}[keyof T]
/**
* This is to make Omit works correctly with union type.
* For example,
* type A = {
* key1: 'A'
* key2: string
@imekachi
imekachi / type-safe-lodash-set.ts
Created August 9, 2023 02:43
Type-safe lodash set
import _set from 'lodash/set'
export const set = <
Obj extends UnknownObject,
KeyPath extends Path<Obj>,
Value extends PathValue<Obj, KeyPath>
>(
obj: Obj,
path: KeyPath,
value: Value
@imekachi
imekachi / disable-apple-music-play-btn.md
Created August 29, 2023 03:19
Disable Apple music from opening when pressing play / pause / media keys on Mac and Headphones

Run this command to disable it

# Disables it immediately
launchctl bootout "gui/$(id -u "${USER}")/com.apple.rcd"
# Prevents reactivating on restart
launchctl disable "gui/$(id -u "${USER}")/com.apple.rcd"

To revert to the default behavior