Skip to content

Instantly share code, notes, and snippets.

@icecreammatt
icecreammatt / coreos-cloud-config
Last active August 29, 2015 14:18
CoreOS Cloud-config
#cloud-config
coreos:
update:
reboot-strategy: off
etcd:
discovery: https://discovery.etcd.io/<token>
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
fleet:
@icecreammatt
icecreammatt / ip-lookup.service
Last active August 29, 2015 14:18
Systemd Unit file for docker
[Unit]
Description=IP Lookup
After=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker kill lookup
ExecStartPre=-/usr/bin/docker rm lookup
ExecStartPre=-/usr/bin/docker pull icecreammatt/lookup
@icecreammatt
icecreammatt / site.conf
Created April 11, 2015 04:39
site.conf
server_names_hash_bucket_size 64;
server {
listen 80;
server_name sample.com www.sample.com;
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@icecreammatt
icecreammatt / watertest.sh
Last active August 29, 2015 14:18
Water table example
#!/bin/bash
# Check to see if the data is already downloaded
if [[ -e ./waterData ]]; then
echo "Water data already downloaded reading from cache";
else
# Data isn't downloaded so grab it from the web
echo "No cached data found downloading water data...";
wget -O waterData "http://nwis.waterdata.usgs.gov/ca/nwis/uv/?search_station_nm=russian%20river&search_station_nm_match_type=beginning&county_cd=06097&index_pmcode_00400=1&index_pmcode_00095=1&index_pmcode_00010=1&index_pmcode_63680=1&group_key=NONE&sitefile_output_format=html_table&column_name=agency_cd&column_name=site_no&column_name=station_nm&range_selection=date_range&begin_date=2008-01-01&end_date=2008-12-31&format=rdb&date_format=YYYY-MM-DD&rdb_compression=value&list_of_search_criteria=county_cd%2Csearch_station_nm%2Crealtime_parameter_selection";
# Convert line endings to unix style (The site is currently providing Windows Style)
from ftplib import FTP
# Server connection string
remoteUrl = 'ftp.debian.org'
ftp = FTP(remoteUrl)
# Login
ftp.login()
# Switch to folder
@icecreammatt
icecreammatt / convert-to-h264.sh
Created May 19, 2015 06:28
ffmpeg mpeg to h264 conversion
#!/bin/bash
# For each .mp4 file convert and rename to .mov
for x in *.mp4; do
ffmpeg -i $x -c:v libx264 -acodec aac -ab 192k -strict -2 -ac 2 -qp 0 ${x/.mp4/.mov};
done
@icecreammatt
icecreammatt / encfs-rsync.sh
Last active August 29, 2015 14:26 — forked from mschubert/encfs-rsync.sh
Script to (decrypt encfs and) selectively sync a remote sshfs directory
#!/bin/bash
# Script to (decrypt encfs and) selectively sync a remote sshfs directory
REMOTEDIR=server:/path/to/some/encfs
LOCALDIR=/path/to/local/directory
MOUNTFUNC=_ssh+encfs
# verbose
# set -vx
@icecreammatt
icecreammatt / gist:e9b9cf973a4a1212b8a7
Created September 11, 2015 06:17
Monitor log and call function when output matches pattern
#!/bin/sh
tail -fn0 /var/log/file.log | while read line ; do
echo "$line" | grep "pattern"
if [ $? = 0 ]
then
echo "Log: $line"
fi
done
@icecreammatt
icecreammatt / cf-ddns.sh
Created November 11, 2015 17:50 — forked from larrybolt/cf-ddns.sh
Automatically update your CloudFlare DNS record to the IP, Dynamic DNS for Cloudflare
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# Automatically update your CloudFlare DNS record to the IP, Dynamic DNS
# Can retrieve cloudflare Domain id and list zone's, because, lazy
# Place at:
# /usr/local/bin/cf-ddns.sh

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: