Skip to content

Instantly share code, notes, and snippets.

View holmberd's full-sized avatar

holmberd holmberd

View GitHub Profile
@holmberd
holmberd / titan-sec-key-linux.md
Last active February 5, 2023 21:25
Titan Security Key Linux Setup

Go to the udev rules folder

  • cd /etc/udev/rules.d

Pull down the file from the yubikey github

  • sudo wget https://raw.githubusercontent.com/Yubico/libu2f-host/master/70-u2f.rules

Reboot, or run the following to reload your rules

  • sudo udevadm control --reload

Refs:

@holmberd
holmberd / indexeddb-quota.md
Created July 22, 2020 14:20
Test IndexedDB quotaExceededError

You can trigger and test this in Chrome by launching the browser with flag --user-data-dir pointing at a smaller volume, e.g. sudo mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs

@holmberd
holmberd / git-rebase-onto.md
Last active April 9, 2024 02:11
Git Rebase --onto

Linked Feature Branches

Consider a case where you have multiple features that all depending on each-other going into master at different times. Feature-C depends on Feature-B, and Feature-B depends on Feature-A and so on...

If we squash merge Feature-A into master we first have to resolve our base in Feature-B before it can be merged. Below is an example of resolving it after Feature-A has been merged into master (make sure master is up-to-date).

git fetch --all
@holmberd
holmberd / aws-s3-bucket-ls-date.md
Created July 15, 2019 16:57
AWS S3 Bucket - List records by date

AWS S3 Bucket - List files by date

With s3 ls

ls-s3.sh:

#!/bin/bash
DATE=$1 || $(date +%Y-%m-%d)
echo "List records for date $DATE"
aws s3 ls s3://bucket-name/directory/ | grep ${DATE}
@holmberd
holmberd / nginx-ssl-sni.md
Last active February 21, 2023 01:57
How Nginx determines which SSL certificate to use for multiple domains pointing at a single IP

How Nginx determines which server block to route the request through.

Nginx tests only the request’s header field Host to determine which server the request should be routed to. If its value does not match any server name, or the request does not contain this header field at all, then nginx will route the request to the default server, the first server block if no default is specified, or determine the default alphabetical order.

How does TLS SNI help to determine which SSL certificate to use.

TLS does not provide a mechanism for a client to tell a server the name of the server it is contacting. It may be desirable for clients to provide this information to facilitate secure connections to servers that host multiple 'virtual' servers at a single underlying network address.

@holmberd
holmberd / js-range.md
Last active March 24, 2019 19:08
Simple Javascript Range functions

Examples of Javascript simple Range functions.

// range(n)
`const range = n => [...Array(n).keys()];

// range(start, end)
const range = (start, end) => [...Array(end + 1).keys()].slice(start);
@holmberd
holmberd / js-nestGroupsBy.md
Last active April 13, 2024 11:52
Dynamically create nested level groups by properties in Javascript

Dynamically create nested level groups by properties in Javascript

Code

/**
 * Creates nested groups by object properties.
 * `properties` array nest from highest(index = 0) to lowest level.
 *
 * @param {String[]} properties
 * @returns {Object}
@holmberd
holmberd / grid-columns.md
Created March 12, 2019 21:29
Grid Columns CSS
display: grid;
grid-template-columns: repeat( auto-fit, minmax(500px, 1fr) );
grid-gap: 20px;
``
@holmberd
holmberd / sshfs.md
Last active January 19, 2021 21:42
Mount remote directory with SSH

Mount remote directory with SSH

  1. Install sshfs
  • $ sudo apt-get install sshfs
  1. Create local mount point
  • $ mkdir /home/test/sshfs-path
  1. Mount remote folder /remote/path to /home/test/sshfs-path/
  • $ sshfs user@remote-host:/remote/path /home/test/sshfs-path/
@holmberd
holmberd / clean-full-boot-partition-with-unmet-dependencies.md
Last active January 3, 2019 22:46
Clean full boot partition with unmet dependencies - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Remove old kernels and fix unmet dependency issue

  • See currently loaded kernel: uname -r
  • List all old kernels: dpkg --list 'linux-image*'
  • List old kernels except currently loaded: sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`
  • Remove with force and purge: sudo dpkg --force-all -P linux-image-3.13.0-32-generic
  • Fix dependency problems: sudo apt-get install -f
  • Remove all expect the loaded kernel: sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

Future proof yourself

  • Setup unattended upgrades: sudo dpkg-reconfigure unattended-upgrades