text

How to copy text from the MacOS Terminal to the clipboard alvin April 10, 2017 - 5:48pm

If you ever need to copy text (or a text file) from the MacOS Terminal to the Mac clipboard, I can confirm that the macOS pbcopy command works. It reads from STDIN and copies the text to the clipboard, so commands like these work:

$ echo "foo bar baz" | pbcopy

$ cat /etc/passwd | pbcopy

“Your password is too similar to a previous one”

I don’t know too much about salting, hashing, and encryption, but it always upsets me when I see a “Your password is too similar to a previous one” message like this, because I assumed that whoever was showing this message was storing my passwords as plain text somewhere. This thread on Twitter, started by Anna Filina, addresses this topic.

Opportunity knocking

“Knock, knock.”

“Who’s there?”

“Opportunity.”

“Could you maybe just shoot me a text?”

How to insert text with a custom TextMate Bundle snippet

As a quick note to self, I just created a TextMate Bundle snippet to insert some text at the current cursor position. Using TextMate 2.0.x, I did it with the following steps. I’ll go through these steps quickly as I’m just writing this for myself:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

When you want to store static text in an Android file

As a note to self, when you’re writing an Android application and you think you want to store some static text in an external file, a better approach can be to create a resource file under res/values.

For example, I’m currently adding some help text to an Android app, and to do that I created a file named strings_help.xml under the res/values directory. That file contains HTML wrapped in an XML CDATA tag, like this:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

An Android method to center text when using Canvas drawText

I’m not an expert on this subject just yet, but if you want the source code for an Android method to center text that you want to use with the drawText method of the Canvas class, I know that this code works in two places in my current Android app:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

ASCII drawing software (ASCII art) alvin October 25, 2015 - 9:48am

asciiflow.com is my favorite ASCII art drawing tool. It lets you draw and re-size boxes, draw lines and arrows, add text, supports and undo feature, and more. All online, all free.

How to test for the existence of a key or value in a Scala Map

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one of the shortest recipes, Recipe 11.21, “How to Test for the Existence of a Key or Value in a Scala Map”

Problem

You want to test whether a Scala Map contains a given key or value.

Solution

To test for the existence of a key in a Map, use the contains method:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

A Mac OS X text-to-speech web service (Play Framework, Scala)

I’ve written a variety of small Scala apps that take advantage of the “text to speech” capabilities on Mac OS X (Sarah, Wikipedia Page Reader), and a few days ago I started thinking about consolidating these by creating a Mac “text-to-speech service.” I initially created that as an Akka server (here on Github), then thought to make it a little more generic as a REST web service.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.