A Wallabag bookmarking script for Newsboat
Ruby and httparty worked where a simple bash script wouldn't. Letting Newsboat have two bookmarking commands.
Read the essay →Ruby and httparty worked where a simple bash script wouldn't. Letting Newsboat have two bookmarking commands.
Read the essay →Sorta the mutt of RSS readers. Scripting the Linkding API.
Read the essay →Multi-account, GPG-secure mutt configs. Mutt message scoring with Ruby, and score color-coding.
Read the essay →A Ruby/CLI-based plaintext PRM, Robert DeNiro on exporting org-mode to JSON, blogging with ox-hugo, that Royal Enfield Himalayan
Read the essay →A Mackup/Dropbox glitch, integrating org-contacts and Things, conversations not interviews.
Read the essay →A very cheap and cheerful DayOne-to-org-roam exporter and a link to a useful org-roam search function.
Read the essay →I modified a Perl lbdb backend by @[email protected] to use my org-contacts with mutt
Read the essay →I finally took the time to play with ChatGPT to configure Emacs and write some Ruby.
Read the essay →Some ruby wired up to mutt macros allows for on-the-fly sender scoring and a color-coded message index.
Read the essay →Weekend Science Project (Rails After Time Away)
We need to do a documentation inventory at work. We’ve added a lot to the docs over the past year, and we’ve got a few things lurking around in there that need to be flagged for QA or revalidation. The stock answer is “put all the pages in a spreadsheet and start clicking/scrolling and annotating the list,” but I’ve been pining to fiddle around with a tool for a little while, and spreadsheets suck, so I decided to see how quickly I could put something together to make the job a little easier for the team (and reviewers down the road).
I started out with a Padrino app, which was a great way to do a proof of concept on what I was after:
For that last, “elements of interest” became “ordered lists and things inside pre tags.” They represent the step-by-step instructions in the docs; either in “do this, then this, then this” form, or in “start typing this stuff on the command line” form. They’re the things people gravitate to and start following, and we know that the average technical user is prone to looking for just those things and not looking at the surrounding text.
Putting a checksum on each of them will provide a way to do reports that show when an element appears on multiple pages, and across multiple versions of the docs. You kind of expect things like ordered lists to change a little over time. If one has persisted over four or five releases without changing, you might want to look at it and make sure it hasn’t been overlooked.
So after four or so hours of work, my Padrino app could do all that stuff, wrapped up in Bootstrap. I could fire up the app, get a list of all the documentation pages by product version, and use some widgets to do a few useful things:
That seemed pretty useful just as a way to help someone rip through a collection of pages and look for just the things most likely to cause a user pain, then maybe enter them in a log.
Once I was home for the weekend, though, I realized that I wasn’t as familiar with Padrino as I once had been with Rails, so I decided to do a quick port. Since I’d used ActiveRecord for the original app, and since I was happy with my db schema, it was pretty simple to set up the models, re-run the migrations, and reuse the importer scripts to repopulate my development db with content.
I spent a few hours on Saturday and a big chunk of Sunday trying to see how far I could get before, well, having enough time to blog about it before ending the long weekend and going to bed. I didn’t want to put any more time in on it at work, because if I ran into a dead end and couldn’t make what I wanted, I didn’t want to feel obligated to try using it.
I had to relearn a few things about Rails that have changed since I last used it much (during v2 times), and I had to learn some new things about jQuery that I’ve never dealt with before. Still, I’m pretty happy with where it’s at now:
First, I implemented flags. For now, all you can do is flag a page if you see something you think might be a problem that needs further review. I’ve got a few ideas about how to flag individual elements. One way is super simple, but doesn’t allow you to flag them in the context of the text. The other is tougher and I’m still working on relearning Rails’ AJAXy stuff to figure out a way to flag an element in place, store it, then have it highlighted as flagged next time you visit that page.
Next, I added a working user authentication model with Devise, so flags can belong to individual people. For now, it just means that if two people look at the same page, they don’t have to agree on its flaggability. Down the road, it’ll mean there’s a way to share the tool with all our technical reviewers so that they can flag things and we can capture all the flag data from them. I’d like to add a way to enter a comment, too, but one thing at a time.
Finally, I got thiiiiis close to making the flag button truly dynamic. All the AJAX stuff I knew from when I built my last Rails app has changed, and I couldn’t figure it all out in time, so for now I just force a page refresh when the user clicks the flag button to get it to change its state from “flag this” to “unflag this.”
There are a few more things I’d like to get to:
It’s in a place where I knock most of that stuff off with another leisure-time sprint, then see about hosting it somewhere relatively secure where I can put it in front of a few people for real feedback.
It also reminds me of all the stuff I wish I knew more about, like testing. I guess if I can get it into a useable state for other people, I can use it as a sandbox for learning about that stuff.
Anyhow, here it is. Hope you had a good Presidents Day weekend. Good night.
Not a bad time at all (tech edition)
Sometimes it's nice to stop and look around and think about all the things you've been taking for granted. I've been in the process of handing two projects over to coworkers, one small and one large, and it's caused me to go out looking for ways to make that easier. I don't work on an actual dev team: My stuff has been solo efforts, so I'm aware that it probably looks and feels a little different from what everybody else is used to. It was good to find a few tools to make the handover less painful.
So here are a few things I'm newly grateful for:
Wow. TextMate has great support for git repositories, so it was super-easy to set up a repository, add all the files, write a few READMEs in Markdown and hand things over. When something needed tweaking, it was a simple matter to make a fix, push it up, and let the recipients know. One of them was on Windows and needed different instructions to get things running? Fine ... I made a Windows branch with its own instructions and dependency lists.
Maybe not as important, but GitHub made me feel better about dropping that code on my coworkers because it made everything more approachable. It makes the READMEs look good (and readable) and it makes the source easy to browse with pleasant syntax highlighting.
I've been developing with Rails on OS X, able to install whatever I need to get a gem working, updating my rubygems install whenever it suits me, etc. etc. I didn't want to make my coworkers go through custom-building their own Ruby or rubygems, and after a few years of getting everything just so I know there's a chance I've got something on my machine they don't have on theirs. So RVM completely rocked.
RVM stands for "Ruby Version Manager," and it's a way to get a self-contained Ruby sandbox running on an unprivileged account. At its simplest, RVM lets you bypass your distro's elderly Ruby packages and update your Rubygems package without getting a scolding about how your distro will be pleased to update that on its own timetable.
RVM can do a lot more: You can install multiple versions of Ruby and switch back and forth between them with something like:
rvm use 1.8.7
If you'd like to use whatever Ruby came with your distro:
rvm system
If you've got three or four Rubies floating around, you can set a default:
rvm --default use 1.9.2
You can also create swappable gem sets.
I first reviewed VMWare 11 years ago, when this is what passed for a middling machine:
VMware’s base system requirements are a Pentium II/266 MHz processor and at least 96 MB of RAM. We tested the software on several configurations, ranging from a machine at the very lowest end of the recommended specifications to a Pentium III/500 with 128 MB RAM. Performance is clearly helped by devoting plenty of RAM to the virtual machine. A computer with 160 MB or more is closer to ideal, unless you run X with a conservative window manager and few applications.
I could have spent some time guessing about what might be needed to get my projects working for somebody else, but it was a lot easier to ask "which distro are you running?" download the necessary disc image, set up a VM to match their environment, then run through installation and testing. I did that twice this week: Once to match a developer's workstation, once to make sure I was testing against the company server platform.
Ubuntu each time, by the way. I don't know what the current state of the distro wars is, but Ubuntu went up about the way I remember Debian going up: easily and thoughtfully, leaving me with something that Just Worked for my limited purposes. So good for it.
So, _I_ know the script is doing what it's supposed to be doing because I've been fiddling with it for a year. Not everybody else does, so there are a few ways to denote that something is happening. One is just adding an extra bit of noise to each iteration of the main loop to simulate a comforting beeping noise. Another is to use the handy progress_bar gem, which adds a progress bar that can show a counter, percentage completed, rate and ETA with just a few extra lines. Looks nice, less noisy, took all of a minute to add.
#programming #ruby #the future
Pow! etc.
It seems as if a few colleagues might need to use that little Sinatra-based reclassifier ditty, which is always a nice thing: The first iteration of these things usually seems to come close to breaking even on time saved if I just use it once, but if I can make the same tool available to one or two more people, then it's a lock to earn the development time back and start saving a lot of time.
The problem with sharing stuff like Rails and Sinatra is deployment. Easy for me to set something up on my desktop that never seems to leave dev mode, but less of a pleasure to get it working for others, especially on shared hosting.
Several things will help with that:
First, Pow! from 37 Signals makes it easy to create a local development domain for webapps that use Rack. You just install it, create a config.ru file for your app in its directory, then symlink the app directory to ~/.pow and it becomes available at http://yourappdir.dev. Besides being a great way to work on a number of webapps in parallel, it's a nice way to practice dealing with Rack.
Second, it looks like it's not too hard to use those Rack-enabled apps on Dreamhost. This worked for my config.ru file, and it's the same as the one I use for my desktop machine:
Third, it's not too hard to add http authentication to a Sinatra app. That means I can deploy little apps that don't require a robust user model to a subdomain and protect them for as long as they need to be up, which is just a day or two. Here's all I had to add to the top of my app file to get http authentication:
This all makes me think back to 2008, when I wrote about my recent discovery of Rails: The combination of Sinatra, Pow! and Rack does even more to provide me with a comfortable replacement for lightweight databases, and makes it much easier to share my work, which is even better.
#37signals #dreamhost #pow #rack #ruby #sinatra
Sinatra ftw (Updated)
So, I have this task to accomplish:
I've got 1,180 articles that were all placed in a website directory I no longer want to keep. The friendly dbas gave me an Excel spreadsheet showing me each article's title, url, pub date, author and current directory. I'm to go down the list and reassign each article.
I made it through 15 entries before realizing it's hard to tell what an article's about from just the headline. Some things look like tutorials, but they're reviews, some things look like reviews, but they're analysis. I can either guess, or I can copy the URL, flip to my browser and load the article then decide how to classify it. This process sucks:
So I gathered together a few tools:
Then I set up a sqlite database & fed the Excel spreadsheet into it and sat down with Sinatra.
Here's the finished app (minus the one template page I use):
It's missing some affordances, but the long and short is demonstrated here:
You start with a given article. It shows you the headline, pub date and author. Using the summarizer gem, it pulls in a summary representing 25 percent of the total text. You pick a new category for it from the radio buttons, click "Reclassify," and it takes you to the next record (unless you're done, in which case it just reloads the current record.
The time gain? I dunno. If I worked like a machine, I'd probably be done in four hours. Now it takes less time to update a record and I don't have to do as much to update it: Just click a radio button, click a submit button, move on. Even if it turns out the time I save is offset by the coding time (two hours, with a break for coffee, chatting, answering mail), I guess I figured out a way to spend some time that would be wasted screwing with Excel getting to play with Sinatra. And since I'm going to have to do the same task in a few weeks for another site, I'll have time-saving code ready to go.
Update: Even better with a bit of jQuery: Rather than loading the article summary every time (even though I don't always need it to tell what kind of article I'm dealing with), I wrote an additional route that handles providing just the summary and used jQuery's load function to pull in the summary for review when I click on a "load summary" button. That makes things a lot faster when I can tell what an article is just from the headline.
Update2 : Sinatra uses Mongrel by default, which is fine, except I noticed that every now and then a page load would go from taking an average of a fifth of a third or so to five seconds. Meh. So I sudo gem install thin'd the thin gem, and got much more consistent, snappy performance.
Remodium (and Ruby, just because)
You know what drives me crazy? Walking out of the office to go get a coffee or walk Ben back from school (which usually involves a stop in the park on nice days) and forgetting how I’ve left things with IM in the office. If I forget to sign in with whatever IM app I’m using on the phone, there’s a chance there’s an unseen message in the office. If I sign in with the phone but forget to send a disconnect message to AIM, my chat archives will fill up with one-sided conversations on my desktop. And I don’t get archiving worth having if it’s all on my phone, where it’s harder to track down and copy or paste into my notes.
So Remodium is this iPhone app that acts as a remote control for the Mac IM client Adium:
Remodium allows you to remotely interact with an Adium session on your Mac from your iPhone or iPod Touch. You can view existing chats, resume existing chats, or start new ones!
Using Adium, you only need to sign into your chat services once. All of your groups, contact aliases and meta-contacts will appear normally.
All Remodium chats are stored with regular Adium Chat Transcripts.
Remodium also supports Apple’s Push Notification service. Simply add “Push” to your status to be notified of any incoming messages.
If you’ve got Remodium, you can wander away from your computer and not miss anything, because you’ll get push notifications of incoming messages routed to the iPhone.
So what it can do is pretty neat.
What it can’t do is actually control everything about Adium from afar, which means if you end up wandering away from your office and all the way across town and really do not want to continue to get IMs (or represent to anybody that you’re actually online at all), you can’t sign out. If you need to change your status from “Here” to “Out to lunch,” you can’t do that, either.
On the other hand, if you were the type to carry iSSH around in your pocket, you could always rig up something like this:
!/usr/bin/env ruby
require "rubygems"
require "appscript"
include Appscript
adium = app("Adium")
status_message = ARGV[0]
accts = adium.accounts.get
accts.each do |a|
a.go_away(:with_message => status_message)
end
and set up a few ssh logins that do nothing more than send that command with a message of your choice.
What?
Dumping Your Safari History With Ruby (Apple's Curious Epoch)
This is sort of weird, but it turned out o.k. in the end:
Safari stores its history in ~/Library/Safari/History.plist. It keeps the lastVisitedDate of each entry in Apple’s CFAbsoluteTime format, which is a float, and which represents, according to a message on carbon-dev, a count of seconds since midnight on January 1, 2001.
I don’t know what the significance is of that date, and I don’t know near enough about the traditional Unix epoch to know why it might or might not serve (insert tentative mumbling about the y2k38 problem from the guy who barely made it out of Algebra I in high school … Ed? You always have something to say about this stuff) but at least it was easy to deal with once I knew what CFAbsoluteTime started counting at:
[sourcecode language=‘ruby’]
!/usr/bin/ruby
require “rubygems”
require “osx/plist”
MacEpoch = Time.utc(2001,“jan”,1,0,0,0)
plist = “/Users/mph/Library/Safari/History.plist”
history = OSX::PropertyList.load(File.read(plist), format=“false”)
history[0][“WebHistoryDates”].each do |h|
date = MacEpoch + h["lastVisitedDate"].to_f
puts "{h["title"]} -- {date}"
end
[/sourcecode]
Another weird thing: Using titles is o.k., but I’d rather parse URLs so I can track the attention a domain is getting. When osx/plist coughs up the hash with all the history stuff in it, the first key–the one with the url–is a null value. I can get at it with h[""], but it seems kind of off, and it seems to render osx/plist unable to dump the history back out to XML for less clunky parsing. A quick peek at the plist with plisteditor, though, and the key is, indeed, null.
So all that’s the nub of a further exploration of what’s getting my attentional resources.
Attentional Followup
Yesterday I dropped a bunch of stuff from NetNewsWire, and it was a pleasure to wake up to an immensely less cluttered morning scan. One thing all my poking around in the attentional numbers revealed was that I tend to read a lot of the stuff I’d prefer to read the least. Dumping a few dozen feeds put the highest attentional score for any single feed to 81, where it had been 150 for the top feed prior to all the culling. Most of the remaining feeds score well below 50.
It seemed a little counterintuitive to get rid of the things I read the most – they’re surely what I’m most interested in, right? – but after a little reflection I realized they’re the things I’m most eager to distract myself with, and there’s a difference between those categories.
By way of further exploration, I think I’m going to tweak my script a little so it can take advantage of another NetNewsWire library feature, which is the “scripted attention score”:
To affect the calculated attention score, you can change the scripted attention score. The scripted attention score is a component of the calculated attention score (it’s added).
I can organize feeds into categorized folders, add a scripted attention score value to each of the folders based on my “real” interest in a given category, and start using that to refine cull recommendations from time to time.
A little script to copy address information from mutt messages into an org-contacts file.
Read the essay →