Skip to content

Instantly share code, notes, and snippets.

@maxpeterson
maxpeterson / channgelog.sh
Created January 31, 2014 10:20
Bash function to build a changelog based on the tags and commit entries of a git repo
changelog_entry() {
# Output individual changelog entry
usage="changelog_entry <since> <until>"
since=${1}
until=${2}
if [ "${since}" == "" ] ; then
echo "No 'since' version"
echo ${usage}
return 1
@maxpeterson
maxpeterson / angular-ie8debug
Created November 21, 2014 18:59
Angular factory for debugging IE8 by prepending `compiled` templates to the body
angular.module('ie8debug').factory('prepend', [
'$rootScope',
'$compile',
function($rootScope, $compile) {
return function (template, context) {
var scope = $rootScope.$new(true);
angular.extend(scope, context);
angular.element(document).find('body').prepend(
$compile(template)(scope)
);
@maxpeterson
maxpeterson / pdf-reduce.sh
Created March 8, 2015 19:58
Reduce pdf quality to screen (72dpi)
# Reduce screen : 72dpi
mkdir -p _72dpi
cd _Cropped;
find . -name \*.pdf|while read file; do
src="$file";
dst="../_72dpi/$src"
if [[ $dst != */_old/* ]] ; then
if [ ! -f "$dst" ] ; then
echo $dst;
#!/bin/bash
root=$( cd -P "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)
usage="
Usage: `basename $0` [source] [ratio]
Generate video poster images.
Arguments
@maxpeterson
maxpeterson / twoWayBind.js
Created June 29, 2015 19:37
AngularJs - bind the local variable name to the remote variable name in the parent scope.
// Bind the local variable name to the remote variable name in the parent scope.
module.factory('twoWayBind', function ($parse) {
return function (scope, local, remote) {
// 2-way bind the model attribute
if (angular.isUndefined(remote)) {
remote = local;
}
var parentAssign = $parse(remote).assign;
var localAssign = $parse(local).assign;
scope.$watch(remote, function(value) {
@maxpeterson
maxpeterson / hammer-veevaify.sh
Last active August 29, 2015 14:26
Prepare a Hammered project for Veeva.
#!/bin/sh
for filename in *.html ; do
basename="${filename%.*}";
echo "$filename"
mkdir -p "$basename/slides";
ln -s "../assets" "$basename/assets";
git mv "$filename" "$basename/$filename";
git mv assets/images/slides/2x/$basename* "$basename/slides/";
# Thumbs
@maxpeterson
maxpeterson / migrate_to_feincms.py
Created October 5, 2011 11:27
Management command to migrate structure.page to feincms
from django.core.management.base import BaseCommand
from django.conf import settings
from incuna.structure.models import Page as StructurePage
from feincms.module.page.models import Page as FeinPage
from feincms.content.richtext.models import RichTextContent
def migrate_pages(structure_pages, template, region, parent=None, **options):
"""
Migrate the structure pages and their children (recursively)
"""
@maxpeterson
maxpeterson / gist:3331075
Created August 12, 2012 10:21
Close frozen shell
[enter]
~
.
@maxpeterson
maxpeterson / withenv
Created September 24, 2012 09:31
Run a shell with environment variables set.
#!/bin/bash
display_usage() {
echo -e "\nUsage: $0 [command] \n"
echo -e "Execute the specified command with environment variables set."
echo -e "If no command is specified then execute a new shell.\n"
}
if [[ ( $1 == "--help") || $1 == "-h" ]]; then
display_usage
@maxpeterson
maxpeterson / .jamrc
Last active October 13, 2015 16:38
Cloudant CustomSearch for creating a private jamjs.org
exports.repositories = [
{
url: "https://USERNAME:PASSWORD@USERNAME.cloudant.com/DATABASE",
search: "https://USERNAME:PASSWORD@USERNAME.cloudant.com/DATABASE/_design/lucene/_search/jam"
},
"http://jamjs.org/repository"
];