Skip to content

Instantly share code, notes, and snippets.

@johnholdun
johnholdun / business.js
Created May 29, 2013 20:37
Add some business to your social network
Array.prototype.slice.call(document.querySelectorAll("img[class*='avatar'], img[class*='profile']"), 0).forEach(function(e,i,a){ e.src = ("http://avatarpro.biz/avatar/" + encodeURIComponent(e.src.replace(/\//g, "-"))) })
@johnholdun
johnholdun / simple_server.ru
Last active December 17, 2015 18:09
Serve a directory of files AND parse them if they're not HTML!
# from your working directory, just run `rackup /path/to/simple_server.ru`
require 'tilt'
require 'sass'
run lambda{ |env|
path = ENV['PWD'] + env['REQUEST_PATH']
path += 'index' if path =~ %r[/$]
path.gsub! /\?(.+)$/, ''
params = $1
@johnholdun
johnholdun / tumblr-post-notes.php
Created August 4, 2011 06:32
Retrieve post notes for any tumblr tumblelog
<!--
a styled php version you can throw up on your apache
because i'm some kind of machinist
-->
<style>
/* oooh */
html, body, ul, li { font-family: Verdana; font-size: 14px; line-height: 20px; }
body { width: 400px; margin: 20px auto; background: #333; }
ul { list-style: none; }
li { margin-bottom: 10px; color: #AAA; overflow: hidden; height: 20px; white-space: nowrap; text-overflow: ellipsis; }
@johnholdun
johnholdun / imgur-bookmarklet.js
Created April 9, 2011 22:43
Bookmarklet for uploading the image currently loaded in your browser to imgur
// that is, navigate to the direct URL for an image hosted on the world wide web, then >>>INVOKE<<<
// i wanted the bookmarklet to redirect to the new direct image URL but that was out of scope!
javascript:void(window.location="http://api.imgur.com/2/upload.json?url="+encodeURIComponent(window.location.href));
# That apartment is nice but it's outside your "40 x rent" limit.
# How much more are you gonna have to pay?
# NOTE: I Am Not A Broker, I'm only *pretty* sure this is how it works,
# calculate at your own risk.
def security(rent, salary)
normal_security = rent * 2
base_rent = salary / 40.0
# title_is_summary - does this RSS item REALLY have a title?
# see: tumblr photo posts
#
# title = (title of some RSS item)
# description = (description of the same item)
clean_title = title.strip.gsub(/\s+/, ' ').sub(/\.\.\.$/, '')
clean_description = description.gsub(/(<|&lt;).+?(>|&gt;)/, '').strip.gsub(/\s+/, ' ')
title_is_summary = clean_title == clean_description[0 .. clean_title.size - 1]
# tl;dr
# grabs some tumblr posts from google and returns their word lengths!
# for nostrich!
require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'json'
lengths = []
@johnholdun
johnholdun / audio_player_embed.js
Created December 18, 2009 02:18
A simple bit of code that automatically prepends an AudioPlayer instance (http://wpaudioplayer.com) before the paragraph of any link to an MP3.
/* * *
A simple bit of code that automatically prepends an AudioPlayer instance
(http://wpaudioplayer.com) before the paragraph of any link to an MP3.
Depends on jQuery and AudioPlayer.
* * */
$(function() {