Sonntag, 6. Oktober 2013

Reading list (2012-Sep 2013)


Books I've read in the last one and a half years:


2012

Debug it
SQL antipatterns
The developer's code
Codex alera 2-6
The quest of the warrior sheep
Einmal durch die Hölle und zurück
Pomodoro Technique Illustrated (2nd time)
The Hudson Book
Grau (Jasper Fforde)
Wheel of Time 11&12&13
Der Hundertjährige, der aus dem Fenster stieg und verschwand
The Alloy of law (Brandon Sanderson)
Robocalypse
Engineering long-lasting Software
Programming Ruby 1.9
Ready Player One
Bartimäus - Das Amulett von Samarkand (Graphic Novel)
Shadowheart (Vol. 4 of Shadowmarch)
Infinity Blade: Awakening (Brandon Sanderson)
Programming Haskell (Graham Hutton)



2013


January - July

xkcd
Practical vim
Artemis Fowl and the Atlantis...
The emperor's soul (Brandon Sanderson)
Red seas under red skies
Programming in Haskell (Graham Hutton)
The Lies of Locke Lamore
Learn you a Haskell for great good

August


Little Brother (Cory Doctorow)
Shards of Honor (Vorkosigan Saga) (Lois McMaster Bujold)


September

Two graves (Preston/Child)
GWT in Action
The last unicorn - Deluxe Edition (Peter S. Beagle)
Infinity Blade: Redemption (Brandon Sanderson)




Samstag, 5. Oktober 2013

GamePlay3D - common error messages

Some common error messages you might encounter when developing a game with GamePlay3D, and how to solve the issues:

Attempting to set a material on node ... which has no model

Symptom

After creating a new project, copying the source code from the character sample and running it, you get:
applyNodeProperty -- Attempting to set a material on node 'boymesh', which has no model.Assertion failed: (0), function applyNodeProperty, file /Users/frank/src/GamePlay/gameplay/src/SceneLoader.cpp, line 246.

Cause

Resource file is missing


Solution


Copy the missing resource file to your project directory (I ended up copying the whole res/ folder from the example project)


Texture sampler ... is missing required image file path

Symptom

After creating a new project and copying the source code from the longboard sample and running it, you get:
loadRenderState -- Texture sampler 'u_diffuseTexture' is missing required image file path.

Assertion failed: (0), function loadRenderState, file /Users/frank/src/GamePlay/gameplay/src/Material.cpp, line 418.

Cause

game*.config files missing

Solution

copy the game*.config files to the app directory 

Adventures with GamePlay3D (Part I)

Motivation

Since my son asked me to develop a simple 3D game for him, and I've always wanted to do something like that, I started playing around with 3D game engines.

I've chosen GamePlay3D http://gameplay3d.org, because

  • it's Open Source (this is my main reason for not using Unity)
  • it's Cross-Platform (Linux, Windows, Mac OS X, iOS, Android - I'm especially interested in Mac OS X and iOS)
  • unlike some other Open Source engines, it seems to be actively developed
  • it contains a 3D engine, support for mouse/keyboard/gamepad/touchscreen, and sound support

Getting started

Getting started with GamePlay3D is easy - just download it, open the XCode workspace, compile the samples and play around with them.

Creating a new project

Playing around with the samples is nice, but creating your own project is much more interesting. To create a new project:
  • open a Terminal
  • cd
  • ./newproject.sh
and enter the required information in the wizard. This will create a new XCode project (btw, this will also create a new Visual Studio project) - open the project, compile & run it, and you'll see a cube rotating in space. Woot!

Freitag, 30. August 2013

Riak build failure: 'get-deps' failed

When trying to build Riak on Mac OS X, you might encounter a failure when make is trying to build the dependencies:

ERROR: 'get-deps' failed while processing


The cause (at least for me) was that accessing github via the git:// protocol doesn't work from our corporate network.

Workaround: build at home, where the git: protocol isn't blocked by the firewall.

Freitag, 23. August 2013

Quoting with awk

