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.
This entry shows what I'm doing when I practice programming. I find it helpful to write little programs that use the concepts I'm trying to learn.
Why Ruby? you might ask. No particular reason. I've spend a semester learning C++, and I was pleasantly surprised to find out that the things I learned are applicable in many other programming languages. Ruby is one of them.
Writing scripting-type programs is one of the things I do. I have "practiced" recently with Bash (and all the little Unixy utilities that go along with it) and Perl (for the add-on that does the statistics for this blog).
Ruby just happens to interest me. I'm also interested in Elixir, but for the kind of things I'm interested in doing right now, Ruby with its many, many Gems and "make programmers happy" philosophy looks like a good fit.
I could say the same thing about Perl (or Python, or Java), but for now I'm playing around with Ruby.
I find that writing little programs like these is a great way to learn. And writing the "same" program in different languages is also very helpful. I could re-write this one in, say, Perl or JavaScript (using either Node in the console or rendering it on an HTML.
Here is the program I wrote to practice using Ruby loops and arrays. I also worked with strings (and converting arrays to strings and back again) and outputting results to the terminal.
What is an array? Here's what it is (in my mind anyway): A collection of pieces of data that can be manipulated as a whole. You can mix numbers and strings. In Ruby, arrays can even contain other arrays. I read that somewhere.
Here is the program:
#!/usr/bin/env ruby
=begin
The purpose of this program is to experiment
with Ruby loops, arrays, strings, integers and output.
The program creates an array, uses loops
to *push* numbers into that array, shows what
the array looks like at every stage using *puts*
and *inspect*, then uses *shift* to remove
numbers from the array, also showing
what it looks like at every stage.
There are two more loops in this script.
One prints out numbers ascending, the other
descending.
=end
# Create an array
number_array = Array.new
# loop uses *push* to add a number,
# *puts and *inspect* to print it
(1..10).each do |i|
number_array.push(i)
puts number_array.inspect
end
# loop uses *shift* to remove
# an array element
# 1...10 with three dots runs
# the loop until 9, not 10
(1...10).each do |i|
number_array.shift
puts number_array.inspect
end
# *puts* on its own adds a blank line
puts
# *print* prints the output without adding
# a newline character (aka \n) like *puts*
for i in 1..10
print i
print " "
end
puts
10.downto(1).each do |i|
print i
print " "
end
There's a great book available on the web, "Ruby for Admins."
Grammatically it's a little rough -- I would love to contribute via GitHub if that was available -- but the information seems solid.
Finished my first CS class - programming in C++ - and did another Election Night results script that was supposed to be mostly Ruby but ended up mostly Bash. This time I had help and mostly worked on the back end. Things I did: used git and GitLab, generated JSON from XML, used Ruby Gems. Time constraints drove me back to Bash, but I would like to re-write it using MUCH more Ruby.
I'm still undecided how I will convert XML to JSON in the election results app/script I am working on.
I'm considering Ruby and Node on the back end, and pure Javascript on the front end.
To those ends, I am looking for libraries that can do the heavy lifting for me.
Among the things I've stumbled upon are x2js.
Just putting this here so I don't forget about it.
If I go for Ruby, there is the Crack gem, which is packaged for Fedora, also hopefully for CentOS, and available for installation via Ruby if that doesn't work out.
Also, I don't want to forget my previous entry on xml2json.
Update: I am currently using the Crack gem with Ruby. I'm shelling out to Bash for some file-based operations that I hope to eventually replace with native Ruby code.
My initial idea of doing this all on the client in Javascript wasn't terribly practical because of all the CPU it took to do the XML to JSON operation on such large XML files.
I'm working on my election script, which has been Bash on the server to produce HTML with custom display on nine different websites controlled via CSS. Hacky as shit, but it works.
I've toyed with doing the script in Perl or Ruby, but my colleague Daniel Aitkin asked whether we could script the data into JSON, aka JavaScript Object Notation.
That way we could pretty much do this as a Javascript-on-the-client Web page. For California statewide data, we are working with XML, so a simple conversion to JSON in the browser would do the trick.
And here is one of many solutions to the XML-to-JSON problem: https://github.com/enkidootech/xml2json.
If this works, server-side scripting is limited to fetching and unzipping the XML files from the California Secretary of State. JavaScript will do the rest.
Since LA County sends fixed-width ASCII, this plan goes out the window, but I vaguely remember another ancient data format that I might be able to hack into JSON. Or the LA County data will be mangled the old-fashioned way.
I'm in the mood/mode to do things with JavaScript in the browser. I recently hacked together this simple Web page that takes any URL and spits it out with nine different domains and then copies them to my desktop clipboard via buttons, an admittedly narrow use case but one that I have about 30 times a day.
That's the best way for me to learn: Have an annoying problem and make it go away through code.
Along these very same lines, since I'm collaborating with others on this project, I decided that we needed a way to share the code.
And since I wanted to work out of a private repository, Gitlab ($0/month) beat Github ($7/month). And we are all learning git.
I learn better, or should I say I only learn how to program when I have an actual problem to solve.
My current "problem" is figuring out how to generate more data out of my Ode blog's filesystem for my Ode Counter add-in.
I already report on the number of blog entries, how many are "real" entries and how many are Ode-generated social-media updates, plus how many images are in the filesystem and how many of those appear in actual blog posts.
Another thing I have wanted to do since I began using Ode was have the system generate a Categories/directories list in HTML for both a dedicated "site map" page as well as a sidebar display.

I might as well come right out with it.
I'm going back to school. Community college. For computer science.
Ilene thought I should do it at least a year ago. She's smart that way. It took me awhile to come around. Back then I thought a curriculum anchored in the C++ language (with smatterings of C, Java and C#) and not today's languages of the web (Javascript, Python and Ruby ... OK, really just Javascript) was not for me.
I was ready to do it all on my own: find a language and a framework and a reason to learn them and go. (A few months ago, I even learned a little Go.)
As I ease in to learning how to code in C++, I have a couple of "real" IDEs at my disposal (chiefly Netbeans and Microsoft Visual Studio), I was pleased to find out that my favorite not-quite-an-IDE Geany will build and run both Java and C++ code.
And Geany can do this on Linux/Unix, Windows and Macintosh computers. (It uses the Unixy g++ even in Windows for C++ code.
I even tested a Perl script in Windows, where I'm using Strawberry Perl. Geany will automatically run a Perl script (on a Perl-equipped Windows computer) when I click on the "Execute" button. It opens Perl in the Windows terminal and runs the script without needing to leave the "IDE."
Note: I did install Microsoft Visual Studio Community because I have a feeling I'm going to need it (though instinctively I lean toward Netbeans, and practically am using Geany).
One thing I'm learning about C++ as I dip the very tips of my toes into its vast waters: Like Perl but more so, there is definitely more than one way to do it.
I just found this great list of free C++ books from @TFETimes
I picked up about five.
Like me.
I've got plenty of IDEs on my laptop. At least one has been here a while (Padre, focused on Perl). A few have been here a short time (Eclipse, Netbeans, whatever incarnation of IntelliJ comes with Android Studio).
I've barely used any of them. There is a learning curve.
I never really needed Padre. I write scripts with text editors (often gedit, sometimes Notepad++ if I'm in Windows).
I like Netbeans, and I am able to create, compile and run simple Java programs with it.
I tried to create a C++ program in Netbeans after adding C and C++ support but got held up at the make/configure script portion.
That was after I created a script in gedit and used g++ on the command line to compile it. That works.
So I turned to Geany, the "IDE" (heavy quotation marks) I've been using not just for my rudimentary Java programs but also for most of my general text editing (I need cr/lf line endings for my company's main CMS, and gedit is kind of broken in this regard).
Since I have OpenJDK and all the C build tools installed on my Fedora system, Geany happily builds and runs my Java programs and my now-sole C++ program (see it above). Not much of a learning curve. Click the build brick, then click the "run" gears.
That's it.
There will be a time in the near future when I will need to run a "real" IDE. I will need training wheels.