Skip to content

Instantly share code, notes, and snippets.

View sjas's full-sized avatar
😆
EAX,60

sjas

😆
EAX,60
  • 755517,642095,1140
  • EDESTADDRREQ
View GitHub Profile
#!/bin/bash -e
IFADDR="192.168.3.1/24"
if [[ ! ip link show docker0 ]]; then
ip link add docker0 type bridge
ip addr add "$IFADDR" dev docker0
ip link set docker0 up
iptables -t nat -A POSTROUTING -s "$IFADDR" ! -d "$IFADDR" -j MASQUERADE
fi
@sjas
sjas / pedantically_commented_playbook.yml
Created September 1, 2017 10:25 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@sjas
sjas / tmux_local_install.sh
Created September 6, 2017 20:40 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@sjas
sjas / generate_diagram.py
Created November 1, 2017 07:53 — forked from jul/generate_diagram.py
building entitty relation ship diagram from a db by using introspection
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlsoup import SQLSoup as sql
from sys import argv
DIGRAPH = """digraph structs {
graph [
rankdir= "LR"
bgcolor=white
]
@sjas
sjas / pleac-go.md
Created November 26, 2017 21:02 — forked from dgryski/pleac-go.md
@sjas
sjas / parse_json.go
Created November 27, 2017 03:02 — forked from mjohnsullivan/parse_json.go
Parse JSON objects with arbitrary key names in Go using interfaces and type assertions
// Parsing arbitrary JSON using interfaces in Go
// Demonstrates how to parse JSON with abritrary key names
// See https://blog.golang.org/json-and-go for more info on generic JSON parsing
package main
import (
"encoding/json"
"fmt"
)
@sjas
sjas / ansible-summary.md
Created May 5, 2018 16:41 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@sjas
sjas / check.go
Created June 2, 2018 23:12 — forked from mattes/check.go
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); err == nil {
// path/to/whatever exists
}
@sjas
sjas / rootfs_ubuntu_16.04_btrfs.md
Created June 24, 2018 21:17 — forked from niflostancu/rootfs_ubuntu_16.04_btrfs.md
Installing Ubuntu 16.04 on btrfs using debootstrap

Installing Ubuntu 16.04 with btrfs using debootstrap

Partition layout

First, create a GPT partition table.

  1. boot partition, label: EFI, flags: boot + ESP; size: 1GB, format to FAT32;
  2. root partition (label: root), must same size on all devices!
  3. swap partition.
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)