Skip to content

Instantly share code, notes, and snippets.

View garthhumphreys's full-sized avatar
🎯
Focusing

Garth Humphreys garthhumphreys

🎯
Focusing
View GitHub Profile
# Work in progress
# Need to test in virtualbox
sudo apt-get install libxml2-dev libxslt-dev
sudo apt-get install python-lxml
virtualenv --distribute venv
source venv/bin/activate
@garthhumphreys
garthhumphreys / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@garthhumphreys
garthhumphreys / python_resources.md
Last active August 29, 2015 14:12 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

#!/usr/bin/env bash
# Requirements:
# pdf2swfBatch-poly2bitmap.sh needs to be installed in order to use this, see http://www.swftools.org/
# This is the advanced version of converting pdf to swfs by flattening pages to bitmap.
#
# Copyright (C) 2012 Garth Humphreys, http://garthhumphreys.com, http://konec.ky
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@garthhumphreys
garthhumphreys / RGBColor.h
Created March 30, 2012 16:48
RGBColor Macro
/* rgb color */
#define RGBCOLOR(r,g,b) \
[UIColor colorWithRed:r/256.f green:g/256.f blue:b/256.f alpha:1.f]
/* rgb color with alpha (rgba) */
#define RGBACOLOR(r,g,b,a) \
[UIColor colorWithRed:r/256.f green:g/256.f blue:b/256.f alpha:a]
@garthhumphreys
garthhumphreys / randomCountry.py
Created October 31, 2012 03:57
Print to screen a random country
#!/usr/bin/python -tt
import random
def main():
"""
This script randomly prints to screen a soverign country from a list of 206 countries
"""
try:
@garthhumphreys
garthhumphreys / gist:17d6a1809b6f57be6b5a
Created January 20, 2016 08:49 — forked from blanc0/gist:65a0c4f3dc148c66ad38
PhantomJS + Selenium Testing
'''
You'll need to install npm, nodejs and phantomjs
$ apt-get install nodejs nodejs-dev npm phantomjs
$ pip install selenium-python
'''

###IAB1 Arts & Entertainment IAB1-1 Books & Literature
IAB1-2 Celebrity Fan/Gossip
IAB1-3 Fine Art
IAB1-4 Humor
IAB1-5 Movies
IAB1-6 Music
IAB1-7 Television

###IAB2 Automotive

@garthhumphreys
garthhumphreys / gist:8fe0308ed12cca1816a4ba3fb88da255
Created March 5, 2018 19:08 — forked from anonymous/gist:c3066c657c453c09a48deb1ed8b5d12f
.htacess/httpd.conf maintenance mode changes
RewriteEngine On
# If this file (toggle file) exsists then put the site into maintenance mode
RewriteCond /path/to/where/your/toggle/file/is/located/on/the/server -f
# If coming from approved ip address, then don't put it into maintenance mode,
# here I'm using HTTP:x-forwarded-for in place of REMOTE_ADDR this is because some users (or your yourself) might
# arrive to the site via a proxy server, so it's more accurate to use HTTP:x-forwarded-for to get the real ip address,
# Also please note that the ip address below has '\' in them because HTTP:x-forwarded-for returns or stores the ip address as a comma delimited list
RewriteCond %{HTTP:x-forwarded-for} !^127\.127\.127\.127$
@garthhumphreys
garthhumphreys / fab.py
Created March 5, 2018 19:11
Fab maintenance-mode script
# One for renaming the toggle file from 'maintenance-mode-off' to 'maintenance-mode-on', this will turn on the maintenance mode the next time someone refreshes the page or clicks on a link
def mm_on():
with cd('~/path/to/where/your/toggle/file/is/located/on/the/server'):
run('mv maintenance-mode-off maintenance-mode-on')
# And this command turns the maintenance mode off, again by renaming the "toggle file".
def mm_off():
with cd('~/path/to/where/your/toggle/file/is/located/on/the/server'):
run('mv maintenance-mode-on maintenance-mode-off')