2018-04-11

Writing Locally

I’ve been writing locally recently as I’ve been transferring old notebooks over to a digital format.

I would have thought that I would want to post stuff that I find in the notebooks on the blog, but what I’ve found is that a lot of the stuff that I write seems trite and uninteresting when I read it later.

This is something I’ve noticed before, the obvious implication is that a blog that is updated with current unfiltered thoughts is unlikely to be interesting. It may be that a blog would be better served purely as a repository for essays, than as a public journal of my life and thoughts.

Is it worth having both?

  • A section for essays
  • A section for daily thoughts

Is there value in daily thoughts that is worth having those published in addition to the essays that I put time and effort into?

Notebook Writing for Blog

One thing that is hard about just directly transferring notebook writing to the blog is that a lot of times I’m just jotting down my current thoughts about a topic in my notebook, and it’s only after I’ve gone on and returned to the topic a few times that my thoughts actually coalesce into a coherent whole. Just directly transferring the notes verbatim forces someone else to go through that whole process rather than getting the finished product.

Looking at the pieces one at a time is often annoying.

Getting the whole, is usually more satisfying.

Standard

2018-04-06

My Life this Week

So far this week I’ve mainly focused on 3 things:

  • Lazarus – an open source clone of Delphi written on top of Free Pascal
  • Boxing – I took my first boxing lesson this week
  • Jump Rope – Related to Boxing, I’ve started trying to learn to jump (or skip) rope

So far with Lazarus I’ve done some quick GUI toys, one of which fired off requests to a web server written in Go to process the data and then displayed the result of that process. I’m a bit excited about that as it offers a possible way to connect a GUI written in Lazarus to code written in another language as long as that other language can expose itself over http.

I had my first Boxing lesson on Tuesday, and I’m totally engaging with it now. I think I would really like getting into Boxing. It seems simple enough to learn that I should be able to get the basics down quickly. After that I think I’ll be able to continue working at it on my own. It emphasizes getting in shape in a way that I think I wouldn’t have gotten from other martial arts I’ve been considering.

That has actually been surprisingly exciting, I am liking the exercise activities related to boxing that I’ve been doing. I’m enjoying learning how to jump rope. It’s been encouraging to realize that my previous attempts at jumping rope were frustrating not just because I’m uncoordinated, but because it actually takes a while to get to where you can successfully jump rope.

So, I’m working on this "30 days to Jump Rope" video that is on YouTube, and I’m currently on the 3rd day. I will have to see whether I need to continue to try this "day" for a while, or whether I can handle moving on.

Evolving Applications

You can evolve an application by adding another layer to maintain compatibility with the old architecture.

How do you handle the accumulation of those layers as further evolutions and migrations happen?

Is there a way to simplify things or is each layer doomed to be locked and ossified?

Windows 10 Popup from Script

I had been trying to figure out how to create a popup that would be visible from a Tcl script after it had started several other processes to tell you that they had completed.

The problem was that Tk never got the focus back once the the other gui applications started. The best I could achieve was to get the tray icon to flash, which when clicked would raise the dialog.

Today I found a solution, and perhaps a principle that could apply even to other solutions.

Windows has a command line utility called msg that allows one to send a message to a user that appears as a popup.

Here is an article that describes it.

It seems to appear over other application windows, but I’m not sure if that’s innate to the utility or because it’s a new process.

That last point is what I think might be more generally applicable. I think any new application on Windows 10 seems to steel focus when it appears onscreen.

So if I wanted to do a popup that would be seen purely in Tcl, I think I could have executed another Tcl process that would then produce the Tk Dialog. That way, when it came onscreen it would take the focus so that people could see it.

Windows Popups via PowerShell

Here is another article from the same source that describes how to do the same thing using PowerShell.

Standard

2018-04-03

Lazarus and other Cross Platform GUIs

I’ve been thinking about cross-platform GUI toolkits since sometime last night.

I typically use Tcl and Tk for writing quick GUI applications. I think that’s a great combination for prototyping.

However, I’ve been wondering what I would use if I had a bigger application.

The obvious contenders are:

  • C++ with WxWidgets
  • C++ with Qt
  • Java with Swing

However, I took a look at Lazarus again, and tried it out.

