Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
my_color=$(printf "%02x%02x%02x" \
$(shuf -i 1-255 -n 1) \
$(shuf -i 1-255 -n 1) \
$(shuf -i 1-255 -n 1))
echo "New color: ${my_color}"
magick -size 1920x1080 \
xc:#${my_color} \

LXD

Some handy lxc commands.

lxc start $(lxc ls -cn --format csv)
lxc stop -f $(lxc ls -cn --format csv)
lxc delete -f $(lxc ls -cn --format csv)
lxc image delete $(lxc image ls -cf --format csv)
lxc image cp images:alpine/3.10 local: --copy-aliases

Control lxd from penguin

@outerpasta
outerpasta / gist:1e433e6f7ea4da9e2c6f069a34189231
Created July 8, 2019 09:33
Crostini (Linux on ChromeOS) setup script
sudo apt update \
&& sudo apt upgrade \
&& sudo apt install clang lld lldb
@outerpasta
outerpasta / serve_and_open_browser
Created February 21, 2017 22:59
Starts a SimpleHTTPServer and opens the root in a browser
#!/usr/bin/env python2
"""Run server"""
import SimpleHTTPServer
import SocketServer
import webbrowser
import socket
import argparse
def main(port=8000):
from requests import ConnectTimeout, get
from os.path import join, dirname, isfile
from zipfile import ZipFile
import random
import csv
try:
from io import BytesIO
except ImportError:
from StringIO import StringIO
BytesIO = StringIO
@outerpasta
outerpasta / uninstallatompackages.sh
Created December 27, 2016 06:31
uninstall all installed atom packages
apm uninstall `apm list --installed --bare | sed 's/@.*//g'`
#!/usr/bin/env python
"""
Python wrapper thing"""
# encoding: utf-8
import os
from os.path import curdir, join, isfile
from subprocess import check_call
import sys
try:
from pip.locations import running_under_virtualenv
docker run --privileged -v /var/run/docker.sock:/run/docker.sock -ti -e TERM tomastomecek/sen

Automatically escape a string for shell expansions!

$ alias shellescape="python -c 'import sys,subprocess;sys.stdout.write(subprocess.list2cmdline([sys.stdin.read()]))'"
$ echo '{"username":"$MYUSERNAME","password","$MYPASSWORD"}' | shellescape
{\"username\":\"$MYUSERNAME\",\"password\",\"$MYPASSWORD\"}
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
"""# For shell completion:
# eval "$(swear -c)"
_python_argcomplete() {
local IFS=' '
COMPREPLY=($(IFS="$IFS" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" \
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" _ARGCOMPLETE=1 "$1" \
8>&1 9>&2 1>/dev/null 2>/dev/null) )