Skip to content

Instantly share code, notes, and snippets.

View drewsberry's full-sized avatar

Drew - Account Moved drewsberry

View GitHub Profile
@drewsberry
drewsberry / jekyll-excerpt.html
Created July 30, 2014 15:23
Jekyll excerpts, split by <!--more--> by default. If not found, default to the first 500 words.
{% if post.content contains '<!--more-->' %}
{{ post.content | split:'<!--more-->' | first %}}
<p><a class="btn btn-primary btn-lg" href="{{ post.url }}">Continue reading...</a></p>
{% else %}
{{ post.content | truncate: 500 }}
<p><a class="btn btn-primary btn-lg" href="{{ post.url }}">Continue reading...</a></p>
{% endif %}
@drewsberry
drewsberry / bootstrap_buttons.css
Last active August 29, 2015 14:04
Bootstrap CSS, arranged by the classes they give
/* Provides all btn and btn related classes */
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
@drewsberry
drewsberry / README.md
Last active August 29, 2015 14:04
Errors from pygments_global_config.rb
@drewsberry
drewsberry / README.md
Last active August 29, 2015 14:04
Add lineanchors to all Liquid highlight tags

This small bash script replaces all Liquid codeblock tags with one including the lineanchors option. For instance:


{% highlight vim %}

{% highlight ruby %}```

Is converted to:
@drewsberry
drewsberry / cpanminus.sh
Created August 6, 2014 11:56
Install cpanm locally and set it to install all CPAN modules locally
wget -O- http://cpanmin.us | perl - -l ~/Programs/perl5 App::cpanminus local::lib
eval `perl -I ~/Programs/perl5/lib/perl5 -Mlocal::lib`
echo 'eval `perl -I ~/Programs/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
@drewsberry
drewsberry / update-all.sh
Last active August 29, 2015 14:05
Update all your git repositories within your development directory in one go.
#!/bin/bash
# Updates all my repositories in my ~/Dev folder.
# Requires `git-up`: `# gem install git-up`
REPO_DIR=$HOME/Dev # Replace with your development directory
cd $REPO_DIR
DIRS=`ls -d */`
@drewsberry
drewsberry / hazz_waves.pde
Last active August 29, 2015 14:06
Harry's Waves in Processing
import grafica.*;
GPlot plot;
GPointsArray points;
int nPoints = 200;
int LEN = 200;
float[][] mesh = new float[1080][LEN];
float gaussian(float x, float mean, float stddev) {
@drewsberry
drewsberry / sipm_macro.tex
Created September 19, 2014 16:05
LaTeX macro for siunitx x plus/minus y units (requires package siunitx)
% Without parentheses
\newcommand{\sipm}[3]{#1 $\pm$ \SI{#2}{#3}}
% With parentheses
\newcommand{\sipmp}[3]{(#1 $\pm$ #2)\si{#3}}
@drewsberry
drewsberry / katextest.rb
Created September 20, 2014 13:12
KaTeXifier test
require 'execjs'
def convert(content)
singledollar = /(?<![\$])\$([^$]+)\$(?!\$)/
doubledollar = /\$\$([^$]+)\$\$/
path_to_katex = "../public/js/katex.min.js"
katexsrc = open(path_to_katex).read
katex = ExecJS.compile(katexsrc)
@drewsberry
drewsberry / convert.zsh
Created March 16, 2015 19:59
Convert all eps files in folder to cropped pdf
#!/bin/zsh
files=(*)
for f in $files; do
if [[ $(echo $f | rev | cut -c1-3 | rev) == "eps" ]]; then
echo "Converting $f..."
basename=$(echo $f | rev | cut -c1-4 --complement | rev)
epspdf --bbox $f
pdfcrop --noverbose ${basename}.pdf ${basename}.pdf