Skip to content

Instantly share code, notes, and snippets.

Mask or stay home

Ken J. kenjij

Mask or stay home
View GitHub Profile
kenjij / config
Created Feb 18, 2022
User SSH config
View config
# Save this at ~/.ssh/config
Host nickname
User nick
Port 2222
IdentityFile ~/.ssh/id_nick
Compression yes
Host *
Compression no
kenjij / exceptions.rb
Created Jan 29, 2022
Exception handling in Ruby
View exceptions.rb
# do something bad
rescue => e # StandardError by default
puts "Exception class: #{ }"
puts "Exception message: #{ e.message }"
puts "Exception backtrace: #{ e.backtrace }"
# Or just: puts "#{e}"
kenjij / ddb_batch_put.rb
Created Oct 5, 2021
AWS DynamoDB batch write (put) in Ruby, ideally use in Lambda
View ddb_batch_put.rb
require 'aws-sdk-dynamodb'
# DynamoDB batch write (put) routine
# @param items [Array<Hash>] DynamoDB items to put
# @param table [String] DynamoDB table name
def ddb_batch_put(items, table)
ddb =
batch = { |item| {put_request: {item: item}} if Hash === item }
puts "Batch write to: #{table}, #{batch.length} items."
kenjij /
Created Jul 15, 2021
Ubuntu 20.04 Focal Networking
# Check IP address
ip a
# Check default gateway
ip r
route -n
# Check DNS server
systemd-resolve --status
kenjij / twilio.rb
Created Apr 28, 2020
[Twilio] Validate Signature of Request (in pure Ruby)
View twilio.rb
require 'base64'
require 'openssl'
# See:
# Example of AWS API Gateway (HTTP) + Lambda
def is_twilio_request_valid?(event)
# Create a string that is your URL with the full query string
url = "https://#{event['headers']['host']}#{event['rawPath']}"
# Sort the list of POST variables by the parameter name
kenjij /
Created Apr 11, 2020
macOS Terminal Setup

Install Homebrew

/bin/bash -c "$(curl -fsSL"

Install Oh My ZSH!

sh -c "$(curl -fsSL"
kenjij / GET.json
Created Feb 7, 2020
Sample: AWS Lambda function event contents received from API Gateway (HTTP API; route: "/event")
View GET.json
kenjij / Makefile
Created Feb 7, 2020
Build and Package RubyGems for AWS Lambda Layer Use (example)
View Makefile
# Build and Package RubyGems for AWS Lambda Layer Use
all: build package
gem i firebase-ruby -Ni ruby/gems/2.5.0
gem i darksky-ruby -Ni ruby/gems/2.5.0
ls -m ruby/gems/2.5.0/gems
kenjij /
Last active Jan 29, 2019
Swap Control and Caps Lock on Windows

Edit Windows Registry

  1. Open Registry Editor
  2. Go to: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
  3. Edit, or add, binary value key: Scancode Map (see below)
  4. Restart to take effect

Map Value

kenjij /
Created Jul 26, 2018
SSH Key Administration
# Generate the now preferred Ed25519 key
ssh-keygen -t ed25519
# Search in known_hosts file
ssh-keygen -F "hostname"
# Remove key(s) from known_hosts file
ssh-keygen -R "hostname"