Skip to content

Instantly share code, notes, and snippets.

@husjon
husjon / mirror.list
Created February 23, 2018 20:49 — forked from chusiang/mirror.list
Creating a Debian Repository with apt-mirror
It's very handy to have a local mirror of the Debian stable repository, especially if you want to do fast network installs and updates for multiple systems. By default, the Debian utility apt-mirror does a great job of pulling over packages, but to be able to use PXE netbooting and other cool tricks you need to do a few tweaks to its basic configuration.
#### START /etc/apt/mirror.list ####
set base_path /var/spool/apt-mirror
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var
set cleanscript $var_path/clean.sh
@husjon
husjon / README.md
Created March 13, 2018 14:39 — forked from obscurerichard/README.md
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

# ~/.oh-my-zsh/custom/workon_cwd.zsh
function workon_cwd {
# Credits to: Harry Marr (https://hmarr.com/2010/jan/19/making-virtualenv-play-nice-with-git/)
cd $@ 2>/dev/null
# Check that this is a Git repo
GIT_DIR=`git rev-parse --git-dir 2> /dev/null`
if [ $? = 0 ]; then
# Find the repo root and check for virtualenv name override
GIT_DIR=`\cd $GIT_DIR; pwd`
PROJECT_ROOT=`dirname "$GIT_DIR"`
@husjon
husjon / .gitlab-ci.yml
Last active March 16, 2018 12:37
gitlab-runner
# Example
---
stages:
- test
- build
run_all_tests:
stage: test
script:
- nose2
@husjon
husjon / PinDistrictApps.cmd
Created March 30, 2018 19:12 — forked from sirlancelot/PinDistrictApps.cmd
Windows 7 script to pin items to the taskbar. Can be placed in the default user's startup folder. Self-terminating.
@echo off
cscript PinItem.vbs /taskbar /item:"%ProgramData%\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox\Mozilla Firefox.lnk"
cscript PinItem.vbs /taskbar /item:"%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office Word 2007.lnk"
cscript PinItem.vbs /taskbar /item:"%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office Excel 2007.lnk"
cscript PinItem.vbs /taskbar /item:"%ProgramData%\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office PowerPoint 2007.lnk"
#!/usr/bin/env python3
import argparse
import collections
import json
import os
import requests
token_env_name = 'GIST_TOKEN'
@husjon
husjon / sample.sh
Created May 12, 2018 13:02 — forked from e7d/sample.sh
Bash "try catch"
#!/bin/bash
export AnException=100
export AnotherException=101
# start with a try
try
( # open a subshell !!!
echo "do something"
[ someErrorCondition ] && throw $AnException
@husjon
husjon / mpvctl
Created April 4, 2019 18:33 — forked from dwgill/mpvctl
A small script for controlling mpv via the JSON IPC. Intended to resemble playerctl.
#!/usr/bin/env bash
# This script requires:
# - that the directory $HOME/.mpv exist
# - that the program socat be installed
# - that you start mpv with the unix socket feature pointing at that directory
# I recommend an alias in your .bashrc or equivalent file:
# alias mpv="mpv --input-unix-socket=$HOME/.mpv/socket"
socket="$HOME/.mpv/socket"
from pydub import AudioSegment
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtMultimedia import *
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
import sys
import time
import math
@husjon
husjon / build.sh
Created February 9, 2020 18:59 — forked from Forst/build.sh
Ubuntu ISO with preseed.cfg generation script
#!/bin/bash
## FORSTWOOF UBUNTU PRESEED :: BUILD SCRIPT
# Quit on first error
set -e
# Temporary directory for the build
TMP="/var/tmp/ubuntu-build"