Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# PROVIDE: www
# REQUIRE: LOGIN FILESYSTEMS
# KEYWORD: shutdown
. /etc/rc.subr
name="www"
rcvar="${name}_enable"
@lamberta
lamberta / amazondotcom.xml
Last active September 1, 2020 10:04
Firefox search plugins. Some slighty customized.
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>Amazon.com</ShortName>
<Description>Amazon.com Search</Description>
<InputEncoding>ISO-8859-1</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,AAABAAIAEBAAAAAAAAC0AQAAJgAAACAgAAAAAAAA6QIAANoBAACJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAF7SURBVDjLlZPLasJAFIaFRF+iVV+h6hO0GF+gVB9AaHwDt64qCG03tQgtdCFIuyhUelmGli66MXThSt24kNiFBUlAYi6ezjnNxSuawB/ITP7v/HNmJgQAEaZzpgHs/gwcTyTEXuXl2U6nA8ViEbK5HKler28CVRAwnB9ptVrAh8MrQuCaZ4iA8fzIqSgCxwzpTIaSuN/RWGwdYLwCUBQFZFkGSZLgqdmEE7YEN8VOAKyaSKUW4nNBAFmnYiKZpDRX1WqwBBzP089n5f/NEQsFL4WqqtsBWJlzDAJr5PwSMM1awEzzdxIbGI3Hvc6jCZeVFgRQRwpY7Qcw3ktgfpR8wLRxCPaot/X4GS95MppfF6DX9n2A3f+kAZycaT8bAZjU6r6B/duD6d3BYg9wQq/tkYzHY1blEiz5lmQyGc95mrO6r2CxgpjCBXgNsJVviolpXJiraeOIjJRE10juUa4sR8V+mO17VvmGqtuOcdNlwut8zTQJcJ0njifyB2bgTdKh6w4BAAAAAElFTkSuQmCCiVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACsElEQVRYw71XQWsTURBe2LQgeNKLB+tVemt6txcteNSD/QGC6VEIGDx5s+eKPQqFgJhLNdFLBWMP7cU0oSAWjB70koC9WHbVQ5SO8
@lamberta
lamberta / git-browse
Created January 5, 2014 07:39
Git command line tool for quickly jumping to a project's web page or issue list.
#!/usr/bin/env bash
##
## Git command line tool for quickly jumping to a project's web page or issue list.
## Inspired by https://github.com/github/hub
## Save file as git-browse somewhere on your path.
print_help() {
echo "Usage: git browse [options]"
echo " -i, --issues Navigate to the project's issue page."
}
@lamberta
lamberta / coursera-slurp
Last active June 16, 2018 13:34
Download all the lecture videos from a Coursera class index page. Requires phantomjs and wget.
#!/usr/bin/env phantomjs
/**
* Scrapes a Coursera class index page and downloads the
* individual lecture mp4s. Requires phantomjs and curl.
* Usage: ./coursera-slurp [index-url]
*
* If something breaks, it's probably the DOM selector in the
* remote page. Try fiddling with the 'linkSelector' function.
*/
var page = require('webpage').create(),
@lamberta
lamberta / raspberry-pi-config.sh
Last active November 7, 2021 17:51
Useful settings for my Raspberry Pi.
# Finish headless installation via `ssh pi@192.168.2.x`
# See /boot/config.txt
sudo apt-get update && sudo apt-get --purge dist-upgrade
sudo raspi-config
# Add locale en.us-utf8 (but keep en.gb-utf8)
sudo dpkg-reconfigure locales
# Timezone
sudo dpkg-reconfigure tzdata
# Update firmware
@lamberta
lamberta / duckduckgo.xml
Last active July 17, 2021 14:11
Firefox search plugin using DuckDuckGo and auto-complete from Startpage.
<!-- DuckDuckGo HTTPS search using Startpage suggestions.
- Url params: https://duckduckgo.com/params
- OSX location: Firefox.app/Contents/MacOS/browser/searchplugins
- In about:config, browser.search.defaultenginename = DuckDuckGo -->
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>DuckDuckGo</ShortName>
<Description>DuckDuckGo Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">https://duckduckgo.com/favicon.ico</Image>
@lamberta
lamberta / parseFunction.js
Created September 23, 2012 03:57
Parse a JavaScript string function definition and return a function object. Does not use eval.
/* Parse a string function definition and return a function object. Does not use eval.
* @param {string} str
* @return {function}
*
* Example:
* var f = function (x, y) { return x * y; };
* var g = parseFunction(f.toString());
* g(33, 3); //=> 99
*/
function parseFunction (str) {
@lamberta
lamberta / vbox.sh
Created August 6, 2012 04:31
Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#!/usr/bin/env bash
# Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#
# Headless Ubuntu server gets stuck at boot menu on unsuccessful boots:
# http://serverfault.com/questions/243343/headless-ubuntu-server-machine-sometimes-stuck-at-grub-menu
function print_help {
echo "Usage: $(basename $0) [options] name"
echo "Easy control of VirtualBox virtual machines."
echo " -h Show this usage guide."
@lamberta
lamberta / extract-meta.sh
Created March 5, 2012 05:30
Parse metadata variables from a markdown file.
#!/usr/bin/env bash
##
## Parse metadata variables from a markdown file.
##
## The key-values are returned as field-deliminated lines to
## stdout, or, as a variable string that can be passed to pandoc
## as command-line parameters.
##
## Delcare metadata in the markdown file using the format:
## % meta keyname1="value1"
@lamberta
lamberta / contacts-to-addressbook
Created October 3, 2011 16:15
Formats a Google contacts list for use in a Pine address book.
#!/usr/bin/env bash
##Formats a Google contacts list for use in a Pine address book.
##Requires the Google Command Line Tool: http://code.google.com/p/googlecl/
##Usage:
## contacts-to-addressbook > $HOME/.addressbook
GOOGLECL=$(which google)
if [ ! -x "$GOOGLECL" ]; then
echo "Error: Requires the Google command line tool."
exit 1