Skip to content

Instantly share code, notes, and snippets.

@danmactough
danmactough / fail.js
Created July 31, 2013 18:25
slug fail
var slug = require('slug');
console.log(slug('Ȁ ȁ Ȃ ȃ Ȅ ȅ Ȇ ȇ Ȉ ȉ Ȋ ȋ Ȍ ȍ Ȏ ȏ Ȑ ȑ Ȓ ȓ Ȕ ȕ Ȗ'));
// ''
@danmactough
danmactough / snippet.js
Created July 31, 2013 14:34
Easy undo/redo
this.on('change', function () {
changes.push(this.previousAttributes());
});
undo: function () {
undone.push(this.toJSON());
this.set(changes.pop());
};
redo: function () {
@danmactough
danmactough / apple.sh
Last active March 24, 2021 00:22
Apple cli tweaks
# Disable gesture navigation only in Chrome
# http://apple.stackexchange.com/a/80163/53921
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE
# Make Finder display "hidden" files and folders
# like ~/.ssh
defaults write com.apple.finder AppleShowAllFiles TRUE
# Apache in Mountain Lion
# http://reviews.cnet.com/8301-13727_7-57481978-263/how-to-enable-web-sharing-in-os-x-mountain-lion/
@danmactough
danmactough / index.js
Created July 1, 2013 14:23
Example of using feedparser v0.16.x with a string input
var fs = require('fs')
, feedparser = require('feedparser');
var str = fs.readFileSync('./rss2sample.xml', 'utf-8')
, parser = new feedparser();
parser.on('error', console.error)
.on('readable', function () {
var stream = this, item;
while (item = stream.read()) {
#! /usr/bin/env node
var feedparser = require( 'feedparser' );
var request = require( 'request' );
var feedTest = function (url){
var object = {};
object.articles =[];
request( url, {timeout: 20000}, function(error, resp, body){
if (error){
@danmactough
danmactough / localStorageExport.js
Created March 26, 2013 21:00
Save a copy of your Little Outline
var $target = $('div.divExplanation:first');
var $dl = $('<div></div>', { 'class': 'divExplanation' });
$dl.prepend($('<a></a>', {
'class': 'saveCopy', // IE 8 bug with the "class" attr requires quotes
href: '#',
title: 'Click here to save a copy of your Little Outline',
download: 'myLittleOutline.opml',
text: 'Download Your Litte Outline'
}));
$dl.insertBefore($target);
@danmactough
danmactough / chain.js
Created January 10, 2013 20:30
Simple function chaining function
var chain = module.exports = function(x, fns){
for (var i=0, l=fns.length; i < l; i++){
x = fns[i](x);
}
return x;
};
@danmactough
danmactough / git-changelog.sh
Created October 22, 2012 02:34
Custom git-changelog
#!/bin/sh
DATE=`date +'%Y-%m-%d'`
HEAD="\nn.n.n / $DATE \n==================\n\n"
function gcl () {
version=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1))
if test -z "$version"; then
git log --no-merges --pretty="format: * %s (%an)"
else
[{"title":"Techmeme","xmlUrl":"http://www.techmeme.com/feed.xml"},{"title":"Sam Ruby","xmlUrl":"http://intertwingly.net/blog/index.atom"},{"title":"Lethal Librarian","xmlUrl":"http://www.lethal-librarian.net/?feed=rss2"},{"title":"inessential.com","xmlUrl":"http://inessential.com/xml/rss.xml"},{"title":"Amyloo","xmlUrl":"http://hosting.opml.org/amyloo/blog/rss.xml"},{"title":"bits & bytes & pixels & sprites","xmlUrl":"http://www.bitsbytespixelssprites.com/blog/feed/"},{"title":"Bad Gods","xmlUrl":"http://badgods.com/rss.xml"},{"title":"Geek's Guide to the Galaxy","xmlUrl":"http://io9.com/podcast.xml"},{"title":"Writing (3)","xmlUrl":"http://www.quicktopic.com/36/H/QaFaSkQcyBG.rss"},{"title":"Ficlets Blog","xmlUrl":"http://ficlets.com/blog/feed"},{"title":"Achewood","xmlUrl":"http://achewood.com/rss.php"},{"title":"Achewood","xmlUrl":"http://www.achewood.com/rss.php"},{"title":"Auralgasms News","xmlUrl":"http://www.auralgasms.com/AuralgasmsNews.xml"},{"title":"100 Word Stories","xmlUrl":"http://100wordstories.
@danmactough
danmactough / sanitizeQuerystring.js
Created May 17, 2012 20:41
Sanitize Querystring
function sanitizeQuerystring (url){
var Url = require('url');
var u = Url.parse(url, true);
delete u.search;
for (var key in u.query){
/^utm_/.test(key) && delete u.query[key];
}
return Url.format(u);
}