Skip to content

Instantly share code, notes, and snippets.

Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@artbikes
artbikes / make_flask.sh
Created May 26, 2018 21:14
Flask Skeleton
mkdir -p new_app
cd new_app
touch run.py
touch config.py
mkdir app
cd app
touch __init__.py
mkdir templates
mkdir static
mkdir module_one
@artbikes
artbikes / vault-token-role-via-api.sh
Created May 7, 2018 19:47 — forked from greenbrian/vault-token-role-via-api.sh
HashiCorp Vault Token Role overview
# start vault in dev mode
VAULT_UI=true vault server -dev -dev-root-token-id="password"
# write some secrets for our example usage
curl --request POST \
--silent \
--header "X-Vault-Token: password" \
--header "Content-Type: application/json" \
--data '{ "options": { "cas": 0 }, "data": { "username": "administrator", "password": "hunter2" } }' \
http://127.0.0.1:8200/v1/secret/data/dev | jq '.'
@artbikes
artbikes / downgrade_Mongodb_replica_to_standalone.txt
Created March 2, 2018 15:28 — forked from marcoberri/downgrade_Mongodb_replica_to_standalone.txt
Migrate MongoDB ReplicaSet to single MongoDB Node
mongoserver:PRIMARY> rs.status();
{
"set" : "mongoserver",
"date" : ISODate("2016-02-02T10:47:07.510Z"),
"myState" : 1,
"members" : [
{
"_id" : 3,
"name" : "192.168.1.10:37017",
"health" : 1,
@artbikes
artbikes / Makefile
Created February 15, 2018 13:37 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@artbikes
artbikes / s3_ls.go
Created January 18, 2018 20:39
List all keys in S3 bucket
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
@artbikes
artbikes / postgres-cheatsheet.md
Created January 8, 2018 19:04 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

When you set Let's Encrypt up, you will:

  • generate a key on your computer (among other things), which we will call domain.key
  • regularly update a certificate file via Let's Encrypt (most probably using one of the Acme Client Implementations), we will call this file domain.crt

The domain.key file is for your eyes only; you should keep it safe where you run taskd and set server.key to point to it.

Create patch file

git diff --no-prefix > [path file name]

Apply path file

patch -p0 < [path file name]

@artbikes
artbikes / yooper.sh
Created December 5, 2017 21:54
Display title of youtube video
#!/bin/bash
curl -s \
--data-urlencode "url=$1" \
--data-urlencode "format=json" \
http://www.youtube.com/oembed |
jq '.title'