Pseudo-random thoughts by a random guy

Use Github Wikis Locally

I work offline fairly often, so I wondered if there was a way to get the documentation stored on Github Wiki’s and display it from a local source. After asking Zach Holman on Twitter, it turns out github already thought of this. Since it’s been a while since anybody last talked about this, I am writing up the general process and passing it around.

General Steps:

  • Install gollum
  • Clone the reveleant repo
  • cd into repo
  • gollum

Command line steps:

1
2
3
4
gem install gollum
git clone https://github.com/[USER]/[REPO].wiki.git
cd [REPO].wiki
gollum

Now navigate to localhost:4567 and you have your own copy of the wiki. Congrats!

Useful troubleshooting links:

Please, Please, Please Use This Gist to Customize Your Octopress Blog

Yesterday, I almost had a heart attack. I was browsing Hacker News and clicked on one of the links on the front page. Suddenly, I was looking at my website. Holy shit! This brave octopress blog had done me good! I had arrived. Instantly I wanted to know, how did it happen? What did I write that was so insightful that people upvoted it to the top? I had much to glory in about my great and meaningless internet victory and I needed to know the details.

I happily looked at the title of the post. Wait. When did I write something about how C++ is for real men? I hate C++. It was no matter, I was on the front page. This was my blog. Must have done it in my sleep! I’m just that awesome. Just in case though, I looked at the title of the website. When did I name my blog “(insert clever code here)”? I definitely didn’t do that. What was going on? Why would someone hack my blog and write something worthy of the front page? What was going on?

And in that moment I realized a plague had been unleashed upon the young programming hipsters of the world: bare untouched octopress blogs. It wasn’t my blog! I wasn’t even anywhere near the front page! Wat! I hadn’t been thoughtful enough to make it to the top of Hacker News. Somebody else was glorying in my internet victory! I let myself look like a fool with a flash flush of misplaced confidence! Duped with a blog that looked and felt exactly like mine. Words!

There are probably hundreds, if not thousands, of octopress blogs out there. And I would bet you that a vast majority of these blogs are the basic install without any sort of customization. Maybe, if they were lucky, they switched to the other default theme or changed the favicon. Usually, they are nothing but clones of an incredibly well designed blog.

When I look at an untouched octopress blog, my mind glazes over who actually did all this work and wrote everything up. They get put into the “probably an excellent hacker” bucket and are promptly forgotten as individuals. In terms of me actually remembering who a person is, untouched octopress blogs are basically as effective as a pastebin post. In both cases, I have no idea who wrote what and resign myself to never knowing. I am sure that was happening to me as well. “Who cares about this kid? He is just another loud mouth who uses too many exclamation points and swears too much! Forgotten.””

So I did some digging and made an easy solution for how to customize a octopress theme. I don’t want to be lumped in with everybody else. I don’t want you, humble octopress bloggers, to be lumped in with everyone else either! You are an individual and should be treated as such. I want to remember who you are so I can give you high fives later on if we meet in person.

Gist of this sassy gist: pick a color and base the entire theme around it.

  • Create a new branch for this experiment with git. (git branch rararogaga, git checkout rararogaga)
  • Copy the entirety of this gist into {octopress}/sass/custom/_colors.scss. This file should already exist.
  • Run “rake preview” in the command line.
  • Open up localhost:4000 in your browser.
  • Pick a color besides blue.
  • Get the hex for that color.
  • Go into _colors.scss and set $main-color to your not blue color.
  • Observe sass’s syntax. For what we want to do, it’s very simple and if you break something then your webpage will go back to 2001[1] in terms of design and an error message will be displayed at the top of your webpage.
  • Play with the lighten and darken functions to find the perfect balance for your color of choice. Sometimes you might have to interchange the two functions. This part is pretty fun and made me feel like I almost knew what I was doing.
  • Merge your two branches together in perfect colorful harmony!

Yes, yes, I know, it doesn’t look perfect. “Open Mind”” is now only almost as pretty as the base install. But if you change your colors, at least I will remember who you are, warts and all. You will be the gal with the terrible shade of blue for her octopress blog. And I know you, dear reader, will have a much harder time forgetting me and my blood red Open Mind octopress blog now.

"This website, as of 24 hours ago" "This website, as of 24 hours ago" "This website, as of 24 hours ago" "This website, as of 24 hours ago" "This website, as of 24 hours ago"

[1] Fun fact: I was 10 years old in 2001.

Abusing Javascript, Part ++[+[]][+[]]

To prepare for an interview with a company out in California, I started fooling around with Javascript a few weeks ago. Right at that time, there was a bunch of chatter on Hacker News about how you can do weird things with []’s and +’s with js. Go read the stackoverflow and HN threads for all the details about why the following works and why the hell you would want it to work this way.

The basics needed to understand the following:

  • +[] evaluates to 0 in Javascript.
  • ++x increments a number by one.
  • array[x] takes the xth element of an array
  • [x] returns an array with x as the only element.
  • Arrays in JavaScript are zero-indexed.
  • [1]+[2] == “12”. Each array gets toString called on it and the resulting strings are then concatenated together.
  • 12==”12”. 12 gets toString called it to match types.

So without further ado, here a way to convert any positive integer into just +’s and []’s (written in JavaScript!):