I’ve only used it briefly on Windows so far, but it’s been a way easier process than trying to get going with the other options.

It’s still pretty niche, but it continues to be developed, and has a good reputation by people who use it.

Now I’m trying to figure out if there is a way to develop a GUI using it, that can interface with other languages that I’m interested in.

Pascal can call into C, so that’s one way to do it. The ease of that method of interface would depend on how easy it is to talk to C from the other language.

Standard

2018-04-02

Easter Weekend

I didn’t work on the blog at all this weekend. I don’t know if that’s going to be typical, or if it was just an artifact of this weekend being Easter. It’s easy between dealing with the kids, and interacting with my wife, to never have time to focus on coding for a long period.

Two solutions I can see to this might be:

  • Get up early in the morning and work on personal programming in the morning. This might or might not work – the kids tend to also wake up early and might want to play.
  • Try to have bite size tasks to work on, and have things setup where I can immediately get to my code to work on it. That doesn’t really allow for research or discovery time, where I don’t really know what I’m doing yet, and still need to figure it out.

Mercurial Add files

I mostly interact with Mercurial on Windows through TortoiseHG. But I’ve been trying to script using the command line lately.

I needed to script adding new files to the repository without having to confirm each one.

It turns out to do that you use the -A option, so the mercurial command looks like:

hg commit -Am "<message>"

I guess because of Git, I was expecting the add option to be -a, so Mercurial’s use of a capital in the option took me by surprise.

However, now that I’ve really looked at the details, the -A for Mercurial and the -a for Git are somewhat different scenarios.

For Git the -a does not include adding files that Git does not already know about, whereas for Mercurial it does. So that probably justifies the capital letter for Mercurial, whereas for Git, adding an untracked file is a separate command first:

git add

Launching Chrome from Tcl on Windows

I’ve been working on getting a preview (really a post-view) of blog post changes in my blog post script.

So, I’ve been trying to figure out how to launch Chrome pointing at web page from a script.

It turns out that on Windows 10 the easiest way to start chrome from the command line is using "start":

start chrome <url>

However, it’s not quite that simple from a Tcl script because Tcl doesn’t know where to find "start". So you have to launch an instance of cmd.exe and give that the start command.

Thus it becomes (from Tcl):

exec cmd.exe /c start chrome <url>

Unproductive

I’m ignoring my guideline of no internet before noon today. My productivity will probably suffer.

However, I’ve learned some interesting things. Or at least it feels that way. Maybe that’s the problem with the internet – it feels important while you are doing it, but after the fact you look back and say – "What did I really gain from that?".

That is especially prevalent on Twitter, which is the extreme end of the spectrum for me. It is the epitome of urgent but ultimately meaningless.

At least the stuff I was looking at this morning was research inspired by coding. And I found some packages that might be interesting if I look at them further.

I also found some interesting people to read more about. Sadly, I also found out that one of the people I’ve enjoyed following over the years has decided to stop writing publicly again.

Single click blog post

Right now I’ve got:

  1. a Windows shortcut
  2. that starts a Windows .bat file
  3. that executes a Tcl script that does everything else.

That’s a lot of indirections.

However, I can now click on a file, and get the entire process rolling.

Morning Productivity

One consequence of my guideline of no internet use before noon is that I am more likely to read material that I have previously saved offline. Some of that stuff I would probably never have the patience to read if it was competing against the instant gratification game of the internet.

For example, I am current reading Category Theory for Programmers, which I haven’t in the past been willing to put the effort into. But now, I have the focus to be able to work through it when my morning workload is light, instead of going toward instant distractions.

Apache Rivet

This morning I was reminded of Apache Rivet, which is a project that embeds a Tcl interpreter into Apache much like mod_php embeds PHP.

I don’t know if I have an immediate use for it, but it seems like it has had some recent updates, or at least someone verified that it is working on current version of Apache on Windows.

Since I’ve decided to focus on Apache as my production HTTP server instead of Nginx with fastcgi, this seems like it might be useful.

For me, Apache makes more sense as the application delivery platform than Nginx. I’m more familiar with configuring Apache and Apache seems more flexible without having to pull in FastCGI.

I am still planning to use Nginx for SSL termination. I might also use it for caching if I don’t stick Varnish in between Nginx and Apache.

