Skip to content

Instantly share code, notes, and snippets.

View cmandersen's full-sized avatar

Christian Morgan Andersen cmandersen

View GitHub Profile
@cmandersen
cmandersen / gist:91d840db222c3df543c2
Created July 2, 2014 04:26
Setup nginx to redirect Google's _escaped_fragment_= request to a snapshots folder
# This should be inserted into the server {...} block.
# These lines rewrite the url to access the snapshots folder, or where ever you keep
# you prerendered pages (mainly used when working with pages rendered by JavaScript).
#
# example.com/?_escaped_fragment_= --> example.com/snapshots/index.html
# example.com/?_escaped_fragment_=/blog --> example.com/snapshots/blog.html
# example.com/?_escaped_fragment_=/blog/post --> example.com/snapshots/blog/post.html
# Captures URLs with any amount of levels (?_escaped_fragment_=/.../...)
@cmandersen
cmandersen / gist:d21321543bb0c061f779
Created March 16, 2015 15:18
Log only when run on localhost
/**
* Logging function to log only when run on localhost
*/
function log() {
if(document.location.hostname == 'localhost') {
console.log.apply(console, arguments);
}
}
@cmandersen
cmandersen / _font-smooting.scss
Created April 22, 2015 12:53
Font smoothing SASS mixin
@mixin font-smoothing($value: antialiased) {
@if $value == antialiased {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@else {
-webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: auto;
}
}
@cmandersen
cmandersen / gist:8dbe4a3cad163228999611d2bf4ed77a
Created October 31, 2016 12:29
Convert an SVN project to Git
# `cd` into the svn directory
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
# translate the svn usernames
# cma = cma <cma>
# into this:
# cma = Christian Morgan Andersen <[email protected]>
# create a directory for the git project
# move the authors.txt into the new directory
@cmandersen
cmandersen / archive-downloader.sh
Created October 18, 2021 10:03
Download all .mp4 files from a archive.org collection
#! /bin/bash
IFS=$'\n'
ia list --glob="*.mp4" $1 | parallel --bar -j10 "ia download $1 {}"