Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:
- CA certificate
- Server certificate
- Server key
- Client certificate
- Client key
#!/usr/bin/env bash | |
# https://docs.docker.com/install/linux/docker-ce/ubuntu/ | |
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
# https://docs.docker.com/compose/install/ |
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
# Things I learned dealing with recursive JSON objects | |
This is a summary of my findings while dealing with a django model, TaskCategory. | |
## Two ways for manipulating a set of trees | |
I found two different ways for manipulating objects with an uncertain amount | |
of ascendants / descendants. The first involves manipulating an object within | |
a tree and the second involves taking apart the tree, manipulating the branches | |
and building a new tree |
#!/bin/sh | |
# Usage: heroku-pg-dump-schema.sh HEROKU-APP-NAME DB-ENV-VAR-NAME SCHEMA-NAME | |
app=$1 | |
env_var=$2 | |
schema=$3 | |
db_url=`heroku config -s --app ${app} | grep ${env_var}` |
// International Chemical Identifier Regex, by lo sauer - lsauer.com | |
// Morphine InchI: | |
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1" | |
// applying an organic character-subset | |
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..) | |
!!x.trim().match(/^((InChI=)?[^J][0-9BCOHNSOPrIFla+\-\(\)\\\/,pqbtmsih]{6,})$/ig) | |
>true | |
//generic: | |
x.trim().match(/^((InChI=)?[^J][0-9a-z+\-\(\)\\\/,]+)$/ig) |
#INSERT INTO `core_url_rewrite` (`store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`) | |
SELECT 1 AS `store_id`, | |
`sub`.`category_id`, | |
`sub`.`entity_id` AS `product_id`, | |
CONCAT('product', '/', `entity_id`, '/', `category_id`) AS `id_path`, | |
`value` AS `request_path`, | |
CONCAT('catalog/product/view/id/', `entity_id`, '/category/', `category_id`) AS `target_path`, | |
1 AS `is_system` | |
FROM | |
(SELECT |
#include <event.h> | |
#include <evhttp.h> | |
#include <pthread.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <netinet/in.h> | |
#include <iostream> |
// Asynchronous Client Socket Example | |
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx | |
using System; | |
using System.Net; | |
using System.Net.Sockets; | |
using System.Threading; | |
using System.Text; | |
// State object for receiving data from remote device. |