Tcl Alive

Looking at Tcl this morning, there seemed to be more signs of stable life than previous times I’ve looked at it recently.

Un-Spiritual Life

I want to write more about spiritual life, but I haven’t really read the Bible in a few days or prayed. For me particularly, if I haven’t been doing activities that promote thinking about God or the kingdom of heaven, I don’t dwell on them.

Jesus said "Abide in me, and you will bear much fruit."

I see clearly that if I am not doing things that cause me to think about God, my life suffers.

It is not just that my "spiritual life" suffers if I’m not dwelling in my thoughts on God. It’s also that I am less happy, and I am less inspired in my normal life. I am also less likely to act in ways that are helpful to myself or others.

Go and PHP

I’m pretty sure I want to transition my bookmark app from PHP to Go at some point.

Doing so would decouple the bookmark app from Apache and allow it to run in whatever other environment I might want it to in the future.

I’ve been thinking about how to decide between PHP and Go for different application. For example, why PHP for the blog but Go for the bookmark app? I think the decision really boils down to …

Do I know how to build the app?

  • If yes, build it in Go
  • If no, build it in PHP

I think it might make sense to prototype things in PHP and then rewrite them in Go. PHP is much more flexible than Go as far as adding to the project on the fly. Once the application is nailed down and stabilized, then the higher performance of Go becomes attractive.

Both PHP and Go are easier for me to deal with as far as building web apps than Python, Ruby, or C#.

A Little Blah

I’m feeling a little blah this afternoon. Maybe it’s because I haven’t really eaten lunch. Whatever …

Blog Next Steps

I’ve been thinking about the next things I need to do for this blog.

I still need to figure out what I want to do about permalinks for posts, or separate entries for posts or essays. I also need to figure out how I want to deal with images. I suppose I could host images somewhere else, which might be easier than figuring out how to upload images to my server. But that seems like an easy way to lose control of my images or pictures, or let them disappear if I’m not paying attention. I also still want to come up with two archive listings, one by date and one by topic. And I need to point connorberry.com to this new blog instead of the error page it currently goes to. Also, it desperately needs some more styling.