Getting awk to print certain special characters (e.g. the single quote ') can be cumbersome. This is frustrating especially when you want to generate SQL statements, where the single quote is used as the string delimiter.

One way to overcome this is to use escape sequences with (octal) ASCII codes:

awk '{print "\047" $1 "\047,\047" $2 "\047";}'

This will convert a list like

Doe John
Mustermann Max

into

'Doe','John'
'Mustermann','Max'


UPDATE
Alternatively, you can use \x with hexadecimal ASCII codes:

awk '{print "\x27" $1 "\x27,\x27" $2 "\x27";}'

Montag, 19. August 2013

Finding files with find

find is the Swiss Army Knife tool for quickly finding files from the command line, but its syntax is somewhat unusual. Here are some quick examples:

  •  list all files with ls that were modified within the last 15 days:

     find ./ -type f -mtime -15 | xargs ls -l  

  •  list all files whose name contains "test":

     find ./ -type f -name "*test"   

  •  grep for OUR in all files modified within the last 15 days

     find ./ -type f -mtime -15|xargs grep OUR   

Donnerstag, 15. August 2013

Delete all photos from iPhone 4S

When ordering my new iPhone 4S about 2 years ago, I thought 16 GB would surely be enough - boy, what a mistake.

Since my photo collection (> 2600 photos and a couple dozen videos) was about 9.5 GB in size, I decided to remove all of them and re-import only the most important ones. Sadly, the photo app doesn't have a "Remove all" button, but as usual, the Internet provided a quick solution:
  • connect iPhone to Mac
  • open Preview
  • File -> Import from iPhone
  • Select all (Cmd+A)
  • click the "Delete" button in the lower left corner

(see https://discussions.apple.com/thread/3777283?start=0&tstart=0 for alternative approaches)

Mittwoch, 17. Juli 2013

Mercurial: recursively remove all class files

Assuming you have erroneously added some .class files to your hg repo and want to get rid of them:

  hg rm "glob:**/*.class"

(as always, StackOverflow provided the answer - see http://stackoverflow.com/questions/4828211/how-do-i-recursively-remove-folders-from-mercurial-tracking-system )

Finding the process belonging to a given TCP/IP port

Finding the process that listens on a given TCP/IP port isn't too hard, but of course, each O/S insists on doing it differently.
Some possible approaches for different operating systems (examples for local GWT server listening on port 8888):

Mac OS X
sudo lsof -i TCP:8888

Windows
netstat -ano | findstr 8888

Linux
netstat -ano | grep 8888

I'm sure there exist more elegant solutions, but these work for me :-)

Dienstag, 7. Mai 2013

Haskell & the dreaded "Ambiguous type

Every time I come back to Haskell, I'm stumped by some mysterious error messages.

Today it was the infamous "Ambiguous type variable `a0' in the constraints" for this piece of code (some tests for problem 2 of 99 Haskell problems):

module LastButOne_02_Test where

import HUnit
import LastButOne_02
 
lastButOne2Elements = test ["last but one for 2elems" ~: Just 1 ~=? lastButOne [1,2]]
lastButOneEmptyList = test ["last but one for empty list" ~: Nothing ~=? lastButOne [] ]
lastButOne3Elements = test ["last but one for 3elems" ~: Just 5 ~=? lastButOne [3,5,2]]

tests = TestList [
  lastButOne2Elements,
  lastButOne3Elements,
  lastButOneEmptyList ]

main::IO()
main = (runTestTT tests) >>= (\x -> putStrLn $ show x)


The reason was the comparison between Nothing and lastButOne [], but thanks to StackOverflow and the online version of Learn You A Haskell For Great Good, I was able to figure it out.

Apparently, the compiler is not content to compare Nothing with [a], so you have to tell it which a you want:

lastButOneEmptyList = test ["last but one for empty list" ~: Nothing ~=? (lastButOne [] :: Maybe Int) ]
Et voilá, the compiler is happy, and therefore am I :-)

Montag, 6. Mai 2013

Replacing Ctrl+M with newline

Differences in line endings (CR vs CR+LF vs ...) are a constant PITA. Here's one quick hack I used to fix some Haskell source code copied from StackOverflow and pasted via pbpaste:

cat udp_syslog_server.hs | tr "[^M]" "[\n]"

Freitag, 4. Januar 2013

tmux cheatsheet

tmux is a kind of terminal multiplexer - similar to GNU screen, but with additional features.

Command-line parameters

 new -s create a new session with name

Examples

tmux lsList running sessions
tmux new -s vimStart a new session named "vim"

Keyboard Shortcuts

Ctrl+bPrefix
Prefix c Create window
Prefix , Rename window
Prefix n Next window
Prefix pPrevious window
Prefix <n>Window #n (n between 0 and 9)
Prefix fFind window by name
Prefix wWindow list
Prefix %Split pane vertically
Prefix "Split pane horizontally
Prefix oCycle through panes
Prefix up/down/left/rightMove around panes