• Tip Jar

CLI Day 2015

For CLI Day this year, I have put together a collection of one-line games. You can copy and paste these games directly into your terminal and play them, or you can put them into a file, one per file, and run them that way as well. These were a lot of fun to make, and even more fun to play. If you follow @storm@social.stormdragon.tk you have seen a few previews. Here are the games. I hope you enjoy them as much as I do. If you have any to contribute please leave them in the comments.

#Match the letter
s=99;while [ : ];do t=$(shuf -n1 -e {a..z});read -t0.$s -n1 -p " $t " p;if [ "$t" != "$p" ];then play -nV0 synth pi fade q 0 1 0.5;break;else play -nV0 synth .05 tri C8:C3 norm -7;fi;((s--));done
#guess 1 to 10
read -p"Guess from 1 to 10 " num;if [ $num -eq $(seq 10|shuf -n1) ]; then echo "Yay!";else echo "Boo!";fi
#order the numbers 1-9 type the number to reverse the string from that number to the right
c=0;n=$(shuf -i 1-9|tr -d "\n");while [ $n -ne 123456789 ]; do read -n1 -p$n i;l=${n%$i*};l=${#l};a=${n:0:$l};b=$(echo ${n:$l}|rev);n=$a$b;echo;((c++));done;echo "$n $c tries"
#spelling game with changable list
l=(champagne neighbor tortoise);clear;s="espeak -v en-us -a 200";for i in ${l[@]};do $s $i;read w;if [ "$w" = "$i" ];then $s "Got it!";else c=0;while [ $c -lt ${#i} ];do $s ${i:$c:1};((c++));done;fi;done &> /dev/null
#Simple configurable math game, change o for different types, set n min and x max numbers used.
n=0;x=10;o=+;m=0;r=0;s=5;t=0;a=-;while [ "${a^}" != "Q" ];do p="$(shuf -n1 -i$n-$x)$o$(shuf -n1 -i$n-$x)";read -t$s -p "$p " a;if [ $a -eq $(($p)) ] ; then echo "Yay!";((r++));s=$(echo "scale=2;$s-0.05" | bc);else echo "Wrong: $(($p))";((m++));fi 2> /dev/null;((t++));done;echo -e "\n$r right and $(($m-1)) missed of $(($t-1)) total."
#Pig dice game. any letter to roll, space or enter to bank.
c=0;p=0;s=0;t=$(shuf -n1 -e c p);while [ $c -lt 100 -a $p -lt 100 ];do if [ $t = c ];then a=$(shuf -n1 -i0-6);case $a in 0)c=$(($c+$s));s=0;t=p;echo "CPU banked $c.";;1)echo "CPU Pigged\!";s=0;t=p;;*)s=$(($s+$a));echo "CPU $s : $c";esac;else read -n1 -p "? " a;if [ -z $a ];then t=c;p=$(($s+$p));echo "You banked $p.";s=0;else a=$(shuf -n1 -i1-6);if [ $a -eq 1 ];then s=0;t=c;echo "You Pigged\!";else s=$(($s+$a));echo "You $s : $p";fi;fi;fi;done;echo "CPU $c : You $p"
#Shoot down the eroflcopter you hear when sound is centered. Random speeds.
h=0;n=1;s=20;while [ $n -eq 1 ];do x=9;y=0;while [ $x -gt 0 ];do espeak --stdout [[schXh | play -qV0 - norm remix v0.$x v0.$y&read -st0.$s -n1 p;if [ -n "$p" ]; then if [ $x -eq 5 -a $y -eq 4 -o $x -eq 4 -a $y -eq 5 ];then x=9;y=0;play -nqV0 synth pi fade h 0 1 1 pad 0 1 reverb overdrive riaa speed 32 repeat 2;play -nqV0 synth pi fade h 0 1 1 norm -18 pad 0 1 reverb overdrive riaa;((h++));s=$(seq 10 20|shuf -n1);else n=0;fi;fi;((x--));((y++));done;done;echo "You shot down $h eroflcopters."
#Talking CLIcat (pitch shifter).
e="norm pitch 1000";echo "Hold down control+c to exit.";f=$(mktemp -u);while :;do rec -q $f.wav silence 0 1 0:00:00.5 25% && play -qV0 $f.wav $e;done
# Small polyphonic music synthesizer.
n=CDEFGAB;l=asdfghj;while read -n1 k;do x=$(tr $l $n< <<$k);play -qn synth pl ${x}3 fade 0 .7 & >/dev/null;done

Charm Works Again

This is just a quick post to test the GNU Social Comments plugin. I decided to try charm again to post this, and was pleasantly surprised to find it works again. Something in the last wordpress updates broke it, but now it’s back.
Just as a reminder, CLI Day 2015 is approaching quickly. GNU Social users can join the CLI Day Group. Don’t have a GNU Social account? Get one at social.2mb.solutions. Let’s make this year the biggest CLI Day ever!

A Better Way to Microblog – GNU Social!

GNU Social is extremely cool. Not only can you have your own microblog, under your terms, with your rules, but you can also follow other people who have their own microblog as well. Not up to running your own? No problem, because there are plenty of public nodes out there already set up and waiting for you to make an account. I personally recommend 2mb.social or social.mayfirst.org, but those are just two of the ones I know of. There’s also Quitter.se, or gnusocial.net. All you have to do to get microblogging in a matter of a couple minutes is go sign up at one of the sites listed above. But, if you wanna take the bull by the horns, you can install GNU Social by downloading it from its git repository or from the .tar.gz file.
To follow a person, go to their page, https://social.stormdragon.tk/storm, for example and click on subscribe. Enter your webfinger (the full URI to your account) into the box, you@wherever.whatever, then click subscribe. You will be presented with a page to confirm your subscription.
You can also follow people from your own page. To do so, click on profile, remote, and enter the person’s webfinger into the box and confirm you want to subscribe to them.
As with other microblogging services, hash tags are used. In fact, you can see a list of trending tags right on the site. However there is another aspect to GNU Social not available in other microblogging options. If you prefix a word with an exclamation point, it will post to a group, so long as you are subscribed to said group. People in a group see things posted by everyone in that group regardless of following status. You may choose to post your currently playing music track to the !listening group, which gasher, (see below), does for you automatically. Here are some groups I recommend:

Alter Aeon>
Keep up with happenings on the game Alter Aeon.
Listening to something awesome? Post it here!

When you are setup and ready to rock, you may be interested in some clients for GNU Social. I am currently developing a command line client called Gasher. It is very functional so far and contains features you won’t likely find in most other clients, including the ability to post your currently playing song or the ability to record and post sound clips right from the program itself. For Arch Linux users, Gasher is available in the AUR as gasher-git.
The previous version of TTYtter also works well as a client, so long as you add a few things to your .ttytterrc before launching it. First, install the required version of TTYtter:

sudo wget -O /usr/bin http://www.floodgap.com/software/ttytter/dist2/2.0.00.txt

Then, create ~/.ttytterrc with the minimum of the following settings. Note, for the following example, I’m going to use https://social.2mb.solutions:


You are now ready to use GNU Social with TTYtter, awesome! You may have noticed we had to set the line length in the above example. That’s because GNU Social does away with that silly 140 character limit, allowing the site administrator to set the character limit to whatever they wish. So, prepare to get used to being able to say what you want to say without running out of space.
BitlBee is another option as a GNU Social client. It’s been available since back when Identica was actually good. The third parameter in the account add line isn’t really needed, so just put whatever you want there. To add your account:

account add identica foo
account identica set base_url https://social.2mb.solutions/api
account identica set oauth false
account identica set message_length 512
account identica set username USER
account identica set password PASSWORD

If you would like an extra layer of protection, so you don’t accidently post something you don’t mean to, then do the following:

account identica set commands strict

With this option set, you have to type post then the text you want to post. Finally, to enable the account:

account identica on

For those of you who aren’t into the command line, there is a nice graphical app called Yaics which may or may not be in your distro’s repositories. For Arch Linux, it is available in the AUR. The source is available at https://gitlab.com/stigatle/yaics. It is accessible with orca, but you will have to use flat review almost exclusively. During configuration, if you find text boxes that don’t say what they are, just press orca+numpad5 for desktop layout, or orca+k for laptop layout, and it will tell you what the box is.
For Android users, the application Mustard is a great way to connect to your GNU Social account. Install it from the Playstore. Setup is straight forward and easy.

Easily Load Books from Bard on to Your Cartridge

So you’ve just downloaded several books, for hours of reading enjoyment from the BARD service, and now you have to create a folder on your cartridge or pendrive for each book, extract the book to its folder, and remove the zip file. Wouldn’t it be much easier if it were automated?
Well, now it is. just grab the bookloader.sh script, place it on your drive where you want the books loaded, and then type:

bash bookloader.sh

The script creates a folder called book# where # is the number of the book it is currently extracting, e.g. book1. The script next extracts the zipfile containing the book to the newly created folder. Finally, the script removes the .zip file. When the prompt returns, simply unmount the drive, and put it in your book player. Very easy, and I hope useful.

Arch Linux Virtual Machine Creation Script

Some people have been asking about trying Arch Linux without giving up their current configuration. For You, I have created a script that will help to set up a talking VM. Any virtual machine program should work, but here is the process for using VMWare Player.
First, get the talking arch disk from talkingarch.tk. Next create an Arch Linux virtual machine. To do this, press the welcome to vmWare player or similar button to start the vm creation process. Note that the button may or may not be labeled something different, as your screen reader may be reading the wrong label, so it may take a bit of guesswork to figure out which button to press. However, it is usually the first button after the list of vms, which will most likely be empty at this point. After the wizard opens, choose to install the operating system with an iso image, browse to the location of the iso image, then press next. Next, choose guest operating system – linux from the radio buttons, and other linux 3.x kernel (64 bit if required). Press next, and fill in the name of your vm, which will simply be what you choose it by in the dropdown list when vmware player opens and press next. Then choose how big you want your disk to be, and press next again, unless you wish to change the type of storage of the virtual hard disk. At this point it will present you with the specs of your vm, but you will most likely want to change the hardware, as it gives it very low hardware by default. To do this, press the customize hardware button. The first choice will be for memory, which by default will be 384 mb for 64 bit kernels and 256 mb for 32 bit. You will most likely want 512 mb or more, though don’t give your vm too much so that your host operating system has enough memory to continue running. Next option in the list will be processer cores, which you probably want to change from 1 to 2 or more if you have more than 2 processer cores. Again, make sure to give enough, but not too much or your host OS may not run optimally. After this press close, and finally press finish. your vm should boot, and you may hear a beep from your pc speaker. If you do not hear a beep or do not have a pc speaker to hear a beep from, you may wait a minute or two, then press control + g to enter the vm, and press any key. Espeak should start announcing messages as the vm boots, although in some cases it will not, so after a while of no speech press the numlock key a few times to make sure there is speech. If there is but it is very low, see the section below.
Now that you are booted into your virtual machine, you may notice the volume is very low. If this is the case, type:


Press the up arrow key until the volume is where you want it. If the volume doesn’t change, press right arrow once, and press up arrow again. Repeat this process until the volume changes when you press the up arrow. When you are satisfied with the volume, press escape to close alsamixer.
Also note that if the volume does change when you press up arrow, but it is still somewhat low when it seems to be at max volume, continue the process of pressing right arrow then up arrow until the volume is where you want it.
now, to install Arch Linux, using my script, type the following:

curl -s http://stormdragon.tk/scripts/vm.sh && bash vm.sh

Speakup can get a bit chatty while everything is installed. To make it go silent, press numpad insert+numpad enter. This is a toggle, so to make speakup read normally again, simply press the key combination again. For laptop users without a numpad, capslock+enter will do the same thing.
Simply follow the instructions, and in just a few minutes you will have a talking arch virtual Machine to play with.

2MB Autocode for WordPress

Introducing 2MB Autocode for WordPress! I wish I had had this plugin years ago. It allows you to add html, php code, or preformatted text to the top and/or bottom of each post.
Before, I was using a small script to display my links at the top of each post. It worked ok, but I always wanted something a bit easier to change on the fly. 2MB Autocode provides just that. The plugin is designed to be very easy to use, and changing the text or code is as simple as entering information into a textbox. This is a must have plugin for any WordPress site. It is just one of the great innovations you can look forward to from 2MB Solutions!

Console Keyboard Shortcuts

People have been asking about keyboard shortcuts from the console. They do exist, and are very powerful. To create the shortcuts, you need to edit your ~/.inputrc file. These shortcuts are available in the terminal, not in applications. So, your shortcut won’t work inside Linphone for example. The following is a setup that will create keyboard shortcuts for the musicl player XMMS2, including a soft volume control, so your whole computer doesn’t drop or rise in volume with the music. Before using the volume controls you need to enter this in your terminal:

nyxmms2 server config effect.order.0 equalizer
nyxmms2 server config equalizer.enabled 1

You may notice that each of the following shortcuts end with \C-M. This is what appends a new line to the command, it’s the same as pressing enter when you’re done typing. Without it, the command would just sit there, looking all purdy, but not really doing anything. And now, here are the lines you can add to your ~/.inputrc for XMMS2 controls:

"\ez":"nyxmms2 prev&&sleep 0.5&&nyxmms2 current\C-M"
"\ex":"nyxmms2 play&&nyxmms2 current\C-M"
"\ec":"nyxmms2 toggle&&nyxmms2 current\C-M"
"\ev":"nyxmms2 stop\C-M"
"\eb":"nyxmms2 next&&sleep 0.5&&nyxmms2 current\C-M"
"\e-":"nyxmms2 server config equalizer.preamp $(($(nyxmms2 server config equalizer.preamp | tr -Cd \"[:digit:]-\") - 5))\C-M"
"\e=":"nyxmms2 server config equalizer.preamp $(($(nyxmms2 server config equalizer.preamp | tr -Cd \"[:digit:]-\") + 5))\C-M"

As you can see, the format is "key":"command". The \e means to use alt as a modifier. Here is a nifty little table that shows the keybindings for the code above.

Key Action
Alt+z previous track
Alt+x play
Alt+c pause
Alt+v stop
Alt+b next track
Alt+- volume down
Alt+- volume up

If you want to use the control key in your keyboard shortcut, simply replace \e\C like so:

"\C-t":"\C-k \C-utalking-clock -c &> /dev/null\n" #speak time control+t

And there you have it, keyboard shortcuts in the console. These are very useful, I have a lot of them in my ~/.inputrc and use most of them every day.

Recent Down time

You may have noticed that the site was down briefly, followed by a slight name change. This is because my previous host, due to a billing error, deleted all my content with out warning. well, they sent an email to be fare, but I went to see what was going on, all my stuff had been deleted. Needless to say, I was ANGRY. Actually, that doesn’t even begin to describe the feelings of rage that coursed through me, especially when I discovered my backup directory only contained a database backup from well over a year ago.
To make things worse, some of the stuff hosted here is gone, probably forever. Yes, I made the same mistake a lot of people do. I had been hosted with my previous host for over 10 years. In that time, there had never been a problem, everything went smoothly, they even gave me a free month of service for some down time that was so brief I would never have known about it if they hadn’t emailed me and told me about it. So, I did a lot of edits right on the site, without backing up to my computer or anywhere else. Yes, I know, bad me. But, 10 plus years of trouble free service has to be worth something right? I read all the articles about backing up, I knew the risk, I made backups for years and years, but within the last two or three, I became sort of lax about keeping up with it.
As you may have noticed, the blog part of the site is back pretty much unchanged, except for the theme. I remembered that some time ago I had changed the path where I was saving my database backups and was able to get one from only a few days before my stuff vanished into oblivion. Getting it set up on the new server was very interesting, to say the least, and my friend Kyle worked tirelessly until about 4:30AM to help me get it all Working. Thanks Kyle! you’re AWESOME!
So, if any links on the site are broken for things that were hosted here, let me know and I will try to get them back. I can’t make any promises though. The important part is, I have learned my lesson, and with the added benefits that come with my new hosting service, most backups are automatic since I now use git to manage pretty much every part of the site. the blog part is still being backed up via the database backup plugin. I am very happy with my new plan which gives me 20GB of space, 1TB of transfer, shell access and more, and only cost $1.5 more than what I was paying for a shared hosting plan. so if you’re looking for a new home on the web, I highly recommend Digital Ocean.
As for the name change, the stormdragon.us link will still work because I bought up ten years time for that name. I really don’t want anything to do with my old hosting company, so I wanted to completely close the account, but they say it’s not possible or I will lose something like eight years of time on that name. So, I left the account in place, but after that name is used up it will be gone. A note to providers, if you delete someone’s stuff, that’s pretty much the end of them doing business with you, the offers of free service, free upgrade plans, etc don’t really mean anything, cause the customer is left wondering when it will happen again.
The good news is, everything is pretty much back now. The new .tk extension is most likely here to stay. You can get a .tk domain for free in increments of 1 year. I always say, you can’t beat free, and their are so many things you can do with a domain name, from making an easy to remember Facebook link, to creating your own website.
Now that everything is back, stay tuned for more articles. Thanks for reading.

Reset the Internet – Securing Mutt with GPG

With all the privacy issues these days, it is important to encrypt pretty much everything you can. This includes email. So, I went to set up Mutt with encryption. I’m one of those people who likes a “Do this, then do this, then” … etc style how-to. Most things have those readily available, but I haven’t yet been able to find one for mut with encryption. There are a lot of good tutorials out there, but they all seem to assume you have knowledge of what to put where. So, this is a “do this, then do that” … style tutorial.
If you’re interested in why you do the following steps, this is probably not for you.

Mutt Setup

First, install mut and gnupg. In Arch you do:

pacman -S --needed mutt gnupg

Next, set up your muttrc file with your email information. If you’re not sure how, there are a lot of good tutorials to help. Most of them recommend you put your muttrc in ~/.mutt/muttrc, and this is where I will assume yours is. Since w’re focusing on security, I will also include directions for encrypting your password so it’s not stored in plain text.
Add the following lines to your ~/.mutt/muttrc:

source ~/.mutt/gpg.rc
source "gpg -d ~/.mutt/passwd.gpg|"

Next, to get the gpg.rc file:

cp /usr/share/doc/mutt/samples/gpg.rc ~/.mutt/

Finally, add the following to the end of ~/.mutt/gpg.rc:

set pgp_sign_as=KEYNAME
set pgp_autosign=yes
set crypt_autosign=yes
set pgp_replyencrypt=yes
set pgp_timeout=1800

Later, after we have set up a gpg key, we’ll come back and change KEYNAME to its propper value.

GPG Setup

Edit the file ~/.gnupg/gpg.conf and add the following:

charset utf-8
personal-digest-preferences SHA512
cert-digest-algo SHA512
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
keyserver wwwkeys.pgp.net
keyserver hkp://pool.sks-keyservers.net
keyserver pgp.zdv.uni-mainz.de

Edit the file ~/.gnupg/gpg-agent.conf, create it if necessary, and add the following:

default-cache-ttl 300
max-cache-ttl 999999

Create a key:

gpg --gen-key

Press enter to select the first default. RSA keys may be between 1024 and 4096 bits long. You can select the default of 2048, but of course 4096 will be harder to break. Next, select how long the key is valid.
Enter your name, email, and a comment, e.g., email encryption key. You will be given the chance to change anything you think is wrong. If you are happy with everything the way it is, press o and enter. You will be asked for a password. You need to make a good, strong password. Make sure it has a mix of upper and lower case letters as well as numbers. Don’t lose the password, it will make all this work useless, and you won’t be able to view messages sent to you that are encrypted.
The key will be generated, it takes a while, and while it is being made, try to do some tasks that require you to use the keyboard, mouse, and the disk drives. I am writing this while generating a key, so I’m getting lots of keyboard usage.
When it is finished, you will get a line that reads something like:

gpg: key DFE7A865 marked as ultimately trusted

The name of the key is DFE7A865. Take this number, and edit ~/.mutt/gpg.rc. Change the word KEYNAME to the name of your key. In the case of our example:

set pgp_sign_as=DFE7A865

If you want to publish your public key to a server:

gpg --send-key DFE7A865

To get the password info encrypted, create the file ~/.mutt/passwd with your favorite text editor. Add the following information:

set imap_pass="IMAPPASSWORD"
set smtp_pass="SMTPPASSWORD"

Now, to encrypt it:

gpg -r EMAIL@DOMAIN.EXT -e ~/.mutt/passwd

replace EMAIL@DOMAIN.EXT with the email address you used to create your gpg key. this will create your encrypted password, and now we need to get rid of the unencrypted version. This is easily done with srm, which is part of the secure-delete package:

srm ~/.mutt/passwd

That should do it. You should be able to send mail that is automatically signed using your key. To bring up the gpg menu in mut, after composing a message, press p and you will get encryption options. I hope this has been useful, and that all your data remains safe.

CLI Day 2014

CLI day has been a great holiday. I came up with it a few years ago to celebrate all the cool stuff you can do with the command line, and to hopefully get more people using it.
Last year, because of some events, I didn’t really do much for CLI Day. This year, it’s back and stronger than ever. I wanted to make some changes though, and since it’s my holiday, I figured what the heck, I may as well.
Someone suggested to me that CLI Day should be on May 31, because CLI in Roman Numerals is 151. Originally I wanted my birthday, may 29, to be CLI Day, but I realize the my birthday rocks all by itself, so the Roman Numeral thing is a great idea.
Second, I think CLI Day should be decentralized. So, if you have a blog or whatever, write about it. If you have a Identi.ca or Diaspora account, mension #CLIDay. Enjoy using the commandline, and share the love with others.
This year, for CLI Day, I would like to share a new git project with you. I have written, and am in the process of writing, some games for the command line. It’s definitely a work in progress still, but the games are a lot of fun. If you would like to play, you need bash 4.2+, rolldice, and sox.

git clone git://github.com/stormdragon2976/storm-games.git
Have fun, and enjoy CLI Day 2014!

  • Tip Jar