Skip to content

Instantly share code, notes, and snippets.

Guy Pursey guypursey

View GitHub Profile
@guypursey
guypursey / gist:8963ca9c6e16f5d11867
Created Sep 7, 2014
Post a file to Scriptogr.am via the API
View gist:8963ca9c6e16f5d11867
# 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 Aug 29, 2015
Remove file from Scriptogr.am via the API
View gist:71c0f5c80fae51daedd8
# 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 Sep 21, 2014
Move files into their own directories, using filenames without extensions.
View gist:a792d42811918518a741
# 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 Aug 29, 2015
Add or remove post on Scriptogram, pulling in relevant metadata from a separate file
View autoscrp.sh
# 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 Nov 30, 2014
Rename folders and main file within to new convention.
View gist:ad548f7bf935ac7a2bf3
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
Script for crawling a Mustache/Handlebars template file and finding all the variables.
View find-context-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 Jun 4, 2015
Bookmarklet to add scrollbar to Google Organisational Chart
View gist:cbef413f2670f066ee8b
javascript: (function () { document.getElementsByClassName("waffle-objwrap-gvizchart")[0].style.overflow = "scroll"; } ())
@guypursey
guypursey / .block
Last active Aug 19, 2016
Tweaked timeline in D3.js
View .block
license: mit
@guypursey
guypursey / post.sh
Created Jun 13, 2016
A script for aiding workflow in a Jekyll blog.
View post.sh
# 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 Jun 8, 2017
Playpool chart (sample data)
View .block
license: mit
You can’t perform that action at this time.