Tag Archives: linux

Back in a minute 1.2 released!

The first public release of my BASH game Back in a minute has finally been released on my coding blog: Back In a Minute First Public Release, Version 1.2!

Back in a minute running in gnome-terminal

Back in a minute a.k.a biamin

You can download a tarball or clone my git repository. Please enjoy!

It feels great to finally give something back to the Free and Open Source software community! The ~2200 lines of code reflects a need for optimization, but I am not planning to do any major overhauls on the current game. (It runs fine and is stable.)

If you ever wanted a random, Warhammer-like BASH terminal adventure game, you’re in for a treat! The world of Back in a minute has 4 playable races, 6 enemies, 8 items and 6 scenarios in 270 sections of the world map. And if you tire of the default map, you can create your own using the map template generator that is built in!

Have fun and a great weekend! It is time to make dinner and mix myself a drink:)

Introducing Back in a minute blog!

Last year, having finished my CD-to-FLAC automation script called FLACRIPPER, I jumped head first into my next project: Create a fun game that is completely written in BASH. I started out with these ideas:

  • It must be quick
  • …but also vast, if you want it to be
  • It must be a full world (have a navigational map)
  • It must have monsters you can fight
  • It must be random

This was the start of forest.sh which later became Back in a minute.

I started coding while reading a lot of political philosophy, simply because I needed a break from books. Creating something that’s in your head on paper is pretty much my everyday life, but there is usually little feedback except when you receive a grade on a paper. Which is pretty arbitrary and not very constructive.

Coding, on the other hand, provides instant feedback! In addition, it does train the same ontological skills that I need in philosophy, so it isn’t a complete waste of time. One big difference is that an article can have spelling mistakes without affecting the content, whereas code simply breaks down in a pile of error messages..

Having coded on and off for half a year, I understood that while being a favourite pastime I couldn’t force my readers (what readers?) to read about it, so I played with the idea of creating a separate blog for the project. When I came to the point of having a working game, I was pretty much planning a sequel. This prompted me to create a separate blog:

I present to you the official Back in a minute homepage!

Please note, there is currently no code in the repositories, because there are 2 bugs I want to iron out first so the game is 100% playable from day one. Last night I watched a Kickstarter update from Tim Schafer‘s development of Broken Age, of which Act 1 was released to backers just yesterday. Anyway, he said that as a game developer at the end of creating a game, there are a hundred things you’d like to do; but there are only 10 things you _can do_, and those are the things you _have to do_.

Without any comparison to the inspiring genius of Tim Schafer, who gave us Monkey Island and Grim Fandango among others, it gave me a push in the right direction. ‘Cause I’ve been struggling with a «social media» feature of my game, which posts a row from the highscore list on Twitter etc. But it has created more problems than it solves, and yesterday I realized that it has nothing to do with the game. So I’m re-doing it in a more basic manner, by simply creating a copy-pastable message in the terminal using echo the player can post him or herself.

That leaves 2 (known) bugs for me to fix, commenting the code a bit more verbosely, and making it more readable (casing). I began writing it in gedit, which is okay for smaller projects, but as soon as I got more than 1500 lines of code it became too slow. I am now using geany, and considering learning emacs instead. That’s what Jesus would do. Anyway, you can follow the development on Back in a minute blog, which was created so those who don’t care don’t have to be bothered! :D

Quick GNU Screen Howto

In Linux, I use screen to start continuous processes on my headless server, so that processes will keep going even though I log out. Here’s a quick how to.

[sigg3@gamer ~]$ ssh sigg3@192.168.1.12
sigg3@sheeva:~$ screen

Screen welcome screen (just hit ENTER)

sigg3@sheeva:~$ nano \\ replace with your program here

type some stuff in nano

CTRL+a d \\ e.g. Detach from screen session

