Skip to content

Instantly share code, notes, and snippets.

View mdigital's full-sized avatar

Robin Marshall mdigital

View GitHub Profile
@mdigital
mdigital / README-Template.md
Last active February 18, 2019 01:52 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of product description goes here

Getting Started

These instructions will get you a copy of the product up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

function pr () {
target_branch=$1
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
local branch=`git name-rev --name-only HEAD`
echo "... creating pull request for branch \"$branch\" in \"$repo\""
if [[ ! -z $target_branch ]]; then
open https://github.com/$repo/pull/new/$target_branch...$branch
else
open https://github.com/$repo/pull/new/$branch
fi
@mdigital
mdigital / to_haml.rb
Created June 7, 2012 22:41 — forked from johnnyicon/to_haml.rb
Convert all html.erb files to html.haml while preserving git history
# Adapted the script listed in the following link to maintain git history
# Original Script: http://snippets.dzone.com/posts/show/5449
# Usage:
# 1) Copy the file to the root of your Rails app
# 2) Run the script (i.e., ruby to_haml.rb app/views)
class ToHaml
def initialize(path)
@path = path
end
@mdigital
mdigital / JsonPExampleinBackbone.js
Created June 7, 2012 02:21 — forked from denisos/JsonPExampleinBackbone.js
Backbone.js model calling jsonp
// backbone.js continues to impress, I needed to get data from a jsonp api
// I really wanted to do this the "right" backbone.js way and create a model and call fetch.
// But the default backbone synch is not jsonp
// Turns out you can override a synch on a per model basis (thanks stackoverflow)
// whats nice is backbone.js continue to work as expected with the override
// here's a snippet (some changes to protect our privacy). An improvement could be to create a jsonp model class which MyModel inherits
// the synch function is most important below, that's what tells backbone it's jsonp
MyModel = Backbone.Model.extend({
@mdigital
mdigital / .bashrc
Created May 31, 2012 21:33 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@mdigital
mdigital / pwm.py
Created February 27, 2012 03:32 — forked from arthurnn/pwm.py
beaglebone PWM
from mmap import mmap
import struct
MMAP_OFFSET = 0x44c00000 # base address of registers
MMAP_SIZE = 0x48ffffff-MMAP_OFFSET # size of the register memory space
CM_PER_BASE = 0x44e00000 - MMAP_OFFSET
CM_PER_EPWMSS1_CLKCTRL = CM_PER_BASE + 0xcc
CM_PER_EPWMSS0_CLKCTRL = CM_PER_BASE + 0xd4
CM_PER_EPWMSS2_CLKCTRL = CM_PER_BASE + 0xd8
@mdigital
mdigital / gist:1094836
Created July 20, 2011 12:01 — forked from paulirish/gist:366184
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
;(function(geolocation){
if (geolocation) return;
var cache;