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 / geoip.sh
Last active February 14, 2024 22:32
Downloading free MaxMind GeoIP file, use with NGINX
# Download the legacy format for NGINX compatibility
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# Unzip
gunzip Geo*.gz
# Copy to /usr/share/GeoIP/
cp Geo*.dat /usr/share/GeoIP/
@kenjij
kenjij / gist:9016204
Last active December 6, 2022 23:00
Create GeoIP database for iptables in Ubuntu
# Install necessary packages
sudo apt-get unzip
sudo apt-get install libtext-csv-xs-perl
# Create database location
sudo mkdir /usr/share/xt_geoip
# Download the database file and convert
/usr/lib/xtables-addons/xt_geoip_dl
sudo /usr/lib/xtables-addons/xt_geoip_build -D /usr/share/xt_geoip *.csv
@kenjij
kenjij / README.md
Created April 11, 2020 02:35
macOS Terminal Setup

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Install Oh My ZSH!

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@kenjij
kenjij / Firebase.md
Last active November 2, 2022 20:41
Firebase REST authentication
@kenjij
kenjij / neko-logger.rb
Last active October 17, 2022 18:26
Generic Ruby Logger Wrapper
# Configure logger
NekoLogger.logger = Logger.new($stdout, formatter: proc { |s, d, n, m| "#{s} : #{m}\n" })
L = NekoLogger.logger
lvl = ENV['NEKO_LOG_LEVEL']
if String === lvl && ['DEBUG', 'INFO', 'WARN', 'ERROR'].include?(lvl.upcase)
L.level = eval("Logger::#{lvl.upcase}")
end
#
@kenjij
kenjij / textmate-lineheight.sh
Created August 21, 2015 22:06
Line-height adjustment in TextMate
# This example will make Adobe Source Code Pro font look snug in TextMate.
# Adjust space above the line
defaults write com.macromates.TextMate.preview fontAscentDelta -float -2
# Adjust space below the line
defaults write com.macromates.TextMate.preview fontLeadingDelta -float 0
# Reset to default
defaults delete com.macromates.TextMate.preview fontAscentDelta
@kenjij
kenjij / openssl.sh
Last active April 29, 2022 20:42
OpenSSL SSL certificate generation process
# Generate private key with passphrase
openssl genrsa -des3 -out server.key 2048
# Private key without passpharase; UNDERSTAND THE RISK!
openssl rsa -in server.key -out server.key-nopass
# Generate CSR to submit to CA
openssl req -new -sha256 -key server.key -out server.csr
# Check/view CSR
@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 / config
Created February 18, 2022 02:15
User SSH config
# Save this at ~/.ssh/config
Host nickname
Hostname 192.168.0.123
User nick
Port 2222
IdentityFile ~/.ssh/id_nick
Compression yes
Host *
Compression no
@kenjij
kenjij / exceptions.rb
Created January 29, 2022 00:21
Exception handling in Ruby
begin
# do something bad
rescue => e # StandardError by default
puts "Exception class: #{ e.class.name }"
puts "Exception message: #{ e.message }"
puts "Exception backtrace: #{ e.backtrace }"
# Or just: puts "#{e}"
end