This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Soooooo. Its hacky, and I'm sure there are improvements (shout if you have any) but... | |
# # # # # # # # # # # # # # # # # # # # # # # # | |
# - - - Where On The Web - - - | |
# A ruby-processing tool that lets you visualize where your network traffic is coming from. | |
# | |
# My thanks to jashkenas for his excellence - not only in releasing ruby-processing | |
# but also for his rapid help in the forums when Java and Ruby fell out. | |
# | |
# Code as art, | |
# JP - jphastings.tumblr.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem install jphastings-dlc | |
require 'dlc' | |
s = DLC::Settings.new | |
s.name = "Your Name" | |
s.url = "http://yourdomain.com" | |
s.email = "[email protected]" | |
# Now you can make a dlc: | |
package = DLC::Package.new | |
package.name = "My package" # Suggested, but not required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lets javascript add twitter links to @reply style text items in any selected html elements | |
// Requires MooTools' selectors | |
function tumblrTweets(selector) { | |
$$(selector).each(function(t) { | |
t.set('html',t.get('html').replace(/@([a-zA-Z0-9_]+)/,"<a href=\"http://twitter.com/$1\">$1</a>")); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Time | |
# Gives a 'fuzzy' output of the distance to the time stored. | |
# | |
# eg. 'in 28 minutes' or '23 hours ago' | |
def roughly | |
diff = self.to_i - Time.now.to_i | |
ago = diff < 0 | |
diff = diff.abs | |
case diff | |
when 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks Ellie and Robert! http://www.ruby-forum.com/topic/187604 | |
# Allows relative times, most frequently used in times of arrival etc. | |
class ETA < Time | |
# Takes a number of seconds until the event | |
def self.new(seconds) | |
raise "ETA requires a number of seconds" if not seconds.is_a?(Numeric) | |
at Time.now + seconds | |
end | |
# Requires http://gist.github.com/116290 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cheers Andrew http://www.ruby-forum.com/topic/187508 | |
require 'delegate' | |
# Allows percentages to be inspected and stringified in human | |
# form "33.3%", but kept in a float format for mathmatics | |
class Percentage < DelegateClass(Float) | |
def to_s(decimalplaces = 0) | |
(((self * 10**(decimalplaces+2)).round)/10**decimalplaces).to_s+"%" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'plw' | |
### Program | |
if ARGV[0].nil? or not File.exists? ARGV[0] | |
$stderr.puts "Usage: #{$0} filename.plw\n You must specify a PLW file to parse" | |
Process.exit | |
end | |
$stdout.sync = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This options file will have your get_iplayer (linuxcentre.net) running smoothly on mac os x, outputting iTunes friendly m4v files (provided you install the binaries as explained below) | |
# Usually found in ~/.get_iplayer/options | |
# Download and install the binaries as described on his site, but be sure to install them to /usr/local/bin (and make sure they're executable) | |
# $ chmod +x ffmpeg | |
# $ sudo mv ffmpeg /usr/local/bin/ffmpeg | |
# and similar for flvstreamer. lame will install there by default and mplayer is explained below (for itv downloads) | |
rtmpdump /usr/local/bin/flvstreamer | |
lame /usr/local/bin/lame | |
fileprefix <name> - <episode> - <pid> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This is a quick rundown of how I got geotagging working in Tumblr via javascript and some hacking. Its in use at http://jpinjapan.tumblr.com - I hope tumblr builds it into their site soon! --> | |
<!-- This has to go somewhere at the top of your page, inside your <head>, as javascript --> | |
<!-- It prepares the regular expression that finds the geo: tags inside your various tags --> | |
var geore = new RegExp(/^geo:(-?\d+\.\d+);(-?\d+\.\d+)$/) | |
<!-- You must alter every <div> containing a post to look like this: --> | |
<div class="post text" id="post-{PostID}"> | |
<!-- This is so that the javascript can find the posts it needs to. Its a hack around my unfamiliarity with jQuery really. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- Please read the blog entry for a description as to what this is: http://jphastings.tumblr.com/post/246130623 --> | |
<playlist simulatneous="true"> <!-- Or way informing that this playlist needs to be interpreted according to this article --> | |
<chapters> <!-- A new element entirely. The Hospital Podcast is a good example of chapter use in Podcasts. --> | |
<chapter> <!-- NB. There are other ways to define chapters --> | |
<cueTime relativeTo="id_of_element">±3142</cueTime> <!-- Milliseconds in from beginning (+) or back from the end (-) of the track referenced --> | |
<name>Name of Chapter</name> | |
<image>http://path.to/image</image> <!-- Individual chapters might have the album art of the song etc --> | |
</chapter> | |
</chapters> |
OlderNewer