So far, the blog still needs:

  • A topic index
  • A date index[
  • Permalinks
  • A solution for essays
  • Some way to deal with images
  • Better styling
  • A domain name that points directly to it

Poem

   Strange day in which I live
   can't find Spirit, heart or edge.
   Maybe I could find a way
   if I could live another day
   
   Where wolves dwell or willows weep
   and trees and mortals intermix
   And find myself a single tree
   where mountains meet the sea
Standard

2018-03-30

Thoughts About New Blog

I’ve finally (baring errors) transferred all my old posts into my new blog.

Doing so has caused me to think about what I’ve spent my time writing about.

So much of the code that I’ve posted feels irrelevant now, and there were many posts dealing with computer technology that also feel like they haven’t provided lasting value. I’m wondering if in the future I’ll mostly post stuff about personal thoughts rather than technology.

I could still see posting about technology if I was trying to teach specific topics, but just posting random snippets doesn’t seem as useful. On the other hand, maybe if I do solve specific problems, maybe it would be useful to post those in case others have the same problems, or in case I have the same problem later (which has happened in the past).


Deft vs Org

I’ve been using Org mode for the last several years off and on for my personal note taking and information storage. Before that I used a package for Emacs called Deft that is very similar to the Mac note taking app Notational Velocity

There are things I like about Org mode that I like, but I haven’t ever found myself really using all it’s features. This morning I started considering if going back to Deft, but using it with Markdown would make sense instead of Org.

There would be some advantages and disadvantages to such a move.

If I used Deft with Markdown, it would be trivial to transfer those entries to my blog. And Deft would allow me to be fairly specific with what I’m working on at the moment without having to use folding. But Deft would create a lot of files if I was using a separate file for every note, and that would make it a little harder to keep in version control, because I would have to add all those files after I created them if I wanted to protect them in version control.

On the other hand, Org mode allows folding, but there are times that makes me nervous that I’m going to somehow delete something that is currently folded without me realizing it. However, because of the folding, Org mode allows me to have many topics in one file, without having to pay attention to what I’m not interested in, by hiding away the outline nodes that I’m ignoring.

I don’t really use the Org mode outline restructuring functions anymore. I’ve been bitten a few times by not understanding how they were going to effect the structure, so now I mostly avoid them and restructure by direct cut and paste.

Org does allow task tracking, with automated agendas, but I haven’t been using that much either these days, since I’m not always at my computer, having a paper based planner seems to be more effective for me these days.

Also, markdown is easy to transform in ways that I care about, whereas, while I know it’s possible with Org, it’s enough harder to figure out that I haven’t really been happy with my attempts so far.

As a result I don’t know that I’m actually getting that much benefit from Org mode these days. I don’t dislike it, but I don’t find myself engaged with it.

In contrast, when I was using Deft, I enjoyed it.


Fish

I think I accidentally ate some fish this morning. At the moment I think I’m ok, but if something happens:

Jayne I love you


Pandoc and Org

The new version of Pandoc (the program I’m currently using to process my blog entries) also handles Org files now. So maybe it’s not such a steep transition to be able to take notes that I’ve got in Org, and transfer them to HTML for my blog.


Prototyping

I’ve been thinking about prototyping applications.

I feel like a lot of my computer skills are oriented around prototyping. I know a lot of languages that excel at creating prototypes.

Things that I feel like are useful in languages for prototyping:

  • They need to make it easy to get something working quickly
  • They need to work together with other programs easily

Given those two things, you can string together lots of little application to get something that works for the task.

Generally what you create won’t be elegant. But if you can solve the problem with it, then you have a much greater understanding of what you are doing, if you want to then create a more elegant application to solve the same problem.

I am realizing that I need to approach problems by starting with a prototype. I need to get something working as soon as possible, and it doesn’t matter if it is in an ugly language or collection of ugly languages.

I have found that if I don’t start by prototyping, I generally won’t start. I will spend my time studying the good languages to use, and flailing around trying to figure out what to use, but won’t get over the initial friction to get something actually started and working.

On the other hand, when I prototype first, I get something running. And I also learn about the actual issues that are lurking beneath the surface, that also need to be solved. But in this case, I have actually made progress. And once I know what I’m doing, I can realistically think about a more elegant rewrite. At that point I can use a more structured language and create one application instead of stringing together separate utilities to achieve my goals.


Prototyping Languages

Languages that I find especially useful for prototyping:

  • Go
  • Perl
  • Tcl
  • PHP
  • Unix Shell

These are all languages that seem to have a bias towards getting something working quickly. They may not be the best at handling edge cases, but they get me initial functionality quickest.

They are fairly simple to use, fairly simple to teach, and have decent documentation available.

In most cases, given a little initial familiarity, one can just sit down and start using them, and figure things out as they go.

Perl is maybe the exception to the easy to learn, easy to teach criteria above. However, if one keeps it’s use to scripts of one file, and to such tasks as Learning Perl teaches, then I think it holds.


Desktop Blog Editor

I’m starting to think about writing an app to help automate all the steps in creating a new post and publishing it to my blog.

I had imagined that it would include an editing pane, but it could be as simple as a toolbar with buttons to perform the following actions:

  • launch an editor
  • commit to local repository
  • push to remote repository
  • submit http request to update blog to latest version

Desktop Blog Script

So far I have a quick script written in Tcl that allows me to:

  1. Launch Vim
  2. commit to my local repository
  3. push to my remote repository
  4. submit an http request to update my blog to the latest version.

There is no graphical component at the moment, but I don’t think it would be hard to add one if I want to.


Blog Entry Scheme

Currently the way that this blog works is that there is one file per day. If there are more than one post per day, they are just subheadings in that daily file.

This doesn’t allow for the possibility of writing essays that would need to stand alone.

There are a couple of possibilities that I can see to address this.

One possibility would be to instead save each entry in it’s own file. Then the blog could be reworked to collect all the posts for one day and concatenate them before displaying them. Or each post could be separate not combined in a per day display.

I could see doing that either by embedding the date and post number in the filename, or by inserting that into metadata in the file somehow.

Another possible solution to allow the ability for standalone essays would be to just have a separate stream for essays. Either, the file would indicate that it is an essay, or perhaps it goes in a separate directory for essays.

These would be displayed by themselves, perhaps not even in the normal day by day navigation. They migth have a separate listing of all of the essays, while the regular posts would form more of a "journal".


Testing Tcl Raise Focus

I’m testing whether my automated script from earlier can display a dialog when the blog is finished updating.

After

The Tcl command after can be used to either schedule a task to run after a certain length of time, or without a script to force a synchronous sleep for a certain length of time.

Update Idletasks

Tcl has an update idletasks command that causes any pending tasks that are waiting for an idle moment to run, to instead be force run immediately even if it blocks other updates momentarily.

Dialog problems

I’m trying to get my Tcl script to display a dialog announcing that the update process is finished. So far it isn’t working. I’m not sure if it’s an interaction between the sleep and the repaint cycle, or something else at this point.

Focus command

Tk’s focus command with the -force option seems like it should make the label visible.

Update: all this seems to do is cause the taskbar icon to flash on Windows 10.

Tcl wm attributes -topmost

Trying this next wm <window> attributes -topmost to attempt to get this to work.

Note: I think this needs to be a toplevel window for this to work.

Note: So far this method has not worked.

Further testing

So far nothing has worked. I’m now trying to get the dialog that I need on the screen before other applications take the focus away.

Final results

So far I have not been able to achieve the dialog box. At the moment that is not a big deal, however, I may try again later.

I am currently considering just shelling out to powershell to have it display a dialog.


Wondering whether tclkit requires a forced exit if I’m not obviously using Tk.

So far the answer is yes.


Testing again

testing tk_messageBox to see if it will raise focus

update: The answer is no.

Testing deiconify

maybe deiconify will work. maybe … maybe … maybe … maybe … no


Next Steps for Blog

At this point I have posting working in some sense, and all of my previous posts imported.

I’m at the point where I can write whenever and whatever I want and have it show up.

I think the next thing I would like to focus on is redoing the post ids so that I can get some kind of permalinks to specific pages or posts.


Blog Thoughts

Today I wrote a fair amount.

One thing I’m realizing that I’m not sure if I like is the way that the blog looks when there are a lot of posts or words on one day.

Maybe it’s something I can address with styling or fonts but at the moment, once the text goes to the bottom of the screen it starts to feel a bit overwhelming.

Maybe that is because I’ve got my monitors at work set up vertically, maybe it wouldn’t be the same feeling if I was looking at it on a laptop or a monitor setup normally.


Pandoc "Smart" option

There is a difference between the version of Pandoc that is running on my current server and the version of Pandoc that I have installed locally on my Windows workstation.

The version on my Windows workstation is more current and by default translates some characters (for example apostrophes or single quotes) to some kind of special unicode representation.

The version of Pandoc on my server is older and does not.

The achieve the older behavior where a quote is just a quote, you need the filter I think you need to run -f markdown-smart instead of just -f markdown.

Standard

2018-03-23

Change and Obsolescence

I’ve been spending the last week or so transcribing or reformatting posts from my old blog into markdown to go on my new blog.

A lot of those posts have been about technology topics. A lot of that stuff that I wrote 5 to 10 years ago is now probably out of date or obsolete. How much is it worth me putting effort into talking about those kinds of topics? If I spend time today talking about technology, those things will be worthless in another 5 to 10 years.

If I focus on things that don’t change, or that will last, then potentially someone else could gain some value from what I write down the road.

Incantations

This is the line of commands that lets me know how many words I’ve transcribed into the new blog today:

ls -l | grep 'Mar 23' | perl -lna -e 'print $F[-1]' | xargs cat | wc -w

Looking at this, I can’t help the feeling, how is this not some kind of magic spell in a secret language?

Who outside of someone who had studied strange things for too long, could even understand what this line of text is doing?

Yet it tells me that so far I’ve transcribed or written 9112 words today.

Standard

2018-03-22

Showing Off

I’m showing off the innards of my current blog implementation.

Hopefully after I create this file in a local repository and committing and pushing to the remote repository the blog will draw from the remote repository and then post it.

Vim Spell Check

One cool thing about Vim that I don’t think many other editors have is a fairly robust spell checking functionality.

To turn it on just do:

:set spell

Then whatever text you are editing will be spell checked on the fly.

I don’t use it much while programming, but I find it useful while writing prose.

Standard

2014-12-11

Language Comparison

Perl:

while (<>) { print "$. : $_" }

Perl:

while (<>) {
  print "$. : $_"
}

CSharp:

using System;
using System.IO;

class App {
	public static void Main(string[] args) {
		int line_number = 1;
		foreach (string arg in args) {
			foreach (string line in File.ReadLines(arg)) {
				Console.WriteLine(line_number + ":" + line);
				line_number++;
			}
		}
	}
}

Python:

import sys

for arg in sys.argv[1:]:
	for index, line in enumerate(open(arg).readlines()):
		print(index + 1, ":", line, end='')

Golang:

package main

import (
	"fmt"
	"os"
	"bufio"
)

func main() {
	line_number := 1
	for _, arg := range os.Args[1:] {
		file, _ := os.Open(arg)

		scanner := bufio.NewScanner(file)
		for scanner.Scan() {
			fmt.Printf("%d : %s\n", line_number, scanner.Text())
			line_number++;
		}
	}
}

Java:

import java.io.*;
import java.util.*;

class Linum {
        public static void main(String[] args) throws FileNotFoundException {
                int line_number = 1;
                for (String arg : args) {
                        Scanner s = new Scanner(new BufferedReader(new FileReader(arg)));

                        while (s.hasNextLine()) {
                                System.out.println(line_number + " : " + s.nextLine());
                                line_number++;
                        }
                }
        }
}

Ruby:

while gets
  puts "#{$.} : #{$_}"
end
Standard

2014-06-18

Food for Two (or three)

Jayne and I went to Olive Garden tonight and took Hiram. We all just ate soup and an appetizer of fried raviolis and fried zucchinis. It was one of the best meals I remember at Olive Garden. It was really simple, but everything tasted really good.

We are trying to cut back our spending on going out to eat, so it was nice to have a really enjoyable meal that was pretty affordable. Over the weekend we also went to La Hacienda Ranch to celebrate Father’s Day with Jayne’s dad. That is another restaurant where one can get a really enjoyable meal for two fairly cheaply. The veggie fajitas for 1 (but shared between two) seems like an excellent choice.

The One Thing I Don’t Like about Scala (so far)

The one thing I’ve found so far about Scala that I don’t like is a tendency to have syntactic shortcuts in certain situations that are not very regular with the rest of the language. One example specifically is in the way that you can define a curried function that takes 2 arguments and then call it with the second argument enclosed in curly brackets ("{" and "}") rather than parenthesis. This seems to be so that you can mimic the look of Scala’s native control structures. However, I believe you can only have one argument (one expression?) in between the curly brackets, which breaks the expectation that curly brackets usually enclose a block. That expectation is set not just by c based languages like C, C++, Java, C# and JavaScript, but also in most other cases by Scala itself.

This breaking of expectation is what frustrates me the most about Scala, because otherwise I really like the language. In general it does a really good job of unifying object oriented and functional concepts, so that semantically it reminds me of a cross between Smalltalk or Ruby and SML. In fact, along with Ruby, I think of it as one of the few languages to really get object orientation right. The frustrating thing about the ways that syntactic sugar seems to have been added for convenience rather than coherence is that it’s not obvious why the shortcuts are that much better than the desugared alternatives. Now this criticism isn’t applicable to all syntactic sugar in Scala, some of it is done really well. But there are enough places where it is rough, that it feels like there is a constant slight cognitive load to the language that doesn’t need to be there.

Even though I’ve noticed these little nits, I still plan to keep using it. Overall, I really like the language. I find it’s support for functional programming refreshing, and I think the way it deals with objects makes dealing with them a lot nicer than in C# or Java.

Standard

2014-06-16

Blathering about Blogging

I’m just blathering about blogging today. If I was going to try to do a blog I think it would be valuable to concentrate on doing actually valuable writing. Maybe it would make sense to do about 1 essay per week and then try to post something in the roughly 200 word range each day. Something like 200 words a day and a 1000 word essay per week. Something like that I think could actually be fairly valuable. I still don’t really know what platform I’d like to use for blogging.

I think I’d like to modify my blog layout so that there is a clear delineation between daily posts that can be just blather and essays and tutorials that should be better written.

Standard