[detached from 2276.pts-0.sheeva] \\ your program is still running
sigg3@sheeva:~$
sigg3@sheeva:~$ logout
Connection to 192.168.1.12 closed.
[sigg3@gamer ~]$ ssh sigg3@192.168.1.12
sigg3@sheeva:~$ screen -ls \\ list running sessions
There are screens on:
2776.pts-0.sheeva (11/27/2013 04:17:01 PM) (Detached)
2170.pts-0.sheeva (11/26/2013 07:08:28 PM) (Detached)
2 Sockets in /var/run/screen/S-sigg3.
sigg3@sheeva:~$ screen -r 2776.pts-0.sheeva \\ re-attach to screen

Type more stuff and exit nano

sigg3@sheeva:~$ screen -ls
There are screens on:
2776.pts-0.sheeva (11/27/2013 04:17:00 PM) (Attached)
2170.pts-0.sheeva (11/26/2013 07:08:27 PM) (Detached)
2 Sockets in /var/run/screen/S-sigg3.
sigg3@sheeva:~$
CTRL+a k \\ e.g. Kill the screen session I'm in
[really kill this window? y/n] y
[screen is terminating]
sigg3@sheeva:~$
sigg3@sheeva:~$ screen -ls
There is a screen on:
2170.pts-0.sheeva (11/26/2013 07:08:28 PM) (Detached)
1 Socket in /var/run/screen/S-sigg3.

sigg3@sheeva:~$ logout
Connection to 192.168.1.12 closed.
[sigg3@gamer ~]$ echo "That's all, folks"
That's all, folks

For more screen commands, see the man page for screen

Link

If you’ve ever stood in line at your local news stand waiting for a greasy bacon hotdog, you’ve seen the Linux Format magazine under the Technology header, you know, down to the left from the dirty adult mags. Linux Format is, like every other societal institution, defined by the people running it. Now, the people have gone. They quit. Introducing Linux Voice Magazine!

We were the first to cover the Raspberry Pi from the newsstand. We beat the C.I.A. before it was cool. We sent a comfort package to Edward Snowden, and taught the world how easy servers were to hack (er, sorry, crack). Our fortnightly TuxRadar podcast entertained thousands of insightful and generous listeners, and we loved every minute of it.
Last month we quit, and we quit because we wanted to do something different. We want to create an even better magazine; a bigger, more entertaining and more accountable magazine for the community we love to serve. The magazine we want to make is called Linux Voice.

In the first 24 hours, they’ve raised more than £10,000 of their £90,000 goal. Please support the indie go-go campaign @ Linux Voice campaign by clicking that link. You can also check out their website here.

From my empty pockets I’ve still managed to shell out £80 for a year’s subscription. If I can do it, so can you. And if you like Linux, you’re gonna love these guys!

FLACRIPPER released! (updated)

I am going to be ripping a whole lot of CDs in order to digitize my CD collection (500+ CDs). I want lossless or close to lossless FLAC files of every single one. But I am lazy. And the GTK based rippers are slow and cumbersome (i.e. require my attention). Why not just drop down to the commandline and run cdparanoia? But then I’d still have to FLAC’em and tag’em, sort out the folders and correct wrongly named files..

This is where you go "There’s an app for that!" and narrowly escape my swinging fist. Of course there is. There are millions of apps– I mean programs that does this. But this is also the perfect excuse for actually getting to know bash scripting in GNU/Linux, and at a comfortably simple level. So for the last 3-4 days I’ve been writing a bash utility called FLACRIPPER that does exactly what I wanted and MORE. Which explains the 1.2 version number:)

FLACRIPPER in action
Ripping Stranger in Moscow because it’s the shortest single I have

The GPL v3 licensed source is here:
Flacripper (directory): sigg3.net/blogger/flacripper/
Flacripper (latest): sigg3.net/blogger/flacripper/flacripper.sh.txt
Please report bugs in the comments or by this form.

