Skip to content

Instantly share code, notes, and snippets.

View bergantine's full-sized avatar

Bergantine bergantine

View GitHub Profile
@bergantine
bergantine / gist:2390284
Last active March 10, 2024 11:47
Python String Generator of "Random" English Nouns. #python #password
import random
"""
Returns a "random" 4 word phrase from a list of words.
"""
nouns = [
@bergantine
bergantine / gist:2623697
Last active November 20, 2019 13:38
Create md5 Hash of a File using Python. #python #md5 #hash
import hashlib
filehash = hashlib.md5()
filehash.update(open('/path/to/file.zip').read())
print filehash.hexdigest()
@bergantine
bergantine / gist:3056393
Last active October 6, 2015 21:37
Django Template Current Date (used primarily in Copyright notices). #djangotemplate
{% now "Y" %}
@bergantine
bergantine / gist:3164284
Last active October 7, 2015 12:18
Internet Explorer (IE) Conditional Comment Stylesheet Import. #html #ie #conditional #djangotemplate
<!--[if lte IE 9]>
<style type="text/css" media="screen">
@import "{{ STATIC_URL }}stylesheets/stylesheets/ie9.css";
</style>
<![endif]-->
<!--[if lte IE 8]>
<style type="text/css" media="screen">
@import "{{ STATIC_URL }}stylesheets/stylesheets/ie.css";
</style>
@bergantine
bergantine / gist:3399286
Last active October 8, 2015 22:38
MTPUB Volume Distro Prep (unofficial copy for reference - uses parser, file renaming, image resizing, file hashing, system; use the one in the BitBucket repo). #demo #python
#! /Users/joebergantine/python_projects/mtpub_glmt_mag_utils/bin/python
import datetime
import hashlib
import Image
import optparse
import os
try:
import simplejson as json
except:
@bergantine
bergantine / postactivate
Created September 10, 2012 20:52 — forked from carljm/postactivate
Git hooks to activate a ruby gem environment. #git #hook #ruby #gem #bash
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
@bergantine
bergantine / post-merge
Created September 18, 2012 18:55 — forked from robhudson/post-merge
post-merge Git hook to look for changes to requirements. #bash #git #hook #pip #python
#!/bin/sh
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'requirements/' -c) -ne 0 ]
then
$VIRTUAL_ENV/bin/pip install -r requirements/dev.txt
fi
@bergantine
bergantine / gist:3868451
Last active December 16, 2019 19:34
Modernizr 2.6 (Custom Build). #modernizr #javascript
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-shiv-cssclasses-load
*/
;window.Modernizr=function(a,b,c){function u(a){j.cssText=a}function v(a,b){return u(prefixes.join(a+";")+(b||""))}function w(a,b){return typeof a===b}function x(a,b){return!!~(""+a).indexOf(b)}function y(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:w(f,"function")?f.bind(d||b):f}return!1}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m={},n={},o={},p=[],q=p.slice,r,s={}.hasOwnProperty,t;!w(s,"undefined")&&!w(s.call,"undefined")?t=function(a,b){return s.call(a,b)}:t=function(a,b){return b in a&&w(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=q.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(q.call(arguments)));return Object(g)
@bergantine
bergantine / gist:3870080
Last active February 18, 2016 12:57
post-merge Git hook to install requirements if changed, compile stylesheets, syncdb, run a south migration on the database, and rebuild the haystack index using the active virtual environment's python installation. #bash #git #hook #django #compass #sass #pip #south #haystack
#!/bin/sh
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'requirements/development.txt' -c) -ne 0 ]
then
sudo $VIRTUAL_ENV/bin/pip install -r /vagrant/myproject/requirements/development.txt
fi
compass compile /vagrant/myproject/myproject/static_media/stylesheets -e production --force
$VIRTUAL_ENV/bin/python /vagrant/myproject/manage.py syncdb
@bergantine
bergantine / Vagrantfile
Last active October 11, 2015 14:57
Vagrantfile for Django-Newproj. #vagrant #vagrantfile #django #python
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise64"
# The url from where the 'config.vm.box' box will be fetched if it