Skip to content

Instantly share code, notes, and snippets.

@jcataluna
jcataluna / gist:1dc2f31694a1c301ab34dac9ccb385ea
Created July 8, 2016 17:23
Script to save all images from a docker-compose.yml file
#!/bin/bash
mkdir -p out
for img in `grep image $1| sed -e 's/^.*image\: //g'`;
do
cleanname=${img/\//-}
tag=`docker images | grep $img | awk '{print $2}'`
echo "Exporting image: $img, tag:$tag ($cleanname)..."
docker save $img -o out/$cleanname.tar
@zot24
zot24 / create_rancher_environment_api_key
Last active August 29, 2018 12:33
Script to create a Rancher Environment API Keys programmatically #test
#!/bin/bash
docker exec --privileged -i rancher-agent bash << EOF
ACCOUNT_ID=\`curl -sL "\${CATTLE_URL}/accounts?name=Default" | jq -r .data[].id\`
echo \`curl -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"description":"Development API key", "name":"development"}' \
"\${CATTLE_URL}/projects/"\$ACCOUNT_ID"/apikeys"\`
@runozo
runozo / LVM on Ubuntu howto
Last active December 6, 2024 10:20
Using LVM on Linux and resize swap partition
# RESCAN FOR NEWLY ADDED HDS
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
# NEW LOGICAL VOLUME
sudo fdisk /dev/sdb
# then create a new partition of type 8e (Linux LVM)
# create a phisical volume
sudo pvcreate /dev/sdb1
# create new volume group
// @copyright
// © 2005, 2006, 2013 Apple Inc. All rights reserved.
// © 2009 Torch Mobile, Inc.
// © 2016 Jarosław Foksa
// @src
// https://drafts.csswg.org/css-transforms-1/#recomposing-to-a-3d-matrix
// http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
let {abs, sqrt, asin, sin, cos, tan, atan2} = Math;
@simongong
simongong / camelSnake.js
Created May 10, 2016 06:40
JavaScript: convert format of object keys between camel-case and snake-case
/**
* @param {Object|String} data string or keys of object are named in form of snake
* @param {number} depth to which level of keys should it process
* @return {Object|String} string or keys of object are named in form of camel case
*/
exports.snakeToCamel = function(data, depth) {
if (Util.isObject(data)) {
if (typeof depth === 'undefined') {
depth = 1;
}
@dpino
dpino / ns-inet.sh
Last active April 14, 2025 23:41
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@m4ce
m4ce / iptables
Created April 7, 2016 09:28
Transparent proxy with Squid and IPTables
# Rules for transparent proxying
iptables -N NO_PROXY -t nat
iptables -A NO_PROXY -t nat -d 0.0.0.0/8 -j ACCEPT
iptables -A NO_PROXY -t nat -d 10.0.0.0/8 -j ACCEPT
iptables -A NO_PROXY -t nat -d 127.0.0.0/8 -j ACCEPT
iptables -A NO_PROXY -t nat -d 169.254.0.0/16 -j ACCEPT
iptables -A NO_PROXY -t nat -d 172.16.0.0/12 -j ACCEPT
iptables -A NO_PROXY -t nat -d 192.168.0.0/16 -j ACCEPT
iptables -A NO_PROXY -t nat -d 224.0.0.0/4 -j ACCEPT
iptables -A NO_PROXY -t nat -d 240.0.0.0/4 -j ACCEPT
@ephemient
ephemient / nspawn-enter
Last active March 15, 2021 15:33
A substitute for "machinectl shell" when the systemd-machined inside the nspawn container is too old (e.g. CentOS 7)
#!/usr/bin/env python3
import argparse
import contextlib
import ctypes
import dbus
import errno
import fcntl
import io
import os
import pickle
@rpggio
rpggio / PaperJSViewZoom.ts
Last active December 25, 2019 11:23
An implementation of pan and zoom in Paper.js, based on http://matthiasberth.com/articles/stable-zoom-and-pan-in-paperjs/. Requires jquery-mousewheel to capture wheel events.
class ViewZoom {
project: paper.Project;
factor = 1.25;
private _minZoom: number;
private _maxZoom: number;
private mouseNativeStart: paper.Point;
private viewCenterStart: paper.Point;
@fabiovalse
fabiovalse / README.md
Last active October 1, 2021 19:58
A-Frame DAE isometric view

The camera of A-Frame is set in order to simulate an isometric view.