Recently, I’ve been using a lot of rounded corners in my layouts. Declaring each rounded corner in each of three different ways gets old really fast. So, I created a set of mixins. Sass mixins are almost like functions. You define a mixin with a series of CSS properties and then include that mixin in a selector. Mixins can even take parameters (including default values). The rounded corner mixins I created are pretty simple:

=round-top-left(!radius)
  :-moz-border-radius-topleft = !radius
  :-webkit-border-top-left-radius = !radius
  :border-top-left-radius = !radius
=round-top-right(!radius)
  :-moz-border-radius-topright = !radius
  :-webkit-border-top-right-radius = !radius
  :border-top-right-radius = !radius
=round-bottom-left(!radius)
  :-moz-border-radius-bottomleft = !radius
  :-webkit-border-bottom-left-radius = !radius
  :border-bottom-left-radius = !radius
=round-bottom-right(!radius)
  :-moz-border-radius-bottomright = !radius
  :-webkit-border-bottom-right-radius = !radius
  :border-bottom-right-radius = !radius
 
=round-top(!radius)
  +round-top-left(!radius)
  +round-top-right(!radius)
=round-bottom(!radius)
  +round-bottom-left(!radius)
  +round-bottom-right(!radius)
=round-left(!radius)
  +round-top-left(!radius)
  +round-bottom-left(!radius)
=round(!radius)
  :-moz-border-radius = !radius
  :-webkit-border-radius = !radius
  :border-radius = !radius

Now, I can just @include round.sass in any Sass file I want to use rounded corners in. After that, adding rounded corners is as easy as:

.something_rounded
  +round(1em)

Which generates the following CSS:

.something_rounded {
  -moz-border-radius: 1em;
  -webkit-border-radius: 1em;
  border-radius: 1em; }

To round just some corners:

.something_somewhat_rounded
  +round-top-left(2px)

Will generate the following CSS:

.something_somewhat_rounded {
  -moz-border-radius-topleft: 2px;
  -webkit-border-top-left-radius: 2px;
  border-top-left-radius: 2px; }

Easy-peasy! Not only do I no longer have to include the three different browser definitions and remember which ones format the corners in which way (radius-topleft vs. top-left-radius), but when I want to change the value, I only have to change it in one place.

I’ve been wanting to use Instapaper a lot more than I currently do. It seems perfect for moving links around between all the various places I use the internet, but to do that well, I need a lot of different accounts. And I need to be able to post to any of those accounts with one click.

After a bit of searching around the internet, I concluded that if I wanted to have per-account bookmarklets, I’d have to make them myself. It took a little bit of doing (URL-encoding, you are not my friend) but I have done it!

If you’d like your very own account-specific bookmarklet, drag this link to your bookmarks bar then edit it to add in your own username and password in the appropriate spots. If you don’t have a password, you can leave that part out.

It’s really, really hacky at the moment. You can’t select text to use as the summary, you can’t manually change the title (it’ll be automatically pulled from the page) and all you get to tell you it worked it a little window that says 201. If it says anything else, it didn’t work. If you get a 403 the first thing to check is that any special characters in your username or password are escaped.

I just ran in to a really interesting result from Ruby, and one that my google-fu turns up no other references to. When you split a string, you can use a regex as your split delimiter. It’s pretty handy. I’m trying to do some parsing on an Emacs org-mode file, so I wanted to split the text of the file on any number of *’s at the beginning of the line, followed by a space. Simple regex, right? Yes, but with a catch. I will want to know how many stars there were matched, and split strips out the delimiters.Ok, I thought, I’ll put my delimiters in a group and use that. If I’d stopped and though about split for a minute, I would have known that wouldn’t work. What would it capture? The group matched at the last split? I thought it would work since I was immediately calling each on the split string. Ok, so unsurprisingly, $1 is nil inside my each. But what is surprising: the group was then included in the array generated by split. Not so helpful for the each, but an interesting approach. My googling has turnedup nothing about this. It’s a very interesting mechanism. Here’s some sample code:

string = "joe says hello there bob to jane who says hello there bob to sue"
string.split(/ hello there bob /).each do |i|
  puts i
end

string.split(/ hello (there) bob /).each do |i|
  puts i
end

The first split and each outputs:

joe says
to jane who says
to sue

The second split and each outputs:

joe says
there
to jane who says
there
to sue

Not quite what I was trying to achieve, but certainly an interesting result.

I tried out The Hit List and, after using it for a little while, decided it wasn’t for me. I wanted to get my data back out and into org-mode. It’s all stored in a SQLite3 database, so I wrote a Ruby script to go through the database and spit everything out in org-mode format. It’s available on pastie here.

The script works pretty well, but it does have some problems. It spits out a good bit of unnecessary stuff, it doesn’t do anything with tags and contexts, and it makes some assumptions about your org-mode setup. It assumes you’re using org-odd-levels-only and that you have the TODO keywords ’TODO’, ’DONE’, and ’CANCEL’ defined. It also assumes that you haven’t changed any of the standard keywords for item timestamping.