Title photo
frugal technology, simple living and guerrilla large-appliance repair

Regular blog here, 'microblog' there

Many of my traditional blog post live on this site, but a great majority of my social-style posts can be found on my much-busier microbloging site at updates.passthejoe.net. It's busier because my BlogPoster "microblogging" script generates short, Twitter-style posts from the Linux or Windows (or anywhere you can run Ruby with too many Gems) command line, uploads them to the web server and send them out on my Twitter and Mastodon feeds.

I used to post to this blog via scripts and Unix/Linux utilities (curl and Unison) that helped me mirror the files locally and on the server. Since this site recently moved hosts, none of that is set up. I'm just using SFTP and SSH to write posts and manage the site.

Disqus comments are not live just yet because I'm not sure about what I'm going to do for the domain on this site. I'll probably restore the old domain at first just to have some continuity, but for now I like using the "free" domain from this site's new host, NearlyFreeSpeech.net.

Sun, 07 Oct 2018

That was a spectacular SpaceX launch in the skies to the northwest of Los Angeles

That was a spectacular SpaceX launch in the skies to the northwest of Los Angeles

Wed, 04 Apr 2018

Separating functions in programming

If you get everything you know about programming languages from Twitter, Reddit or blogs, you might miss that there are fascinating things in every programming language, old and new.

Or at least they're fascinating to me (or you) at any given moment.

My semester of programming at LA Valley College was heaving on using loops of all kinds, but we didn't get to separating things via functions or object-orientation.

I'm trying in my own code (currently Ruby) to make things more modular with blocks, some taking arguments and others not, and using classes is something I'm trying to wrap my head around.

I was reading one of my Java books (Sedgewick and Wayne's Computer Science) where the authors say in the long Chapter 2 (they're all long chapters) that separating operations into distinct functions is something programmers should strive to do.

It's the idea of organizing the code, and the ways the various languages allow (or maybe encourage you to do that) that I find fascinating at the moment.

Hunting the random \n

There's a random \n in my BlogPoster script. It doesn't show up all the time, but there are circumstances where it appears in the final output.

Am I inadvertently inserting it, or will I have to chomp it out? That is the question.

Update: I figured out where the random \n was being inserted, and I was able to .chomp it out in Ruby.

I'm not sure exactly why the random \n was being inserted. It could be in the editing operation of the file (I hope not, because that complicates things), or in the conversion of the edited file back to a Ruby variable.

Fri, 16 Mar 2018

I am still working on my BlogPoster app

I am still working on my BlogPoster app, which will take a URL pasted into a terminal, grab the web page's title and make that title and link the basis for a blog and social post.

The app is written in Ruby and uses the Nokogiri and Twitter gems, among others. I have code that will allow me to eliminate Nokogiri, but that's a fairly "light" gem. The Twitter gem, which makes posting via the Twitter API easy, has a lot of dependencies, and that is the one I'd really like to get rid of in favor of native code.

But that's getting ahead of myself. The app, as it stands now, is a huge if/then loop with a lot of ungainly code. I did add some code that keeps the app from crashing if Nokogiri doesn't get a "real" (i.e. live) web page, or there are connectivity problems.

What I am doing now is re-writing the app with distinct and separate methods, which I'm thinking of as functions that can allow for more modularity and code reuse. I probably should be using Ruby classes to organize these methods, but I'm saving that for the next rewrite. Going from a monolith with a lot of repeated code to a bunch of modules (still probably accessed via an if/then structure, albeit a much shorter and manageable one) is enough improvement for the next version.

For the next version, I hope to have a GUI. I'm leaning toward the Tk toolkit because this app isn't very complicated, and Tk is probably the most well-known of a very motley bunch of desktop GUI solutions for Ruby. It may be a little ugly, but it is cross-platform, which is what I have been aiming for. I am open to other GUI toolkits, but even this recent article, An overview of desktop Ruby GUI development in 2018 doesn't offer much hope.

I'm also considering a full rewrite in another language. I'm working on Racket right now, but I'd have to figure out a lot of things to make it happen.

