Skip to content

Instantly share code, notes, and snippets.

Dag Holmberg holmberd

Block or report user

Report or block holmberd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
holmberd /
Created Jul 15, 2019
AWS S3 Bucket - List records by date

AWS S3 Bucket - List files by date

With s3 ls

DATE=$1 || $(date +%Y-%m-%d)
echo "List records for date $DATE"
aws s3 ls s3://bucket-name/directory/ | grep ${DATE}
holmberd /
Last active May 30, 2019
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 /
Last active Mar 24, 2019
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 /
Last active Mar 19, 2019
Dynamically create nested level groups by properties in Javascript

Dynamically create nested level groups by properties in Javascript


 * Creates nested groups by object properties.
 * `properties` array nest from highest(index = 0) to lowest level.
 * @param {String[]} properties
 * @returns {Object}
display: grid;
grid-template-columns: repeat( auto-fit, minmax(500px, 1fr) );
grid-gap: 20px;
holmberd /
Last active Jun 10, 2019
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 /
Last active Jan 3, 2019
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
holmberd /
Created Dec 11, 2018 — forked from gaearon/
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

holmberd / cart-example.js
Last active Dec 12, 2018
Cart pub-sub example
View cart-example.js
/** Quick and dirty Cart pub/sub example */
class CartStore {
add(item) {}
remove(index) {}
update(index, item) {}
get(index) {}
getAll() {}
holmberd /
Last active Nov 6, 2018
Setup Automatic Security Updates On Ubuntu

Setup Automatic Security Updates On Ubuntu

Install unattended-upgrade pkg

  • (Might already be installed depending on your Ubuntu release)
sudo apt update
sudo apt install unattended-upgrades

Configure unattended-upgrade for security updates only

You can’t perform that action at this time.