For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
var mqtt=require('mqtt'); | |
var mongodb=require('mongodb'); | |
var mongodbClient=mongodb.MongoClient; | |
var mongodbURI='mongodb://username:password@server.mongohq.com:port/database'; | |
var deviceRoot="demo/device/"; | |
var collection,client; | |
mongodbClient.connect(mongodbURI,setupCollection); | |
function setupCollection(err,db) { |
#!/bin/bash | |
# You need: curl, jq, and ipcalc to run this. | |
# You should already have cut, sort and uniq if you're on OS X or Linux. | |
RANGES=$(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq .prefixes | jq '.[] | select(.region=="us-east-1")' | jq 'select(.service=="EC2")' | jq .ip_prefix | cut -d '"' -f 2 | sort | uniq) | |
for range in $RANGES | |
do | |
MIN=$(ipcalc -bn $range | grep "HostMin" | cut -d ':' -f 2) |
In order to access a server hosted within a vm (guest), for development purposes from the host OS, which is restricted to same origin / localhost only requests, I set up a siple nginx reverse proxy to forward my requests.
/** | |
* MongoDB NodeJS Driver Production Connection Example | |
* | |
* Copyright (c) 2015 ObjectLabs Corporation | |
* Distributed under the MIT license - http://opensource.org/licenses/MIT | |
*/ | |
var MongoClient = require('mongodb').MongoClient; | |
/** |
Let's start by getting it out on the table: Sublime Text is great, and version 3 should no longer be considered "abandonware" as of build 3065. Sublime Text served me very, very well over the years. That said, trying out new things is a major part of leveling-up, and in that vein Vim deserves a go. (And have you seen some of those thoughtbot guys flying around in Vim? It's awesome!)
Getting Vim up-and-running on your Windows machine doesn't have to be an all-day project. In this post, we'll walk through:
# Copyright 2018 Simon Davy | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in |
image: debian | |
before_script: | |
- apt-get update && apt-get clean | |
- apt-get install --fix-missing -y python-dev python-pip python-setuptools | |
- apt-get install --fix-missing -y build-essential | |
- apt-get install --fix-missing -y libyaml-dev | |
- apt-get install --fix-missing -y libssl-dev openssl | |
- apt-get install --fix-missing -y libffi-dev | |
- apt-get install --fix-missing -y curl tree netcat |
function Disable-ieESC { | |
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" | |
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" | |
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 | |
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 | |
Stop-Process -Name Explorer | |
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green | |
} | |
Disable-ieESC |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |