Skip to content

Instantly share code, notes, and snippets.

View victoriadrake's full-sized avatar

Victoria Drake victoriadrake

View GitHub Profile

Add the current git branch to your bash prompt! In .bashrc:

parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[0;1;38;5;247m\]> \[\033[3;38;5;68m\]\W $(parse_git_branch)\[\033[00m\] '
else
 PS1='${debian_chroot:+($debian_chroot)}\W $(parse_git_branch)\[\033[00m\] '
@victoriadrake
victoriadrake / steps-to-install-html-proofer.md
Created March 26, 2019 23:28
`$ gem install html-proofer` they said...

Steps to install html-proofer

sudo apt-get install ruby-dev
sudo gem install pkg-config
sudo gem install nokogiri -- --use-system-libraries
sudo apt-get install zlib1g-dev
sudo gem install html-proofer
@victoriadrake
victoriadrake / slice-pie.go
Last active July 28, 2019 19:48
Figure out if a pie is big enough.
package main
import (
"fmt"
"math"
)
// Slice a `x` inch diameter pie into `n` pieces.
// Return true if each slice is greater than `m` inches wide.
@victoriadrake
victoriadrake / Makefile-generate-HGP-site
Created May 22, 2018 15:42
A makefile that regenerates the public/ folder for Hugo sites, optimizes images and prepares the git commit for GitHub Pages.
SHELL:=/bin/bash
BASEDIR=$(CURDIR)
OUTPUTDIR=$(BASEDIR)/public
optipng = find $(OUTPUTDIR) -name '*.png' -print0 | xargs -0 -P8 -n2 optipng -o5 -strip all -quiet
optijpg = find $(OUTPUTDIR) -name '*.jpg' -print0 | xargs -0 -P8 -n2 jpegoptim --strip-all -m30 -q
site:
@echo "Deleting files from old publication"
@victoriadrake
victoriadrake / pre-commit-imgopt
Created May 22, 2018 14:11
A pre-commit hook that optimizes images in-place in the current directory.
#!/bin/sh
# in git repo: cp pre-commit-imgopt .git/hooks
# add execute permissions: chmod +x .git/hooks/pre-commit-imgopt
find . -name '*.png' -print0 | xargs -0 -P8 -n2 optipng -o5
find . -name '*.jpg' -print0 | xargs -0 -P8 -n2 jpegoptim --strip-all -m30
@victoriadrake
victoriadrake / lambda-rss-tweeter.go
Last active April 7, 2020 04:11
Tweet RSS feed links for AWS Lambda
package main
import (
"math/rand"
"net/url"
"os"
"time"
"github.com/ChimeraCoder/anaconda"
"github.com/Sirupsen/logrus"
function makeMeASandwich(x) {
var ingredients = x.join(' ');
return function barry() {
return ingredients.concat(' sandwich');
}
}
function makeMeASandwich(x) {
var ingredients = x.join(' ');
var slices = 0;
function barry() {
return ingredients.concat(' sandwich');
}
function barryAddCheese() {
slices += 2;
return ingredients.concat(' sandwich with ', slices, ' slices of cheese');
@victoriadrake
victoriadrake / updating-tagline.js
Created May 19, 2017 14:08
Bit of jQuery that changes a message when the page loads, dpending on the current hour.
// changes based on current time
var time = new Date().getMinutes();
// sets the time to every ten minutes
var index = Math.floor(time/10);
var json = {
0:"Clever message zero.",
1:"Clever message one.",
2:"Clever message two.",
3:"Clever message three.",
4:"Clever message four.",
function flatten(arr) {
if (Array.isArray(arr)) {
return arr.reduce(function(done,curr){
return done.concat(flatten(curr));
}, []);
} else {
return arr;
}
}