Skip to content

Instantly share code, notes, and snippets.

@innyso
innyso / hhkb_reset_bluetooth_pairing.md
Last active April 8, 2024 11:58
#hhkb #bluetooth #pairing #keyboard

Reset bluetooth hhkb pairing

- go into system preference > keyboard > setup bluetooth keyboard
- press Fn+q to get into pairing mode (blue light start flashing)
- Fn+crtl then 1 to reset first pairing

@innyso
innyso / hhkb_mod_control_escape.md
Created April 13, 2023 01:42
#keyboard #hhkb #modkey

To make the left control key also an escape

  1. install Karabiner
  2. Search for complex_modifications rules, find somethin glike Change control key
  3. Impact and Enable
@innyso
innyso / grep_regex.md
Last active May 5, 2021 11:32
#linux #cmd #grep #regex

Difference between grep with and without extended-regex

  • by default grep interpret search pattern as basic regular expression i.e. the meta-characters ?, +, |, ( and ) are interpreted as literal, hence need to escape with backslash
  • can pass in extended regular expresson option -E (or --extended-regex) which means it doesn't take the meta-characters literally hence do not need to escape with backslash

Anchoring

# a line begins with hello
grep '^hello' world.txt 
@innyso
innyso / linux_foreground_background.md
Last active January 16, 2021 04:27
#linux #process #foreground #background #cmd #bg #fg

Linux foreground background process

Foreground Process

A command or process you run directly and wait for it to complete

Background Process

The shell does not need to wait for the process to end. You can run as many of background process as you want within your system memory limit.

@innyso
innyso / aws_cli_config.md
Last active January 12, 2021 11:41
#aws #config #cli #assumerole

Setting up aws cli with assume role

Let's say we have a tools account that we login and assume role with

  1. Run aws configure --profile tools and follow the prompt to setup initial aws related configuration files

  2. Open ~/.aws/config and add the following

[profile tools]
@innyso
innyso / jinja2_template_file.md
Last active May 16, 2020 05:31
#python #jinja #template #input #snippet

Code snippet for how to use jinja2 with file as an input for template.

from jinja2 import Environment,FileSystemLoader

env = Environment(loader=FileSystemLoader('files'))
template = env.get_template('somefilename.sh.j2')
output = template.render(name='elmo')
print output
@innyso
innyso / check_cmd_exist_in_make.md
Last active May 16, 2020 05:30
#makefile #cmd #exist #syntax #snippet

Check if a command exist in Makefile

LS := ; @which ls > /dev/null

ifndef LS
$(eval ls := $(shell which ls))
else
$(eval ls := something/ls
endif
@innyso
innyso / escape_percentage_hiera.md
Last active May 16, 2020 05:29
#hiera #escape #percentage

In hiera, when encounter a percentage symbol, it will try to interpolate it. In order to stop it from happening, make sure you quote the value

TIME_FORMAT: '%d/%m/%Y %H:%M:%S'
@innyso
innyso / command_prepend_timestamp.md
Last active May 16, 2020 05:25
#linux #cmd #timestamp

Prepend timestamp to command

command | ts '[%Y-%m-%d %H:%M:%S]'

Insert the result of a command to the current file:

# insert result of ls to current file
:r !ls

where

:r --> :r file Read contents of a file to the workspace