Skip to content

Instantly share code, notes, and snippets.

@hjst
hjst / gist:1326758
Created October 31, 2011 02:12
Use jQuery to get a Pinboard tag for a given user.Pinboard uses the 'cb' callback method name in it's JSON.
function GetPinboardTag(user, tag, count, handler) {
$.ajax({
url:'http://feeds.pinboard.in/json/v1/u:'+user+'/t:'+tag+'?count='+count,
jsonp:"cb",
dataType:'jsonp',
success: handler
});
}
@hjst
hjst / article_template.tex
Created February 3, 2012 06:39
LaTeX article class template
% See http://code.google.com/p/latex-makefile/ for a useful Makefile
% --- BEGIN HEADER
\documentclass[11pt]{article}
\usepackage{graphicx}
\topmargin -1.5cm % read Lamport p.163
\oddsidemargin -0.04cm % read Lamport p.163
\evensidemargin -0.04cm % same as oddsidemargin but for left-hand pages
\textwidth 16.59cm
\textheight 21.94cm
@hjst
hjst / flac2mp3.sh
Created February 12, 2012 07:35
My flac2mp3 script adapted from one found in AUR
#!/bin/bash
# Usage:
# cd ~/Music/path/to/album/dir
# flac2mp3 /path/to/output/dir
find -name "*.flac" -print0 | while read -d $'\0' IF
do
OF=`echo "$IF" | sed s/\.flac$/.mp3/g | sed s,"$1","$2",g`
echo "$IF" "->" "$1/$OF"
mkdir -p "$1"
@hjst
hjst / gist:2232186
Created March 29, 2012 01:23
Times crossword clues for March 29th 2012
Clue Length Pattern Notes
Tapestry hanging 5 A_R_S Answer from my mum “arras”
Hostility, ill-feeling 6 _N_M__ Answer from @andy_brodie “animus”
Pastoral cantata 8 __R_N_T_ Answer from my mum “serenata”
Flat plate 6 L_M_N_ Answer from @andy_brodie / @Justin_Bradley “lamina”
Plant; purple colour 8 _M_R_N_H Answer from @andy_brodie “amaranth”

Thanks everyone!

@hjst
hjst / Makefile
Created July 13, 2012 13:17
Makefile for Skeleton boilerplate, using yuicompressor
BUILDDIR = .build
YUIURL = http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.7.zip
YUIJAR = $(BUILDDIR)/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar
all: combine squish
build-init: clean
mkdir $(BUILDDIR);
cd $(BUILDDIR); wget $(YUIURL) -O yui.zip; unzip yui.zip;
@hjst
hjst / gist:3109075
Created July 14, 2012 03:39
Pinboard cache miss
HTTP/1.1 200 OK
Cache-Control: max-age=50
Pragma: no-cache
Etag: 2f0467c3bfc98ec1e3280cda779c2ca9
Vary: Accept-Encoding
Content-Type: application/xml
Date: Sat, 14 Jul 2012 03:38:26 GMT
Age: 0
Connection: keep-alive
Server: You got SERVED!
@hjst
hjst / archetype
Created July 15, 2012 04:02
stereotype + archetype defs from the OED
archetype
(ˈɑːkɪtaɪp)
Also 7–8 archi-, 7–9 arch-.
[ad. L. archetypum, a. Gr. ἀρχέτυπον, f. ἀρχε- = ἀρχι- first + τύπος impress,
stamp, type.]
1.1 The original pattern or model from which copies are made; a prototype.
@hjst
hjst / gist:3968511
Created October 28, 2012 12:46
scp files/directories with Chinese characters and spaces
scp -r user@host:'"~/build/江南大学 ESK03/"' local_path/
@hjst
hjst / gist:5033852
Created February 25, 2013 22:17
ab results for clue
Concurrency Level: 100
Time taken for tests: 195.177 seconds
Complete requests: 1000
Failed requests: 387
(Connect: 0, Receive: 0, Length: 387, Exceptions: 0)
Write errors: 0
Non-2xx responses: 387
Total transferred: 538169 bytes
HTML transferred: 385224 bytes
Requests per second: 5.12 [#/sec] (mean)
@hjst
hjst / feed-fixer.php
Created September 25, 2013 00:23
Pulls in an overstuffed RSS feed and removes any content:encoded nodes (which are usually superfluous).
<?php
$ch = curl_init("FEED URL GOES HERE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_USERAGENT, "Henry's very friendly feed fetcher v1.1");
$rss_string = curl_exec($ch);
$dom = new DOMDocument();