Skip to content

Instantly share code, notes, and snippets.

Avatar

Allan Ralph Hutalla aputs

  • Earth
  • Philippines
View GitHub Profile
@aputs
aputs / jwt.cljs
Created Sep 21, 2016
clojurescript JWT encode/decode (SHA version only)
View jwt.cljs
(ns cljsjs.jwt
(:require
[clojure.spec :as s]
[clojure.string :as str]
[goog.json :as json]
[goog.crypt.base64 :refer [encodeString decodeString]]))
;; https://github.com/Caligatio/jsSHA
;; goog.crypt.hmac produces different signature than nodejs version
(def jssha (js/require "jssha"))
@aputs
aputs / centos7-kickstart-iso.sh
Last active Dec 18, 2019
centos7 kickstart iso creation
View centos7-kickstart-iso.sh
# Mandatory Files: copied from Centos7 ISO installer (minimal/full dvd)
#
# $ROOT/cdroot/.discinfo
# $ROOT/cdroot/LiveOS/squashfs.img
# $ROOT/cdroot/isolinux/boot.cat
# $ROOT/cdroot/isolinux/initrd.img
# $ROOT/cdroot/isolinux/isolinux.bin
# $ROOT/cdroot/isolinux/vmlinuz
#
@aputs
aputs / pacman.conf
Created Nov 9, 2014
minimal pacman config
View pacman.conf
[options]
NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/pacman.conf
NoExtract = usr/share/doc/*
NoExtract = usr/share/info/*
NoExtract = usr/share/man/*
NoExtract = usr/share/locale/[a-d,f-k,m-z]*
NoExtract = usr/share/locale/e[a-m,o-z]*
NoExtract = usr/share/locale/l[a-n,p-z]*
NoExtract = usr/share/locale/lo
@aputs
aputs / nspawn-docker-image
Created Nov 7, 2014
run systemd-nspawn on btrfs docker image snapshot
View nspawn-docker-image
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
dest_dir=/var/lib/container/archlinux
btrfs subvolume snapshot $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image) $dest_dir
systemd-nspawn -D $dest_dir
@aputs
aputs / tar-docker-image
Last active Oct 29, 2016
tar docker image (squash)
View tar-docker-image
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
# tar
cd $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image)
tar --exclude={'.','..'} -Pcvzf $tar_file .* *
View minimal-archlinux-for-docker
TGZ=http://hkg.mirror.rackspace.com/archlinux/iso/2014.11.01/archlinux-bootstrap-2014.11.01-x86_64.tar.gz
ROOT=/var/lib/archlinux
TMPROOT=/tmp/archlinux
sudo mkdir -p ${TMPROOT}
wget "${TGZ}" -O- | sudo tar --strip-components=1 -C ${TMPROOT} -Pxzf-
sudo sed --in-place s/^#//g ${TMPROOT}/etc/pacman.d/mirrorlist
sudo btrfs subvolume delete ${ROOT}
sudo btrfs subvolume create ${ROOT}
View squash-docker-save
#!/bin/bash
set -e
set -o pipefail
function list_tars {
ROOT=$1
TAG=${2:-latest}
BASE=$(sed -e 's/.*{\(".*"\)}.*/\1/g' "${ROOT}/repositories" | sed 's/"//g' | awk -v RS=',' -F: '/^'${TAG}'/ {print $2}')
CUR=$BASE
View reset-firewall.sh
#!/bin/sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
View etcd centos init.d script
#!/bin/bash
# Startup script for etcd
#
# chkconfig: 2345 20 80
# description: Starts and stops etcd
. /etc/init.d/functions
prog="etcd"
ETCD_BIN=$(which etcd 2> /dev/null)
@aputs
aputs / replace-centos6x-iptables
Last active Feb 28, 2022
replace centos 6.x iptables
View replace-centos6x-iptables
# compile iptables from source and install to /usr/local
mkdir -p /tmp/iptables
wget "http://www.netfilter.org/projects/iptables/files/iptables-1.4.21.tar.bz2" -qO- | tar --strip-components=1 -C /tmp/iptables -xvj
cd /tmp/iptables
./configure
make
make install
# set alternatives
sudo alternatives --install /sbin/iptables iptables.x86_64 /usr/local/sbin/iptables 100 \