Skip to content

Instantly share code, notes, and snippets.

@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() {
# 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 = []
# 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]
# 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
@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));
@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 / 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 / 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, "-"))) })
ids = [329740082619772928, 329918487558504451, 330280700072833026, 330651260321669121, 331023740257325057, 331355726356291585, 331747132803518465, 332093606355664896, 332458504747110401, 332817496753184768, 333183149867667458, 333542218503696384, 333921623436574721, 334270156035469314, 334632030774099969, 335013040451891200, 335369313466871808, 335719753299685376, 336094052749565952, 336461902785966081, 336790999277916162, 337173236968210432, 337529860106878976, 337875782665912320, 338255438862766080, 338630809231708160, 338988045032370177, 339350345010536448, 339714371792035841, 340065176281837569, 340451705298771968]
ids.each do |id|
method = :post
uri = URI "https://api.twitter.com/1.1/favorites/create.json"
params = { id: id, include_entities: false }
request = Net::HTTP::Post.new uri.request_uri
request.set_form_data params
request['Authorization'] = SimpleOAuth::Header.new(method, uri, params, {
consumer_key: CONSUMER_KEY,
@johnholdun
johnholdun / bible-doge.rb
Last active December 26, 2015 19:49
wow. so minister. much earth. many angels.
require 'open-uri'
puts open('http://johnholdun.com/wardrobe/bible-doge.txt').read.split("\n").sample(1 + (rand * 2).round).shuffle.send((rand < 0.5 ? :unshift : :push), 'wow').join('. ') + '.'