Skip to content

Instantly share code, notes, and snippets.

View kenjij's full-sized avatar
👨‍💻
Hacking away...

Ken J. kenjij

👨‍💻
Hacking away...
View GitHub Profile
@kenjij
kenjij / GET.json
Created February 7, 2020 07:48
Sample: AWS Lambda function event contents received from API Gateway (HTTP API; route: "/event")
{
"version":2,
"path":"/event",
"httpMethod":"GET",
"headers":{
"Content-Length":"0",
"Host":"abcde12345.execute-api.us-west-2.amazonaws.com",
"User-Agent":"curl/7.54.0",
"X-Amzn-Trace-Id":"Root=1-67891233-abcdef012345678912345678",
"X-Forwarded-For":"192.168.1.23",
@kenjij
kenjij / Makefile
Created February 7, 2020 06:00
Build and Package RubyGems for AWS Lambda Layer Use (example)
#
# Build and Package RubyGems for AWS Lambda Layer Use
#
all: build package
build:
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
kenjij / readme.md
Last active January 29, 2019 17:22
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
kenjij / ssh-keys.sh
Created July 26, 2018 18:48
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"
@kenjij
kenjij / fast.rb
Created August 9, 2017 06:23
Pretty format option for JSON.fast_generate
opts = {
indent: ' ',
space: ' ',
object_nl: "\n",
array_nl: "\n"
}
JSON.fast_generate(obj, opts)
@kenjij
kenjij / Slack.md
Last active June 13, 2019 07:33
Slack access token for bots (OAuth)

Slack OAuth for Bot App

1. Autorization

Open in a web browser: https://slack.com/oauth/authorize?scope=bot&client_id=12345.67890

  • Use Client ID from App Credentials.
  • Use bot for scope.

2. Authorization Code

@kenjij
kenjij / Firebase.md
Last active May 24, 2024 14:02
Firebase REST authentication
@kenjij
kenjij / load.rb
Created March 23, 2017 18:16
Load files from list of directories in Ruby
def load_from_path(path)
Dir.chdir(path) {
Dir.foreach('.') { |f| load f unless File.directory?(f) }
}
end
paths = [
'conf.d',
'plugins'
]
@kenjij
kenjij / keys_to_sym.rb
Created January 21, 2017 01:16
Ruby: iterate through nested object and replace keys (convert to symbol)
# Convert all Hash keys to lowercase symbols
# @param obj [Object] any Ruby object
def keys_to_sym(obj)
case obj
when Array
obj.each do |v|
keys_to_sym(v)
end
when Hash
obj.keys.each do |k|
@kenjij
kenjij / rvm_admin.sh
Created January 21, 2017 00:24
RVM administration
# See: https://rvm.io/rvm/install
# Install public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Single-user install
\curl -sSL https://get.rvm.io | bash -s stable --ruby
# Multi-user install; after install, add users to "rvm" group
\curl -sSL https://get.rvm.io | sudo bash -s stable