Skip to content

Instantly share code, notes, and snippets.

View drewsberry's full-sized avatar

Drew - Account Moved drewsberry

View GitHub Profile
@drewsberry
drewsberry / gitjekgit.sh
Last active December 14, 2020 03:03
Useful Jekyll + Git Bash scripts
#!/bin/bash
# Run this scrript in the root directory of your Jekyll source
# repository for your GitHub page, and it will commit and push
# the source to origin/source, then build, commit and push the
# resuling HTML to your origin/master, i.e. your website. The
# commit message for both commits is given by the first
# argument.
if [[ -z "$1" ]]; then
@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 / dollars-to-html.py
Created September 18, 2014 15:16
Replace equations $ ... $ or $$ ... $$ with KaTeX HTML using Python
import re
import execjs
def find_equations(string):
""" Take in a string, and convert everything between $ ... $ into an inline
equation and everything between $$ ... $$ into a centred equation. """
doubledollar = re.compile(ur"\$\$([^$]+)\$\$")
singledollar = re.compile(ur"(?<![\$])\$([^$]+)\$(?!\$)")
@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}}