Skip to content

Instantly share code, notes, and snippets.

View NickWoodhams's full-sized avatar

Nick Woodhams NickWoodhams

View GitHub Profile
@NickWoodhams
NickWoodhams / tosh.py
Created September 5, 2013 15:10
Tosh brain teaser
#last 8 digits- 6812 7167
#first 8 digits- 2, 3, 5, 6, 7, 8, 9, 0
#16 digits, not amex, not mastercard
#start 0000 0001 6812 7167
#end 9999 9999 6812 7167
def luhn(card_number):
@NickWoodhams
NickWoodhams / app.py
Created September 8, 2013 06:59
Freshbooks to Shipwire Python Integration
from flask import Flask, render_template, request, send_file, abort, redirect, make_response, url_for, jsonify
import requests
from pprint import pprint
from bs4 import BeautifulSoup
import urlparse
from raven.contrib.flask import Sentry
app = Flask(__name__)
app.config['SENTRY_DSN'] = ''
@NickWoodhams
NickWoodhams / clear-drupal-cache-selenium.py
Created September 20, 2013 11:03
Automatically clear Drupal Cache - Execute from Github Hook for extra automation goodness
# -*- coding: utf-8 -*-
"""
Post push to Staging
~~~~~~~~~~~~~~~~~~~~
No more manual cache clearing
"""
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
@NickWoodhams
NickWoodhams / testnfs
Created October 16, 2013 07:15
Find the best NFS rsize and wsize for performance
EXPORT="yourdomain.com:/home/shared/folder"
MNTDIR="/local/folder"
TESTFILE="remote-file.test"
NFSPROTO="udp"
if [[ -n "$1" ]]; then
NFSPROTO="tcp"
fi
echo "Testing transfer speed of $NFSPROTO on file $EXPORT/$TESTFILE"
@NickWoodhams
NickWoodhams / pwd.py
Created June 24, 2014 20:22
A better implementation of the built in /bin/pwd function that lists the current working directory. Add a command line argument to give the full file path. Also copies the path to the clipboard automatically on Mac.
#!/usr/bin/python
import os
import sys
from pprint import pprint
if len(sys.argv) > 1:
path = os.getcwd() + "/" + sys.argv[1]
else:
@NickWoodhams
NickWoodhams / addhost
Last active August 29, 2015 14:06
Script to quickly add hosts to your ~/.ssh/config file
#!/bin/sh
echo "==========Add Host to SSH Config============="
echo "What NICKNAME will you call the host? "
read host_name
echo "What USER will be logging in? "
read user_name
echo "What IP ADDRESS is the host? "
read ip_address
echo "What SSH PORT is the host using? "
@NickWoodhams
NickWoodhams / enapp
Created October 1, 2014 13:20
Quickly create matching Nginx and UWSGI app configs
#!/bin/sh
#creates nginx and uwsgi files and enables sites
echo "------------------Add-App------------------"
echo "What is the ABSOLUTE PATH of your WSGI file? "
read wsgi_path
app_home=$(dirname "$wsgi_path")
echo "Using $app_home for your App Directory."
echo "Using $app_home/venv for your Virtualenv."
@NickWoodhams
NickWoodhams / close_deleted_file.py
Last active August 29, 2015 14:12
A SublimeText3 Plugin to close a file's tab if that file is deleted. Saves you from having 3 prompts every time you delete a file. Place in the Packages/User folder.
import sublime_plugin
import sublime
import os
class MyEvents(sublime_plugin.EventListener):
def on_modified_async(self, view):
s = view.file_name()
if s:
if not os.path.exists(s):
@NickWoodhams
NickWoodhams / create_efi_raid.sh
Created February 12, 2015 15:49
Write Clover EFI folder to a HDD or SSD EFI partition when running Mac OS X.
sudo newfs_msdos -v EFI -F 32 /dev/rdisk1s1
sudo mkdir /Volumes/EFI
sudo mount -t msdos /dev/disk1s1 /Volumes/EFI
sudo rm -rf /Volumes/EFI/EFI
sudo cp -R /EFI /Volumes/EFI
sudo diskutil unmount /Volumes/EFI
sudo newfs_msdos -v EFI -F 32 /dev/rdisk2s1
sudo mkdir /Volumes/EFI
sudo mount -t msdos /dev/disk2s1 /Volumes/EFI
@NickWoodhams
NickWoodhams / memmap-bad-config.txt
Created March 9, 2015 07:36
X99-UD5 Clover Memmap debugs - With and without additional PCIe SSD
Type Start End # Pages Attributes
BS_Code 0000000000000000-0000000000007FFF 0000000000000008 000000000000000F
Available 0000000000008000-000000000003EFFF 0000000000000037 000000000000000F
BS_Data 000000000003F000-000000000003FFFF 0000000000000001 000000000000000F
BS_Code 0000000000040000-000000000009FFFF 0000000000000060 000000000000000F
Available 0000000000100000-000000000C985FFF 000000000000C886 000000000000000F
LoaderCode 000000000C986000-000000000CAF4FFF 000000000000016F 000000000000000F
BS_Data 000000000CAF5000-000000000FFFFFFF 000000000000350B 000000000000000F
BS_Code 0000000010000000-000000001000AFFF 000000000000000B 000000000000000F
BS_Data 000000001000B000-0000000022988FFF 000000000001297E 000000000000000F