Skip to content

Instantly share code, notes, and snippets.

@stengland
stengland / marked-out
Last active December 14, 2015 09:28
Render and open markdown
#!/bin/sh
TFILE=`tempfile -s .html`
echo '<link href="https://gist.github.com/stengland/5065514/raw/markdown.css" rel="stylesheet" type="text/css" />' >> $TFILE
marked $1 >> $TFILE &&
xdg-open $TFILE
@stengland
stengland / Cakefile
Created January 28, 2013 17:18
Simple CoffeeScript Cakefile with a "build" task (cribbed from the CoffeScript wiki) and "spec" task that runs jasmine-node.
fs = require 'fs'
{exec} = require 'child_process'
appFiles = [
# omit src/ and .coffee to make the below lines a little shorter
'app'
'models/thing'
'view/window'
]
@stengland
stengland / .vimrc
Last active December 11, 2015 07:08
My vim config.
" General "{{{
set nocompatible " be i\;Mproved
" set timeoutlen=500 " Time to wait after ESC (default causes an annoying delay)
set shell=/bin/zsh
set nowritebackup
set directory=/tmp// " prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//)
set noswapfile
@stengland
stengland / instaweb
Created January 14, 2013 23:17
If you have ruby installed (and therefore webrick) configure git to use it (and your favourite browser) for 'git instaweb'
git config --global instaweb.httpd webrick
git config --global instaweb.browser google-chrome
@stengland
stengland / upload-lumix.sh
Created January 14, 2013 22:57
Uploads all photos and videos from my Lumix to flickr. Run from XBMC 'Advanced Launcher'. Logs results to file. Uses my forked version of flickr-shell-uploader
echo start `date` >> /home/xbmc/lumix.log
/home/xbmc/bin/flickr-shell-uploader -r /media/LUMIX >> /home/xbmc/lumix.log
echo end `date` >> /home/xbmc/lumix.log
@stengland
stengland / truncate-logs.sh
Created January 8, 2013 17:14
Truncate those pesky log files
for item in $(find . -type f -name '*.log' ) ;do cat /dev/null > $item ;done
@stengland
stengland / mongodrop.sh
Last active December 10, 2015 20:08
Quick way to drop a Mongo database from shell.
mongo <dbname> --eval "db.dropDatabase()"
@stengland
stengland / params.js.coffee
Created December 18, 2012 15:46
Little class for extracting query params.
class @Params
constructor: (@queryString) ->
@queryString or= window.location.search?.substr 1
@queryString.split('&').forEach @addValue
addValue: (ps) =>
pv = ps.split "="
@[pv[0]] = pv[1]
@stengland
stengland / servedir
Created November 10, 2012 22:35
Quickly serve the pwd
#!/usr/bin/env ruby
require 'webrick'
server = WEBrick::HTTPServer.new(
:Port => ARGV.first || 8666,
:DocumentRoot => Dir::pwd
)
trap 'INT' do server.shutdown end
server.start
@stengland
stengland / bbcradio.sh
Last active January 11, 2023 14:53
Play BBC Radio with mpd or mplayer from the command line
#!/bin/bash
play() {
playlist="http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_$1.m3u8"
echo $playlist
if mpc
then
mpc add $playlist
mpc play
else
mplayer $playlist