Skip to content

Instantly share code, notes, and snippets.

@BenWard
BenWard / gist:4189f5cf1452adac41fc
Last active August 29, 2015 14:06
Quick and dirty function to extract tracklistings from a BFF.FM show playlist and convert it into a Mixcloud compatible blob of text. Recognises gaps in songs and creates chapter breaks automatically.
(function mixcloudify (startHour) {
var TALK_BREAK_MINIMUM = 4, // minimum length to insert a talk break
showDate;
function showTime () {
var start = startHour.split(":").map(function (item) {
return padNumber(item);
});
return Date.parse([
@BenWard
BenWard / gist:1f38be8e28df87fced81
Created October 15, 2014 08:14
Quick script to generate end-times from track lengths for tracks played on Creek.FM
(function endTimesFromTrackLength () {
function padNumber (i) {
i = "" + i;
if (i.length == 1) return "0" + i;
return i;
}
function timestampToSecs (dateString) {
return Date.parse(dateString.replace(" ", "T") + "-07:00") / 1000;
@BenWard
BenWard / gist:7f47ee00da22dd52ff09
Created October 15, 2014 08:55
Dirty little hack script to make the Creek.FM time-stamp field update live, to make it easier to post tracks at the right time.
(function realTimeTrackTime () {
function padNumber (i) {
i = "" + i;
if (i.length == 1) return "0" + i;
return i;
}
function updatePlaytime () {
var d = new Date()
window.requestAnimationFrame(function () {
@BenWard
BenWard / subl.bash
Last active August 29, 2015 14:13
A simple wrapper for `subl`, which handles opening explicit arguments, `sublime-project` definitions if present, or falls back to open the current directory.
function subl {
if [ -n "$1" ]; then
command subl $1
elif [ -f *.sublime-project ]; then
command subl *.sublime-project
else
command subl .
fi
}
@BenWard
BenWard / faves.php
Created August 17, 2009 20:54 — forked from blowery/faves.php
<?php
if (isset($_GET['errors'])) { error_reporting(E_ALL); } else { error_reporting(0); }
// Requires the Universal Feed Writer from http://www.phpclasses.org/browse/package/4427.html
include("FeedWriter.php");
define('FIREWALLED', true);
define('FIREWALL_ROOT', 'firewall/');
include(FIREWALL_ROOT.'config/db.php');
<!-- Microformats hCard Example. -->
<!-- By Ben Ward - http://benward.me http://twitter.com/benward -->
<!-- Re: http://twitter.com/joelevi/statuses/3897539999 -->
<!-- See hCard: http://microformats.org/wiki/hcard#type_subproperty_values -->
<!-- Initial, incorrect Example: -->
<span class="tel voice work pref">+1-866-461-7001</span>
<!--
@BenWard
BenWard / tidy-value-class-pattern.diff
Created October 11, 2009 03:35
A for HTMLTidy to prevent it dropping empty elements that have class attributes. Allows it to be used to pre-process HTML containing microformats without stripping out the value-class-pattern.
Index: attrs.h
===================================================================
RCS file: /cvsroot/tidy/tidy/src/attrs.h,v
retrieving revision 1.29
diff -r1.29 attrs.h
325a326
> #define attrGetCLASS( nod ) TY_(AttrGetById)( nod, TidyAttr_CLASS )
Index: parser.c
===================================================================
RCS file: /cvsroot/tidy/tidy/src/parser.c,v
<?php
$aOutput = array();
$aLines = explode("\n", file_get_contents($argv[1]));
$aKeys = explode("\t", array_shift($aLines));
foreach($aLines as $line) {
if (!trim($line)) {
@BenWard
BenWard / outlook-mac-access.css
Created January 13, 2010 19:47
A user CSS override to restyle Outlook Web Access 2003; to make it more Mac-like. Use this file with Fluid <http://fluidapp.com/>, or another Webkit renderer, to transform OWA into something more palatable. Micah Laaker has an icon you can use for the Flu
/**
# "Outlook Mac Access" CSS
A user CSS override to restyle Outlook Web Access 2003; to make it more Mac-like.
Use this file with Fluid <http://fluidapp.com/>, or another Webkit renderer, to transform
OWA into something more palatable.
By Ben Ward <http://benward.me>
## Status:
@BenWard
BenWard / microformats-locations.html
Created January 14, 2010 23:35
How to mark up a location using microformats (adr, geo and "named places" in hCard 1.01)
<!-- geo microformat: http://microformats.org/wiki/geo -->
<p class="geo">
<span class="latitude">1.30023</span>,
<span class="longitude">0.523323</span>
</p>
<!-- adr microformat: http://microformats.org/wiki/adr -->
<p class="adr">
<span class="street-address">701 First Avenue</span>,
<span class="locality">Sunnyvale</span>,