Skip to content

Instantly share code, notes, and snippets.

@johnholdun
johnholdun / tumblr-archive.rb
Last active August 29, 2015 14:02
Get all your dang tumblr posts
require 'json'
require 'open-uri'
hostname = 'irc'
posts = []
page = 1
pages = 1
per_page = 20
begin
@johnholdun
johnholdun / spirit-locations.rb
Created September 26, 2014 12:21
Scrape the Spirit Halloween store locator and return a sensible array of hashes
require 'open-uri'
require 'nokogiri'
require 'yaml'
def aggressive_strip text
text.strip.gsub(/[\s\r\n]+/, ' ')
end
postal_code = 10003
url = "http://checkout.spirithalloween.com/storelocation.aspx?zipPostalCode=#{ postal_code }"
@johnholdun
johnholdun / crew.rb
Last active August 29, 2015 14:22 — forked from Will-Sommers/gist:4fe13e7a9383318f4bcd
An okay way to interleave names
FOLKS = %w(
Caroline
Chris
Dave
Devin
Hindi
John
Kai
Nizar
Pat
@johnholdun
johnholdun / Rakefile
Last active August 29, 2015 14:26
commit, build, and publish a new version of your gem
namespace :gem do
task publish: [:commit, :build, :fury]
task :commit do
current_branch = %x(git rev-parse --abbrev-ref HEAD).strip
git_status = %x(git status --short --untracked-files=no)
unless current_branch == 'master'
puts 'Only run this task with master checked out!'
return
@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 / 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 / cookie_test.rb
Last active November 13, 2015 18:27
Cookie Test: Given the same cookie set to different values on different domains, what persists?