What is FLACRIPPER
Essentially, it’s just a smart bash script that runs Monty’s cdparanoia and Josh Coalson’s flac. But it also queries the CDDB (freedb.org) music info database using cddb_query, auto-tags files with metatag after you’ve confirmed them (see screenshot), creates directories and keeps a log of your ripping. Script has been updated to accept commandline arguments (see below).

CONFIGURATION
Just edit the .sh file in your favourite editor (e.g. nano). It’s pretty simple:

# CONFIGURATION

# Path to your music root directory (NO trailing slash!)
musicdir="/home/`whoami`/Music"

# FLAC compression level (0 is none, 8 is full)
flaclvl=2

# Keep original WAV files? (default: disabled)
keepwavs=0

# Enable log? (saves flacripper.log in $musicdir)
enable_log=1

# Enable log check? (default: enabled)
# Exits if disc ID is found in log file, but without regard
# for earlier erraneous rips and CDDB ID duplicates.
enable_logcheck=1

# Confirm CDDB information? (default: enabled)
# Leave enabled to avoid CDDB misinformation. Laziness is key.
# (e.g. "Michael Jackson" vs. "Jackson, Michael" artist field)
confirm_cddb=1

So far it’s only been tested on my Fedora 17 machine, but it should work on any GNU/Linux operating system as long as these dependencies are met: cddb, cdparanoia, eject, flac and metaflac.

INSTALLATION:

# DEPENDENCIES: cddb, cdparanoia, eject, flac, metaflac
wget http://sigg3.net/blogger/flacripper/flacripper.sh.txt .
nano flacripper.sh.txt # Edit config section if you want to
mv flacripper.sh.txt flacripper
chmod +x flacripper
su
mv flacripper /usr/local/bin/
exit

The out of the box experience will rip your CD to WAV, convert these to flac using compression level 2, create folders in your root music dir /ARTIST/ALBUM and tag the flac files according to the CDDB query. If the CDDB query fails, which can happen on brand new CDs as well as obscure ones, flacripper will dump you into an ncurses based interactive editing mode PRIOR to ripping. Cdparanoia is excellent, but can be slow if your media is scratched/old, so the idea is to get all the information gathering done before the machine takes over.

If your CD is known you’ll usually: put it in the drive, type flacripper go [ENTER] and hit [ENTER] to confirm artist and album info. That’s it. If your CD is unknown to freedb.org you’ll be asked to enter Artist, Album name, Genre, Year and the track list before the machine takes over.

What have I learned?
Much thanks to The Linux Commandline and Shell Scripting Bible by Richard Blum, I was able to solve most problems without resorting to google, which was sort of the point. I’ve come to learn a lot about sed, awk and tr, which are excellent tools for manipulating piped output, and without which I wouldn’t know where to begin. But I have much to learn, so I decided to release my godawful code under the GPL v3. I know there are many places where I could probably just reverse the stream to avoid temp files, but I’m not too confident about that just yet. Thanks to the brilliant guys @ bash.cyberciti.biz for their dialog –form write-up and BeGood at stackoverflow.com for a nice renaming while-loop. Happy ripping!

EDIT: UPDATED to version 1.2.2
Fixed a bug where a couple of missing quotes left 2 meta tag fields empty in configured mode. Updated the script so that it runs like a regular GNU/Linux utility:

  • To run in configured mode: $flacripper go 
  • To run in simple mode: $flacripper –quick 

I also added –help and –usage, the latter being displayed also if flacripper is run without arguments. –help will display the current configuration settings in addition to usual help information. Finally, I added a cleanup function to do a little housekeeping if flacripper receives SIGHUP, SIGINT or SIGTERM signal.

EDIT: UPDATED to version 1.2.3
Fixed a couple of bugs stemming from the feature creep above. Also added directory listing so you can browse the sources. I expect no other changes to the script from now on except bug fixes, though I am toying with the idea of an experimental post to $socialnetwork option.. But I need to move on to actually ripping CDs now, studies, and any bugs you can find or fixes you submit. Thanks!