Skip to content

Instantly share code, notes, and snippets.

View kwikwag's full-sized avatar

kwikwag kwikwag

  • Developer of the world
View GitHub Profile
@kwikwag
kwikwag / install-docker.sh
Created May 3, 2021 07:48
Install Docker on Ubuntu/Debian
#!/bin/bash
# based on https://docs.docker.com/engine/install/debian/
# and https://docs.docker.com/engine/install/ubuntu/
# at 2021-05-03
dist=$(lsb_release --id --short | awk '{ print tolower($0) }')
: : : Set up the Docker repository && \
sudo apt update && \
sudo apt -y install \
apt-transport-https \
import argparse
import os
import random
parser = argparse.ArgumentParser()
parser.add_argument('file')
args = parser.parse_args()
data = []
read_size = 1024 * 4
@kwikwag
kwikwag / rect_red.svg
Created April 16, 2018 06:57
SVG img tag sizing problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwikwag
kwikwag / build.bat
Created August 22, 2017 22:54
Windows build batch file for Live555, based on instructions by @nspool
@rem Place this file at the live/ directory of the downloaded LIVE555 source files.
@rem Based on instructions at https://nspool.github.io/2016/02/building-live555/
@rem Tested with Visual Studio 2015 on Windows 10
@echo off
if exist "%TEMP%\sed.vbs" goto skip_gen_sed
> "%TEMP%\sed.vbs" (
REM thanks to https://stackoverflow.com/questions/127318/is-there-any-sed-like-utility-for-cmd-exe
@echo.Dim pat, patparts, rxp, inp
@echo.pat = WScript.Arguments(0^)
@kwikwag
kwikwag / test-split-tail-head.py
Created May 12, 2017 17:53
Python: splitting a string into two parts at the nth delimiter
from timeit import timeit
import re
def a(s, delim, n):
'''
Two-param split, retaining head
'''
r = s.split(delim, n)[n]
return s[:-len(r)-len(delim)], r
import timeit
from math import pow
import sys
# Python 2/3 compatible
# note : alternative versions of this file had pow(x,0.33) replaced with
# sqrt(x) or max(x,33,1,2,3,4,5,6,6,7,8,9) to see the effect of the
# number of arguments on run times.
#!/usr/bin/env python
import re
import fastnumbers
def is_int1(v):
try:
int(v)
return True
except ValueError:
#!/usr/bin/env python
def is_int1(v):
return v.lstrip('+-').isdigit()
def is_int2(v):
try:
int(v)
return True
except ValueError:
@kwikwag
kwikwag / backup-dir.sh
Last active December 21, 2015 14:39
simple script to backup a directory as a tar.gz archive
#!/bin/bash
OUT_DIR=/opt/DUMP
VERBOSE=0
NAME=
show_help() {
cat <<HELP
Backs up a directory.
Usage: $0 [-h -?] [-n name] [-o outdir] <directory> [...tar options]
@kwikwag
kwikwag / link-config-files.sh
Last active December 21, 2015 14:39
suggestion for maintaining config of a system: maintain a list all manually-edited files (/opt/admin/config/FILES), use this script with suggested cron jobs to keep a hierarchy of config files in this central place which is also easy to back up