Skip to content

Instantly share code, notes, and snippets.

from ftplib import FTP
# Server connection string
remoteUrl = 'ftp.debian.org'
ftp = FTP(remoteUrl)
# Login
ftp.login()
# Switch to folder
@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)
@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 / 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 / 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:
#!/bin/bash
# git pre-commit hook that runs an clang-format stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
# modifications for clang-format by [email protected]
# This file is part of a set of unofficial pre-commit hooks available
# at github.
@icecreammatt
icecreammatt / gist:b518ce4897c8644c3e76
Created November 21, 2014 18:13
Enyo video player mouse auto hide
//* Resets the timeout, or wakes the overlay.
mousemove: function(inSender, inEvent) {
if (this.isOverlayShowing()) {
this.resetAutoTimeout();
} else if (this.shakeAndWake) {
this.showFSControls();
}
},
//* Sets _this.visible_ to true and clears hide job.
showFSControls: function(inSender, inEvent) {
#!/bin/bash
# Pad a list of images with 0's
# %03d means pad with 3 0's, 4.jpg renamed to 004.jpg
images=$(ls *.jpg)
for image in $images;
do
echo $image
value=$(echo $image | sed 's/.jpg//')
padded=$(printf "%03d" $value)
echo $padded.jpg
@icecreammatt
icecreammatt / gist:f2dfaf34226b47d015da
Created October 5, 2014 07:11
Docker without Sudo
vagrant@vagrant-ubuntu-trusty-64:~$ docker ps -a
2014/10/05 07:08:23 Get http:///var/run/docker.sock/v1.12/containers/json?all=1: dial unix /var/run/docker.sock: permission denied
vagrant@vagrant-ubuntu-trusty-64:~$ sudo gpasswd -a vagrant docker
Adding user vagrant to group docker
vagrant@vagrant-ubuntu-trusty-64:~$ sudo service docker restart
docker: unrecognized service
vagrant@vagrant-ubuntu-trusty-64:~$ sudo service docker.io restart
docker.io stop/waiting
docker.io start/running, process 4628
vagrant@vagrant-ubuntu-trusty-64:~$ docker ps -a
@icecreammatt
icecreammatt / PromptDefaults.sh
Created August 24, 2014 00:12
Example on how to default prompt questions
echo "Check for updates? [Y/n] \c"
read CHECK_FOR_UPDATE
case "$CHECK_FOR_UPDATE" in
(N|n) echo "Skipping" ;;
*) echo "installing" ;;
esac