Skip to content

Instantly share code, notes, and snippets.

View blackandred's full-sized avatar
Let's change the world

Andrew Johnson blackandred

Let's change the world
  • Non-profit, activist
  • Saskatoon, Canada
View GitHub Profile
@masnun
masnun / annotations.php
Created August 12, 2012 15:54
Demonstration of Doctrine Annotation Reader
<?php
/**
*@Annotation
*/
class AnnotatedDescription
{
public $value;
public $type;
public $desc;
}
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active May 2, 2024 23:15
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
@lanrat
lanrat / docker-recreate.go
Created January 19, 2016 19:41
Recreate a docker container with the same configuration after an image upgrade
package main
import (
"fmt"
"os"
"strings"
"github.com/fsouza/go-dockerclient"
//"github.com/tonnerre/golang-pretty"
)
@blackandred
blackandred / pacman-cleanup-cache
Last active December 30, 2016 17:32
Arch Linux: Clean up pacman cache, leave only 2 versions of every package, the rest of olders remove
#!/usr/bin/python
import os
import collections
def getPackageName(fileName):
exp = fileName.split('-')
found = False
name = ""
sep = ""
@blackandred
blackandred / Example.html.twig
Last active December 25, 2016 13:02
Twig - HTML Meta / SEO tags # https://github.com/Wolnosciowiec
{% import "SEOTags.html.twig" as SEOTags %}
{% block header_meta %}
{{
SEOTags.draw({
'title': 'Hello World',
'description': 'Hi, this is a test',
'keywords': ['first', 'second', 'third'],
'image': 'http://.../image.jpg'
})
@blackandred
blackandred / docker-compose-install.sh
Last active December 30, 2016 17:36
Ansible: Recent version of Docker-Compose on Debian/Ubuntu # https://github.com/Wolnosciowiec
#!/bin/bash
# Installs a recent version of docker-compose
# as on recent Ubuntu version it's pretty old
# but also this script could help to keep consistency
# between developer and production environment
# Based on: https://gist.github.com/wdullaer/f1af16bd7e970389bad3
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9]+\.[0-9]+$" | tail -n 1`
sudo sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
sudo chmod +x /usr/local/bin/docker-compose
@blackandred
blackandred / docker-host-ip.sh
Last active January 1, 2017 17:05
Docker: Get host IP and add it locally as docker_host_machine so it could be accessible eg. via http://docker_host_machine
#!/bin/bash
#
# Get host IP and add it locally as docker_host_machine so it could be accessible eg. via http://docker_host_machine
# ================================
# Requirements: iproute2
#
cat /etc/hosts | grep -v "docker_host_machine" > /etc/hosts.2 && mv /etc/hosts.2 /etc/hosts
echo "$(ip route show|grep src|awk '{print $9}') docker_host_machine" >> /etc/hosts
@blackandred
blackandred / network-redirections.sh
Created March 22, 2017 05:52
#1: Redirect traffic from port to port (local) #2: Route all incoming traffic to other host preserving the information about requester's IP address
#!/bin/bash
function get_gateway_interface() {
route|grep default|awk '{print $8}'
}
# Redirect all incoming traffic to the other port
function redirect_port_to_port() {
# $1 from port
# $2 to port

#Setting up Docker Machine on Raspberry PI

  1. SSH into the pi and install docker with curl -sSL https://get.docker.com | sh (If we let Machine try to install the Docker daemon it will fail.)
  2. Change the OS's ID so Docker Machine won't throw errors. sudo nano /etc/os-release and change the line that says ID=raspbian to ID=debian
  3. From a new terminal window run docker-machine create --driver generic --generic-ip-address YOUR-PIS-IP --generic-ssh-key ~/.ssh/id_rsa --generic-ssh-user pi --engine-storage-driver overlay2 MACHINE-NAME
@magiknono
magiknono / rocket-css-slack.css
Created November 1, 2017 09:12
A minimal slack theme for rocket chat
@import url('https://fonts.googleapis.com/css?family=Lato');
.global-font-family {
font-family: 'Lato', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.message {
font-size:1.1em;
line-height: 1.4em;