Skip to content

Instantly share code, notes, and snippets.

@davidmerfield
davidmerfield / server.js
Last active August 29, 2015 14:03
Dropbox authentication with Node Express server
var express = require('express'),
server = express(),
events = require('events'),
eventEmitter = new events.EventEmitter(),
Dropbox = require("dropbox"),
options = {
key: 'DROPBOX_KEY',
secret: 'DROPBOX_SECRET'
};
@davidmerfield
davidmerfield / layout.txt
Last active September 6, 2017 22:15
Layout tags on Blot
# Layout & typography
{>|} ![A book cover looks great in the margin](https://c1.staticflickr.com/5/4096/4780208213_25074f6779.jpg)
NEW YORK – Text set in all caps gets converted to small-caps by default. This means that acronyms like BBC don’t stand out relative to the rest of the text. Acronyms even work with accents like ÀÊØ. A possessive [acronym](/) like CNN's opinion works as well. What about the FCC! The so called (BBC). Also I automatically convert three dots to an ellipsis... « Hello » there should have non-breaking spaces between the punctuation and the word...
Accents all work perfectly in Georgia. Al­brecht Dürer, François Truf­faut, Plácido Domingo should all render appropriately. Cause célèbre, piña co­lada, Göt­ter­däm­merung straße all work too. Links also are improved: note how the [descenders get cleared](/) from the underline stroke. Composing content for the web is complicated because the designer has no control over the dimensions of the screen on which the content will be viewed?
"Han
@davidmerfield
davidmerfield / Tags
Created February 17, 2016 09:38
List all the tags used on your blog and the associated entries
{{#allTags}}
<a href="/tagged/{{name}}">{{name}} - {{entries.length}}</a>
<ul>
{{#entries}}
<li class="small"><a href="{{url}}">{{title}}</a></li>
{{/entries}}
</ul>
{{/allTags}}
Date: August 10, 2015
# Charts
I recently found out about [Morris.js](http://morrisjs.github.io/morris.js/#getting-started). It makes embedding interactive charts inside blog posts straightforward. View [the source](http://pastebin.com/raw.php?i=U8wRmV3a) for this post.
<div id="myfirstchart" style="height: 250px;width:105%;margin-left:-2.5%"></div>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
h1 a {
position:relative
}
h1 a:after {
content: "→";
position: absolute;
right: -1.333em;
top: 0;
line-height: 1.3;
var lower = 'acemnorsuvwxz'.split('');
var upper = '1234567890ABCDEFGHJKMNPRSTUVWXYZ'.split('');
var chars = lower;
var LEN = 12;
var PREFIX = 'site'; // site file post theme
function uid () {
var res = '';
while (res.length < LEN)
res += chars[Math.floor(Math.random()*chars.length)];
@davidmerfield
davidmerfield / wordpress.xml
Created February 6, 2019 00:16
A view for a Hugo site to generate a Wordpress export file
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@davidmerfield
davidmerfield / feed.rss
Last active March 29, 2019 14:50
RSS feed which improves the display of images on Micro.blog
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title><![CDATA[ {{{title}}}]]></title>
<link>{{{blogURL}}}</link>
<atom:link href="{{{blogURL}}}/feed.rss" rel="self" type="application/rss+xml"/>
<description><![CDATA[ The feed of updates to {{{title}}} ]]></description>
{{#recentEntries}}
<item>
<title>{{#titleTag}}<![CDATA[ {{{title}}} ]]>{{/titleTag}}</title>
// CSS selector which will match all the HTML elements containing a date
var dateSelector = '.date';
// Iterate over all the dates, hiding each date identical to its immediate predeccessor
Array.from(document.querySelectorAll(dateSelector)).reduce(function(previousDate, el){
if (previousDate && previousDate === el.innerHTML)
el.style.display='none';
return el.innerHTML;
}, '');
@davidmerfield
davidmerfield / photos.html
Created May 16, 2019 01:04
Photos page on Blot
<!DOCTYPE html>
<html>
{{> head}}
<body>
{{> header}}
<style type="text/css">
#photos {display:flex;flex-wrap:wrap;align-items:center;justify-content:center}
#photos a {width:33.3333%;padding:1em;flex-shrink:1;flex-grow:1;box-sizing:border-box;background:none;}
</style>
<div class="container">