Thu, 15 Feb 2018

Showtime's 'I'm Dying Up Here': Comic timing ... and parking

So I've been watching Showtime's "I'm Dying Up Here," the excellent series about LA's 1970s stand-up comedy scene and its "Carson's couch means you've made it" vibe, and all I can think about is how easy it was to park your car in LA back in those days.

Mon, 15 Jan 2018

Use the Twitter API instead of a third-party service

I have been experimenting with the Twitter API and using dlvr.it and IFTTT less (ironically because this post will Tweet via IFTTT). My purposefully social posts use a script and the API.

My whole posting setup is big-social-network-optional

My systems and scripts are all focused on publishing content to my sites. Mirroring them on social media, currently Twitter, is optional and can be modified or pulled altogether at any time.

Tue, 26 Dec 2017

Steady work on rewrite of the BlogPoster app

I have been working steadily on the BlogPoster app, both tightening up the current "production" version and slowly coding the new "modular" version based on Ruby blocks.

Over the weekend I coded up a few blocks in what I hope will be a very atomized app in which all of the blocks do just about one thing and can be called upon in various combinations for different tasks.

Today I worked on the regexes for creating filenames based on post title. The hardest part is dealing with strange characters and website <title> text that contains lots of linefeeds. (Confession: This site did the same until I fixed it. Please don't put linefeeds in your <title>.)

I got rid of the extra linefeeds, but I was ending up with occasional doubled underscores (my go-to replacement character for the space between words). I came up (i.e. Googled and stole) the regex for "match two or more of this character," which in this case is __+, and I was off to the races. I also figured out that in HTML titles with extra lines, I was inadvertently adding an underscore to the beginning of a string, and I used ^_ to find that and kill it out. Regex is fun and profitable.

Hopefully I'll get back to working on the "new" version. I'm coding it slowly and deliberately because I don't want it to be a mess. Next version will be more object-oriented (i.e. will use classes) if I can figure that out. First we'll see how this version turns out,

Tue, 21 Nov 2017

My Blog Poster app works well in Ubuntu (ok, really Lubuntu) Linux

I recently updated a 15-year-old IBM Thinkpad R32 laptop (Pentium 4, 1 GB RAM, 20 GB hard drive) to Lubuntu 16.04, and I set it up to run my Blog Poster script written in Ruby.

Since this is a Linux environment, I like to use the Ruby version that the system offers in its repositories, also installing as many Ruby gems as I can from those same repos (instead of using gem install from the console).

The Blog Poster app, which attempts to make it easy to create social and regular blog posts from the command line, uploading them to the blog and sending them directly to Twitter, is fairly simple. It uses two gems: Nokogiri to help pull the titles of web pages and Twitter to (you guessed it) send a post to Twitter.

On Windows I used gem install to get both of those gems, and I could do the same in Lubuntu. But I'm very comfortable with Linux package management, so I opted to install ruby (which, believe it or not, isn't in the Ubuntu/Lubuntu default install) as well as ruby-nokogiri and ruby-twitter, all from the Ubuntu repository.

It worked.

Curiously, the script's call to vim did not work. There is, theoretically, no vim in the Ubuntu/Lubuntu default. But there is vi. You can install vim, but I opted to stick with the vi default, and I modified the system call in my Ruby code to call vi instead of vim.

Also, copy-pasting into the terminal (LXTerminal is what I am using) via right-click works great (though ctrl-v does not work).

The Ruby script works great, and I did a few successful updates to my blog and Twitter feed with this very aged laptop.

Sat, 18 Nov 2017

Procedural vs. object-oriented: How should you code?

I'm a procedural programmer at this point. I understand the idea behind object-orientation, but going from those hokey examples (start with an animal class, then add a dog class) to actual code is another thing entirely.

I planned to base this post on a link that was supposed to be about procedural programming vs. OOP, and the article was pretty much a mess and didn't help me, so I'm not linking to it.

I need to see real code that uses OOP. That's the only way I'll figure it out.