Skip to content

Instantly share code, notes, and snippets.

View guypursey's full-sized avatar
🏠
Working from home

Guy Pursey guypursey

🏠
Working from home
View GitHub Profile
@guypursey
guypursey / gist:8963ca9c6e16f5d11867
Created September 7, 2014 09:31
Post a file to Scriptogr.am via the API
# This script requires `curl` package to be installed.
# Replace `$APP_KEY` with the app key from your Scriptogr.am account below OR uncomment the line below and add the ID as a value to the variable. You can get the app key by adding your application on this page (when logged in): http://scriptogr.am/dashboard#developers
# $APP_KEY=
# Replace `$USER_ID` with the ID from your Scriptogr.am account below OR uncomment the line below and add the ID as a value to the variable. You can get your user ID from towards the bottom of this page (when logged in): http://scriptogr.am/dashboard#settings
# $USER_ID=
# Replace `$POST_NAME` with the name of the file containing the Markdown content of the post (minus the `.md` extension) OR uncomment the line below and add the extension-less filename as a value to the variable.
# $POST_NAME=
@guypursey
guypursey / gist:71c0f5c80fae51daedd8
Last active August 29, 2015 14:06
Remove file from Scriptogr.am via the API
# This script requires `curl` package to be installed.
# Replace `$APP_KEY` with the app key from your Scriptogr.am account below OR uncomment the line below and add the ID as a value to the variable. You can get the app key by adding your application on this page (when logged in): http://scriptogr.am/dashboard#developers
# $APP_KEY=
# Replace `$USER_ID` with the ID from your Scriptogr.am account below OR uncomment the line below and add the ID as a value to the variable. You can get your user ID from towards the bottom of this page (when logged in): http://scriptogr.am/dashboard#settings
# $USER_ID=
# Replace `$POST_NAME` with the name of the file you want to remove (minus the `.md` extension) OR uncomment the line below and add the extension-less filename as a value to the variable.
# $POST_NAME=
@guypursey
guypursey / gist:a792d42811918518a741
Created September 21, 2014 12:56
Move files into their own directories, using filenames without extensions.
# Credit should go to http://stackoverflow.com/a/12607951/1563507
# Move files into their own directories, using filenames without extensions.
die() { echo "$*" >&2; exit 1; }
for file in *.md; do # `md` used as example of filtering files one wants to move
dir=${file%.md}
test -d $dir || mkdir $dir # or just mkdir -p $dir
test -f $dir && die "$dir exists and is a file!"
mv $file $dir
done
@guypursey
guypursey / autoscrp.sh
Last active August 29, 2015 14:07
Add or remove post on Scriptogram, pulling in relevant metadata from a separate file
# Usage: ./autoscrp.sh [OPTION]... [FILE]
# Publish FILE to Scriptogr.am account (grabbing metadata as we go).
# FILE should have no extension.
#
# Expects metascrp.txt accompanying named file to pull metadata from.
# Expects there two text files in location of script,
# one containing app key for Scriptogram,
# the other containing the user ID.
#
@guypursey
guypursey / gist:ad548f7bf935ac7a2bf3
Created November 30, 2014 13:28
Rename folders and main file within to new convention.
for file in $(find * -maxdepth 0 -type d); do
newdirnm=${file:0:4}${file:5:2}${file:8:2}${file:11:2}${file:14:2}-${file:17}
mv $file $newdirnm
cd ./$newdirnm
git mv "$file".md "$newdirnm".md
git commit -m "Optimised filename for SEO."
cd ..
../autoscrp.sh $newdirnm
echo $newdirnm
done
@guypursey
guypursey / find-context-variables
Created May 10, 2015 14:10
Script for crawling a Mustache/Handlebars template file and finding all the variables.
// Run in Node.js
var fs = require("fs");
fs.readFile("./theme/main.html", { "encoding": "utf-8" }, function (err, data) {
if (err) return err;
var context_array = data.match(/\{\{(.*?)\}\}/g),
context_object = {};
context_array.forEach((function (top_context) {
@guypursey
guypursey / gist:cbef413f2670f066ee8b
Created June 4, 2015 08:01
Bookmarklet to add scrollbar to Google Organisational Chart
javascript: (function () { document.getElementsByClassName("waffle-objwrap-gvizchart")[0].style.overflow = "scroll"; } ())
@guypursey
guypursey / .block
Last active August 19, 2016 12:49
Tweaked timeline in D3.js
license: mit
@guypursey
guypursey / post.sh
Created June 13, 2016 17:48
A script for aiding workflow in a Jekyll blog.
# Run from within root folder.
# Check whether the file exists or not.
if [ -e $1 ]
then
re="([0-9]{12})\-(.*)\.md"
if [[ $1 =~ $re ]]; then
# Create date and time stamps and capture post filename.
datestamp=${BASH_REMATCH[1]:0:4}-${BASH_REMATCH[1]:4:2}-${BASH_REMATCH[1]:6:2}
@guypursey
guypursey / .block
Last active June 8, 2017 07:59
Playpool chart (sample data)
license: mit