“Bombay” by El Guincho.

As a youth I had a Stone Protectors action figure—specifically Chester—and only just now found out what they are.
No idea how I got to this page whatsoever. Pretty hilarious story regardless.
EDIT: Disregard all of this since the ruddy API has moved to OAuth for everything.
Seize the day! be a gangster. Put your tumblr in a page using the magic of PHP. I never use Javascript exclusively to deliver content because some people don’t have javascript going, or don’t want it. And it’s just unfair to ask them to process your junk. The following code downloads your Tumblr API XML and makes an array of posts that you can print out in some normal PHP. This code is not even, JV, not even thirds, not even practice sqaud, not even rec. It’s thinking about joining an intramural team. It is weak. Call this an 0.0.0.0.0.0.0.1 release.
Ok first we need to grab the XML. We are going to create a new DOMDocument with it. The DOMDocument::load function returns false if it was unable to load the requested XML. This is important, as Tumblr will often throw 503s.
$doc = new DOMDocument();
while(@!$doc->load("http://perkee.tumblr.com/api/read?$query"))
{
sleep(1); //seriously this is a design for only the criminally insane. Do not use it.
}
So we wait a second between each try. you can use usleep() to wait for less time.
Then we want to make an array of posts. No biggie, but this code is large and in charge. Since I resent the wackiness of PHP, I did not break this up into enough modular functions. My b. I told you this sucks.
$posts = array();
date_default_timezone_set('America/New_York');
foreach($doc->getElementsByTagName('post') as $post)
{
$p = array(
"id" => $post->getAttribute("id"),
"type" => $post->getAttribute("type"),
"date" => date('l j F Y',$post->getAttribute("unix-timestamp")),
"tags" => array(),
);
foreach($post->getElementsByTagName('tag') as $tag)
{
$p['tags'][] = $tag->nodeValue;
}
switch($p['type'])
{
case "regular":
$p['title'] = $post->getElementsByTagName('regular-title')->item(0)->nodeValue;
$p['body'] = $post->getElementsByTagName('regular-body')->item(0)->nodeValue."\n";
break;
case "video":
$p['body'] = "<div class=\"video\">\n ".
$post->getElementsByTagName('video-player')->item(0)->nodeValue.
"\n</div><div class=\"caption\">\n ".
$post->getElementsByTagName('video-caption')->item(0)->nodeValue.
"\n</div>\n";
break;
case "audio":
$p['title'] = $post->getElementsByTagName('id3-artist')->item(0)->nodeValue.
' - <span class="song">'.
$post->getElementsByTagName('id3-title')->item(0)->nodeValue.
"</span>";
$p['body'] = "<div class=\"audio\">\n ".
$post->getElementsByTagName('audio-player')->item(0)->nodeValue.
'</div>'.
"\n<div class=\"caption\">\n ".
$post->getElementsByTagName('audio-caption')->item(0)->nodeValue.
"\n</div>\n";
break;
case "quote":
$p['body'] = "<div class=\"quote\">\n".
" <span class=\"quote\">\n".
// " <big class=\"quote\"><a href=\"./posts/".$p['id']."\">“</a></big>\n".
" ".$post->getElementsByTagName('quote-text')->item(0)->nodeValue."\n".
" </span>\n".
" <div class=\"source\">— ".
$post->getElementsByTagName('quote-source')->item(0)->nodeValue.
"</div>\n</div>\n";
break;
case "photo":
$p['body'] = "<img src=\"".
$post->getElementsByTagName('photo-url')->item(0)->nodeValue.
"\" />\n<p>\n".
$post->getElementsByTagName('photo-caption')->item(0)->nodeValue.
"\n</p>";
break;
case "conversation":
$p['title'] = $post->getElementsByTagName('conversation-title')->item(0)->nodeValue;
$convo = $post->getElementsByTagName('conversation')->item(0)->getElementsByTagName('line');
$p['body'] = "<ul>\n ";
$odd = true;
foreach($convo as $line)
{
$p['body'] .= "<li class=\"".($odd ? "odd" : "even")."\">\n <span class=\"label\">".
$line->getAttribute('label') . "</span>\n ".
$line->nodeValue . "\n</li>\n";
$odd = !$odd;
}
case "link":
$p['title'] = "<a href=\"".$post->getElementsByTagName('link-url')->item(0)->nodeValue."\">".
$post->getElementsByTagName('link-text')->item(0)->nodeValue."</a>";
$p['body'] = $post->getElementsByTagName('link-description')->item(0)->nodeValue."\n";
break;
}
if(count($p['tags']) > 0)
{
$p['body'] .= "<ul class=\"tags\">\n";
foreach($p['tags'] as $tag)
{
$p['body'] .= " <li><a href=\"/blog/tags/$tag\">$tag</a></li>\n";
}
$p['body'] .= "</ul>";
}
$posts[] = $p;
}
?>
Ok, so you’re probably a little weirded out. Well, the XML stores most of the post meta-info in attributes of the <code> tag. So those are dealt with first. They are really easy; getAttribute() does what it says on the tin.
Building the titles and bodies of posts is super arbitrary. I chose the most descriptive things I could, which is why I used the ID3 tags for MP3 posts. If you posted a song without them, then they won’t show up. In fact, everything will go to hell if you leave titles off of most things. It’ll just look terrible; please don’t. It’s easier to read with titles anyways. So that switch builds the bodies and titles based upon the post type. Conversation doesn’t work and I don’t know why. ‘Scuse me while I kiss the sky.
Ok tags are last. They are super easy. Not much to say there. Style them nice of course; they’re worth it. But why, you ask, did I make the links the ones I did? I want permalinks to stay on my page, not on Tumblr. Ditto next page and tags. I’ll throw in search too. So for that part, I have this on top of everything.
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$postsPerPage = 10;
$query = "?num=$postsPerPage";
if(isset($_GET['posts']))
{
$query .= '&id='.$_GET['posts'];
}
elseif(isset($_GET['page']))
{
$query .= '&start='.(($_GET['page'] - 1) * $postsPerPage);
}
elseif(isset($_GET['tags']))
{
$query .= '&tagged='.$_GET['tags'];
}
To handle rewrite the pretty URLs into PHP GET queries, I have this little gem in my ./htaccess file in the blog directory. I should mention that all of the PHP goes into /blog/index.php on my site.
RewriteEngine On RewriteBase /blog RewriteRule ^([^/]+)/([^/]+)$ ?$1=$2
Ok more to come later. I’m writing from a Macbook Pro in a Starbuck’s and if I keep going for too long I’ll have to kill myself. I put most of the finishing touches on this on the AMtrak up to Boston today. Shit was boss.
(Source: perk.ee)
This is the anthem for anyone who has been hit by a car. Real or figurative—in my case, real.
So I’m all done with my math course and its notes. The following is a file I call settheory.sty which I invoke with \usepackage{settheory} and it works pretty well for me. The gist of it is that I don’t have to describe what a symbol looks like, rather what it means. Also, it means that later, when you are writing the stuff out by hand you aren’t saying “A-cup-B” in your head when you really mean “A-union-B”
%%%%%%This is where I put in math commands
\let\Implies\implies
%\renewcommand{\implies}{\ensuremath{\to}}%the normal implies arrow is double width, so this makes it thinner
%particular sets
\newcommand{\algebraics}{\ensuremath{\mathbb{A}}}
\newcommand{\naturals}{\ensuremath{\mathbb{N}}}
\newcommand{\integers}{\ensuremath{\mathbb{Z}}}
\newcommand{\rationals}{\ensuremath{\mathbb{Q}}}
\newcommand{\reals}{\ensuremath{\mathbb{R}}}
%words
\renewcommand{\iff}{\ensuremath{\operatorname{\ iff\ }}}
\DeclareMathOperator{\st}{\ s.t.\ }
%logic
\newcommand{\nd}{\ensuremath{\operatorname{and}}}
\newcommand{\ro}{\ensuremath{\operatorname{or}}}
\DeclareMathOperator{\then}{then}
\DeclareMathOperator{\but}{but}
%set operators
% Relations between sets
\let\propsubset\subset
\renewcommand{\subset}{\subseteq}
\let\propsupset\supset
\renewcommand{\supset}{\supseteq}
% Operations on sets
\newcommand{\cartesian}{\ensuremath{\times}}
\newcommand{\intersect}{\cap}
\newcommand{\union}{\cup}
\newcommand{\symdif}{\vartriangle}
%highly semantic anal retentive perkee at your service stuff
\newcommand{\maps}{\ensuremath{:}}
\newcommand{\bjto}{\ensuremath{\xrightarrow[\text{onto}]{1\text{--}1}}}
\newcommand{\approaches}{\to}
\newcommand{\comp}{\circ}
\newcommand{\nimplies}{\implies\mkern-30mu\not{}\quad\ }
\newcommand{\tet}[2]{\prescript{#2}{}{#1}}
\newcommand{\collection}[1]{\mathscr #1}
%\let\Prime\prime
%\renewcommand{\prime}[1]{#1^\Prime}
%\newcommand{\pprime}[1]{#1^{\Prime\Prime}}
%stuff that puts in brackets
\newcommand{\seq}[1]{\langle #1 \rangle}
\newcommand{\absolute}[1]{\left| #1 \right|}
%\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand\eq[1]{\left[#1\right]}
\newcommand{\ordered}[1]{\left(#1\right)}
\newcommand{\sine}[1]{\sin\left(#1\right)}
\newcommand{\cosine}[1]{\cos\left(#1\right)}
\usepackage{ifthen}
\newcommand{\interval}[3][n]%prints neither, left, right, or both as brackets instead of parentheses
{%
\ifthenelse{\equal{#1}{n}}{\left( #2,#3 \right)}{}%
\ifthenelse{\equal{#1}{l}}{\left[ #2,#3 \right)}{}%
\ifthenelse{\equal{#1}{r}}{\left( #2,#3 \right]}{}%
\ifthenelse{\equal{#1}{b}}{\left[ #2,#3 \right]}{}%
}
%functions
\newcommand{\funct} [2]{#1\!\left(#2\right)}
\newcommand{\inv} [1]{#1^{-1}}
\newcommand{\inverse} [2]{\funct{\inv{#1}}{#2}}
\newcommand{\allf} [2]{\funct{\mathscr F}{#1,#2}}
% Operations on one set
\newcommand{\complementset} [2][]{\ensuremath{\funct{\mathscr{C}_{#1}}{#2}}}
\newcommand{\powerset} [1]{\ensuremath{\funct{\mathscr P}{#1}}}
\newcommand{\id} [1]{I_#1}
%characters that needed better spacing
\let\oldexists\exists
\renewcommand{\exists}{\ \oldexists}
\let\oldforall\forall
\renewcommand{\forall}{\ \oldforall}
%%derivatives
%\newcommand\od[3][]{\frac{\mathrm d^{#1}#2}{\mathrm d{#3}^{#1}}}
%%underbraces
\let\underbrace\LaTeXunderbrace
\let\overbrace\LaTeXoverbrace
When I’m multiplying a bunch of quantities with units, it’s pretty nice to show that they cancel, especially when you want to step through your reasoning when converting units that are actually made up of a lot of SI base units. I developed this little number for showing this in a report or whatever, with the numbers on the left side and units on the right, separated by at least a \quad.
\newcommand{\ufrac}[4]{\frac{\hfill#1\quad\hfill\mathrm{#2}}{\hfill#3\hfill\quad\mathrm{#4}}}