Skip to content

Instantly share code, notes, and snippets.

View lachlanjc's full-sized avatar
🏳️‍🌈
(they/them)

Lachlan Campbell lachlanjc

🏳️‍🌈
(they/them)
View GitHub Profile
@lachlanjc
lachlanjc / kickoff.rb
Last active August 29, 2015 14:04 — forked from nbashaw/kickoff.rb
# Kickoff. The quickest way to start new rails apps
# How it works:
# 1. Install the gem: `$ gem install kickoff-rails`
# 2. Generate your kickoff file `$ kickoff new myapp`
# 3. Edit the kickoff file to specify the foundation of your app
# 4. Generate your app: `$ kickoff`
# Set up your database
database = 'postgresql' # or 'sqlite3' or 'mysql'
@lachlanjc
lachlanjc / svgo.sh
Created October 11, 2014 21:53
Optimize a ton of SVGs from the command line
#!/bin/bash
for file in $@
do
svgo $file
done
@lachlanjc
lachlanjc / md_file.rb
Last active August 29, 2015 14:10
Render public/ Markdown files into Rails views (great for Terms of Service).
def md_file(name)
file_contents = File.open(Rails.root + 'public/' + name.to_s).read
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, underline: true, space_after_headers: true, strikethrough: true)
return markdown.render(file_contents).html_safe
end
@lachlanjc
lachlanjc / sinatra-bang.sh
Created November 28, 2014 22:36
The fast way to start working on a Sinatra app.
mkdir app
cd app
touch app.rb
touch Gemfile
touch config.ru
mkdir views
mkdir public
touch views/index.erb
touch public/app.css
echo "require './app'" > config.ru
@lachlanjc
lachlanjc / publish.sh
Created November 30, 2014 19:29
Publishing a Wintersmith blog to GitHub Pages
#!/usr/bin/env bash
cd src
wintersmith build
cd ..
rm build/*
mv src/build/* .
rm -rf src/build
open .
git add .
.brt1 { border-radius: .125rem .125rem 0 0; }
.brt2 { border-radius: .25rem .25rem 0 0; }
.brt3 { border-radius: .5rem .5rem 0 0; }
.brt4 { border-radius: 1rem 1rem 0 0; }
.brt5 { border-radius: 2rem 2rem 0 0; }
.brr1 { border-radius: 0 .125rem .125rem 0; }
.brr2 { border-radius: 0 .25rem .25rem 0; }
.brr3 { border-radius: 0 .5rem .5rem 0; }
.brr4 { border-radius: 0 1rem 1rem 0; }
.brr5 { border-radius: 0 2rem 2rem 0; }

Keybase proof

I hereby claim:

  • I am lachlanjc on github.
  • I am lachlanjc (https://keybase.io/lachlanjc) on keybase.
  • I have a public key whose fingerprint is 9A63 A29B 51A1 4185 4E9B D90A 92EF E806 C67D B148

To claim this, I am signing this object:

@lachlanjc
lachlanjc / base64.rb
Created November 7, 2015 01:23
Quickly Base64-encode images
def file_extension(filename)
filename.gsub /\w+\./, ''
end
def base64_img(kind, data)
"data:image/#{kind};base64,#{Base64.encode64(data)}"
end
@lachlanjc
lachlanjc / download-links.rb
Created February 1, 2016 19:59
Download a series of files from their links in a text file.
//---------------------------
// Spacing utilities
//---------------------------
$__space-default: 1rem;
@function space($level: 1) {
@if $level <= 4 {
@if $level == 0 {
@return ($__space-default / 2);
} @else {