Skip to content

Instantly share code, notes, and snippets.

@chrisdlangton
chrisdlangton / get_lonlat.sh
Created April 21, 2017 02:56
Postcode in MySQL to Lat Lon script
#!/usr/bin/env bash
user=root
password=admin
result=$(mysql melbdatathon2017 -hmysql -u $user -p$password<<<"SELECT DISTINCT postcode FROM stores")
post_code_list=(`echo ${result}`)
delete=(postcode)
array=( "${post_code_list[@]/$delete}" )
for post_code in "${array[@]}"
@chrisdlangton
chrisdlangton / aws-s3-sync.sh
Last active August 22, 2017 06:51
Network Tap monitoring
#!/usr/bin/env bash
AWS=/home/`whoami`/.local/bin/aws
DATE=`date "+%Y%m%d-%H"`
BUCKET=<change me>
AWS_PROFILE=<change me>
BACKUPDIR=/mnt/share/backup/tshark/
TMPDIR=/tmp/${DATE}/
@chrisdlangton
chrisdlangton / Dockerfile
Created October 25, 2017 09:16
AWS Lambda Node.js 6.10 Dockerfile
FROM node:6.10
RUN mkdir -p /var/task
WORKDIR /var/task
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends build-essential g++ python2.7 python2.7-dev unzip zip curl wget && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
@chrisdlangton
chrisdlangton / slack-post.sh
Created November 16, 2017 03:26
Simple slack post via Incoming WebHooks
#!/usr/bin/env bash
# Usage: date | ./slack-post.sh
# Usage: echo "Hello Word" | ./slack-post.sh
webhook_url=https://hooks.slack.com/services/...
while read LINE; do
text="$text\n$LINE"
done
@chrisdlangton
chrisdlangton / scanner.py
Created November 17, 2017 23:32
Nmap host port scanner in Python
#!/usr/bin/env python
###########################
# pip install python-nmap
# usage:
# ./scanner.py -i 59.x.x.x
# This will take a while, press 's' on the keyboard to
# see the elapsed time (and know it's still running the scan)
import nmap
import argparse
import termios, fcntl, sys, os
@chrisdlangton
chrisdlangton / compute-internet-connected-ip.py
Created November 18, 2017 00:49
Generate csv list of IPs that are internet connected with Python
#!/usr/bin/env python
##################################
# pip install netaddr
from netaddr import IPAddress, IPNetwork
file_out = "./internet-connected.csv"
with open(file_out, mode='a+') as f:
for class_a in range(0, 255):
a = IPAddress("%s.0.0.0" % class_a)
if not a.is_reserved():
@chrisdlangton
chrisdlangton / cpu-temp.sh
Created March 4, 2018 01:24
CPU temperature logged to systemd log
#!/usr/bin/env bash
set -o errexit
systemd-cat -t "cpu-temp" \
echo "CPU `sensors | grep "CPU Temperature" | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' | sed 's/ /\n/g' | head -n1 | xargs`°C"
exit 0
@chrisdlangton
chrisdlangton / fs-xml-http-request.js
Created April 6, 2018 04:53 — forked from bradharms/fs-xml-http-request.js
An XMLHttpRequest-compatible interface to Node's "fs" module.
import fs from 'fs';
let WindowXMLHttpRequest = null;
/**
* An XMLHttpRequest-compatible interface to Node's "fs" module.
*/
class FSXHR {
constructor() {
/**
@chrisdlangton
chrisdlangton / rc.local
Last active January 4, 2019 12:41
Baked Ghost.io Blog for AWS Ubuntu 16.04 EC2 instance for RDS MySQL
#!/bin/bash -ex
exec > >(tee /var/log/rc.local.log|logger -t rc.local -s 2>/dev/console) 2>&1
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
@chrisdlangton
chrisdlangton / czdap_icann_zonefiles_download.py
Created January 11, 2019 03:16
Download, decrypt, and decompress all zonefiles from czdap.icann.org
#!/usr/bin/env python
# -*- coding:utf-8
"""
requires Python 2.x
requirements.txt
pycrypto==2.6.1
requests==2.21.0
urllib3==1.24.1