Skip to content

Instantly share code, notes, and snippets.

@glennzw
glennzw / vidChecker.sh
Last active April 28, 2016 14:45
Video File Checker
#!/bin/bash
# Check all MP4 video files to see if they're corrupt, then merge into one file.
which avprobe
if [ $? -ne 0 ]; then echo "Please install avprobe"; exit; fi
find . -type f -iname "*.mp4" -print0 | while IFS= read -r -d $'\0' line; do
avprobe "$line" &> /dev/null
if [ $? -ne 0 ]; then
echo "Deleting corrupt file $line"
rm "$line"
https://blogs.dropbox.com/tech/2014/07/open-sourcing-our-go-libraries/
http://highscalability.com/blog/2014/5/7/update-on-disqus-its-still-about-realtime-but-go-demolishes.html
https://blog.repustate.com/migrating-entire-api-go-python/
http://s3.amazonaws.com/golangweekly/go_for_pythonistas.pdf
@glennzw
glennzw / unitTest.sh
Created February 9, 2016 16:25
Test GoProxy
#!/bin/bash
#ToDo: Learn how to use functions in Bash :P
MAXTHREADS=20
#####1. No proxy
echo "Downloading `wc -l sites.txt|xargs` sites with no proxy (max threads: $MAXTHREADS)"
start=`date +%s`
for i in `cat sites.txt`
do
@glennzw
glennzw / run_prog.py
Created August 12, 2015 18:33
Run program's from Python
def run_program(rcmd):
"""
Runs a program, and it's paramters (e.g. rcmd="ls -lh /var/www")
Returns output if successful, or None and logs error if not.
"""
cmd = shlex.split(rcmd)
executable = cmd[0]
executable_options=cmd[1:]
@glennzw
glennzw / time.py
Created October 1, 2014 15:31
Python timezone comparisons
dateutil.parser.parse("2014-07-08T10:18:01+02:00") - datetime.datetime.now(dateutil.tz.tzutc())
@glennzw
glennzw / writeSD.sh
Created August 19, 2014 02:09
Script to write to multiple SD cards simultaneously from OSX
#!/bin/bash
# Write an image to multiple SD cards at the same time
# Supply: image to be written, comma separated list of devices
# @glennzw
#set -e
echo -en " +++ Glenn's multi SD writer. Use with care. @glennzw +++\n\n"
BS=1m
OIFS=$IFS;
@glennzw
glennzw / killIPv6.sh
Last active January 16, 2023 05:44
disable IPv6 on Linux
#!/bin/bash
# Disable IPv6 on Linux
# [email protected]
echo "Disabling IPv6..."
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo "Disabling IPv6 on boot..."
cat >> /etc/sysctl.conf << EOF
#disable ipv6 on boot
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
@glennzw
glennzw / fifoDict.py
Created May 12, 2014 09:56
Python dict with max size constraint
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# [email protected]
from collections import OrderedDict
class fifoDict:
"""OrderedDict with FIFO size constraint"""
def __init__(self, size=1000, reducePc=0.2):
self.od = OrderedDict()
@glennzw
glennzw / busStatus.py
Last active August 29, 2015 14:00
Get status of buses via TFL website from bus stop ID
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# [email protected]
# Get times for a bus from TFL
from bs4 import BeautifulSoup
import requests
import re
import os
"""
@glennzw
glennzw / install_tor.sh
Last active March 25, 2023 10:40
Install ToR browser bundle on Kali
# Setup ToR, ToR browser, and Moxie's tortunnel on Kali
# [email protected]
set -e
echo "Installing ToR and privoxy for Kali, and enabling start on boot"
#Install tor services for proxychaining etc
apt-get install -y tor privoxy
/etc/init.d/tor start
/etc/init.d/privoxy start
update-rc.d tor enable