Skip to content

Instantly share code, notes, and snippets.

View nicholaskajoh's full-sized avatar
👨‍💻
Debugging

Nicholas Kajoh nicholaskajoh

👨‍💻
Debugging
View GitHub Profile
@nicholaskajoh
nicholaskajoh / renew.sh
Created December 26, 2021 20:13
Renew wildcard SSL certificate from Let's Encrypt with Certbot on DigitalOcean Droplet
#!/bin/bash
# Get SSL cert from Let's Encrypt.
# See https://www.digitalocean.com/community/tutorials/how-to-create-let-s-encrypt-wildcard-certificates-with-certbot.
certbot certonly \
--server https://acme-v02.api.letsencrypt.org/directory \
--dns-digitalocean \
--dns-digitalocean-credentials /path/to/certbot-creds.ini \
--dns-digitalocean-propagation-seconds 300 \
-d \*.example.com \
@nicholaskajoh
nicholaskajoh / knex_dependency_graph.txt
Created May 25, 2020 22:31
Deduplication in an npm package dependency graph.
nicholas@Inspiron-3542:~/dev/SANDBOX/knex$ npm ls -prod
knex@0.21.1 /home/nicholas/dev/SANDBOX/knex
├── colorette@1.1.0
├── commander@5.1.0
├─┬ debug@4.1.1
│ └── ms@2.1.2
├── esm@3.2.25
├── getopts@2.2.5
├── inherits@2.0.4
├── interpret@2.0.0
function up(knex) {
return knex.schema.table('random', (table) => {
table.boolean('is_deleted')
.defaultsTo(0)
.notNullable();
});
}
function down(knex) {
const tableName = 'random';
@nicholaskajoh
nicholaskajoh / python_setup.sh
Created October 27, 2019 20:42
Python setup (Let's Build an Autonomous Toy Car! series)
# Refresh repos
sudo apt update
# Update system
sudo apt upgrade
# Install Python 2
sudo apt install python2.7 python-pip
# Install Python 3
sudo apt install software-properties-common
@nicholaskajoh
nicholaskajoh / ros_build_run.sh
Last active November 21, 2019 10:25
ROS build and run packages (Let's Build an Autonomous Toy Car! series)
# Source ROS env
source /opt/ros/melodic/setup.bash
# Create package (in path/to/workspace/src)
# NB: std_msgs and rospy are dependencies
# catkin_create_pkg my_package std_msgs rospy
# Create scripts directory in package root
# mkdir scripts
@nicholaskajoh
nicholaskajoh / ros_setup.md
Last active October 20, 2019 13:49
ROS setup (Let's Build an Autonomous Toy Car! series)
@nicholaskajoh
nicholaskajoh / customMap.js
Created October 13, 2019 08:57
Implementation of JavaScript's Array map function without the use of a loop (for, while etc). Recursion is used instead.
Array.prototype.customMap = function(fn) {
if (typeof fn !== 'function') throw Error('Am I a joke to you?');
const arr = this;
const arrLen = arr.length;
const getNewArr = (index, newArr) => {
if (index < arrLen) {
const newItem = fn(arr[index], index, arr);
return getNewArr(index + 1, [...newArr, newItem]);
@nicholaskajoh
nicholaskajoh / carla_setup.sh
Last active November 24, 2019 13:12
CARLA setup (Let's Build an Autonomous Toy Car! series).
# 1. Download latest release and unzip
# https://github.com/carla-simulator/carla/releases/latest
# 2. Start CARLA server
./CarlaUE4.sh -opengl -fps=30 -quality-level=Low -windowed -ResX=1000 -ResY=600
# To use different map,
# Change directory to PythonAPI/util
# Then run:
# python config.py -m Town05
# Change weather:
@nicholaskajoh
nicholaskajoh / elk.sh
Last active August 22, 2019 11:30
Script to run Elasticsearch and Kibana in development with Docker.
# Setup
# 1. Install Docker for your OS
# 2. Pull Docker image for Elasticsearch: docker pull docker.elastic.co/elasticsearch/elasticsearch:7.3.0
# 3. Pull Docker image for Kibana: docker pull docker.elastic.co/kibana/kibana:7.3.0
# 4. Run this script: chmod +x elk.sh && ./elk.sh
# Test
# Elasticsearch: curl http://127.0.0.1:9200/_cat/health
# Kibana: visit http://localhost:5601
@nicholaskajoh
nicholaskajoh / ubuntu-to-pi.sh
Last active March 17, 2019 13:56
Connect from Ubuntu PC to Raspberry Pi via SSH (ipv6).
# 1. Enable SSH on your Raspberry Pi (https://www.raspberrypi.org/documentation/remote-access/ssh/).
# 2. Plug Pi to PC using an ethernet cable and enable the ethernet device in your settings.
# 3. Use the ifconfig command to get the ethernet device name and IP address e.g enx00e04c534458 and fe80::666c:c924:194c:1756 respectively.
# 4. SSH into Pi with default user (pi) and password (raspberry).
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -Y -6 pi@fe80::666c:c924:194c:1756%enx00e04c534458