Thursday, October 31, 2013

Book Review #8

Easy Sushi
Emi Kazuko

Easy Sushi is one of the numerous sushi book I have. Even though I rarely eat raw meat, being too cheap to spring for sushi grade, I nevertheless enjoyed the pictures and presentation of the materials. There is nothing fancy about preparing for sushi. This being vinegared rice, some nori seaweed sheets, and some meat (usually raw) on top. That's about it.

Nothing much in regard to secret ingredient as well. The recipe for sushi is well-known. The book does have simplistic elegant presentation which I like, and there's some materials near the end of the book that updates the recipes somewhat. As far as sushi book, this is average. But as coffee table book, I really like this one. So, think less of a cooking book, more of an art book. If you think your food should be artistic, then give this book a try. You may like what you see.

Tuesday, October 29, 2013

Raspberry Pi Journal #34

Noob-Guru: The Great Divide

Sometimes, reading all the posts on the web reveals the great division between noob and guru. One recent example was a question on how to have your own web address. The answer, of course, is to set up a DNS server. It was suggested that you hire some services out there. There are several questions: How about running your own DNS server? Who would provide DNS server services, but not hosting? Who would provide hosting, and also includes DNS server services? Et cetera.

One of the answer, however, directs me to this site:

which is an excellent Raspberry Pi resource. I printed off quite a few pages out of it. But no answer whatsoever regarding the original question. One of the page does mention on how to set up your own web server. However, there is no instruction on how to connect it to DNS server.

Well, obviously, you need to do such and such. Except, those steps aren't obvious to beginners. Thus, what is simple and natural to experts, are insurmountable obstacle to beginners.

Another example. Google Coder is an excellent piece of work. I went to github, which holds the source, and found no installation instructions whatsoever. I had to go to another site, and apparently, it's a relatively standard install. Except for one thing: You need to install Apple Bonjour Service. What? Why would I need that?

Turns out, I need it so Chrome/Internet Explorer/Mozilla whatever browser is compatible can parse


And that's it. That is the sole function of Bonjour. Talk about technological overkill. Don't you think maybe installing a whole new package just to parse URL is silly? Well, yes. That's why if you connect the server to a monitor, it will show the IP address and you can just plug the number into your web browser. Except the installation instruction does not mention that at all! I think maybe they need better instruction.

Oh, and the browser? It's on a different machine, obviously, because the last time I check, Internet Explorer doesn't run on Raspberry Pi, and support for Chromium is flaky at best.

I don't know about you, but those obvious points aren't obvious to me.

I had a run in recently. I pointed out that a USB drive option is useful for multiple users using the same Raspberry Pi. Somebody tongue-in-cheek suggested using multiple SD card instead. But the real good answer comes in the question as to why would you want to copy the whole root file system, when all you want to do is handling multiple users? Obviously copying /home/username would be much easier and safer than copying and mounting the whole partition. Except, it's not obvious to a noob, like me.

Another trouble that I had. When backing up my system using tar, the process stopped at 4Gig. Obviously, the file system cannot handle more. I did some searching with tar manual. It mentioned replacing tapes. So I tried that, and well, that didn't work too well since the program just replaced the same file name over and over. So I asked around, and the answer was to just replace the whole system with ext4. So I did. It works fine. A few weeks after that, I ran into the split command, which would have solved the problem neatly. Well, obviously I should have done that in the first place. Except, it's not obvious to me.

That is why, I keep saying, that having an enabler device is not enough. You have to have a good instruction along with it.

Imagine this:
You provide a hammer to people. Free hammer for everyone! Will that make everybody happy? Of course not. What would you do with a hammer? Pound nails would be the obvious answer. However, there are many more uses available. How about chiseling a statue? Installing rail road tracks? Breaking a rock? Making jewelries? Tenderizing meat? Husking wheat? And so on...

Without a good instruction, a hammer is just a block at the end of the stick. A Raspberry Pi is just a fancy toy. With good instructions, well, what was Michaelangelo's David but a block of marble?

Monday, October 28, 2013

Cooking Journal #10


I bought a sack of Russell potato from Idaho. The package says that it's good for frying. Actually, it doesn't matter what kind of potato. As long as it says Idaho on the box, it's good.

I sliced the potato thinly, like as if I'm making some potato chips. Ummm. Yes, that's a Buck knife. Not a kitchen knife.

Next I sliced it again. This time perpendicularly. Notice now that the potato are little strings standing upright.

Next step is to fry them. I didn't use anything, except a spoonful of oil. It works fine as-is, but cooking time is too long for me. I guess I just don't have the patience to do it. The potato sticks together, so I have no problem flipping it for even cooking.

Serve with fried egg and sausages. That's a good hearty breakfast! It does take too long to prepare, but doing it once a week isn't bad.

Saturday, October 26, 2013

Nintendo Journal 10

Leatherman Blast

Although my daily carry is a Buck folder, I do have other knives. I have several Swiss Army Knife folders. Some models are Camp, Hunter, and several others. I really like these Swiss Army knives. They are sharp, hold their edge, and very convenient to have.

You see a Leatherman Blast next to it. I guess I got in by the hype. There's no question the metal in Leatherman Blast is good. It may even be better than the one in Swiss Army Knife. However, I think they ignore usability issue. Pulling out the blades and other tools are rather painful, and not at all easy. The plier is nice, and the tool selection is fine. However, pulling those tools out is ridiculously hard when compared to Swiss Army Knife.

Am I being spoiled? I don't think so. Gerber makes a good one and it's easy to use. So, for multi-tool needs, I first go to SAK, then Gerber. If it's not convenient, I'd rather not use it.

Friday, October 25, 2013

Petit Computer Journal #22

5. Loop with Player input + background process

Last post, we were dealing with idle loop and how we process the button inputs and the corresponding code handlers. This time, I'm going to show you a clearer form to handle player input.

One of the most asked question is how to move the player sprite UDLR, and shoot. I'm going to show you how you should structure your code and divide it into two parts:

  1. Process Input
  2. Act on Input

While we are processing input, we want it very, very quick. This means that we do not act on any of the input at all. We simply store the information and that's it.

Later on, depending on the variables set, we can process the data. I'm using an extra variable to determine whether or not the player is shooting, and whether or not the bullet is being shot.

This is a very simple structure. If you can use array for directions, then I suggest that you use it. Even loading array using DATA statements is preferable to hand-coding it, like I'm doing here. Even though it doesn't take much time at all, copying and pasting, using array is the neater and better solution. Easier to maintain, too.

We'll take a look at multi-threading process next.

  1. ACLS
  2. SPSET 1,68,0,0,0,0
  3. SPOFS 1,128,96
  4. SPSET 10,40,0,0,0,0
  5. SPANIM 10,2,6
  6. SPOFS 10,-50,-50

  7. @INIT
  9. BB=0

  10. @LOOP
  13. B=BUTTON(0)
  14. SPREAD(1),PX,PY

  15. IF (B AND 1) THEN PD=1
  16. IF (B AND 2) THEN PD=2
  17. IF (B AND 4) THEN PD=3
  18. IF (B AND 8) THEN PD=4

  23. IF (SPCHK(10) AND 1) THEN BB=1 ELSE BB=0

  24. IF !BB THEN SPOFS 10,-50,-50
  26. GOTO @LOOP

  27. @PMOVE
  28. IF PD>4 OR PD<0 THEN PD=0
  30. @MSTOP
  31. SPCHR 1,68
  32. SPANIM 1,1,0
  33. RETURN
  34. @MUP
  35. SPCHR 1,76
  36. SPANIM 1,4,15
  37. SPOFS 1,PX,PY-16,60
  38. RETURN
  39. @MDOWN
  40. SPCHR 1,68
  41. SPANIM 1,4,15
  42. SPOFS 1,PX,PY+16,60
  43. RETURN
  44. @MLEFT
  45. SPCHR 1,72
  46. SPANIM 1,4,15
  47. SPOFS 1,PX-16,PY,60
  48. RETURN
  49. @MRIGHT
  50. SPCHR 1,64
  51. SPANIM 1,4,15
  52. SPOFS 1,PX+16,PY,60
  53. RETURN

  54. @PSHOOT
  57. @PSTOP
  59. RETURN
  60. @PUP
  61. SPCHR 10,46
  62. SPOFS 10,PX,PY,0
  63. SPOFS 10,PX,PY-160,160
  64. RETURN
  65. @PDOWN
  66. SPCHR 10,42
  67. SPOFS 10,PX,PY,0
  68. SPOFS 10,PX,PY+160,160
  69. RETURN
  70. @PLEFT
  71. SPCHR 10,44
  72. SPOFS 10,PX,PY,0
  73. SPOFS 10,PX-160,PY,160
  74. RETURN
  75. @PRIGHT
  76. SPCHR 10,40
  77. SPOFS 10,PX,PY,0
  78. SPOFS 10,PX+160,PY,160
  79. RETURN

Thursday, October 24, 2013

Book Review #7

Make: Electronics
Charles Platt

This is an excellent book to learn Electronic. By the first chapter, I have learned to lick a battery, blow up a led, and other destructive, yet fun thing to do. I never thought learning electronic circuits can be so much fun! Although the content of the book is nothing special, the presentation is fun, engaging, and clear. I mean, in all electronic books, there is a lesson on how resistors work, how capacitors work, how transistor work. The explanation may not be the most concise available, but they are clear and easy-to-follow. That is the most important thing.

Along the way, I learned not only what different pieces of electronics do, and what tools would be valuable, but also what tools are optional. Breadboard, for one, which I thought was indispensable for trying out electronic circuitry, is actually an optional equipment. You can get by with just using wires and clips all over the place. The book does not mention conductive ink, but it is something I should try sometime in the future.

For the first time in my life, I feel like I truly understand what's going on behind the scene. That is a worthwhile experience, easily worth more than the purchase of the book. Highly recommended.

Tuesday, October 22, 2013

Raspberry Pi Journal #33

Learning Python

The Raspberry Pi device was conceived as educational enabler device. Part of the target audience was kids. That's why it has Scratch programming on it. Also, the official programming language is Python. In fact, that's the "Pi" in Raspberry Pi.

So, after I built the LCD Display kit, it's time for me to learn Python programming. My chosen language was actually Perl, since it's so easy to write in it. But since the official language is Python, I guess I should learn it.

The book I chose is O'Reilly Learning Python. O'Reilly books are consistently high quality. Very few is sub par. So, if I am to buy a learning book sight unseen, it's O'Reilly.

You can see the the picture is that of a rat. Where's the snake? Sorry. That's another book: Programming Python. About the same size and price of this book. The price? $70 with tax. The size? 1500 pages.

Ahem. 1500 pages. Are you nuts? Is that one book? Don't you think, like maybe, it's better to split it into 3 books? After all, isn't that what Prof. Donald Knuth did with his book? Oh, and the other book is the same size?

That makes it 3000 pages total. And remember, Raspberry Pi is designed to teach kids how to program. Somehow, no matter how hard I try, I just can't imagine kids would be wanting to pick this book up, much less two of them.

I must be getting old. It used to be that I can devour such book in a couple of days. So far, because of other commitments, I managed to read 300 pages into it. And learned different object types.

300 pages to explain the different object types.

470 pages will give you loops.

I admit that the book provides an excellent foundation of how Python works. But 300 pages? It deals with the powerful flexibility that Python have that lets you handle complexities with ease. Except, I don't want to go there. I have yet to see source code that maximized the full potential of the language.

I still remember that Learning Perl and Programming Perl book combined is less that this book. I guess it just goes to show you that today's computer, and programming language, is very powerful indeed.

But still, are you sure you want to foist this ultra powerful programming language to kids, even if they have Scratch programming background?

Monday, October 21, 2013

Cooking Journal #9

Cooking Egg with Microwave Oven

In all specialized tools out there, they actually sell a special microwave egg cooker. Correction: I know at least two different devices. The first one is actually an egg steamer using the water on the bottom, and egg holder at the top. It works as advertised, and although normally a good thing, it's too slow for me.

The second one is simply an egg holder. You put cracked egg into it, and close. The egg will blow, but because it's enclosed, it won't splatter.

Well, I'm too cheap to spring for the specialized device like that, so I made do with a substitute.

First, I get a Pyrex bowl. Notice the cover has a vent hole on it. Very important!

Then crack two egg. Put a spoonful of water and swirl. If the egg blows, need more water. If the egg is soggy, use less.

Cover. Cook for 2 minutes on High. Serve.

That's it.

Saturday, October 19, 2013

Nintendo Journal 9

2 Buck Knives

I have several knives. These two here, I picked up in Indiana knife store. I actually was looking for CRST folder, but I couldn't find it. However, they do have something called a Barlow knife.

Barlow knife is an old design. Supposedly, George Washington carried one. It also makes it into a story book, Huckleberry Finn by Mark Twain, if I remember correctly. So, that's a good old standby. It's a good, compact, all-purpose camping knife.

Another knife is the modern version. This one is non-folding fixed blade. I also have the folder version of it that I carry everywhere. However, for heavy duty camping, this knife is as good as it gets without getting into exotic territory.

Buck knives are good, reasonably price all-around common knives. I actually prefer Buck knives to Case.

Friday, October 18, 2013

Petit Computer Journal #21

A Simple Timer

This here is a simplified version of the timer program. I put it here just to clarify that there are other ways to do this. The previous version was used to show LOOP construct, but this version is an optimized version of it. Notice that duplicate codes are collapsed into one, thus simplifying the whole structure.

  2. SPSET 1,156,0,0,0,0
  3. SPOFS 1,-50,-50
  4. SPANIM 1,4,15
  5. SPSCALE 1,200

  6. @INIT
  7. CLS
  8. SPOFS 1,0,96,0
  9. SPREAD(1),X,Y
  11. INPUT T
  12. IF 0>=T GOTO @END
  13. CLS
  15. ?"B SETS NEW TIME"
  16. ?"X EXIT"
  17. ?"Y PAUSE"

  18. @LOOP
  19. VSYNC 1:B=BTRIG()
  20. IF (SPCHK(1) AND 1) THEN SPOFS 1,X,Y,0 
  21. IF (B AND 16) THEN SPOFS 1,224,96,FLOOR((224-X)*T/224)*60:GOTO @TICK
  22. IF (B AND 32) GOTO @INIT
  23. IF (B AND 64) GOTO @END
  24. GOTO @LOOP
  25. @TICK
  26. IF (BUTTON(0) AND 128) GOTO @LOOP
  27. LOCATE 0,8:SPREAD(1),X,Y:?"TIME LEFT: ";FLOOR((224-X)*T/224);"   "
  29. ?"TIME'S UP!":SPOFS 1,0,96,0:X=0:BEEP 50:WAIT 120
  30. GOTO @LOOP

  31. @END
  32. ?"GOODBYE!"
  33. SPCLR 1:WAIT 300

Thursday, October 17, 2013

Book Review #6

The Linux Command Line
William E. Shotts, Jr

I've been looking for a good shell scripting book when I chance upon this book. Reading the book gives me a good understanding, not only in scripting capabilities, but also the standard Linux shell programs. Things like lp, cat, grep, and sed are explored in details. I have come to the understanding that, in fact, I need this book more than anything. In my work with Raspberry Pi, I am dealing with Linux command line every day. I'm happy to say that I have written a few significant shell scripts that do not rely on powerful scripting language such as Perl or Python. Although the resulting scripts run slower, I don't mind at all. It's the learning process that matters.

In regard to Raspberry Pi, it is a great enabler device. However, I am with the opinion that a great enabler device by itself is not enough. I have numerous books about making this project or that project with Raspberry Pi. However, in the process of making the project, I have often come into the stumbling blocks of every day occurence. How do I format SD card? How to disable the screensaver? And so on. This book not only explains all the tools you need in order to navigate the Linux shell, but also gives you the powerful bash scripting technique that you can use to whip up a quick script leveraging the various Linux shell programs.

This is just my opinion, but I think this book is a must have for all Raspberry Pi users, if not all Linux users. Highly Recommended.

Tuesday, October 15, 2013

Raspberry Pi Journal #32

Adafruit LCD w/ Keypad First Test

I finally installed the script to run Adafruit LCD w/ Keypad Kit. Mine is the RGB version, so I get all the colors. It was rather scary trying to enter the unknown. I did it with some trepidation. Obviously, I backed up my system!

Turns out there's no trouble at all.

I'm not running Occidentalis, so I have to do things the hard way, which isn't hard at all. I opened up the file /etc/modules and there's only one entry on it. I simply added these two lines at the end (per instruction)


And that's it. Reboot for it to take effect, and install some programs. Again, this is all mentioned in the helpful instructions.

  • sudo apt-get install python-smbus
  • sudo apt-get install i2c-tools

By the way, I make sure that I don't already have the package. But it's not necessary. The installation will install the latest package version if necessary, but that's about it. Also, i2c-tools install a set of program into /usr/sbin.

Next, I went and installed the source code from github. It turns out that I already have git on my computer. So, all I have to do is clone it from the directory.

  • git clone

And that's it. Very quickly done. Next, install update Python to allow GPIO programming:

  • sudo apt-get install python-dev
  • sudo apt-get install python-rpi.gpio

Thankfully the python demo script auto-detect my device. At first, I wasn't sure that the program is running. Then I remembered that the LCD is contrast sensitive. I pulled out my trusty Swiss Army Knife. Popped out philips screwdriver, and adjusted the contrast. I was elated when I see the lettering, and downright happy when the text and the color changes per button presses!

Oh, yeah! I guess I'm a hardware engineer, now! Well, I guess I should learn Python programming so I can do cool stuff with it!

Monday, October 14, 2013

Cooking Journal #8

Chicken Legs

Now I can get used with this. I like chicken legs, especially deep fried! There is only one problem: Tremendous amount of oil is being used. As it is, I don't want to use too much oil, and as you can see, the legs are only half submerged. This means that I cannot leave the cooking alone. I have to watch the legs being fried and keep turning them around.

On my previous posts, I mentioned how I never use condiment, or spices on all my chicken. Since this cooking method is so time consuming anyway, I decided to bread my chicken. Simply wash the chicken legs, and shake them around in cooking flour.

The result is that the wetness is somewhat contained, and the chicken becomes softer and juicier. Definitely tastier than simple frying without flour. Another thing: The wok will have to be cleaned thoroughly after this. So, good eating, yes, but tremendous amount of work, not only in cooking, but also in cleaning up afterwards.

Saturday, October 12, 2013

Nintendo Journal 8

TopGun LCD game

I also picked up an old LCD games. TopGun by Konami. It's just a single board game with LCD screen. There's a small speaker on the back. It's amazing how simple these things are. I think games like these are perfect for Petit Computer projects. I will be rustling up a few.

I marvelled at how thin the LCD screen is. It's just a thin plastic, nothing more. I looked at the contacts, and they're sooo tiny! I really doubt that they can align it perfectly, and yet, when I reassembled the device, it works fine!

I don't know how they do it. As simple as it is, that's not something any rookie can do. There must have been some degree of experimentation in order to fit things just right.

Friday, October 11, 2013

Petit Computer Journal #20


I'm going to do something different this time around. Usually I would make a new program, illustrating a new concept. However, this time, I won't be doing something new and exciting. I'll be doing something that is old and boring: idle loop.

What is idle loop? Well, you know the main loop on the program that goes like this:

  2. 'get player input
  3. 'process player input

That's it. Idle loop is so called because if the player has no input, it'll just wait around doing nothing. In other words, being idle.

So, you're probably wondering why I want to show that here. Shouldn't that process be known to everybody? Yes, it should. But not to everybody. Just like loop, there are various situations that you have to watch out for. For example, where would you want to put the @INIT function?

INIT function deals with initial state of the program. This is where default values come into play. Also, I like to put in @QUIT function, where the program does clean up when it exits. I don't put it in all my programs, especially simple ones, but for completeness, I want my programs to clean up after itself. It's just good programming practice.

So, the structure would be

  1. Global settings, DIM, and such
  2. INIT function
  3. MAIN function
  4. END/QUIT/CLEANUP function

There is a difference between Global Settings and INIT. In Global Settings, you allocate memory to the variables, and load any static resource needed. Fortunately, Petit Computer takes care most of it for you. Very little needed to be here. Some programming language requires you to load modules/libraries here as well.

INIT function deals with initializing the variables to start-up state. That means loading any custom screens if any. Backgrounds, Icons, and the like. This function gets called whenever the player quit to the title screen. It basically start fresh. If you have game states then you load that separately from this function. And yes, you want to have that special loading function, so you can override default graphics and provide the player with custom sprites and skin.

QUIT function basically says good-bye. There's not much here for Petit Computer. If you don't need anything, just leave it out, or just put out a good-bye message to the player.

The MAIN function will handle several types of cases:

  1. Infinite Loop
  2. Loop with Timer
  3. Loop with VSYNC
  4. Loop with Player input (wait)
  5. Loop with Player input (no wait)
  6. Loop with Player input + background process
  7. Loop with Player input + multi-thread

1. Infinite Loop

The first case is the simplest. You want the program to run forever, like in showing demo.

  1. @LOOP
  2. ?"Hello World"

2. Loop with Timer

Sometimes, you want to have the program run for a certain length of time. Say, like a Timer. You can do it like this:

  2. SPSET 1,156,0,0,0,0
  3. SPOFS 1,-50,-50
  4. SPANIM 1,4,15
  5. SPSCALE 1,200

  6. @INIT
  7. CLS
  9. INPUT T
  10. IF 0>=T GOTO @END
  11. SPOFS 1,0,48,0
  12. SPOFS 1,224,48,T*60

  13. @LOOP
  14. IF (SPCHK(1) AND 1)==0 GOTO @END
  15. BEEP 28:WAIT 60
  16. GOTO @LOOP

  17. @END
  18. ?"TIME'S UP!"
  19. SPCLR 1
  20. BEEP 50
  21. WAIT 300

And that's it. The code before the INIT creates and sets the sprite. INIT is used to send the sprite across the screen, timed according to T variable. The loop then simply waits for the sprite to stop moving, and gave a "ding" sound when it's done. Also, sprite clean up is done at the END.

3. Loop with Player input (wait)

Let's modify the program a bit. We want to have a player input, and we want it to wait for each input. Let's say A to start the timer, B to set the timer, and X to end the program.

  1. @INIT
  2. CLS
  4. INPUT T
  5. IF 0>=T GOTO @END
  8. ?"X EXIT"

  9. @LOOP
  10. VSYNC 1:B=BTRIG()
  11. IF (B AND 16) GOTO @TICK
  12. IF (B AND 32) GOTO @INIT
  13. IF (B AND 64) GOTO @END
  14. GOTO @LOOP
  15. @TICK
  16. SPOFS 1,0,48,0
  17. SPOFS 1,224,48,T*60
  18. @TOCK
  19. LOCATE 0,4:SPREAD(1),X,Y:?"TIME LEFT: ";FLOOR((224-X)*T/224);"   "
  21. ?"TIME'S UP!":SPOFS 1,-50,-50:BEEP 50
  22. GOTO @LOOP

  23. @END
  24. ?"GOODBYE!"
  25. SPCLR 1:WAIT 300

If you notice, there's TICK and TOCK. Normally, I would put these on separate subroutine, but since I'm showing you how to do LOOP while waiting for user input, I simply group it all at once. Does it look like spaghetti code to you?

4. Loop with Player input (no wait)

Let's do one more improvement, and this time, we're going to do player input without waiting. Let's implement a PAUSE button. The truth is, it's very simple. Petit Computer, by default, does not wait for user input.

Here, we simply check if the sprite is moving. If so, then we stop it. Else, we start it.

  2. SPSET 1,156,0,0,0,0
  3. SPOFS 1,-50,-50
  4. SPANIM 1,4,15
  5. SPSCALE 1,200

  6. @INIT
  7. CLS
  9. INPUT T
  10. IF 0>=T GOTO @END
  12. ?"B SETS NEW TIME"
  13. ?"X EXIT"
  14. ?"Y PAUSE"

  15. @LOOP
  16. VSYNC 1:B=BTRIG()
  17. IF (B AND 16) GOTO @TICK
  18. IF (B AND 32) GOTO @INIT
  19. IF (B AND 64) GOTO @END
  20. GOTO @LOOP
  21. @TICK
  22. SPOFS 1,0,48,0
  23. SPOFS 1,224,48,T*60
  24. @TOCK
  25. LOCATE 0,8:SPREAD(1),X,Y:?"TIME LEFT: ";FLOOR((224-X)*T/224);"   "
  26. IF (BUTTON(0) AND 128) GOTO @PAUSE
  28. ?"TIME'S UP!":SPOFS 1,-50,-50:BEEP 50
  29. GOTO @LOOP

  30. @PAUSE
  31. IF (SPCHK(1) AND 1) THEN SPOFS 1,X,Y,0 
  32. IF (BUTTON(0) AND 16) THEN SPOFS 1,224,48,FLOOR((224-X)*T/224)*60:GOTO @TOCK
  33. IF (BUTTON(0) AND 32) GOTO @INIT
  34. IF (BUTTON(0) AND 64) GOTO @END

  36. @END
  37. ?"GOODBYE!"
  38. SPCLR 1:WAIT 300

Simple as that. We simply use the variable values from TIME LEFT to stop the sprite where it stands, and starts it in according to TIME LEFT. There's a trick here, that we use BUTTON(0) instead of BTRIG. We do that because of WAIT 60 that we have will cause BTRIG signal to get lost. BUTTON(0) will read the input continuously. Press A to restart the timer.

Petit Computer Programming can be so easy! Next, we'll examine loops with background processes.

Thursday, October 10, 2013

Book Review #5

Zen and the Art of Well Being
Eric Chaline

This is an old book, published in 2001. I find it interesting that current self-help book deals with medicine. As in, take this medicine for brain, this medicine for stomach, this miracle diet for being thin, and so on. Rarely, that there is a book that emphasize balance. This book, with its Taichi principles does have it. It also has well-being as the core concept. It's certainly a very unique self-help book. It's closer to philosophical look at being healthy, than it is a definite step-by-step method to being well.

And that's why I like it. There is a sense of effortlessness throughout the book, that I enjoy reading. It's the most enjoyable self-help book I've read so far. Not much for resources, though. That I will have to research on my own. Yet, I do not regret purchasing this book. It's worth a read from time to time, as I strive to achieve a balance between work and play. Yin and Yang. Zen.

Tuesday, October 8, 2013

Raspberry Pi Journal #31

Package List and Update

So, the Foundation finally updated their package list. Naturally, I'm curious as to what changes are afoot. So, I did what is natural. I simply dump all package names with what I have right now. I call it pack1.txt

apt-cache pkgnames >pack1.txt

Then I do an update and dump all the package names into pack2.txt

apt-get update
apt-cache pkgnames >pack2.txt

Finally, I did a diff between the two.

diff pack1.txt pack2.txt

And all the new package names appear, just like that!


The update also mention SonicPi, and searching for it yields sonic-pi package name.

apt-cache search sonic
apt-cache show sonic-pi

Monday, October 7, 2013

Cooking Journal #7

Chicken Steak

Remember last week, when I did chicken nuggets, and I said that it's not what I usually do? Well, this is what I usually do: Chicken steak.

The difference is in the cuts. Stir Fry is usually cut into ribbons. It helps in cooking the meat quickly. Chicken nugget makes a nice compromise in cutting time and cooking quickly. Chicken steak like this is cut very broadly, and thickly. This is one of those cook and leave alone for a while.

On medium low, I think this goes about 10 minutes. Again, I go by smell. You can go by bubbles. If the chicken stops bubbling, that means the water is gone, and you can test to see if the chicken is fully cooked by then.

If you look at the chicken, you don't see any brownings at all. There's no caramelization involved. This is because by nature, the chicken breast that I'm using  has water, and it got mixed in the cooking. So, it's partly fried, and partly boiled. The result is well cooked chicken, but somewhat devoid of taste.

If I wanted to, I can dip the chicken into hot oil to induce caramelization process and get the crispy texture outside. This will result in better taste. Alas, I am too lazy for that. Please pass the ketchup. Thank you.

Saturday, October 5, 2013

Nintendo Journal #7

LeapPad circuitry

I've been frequenting Thrift stores lately and picking up old electronic stuff. I was hoping to score one of those servos, or maybe screen display. When I see this Leappad, I picked it up.

Sure enough, there is display in there. Except, there isn't a 2 lines into it. Or maybe four. There's quite a bit in there. I really don't know how many are there. Apparently there is a standard called DSI that is common for LED display. I looked at it, and it's too fine for me to handle.

If you know Raspberry Pi camera ribbon cable. That looks just like that. There's also a touchscreen pasted on top of the screen, but I don't think it works, because the program does not respond to touch at all. It does have standard 4 wires that I can handle if need be.

I do notice something: The audio plug is low profile. So I ended up soldering it to my Raspberry Pi!

noob tools 1

A very rough preview of what is to come: noob version 0.1. I've been working on it a little bit at a time. Backing up SD card using dd remains the longest activity. Make sure the filename is or fix it on the install case. Or else, it won't install.


#echo "$0"

case "$1" in
echo "Halting"
sleep 3
sudo halt

echo "Rebooting"
sleep 3
sudo reboot

echo "Choosing random jpg as wallpaper"
PIC=$(ls *.jpg | shuf -n1)
pcmanfm -w $PIC
echo $PIC

echo "Enable Screensaver"
sudo xset s blank      #Enable blanking
sudo xset s on         #Enable screensaver
sudo xset +dpms        #Enable Energy Saving

echo "Disable Screensaver"
sudo xset s noblank   #Disable blanking
sudo xset s off       #Disable screensaver
sudo xset -dpms       #Disable Energy Saving

echo "Updating package list"
sudo apt-get update
#sudo apt-get upgrade
##rpi-update   ###DANGEROUS### Do not use!!!

echo "Available packages"
apt-cache pkgnames    #Show all package names

echo "Installed packages"
#dpkg --get-selections  #Show installed packages
dpkg --get-selections | grep -o -e ^[[:graph:]]*

echo "Backing up directories to /media/SD/"
echo "Warning: This will copy the files from internal SD card"
echo "to external USB Flashdrive/SD Card. rsync is used to mirror"
echo "the files. Make sure you choose the right directory."
echo "The directories are:"
for i in {0..99}; do sdlist[i]=0; done

for i in `ls /media`; do

for i in {0..99}; do
  if [ -d ${sdlist[$i]} ]; then
    echo $i ${sdlist[$i]}

echo -n "Please choose a directory: "
read sdint

sleep 1
echo "Warning: You are about to overwrite the content of "
echo ${sdlist[$sdint]}
echo "Continue (y/n)? "
read prompt

case $prompt in
y | Y)
echo "rsync --delete -axv /boot ${sdlist[$sdint]}/boot"
sleep 5
sudo rsync --delete -axv /boot ${sdlist[$sdint]}/boot
sleep 5
echo "rsync --delete -axv / ${sdlist[$sdint]}"
sleep 5
sudo rsync --delete -axv / ${sdlist[$sdint]}
sleep 5
echo "Done!"
sleep 2
echo "Terminating operation..."
sleep 2

echo "Restoring up directories from /media/SD/"
echo "Warning: This will copy the files from external USB "
echo "Flashdrive/SD Card to internal SD card. rsync is used to"
echo "mirror the files. Make sure you choose the right directory."
echo "The directories are:"
for i in {0..99}; do sdlist[i]=0; done

for i in `ls /media`; do

for i in {0..99}; do
  if [ -d ${sdlist[$i]} ]; then
    echo $i ${sdlist[$i]}

echo -n "Please choose a directory: "
read sdint

sleep 1
echo "Warning: You are about to copy the content of "
echo ${sdlist[$sdint]}
echo "Continue (y/n)? "
read prompt

case $prompt in
y | Y)
echo "rsync --delete -axv ${sdlist[$sdint]}/boot /boot"
sleep 5
sudo rsync --delete -axv ${sdlist[$sdint]}/boot /boot
sleep 5
echo "rsync --delete -axv ${sdlist[$sdint]} /"
sleep 5
sudo rsync --delete -axv ${sdlist[$sdint]} /
sleep 5
echo "Done!"
sleep 2
echo "Terminating operation..."
sleep 2


help | -h | --help)
echo "Help File"
echo "Noob Tools is a collection of bash shell scripts, wrapped in simple command line for ease of use. The user is encouraged to examine the corresponding man pages for further info."
echo "To install this as a command use:"
echo "  sudo ln -s /home/pi/ /usr/bin/noob"
echo "where /home/pi/ is the name of the script."
echo "This script is work in progress. Currently pre-pre-alpha."

echo "Installing noob on /usr/local/bin/noob"
sudo ln -s /home/pi/ /usr/local/bin/noob

echo "Removing noob from /usr/local/bin/noob"
sudo rm /usr/local/bin/noob

echo "The location of noob is"
which noob

#For printing A4 paper size in US letter size
lp -o scaling=96 $2

echo "Disk Dumping to SD Card"
if [[ $2 == '' ]]; then
echo "This will erase existing data on $path"
read -p "OK to delete SD card on $path? [y/n] " REPLY
  if [[ $REPLY == 'y' || $REPLY == 'Y' ]]; then
     echo "Copying /dev/mmcblk0 to $path"
     sleep 10
     sudo dd if=/dev/mmcblk0 of=$path & pid=$!
     sleep 10

     while [ `ls /proc | grep $pid` ]; do
       sudo kill -USR1 $pid
       sleep 15
     echo "Finished!"
     echo "Terminating process"

echo "Raspberry Pi Mini FAQ"
echo "dd clone operation may fail due to cards of differing size. If the "
echo "target card is smaller than the original, the operation will fail with"
echo "insufficient size error message."
echo "You may circumvent the problem by creating a second Raspbian system"
echo "and backup your current system onto that."
echo "To terminate Xserver. Logout, and do Ctrl-Alt-F1"
echo "Wallpaper seems to be changeable from home root directory"

cat `which noob`

credit | credits)
echo "Noob Tools ver. 0.1"
echo "Oct 4, 2013"
echo "by Harry M. Hardjono"
echo "Specifically written for use on Raspberry Pi"

echo "noob tools: a collection of easy to use commands suitable for beginners."
echo "Written by Harry M. Hardjono"
echo "Sep 30, 2013"
echo "Usage:"
echo "noob help             :Show help screen"
echo "noob faq              :Mini FAQ"
echo "noob install          :Install noob on system"
echo "noob uninstall        :Uninstall noob on system"
echo "noob where            :Shows installed path if any"
echo "noob update           :Update system (packagelist (network required))"
echo "noob halt             :Safely shutdown device"
echo "noob reboot           :Safely reboot device"
echo "noob wallpaper        :Random jpg as wallpaper"
echo "noob blank            :Enable screen blanking"
echo "noob noblank          :Disable screen blanking"
echo "noob pkglist          :List all available packages"
echo "noob pkgondev         :List all installed packages"
echo "noob print (filename) :Print slighly smaller print"
echo "noob clone (/dev/sd?) :Duplicate main SD to external SD"
echo "noob backup           :Mirror files from internal SD to /media"
echo "noob restore          :Mirror files from /media to internal SD"
echo "noob source           :Source code for noob"
echo "noob credit           :Credits for noob"

exit 0
#noob faq             frequently asked question
#adduser user group   auto create group
#userusbon user       mount user directory to USB
#userusboff user      mount user directory to SD
#userusbusb user      copy user directory from USB to SD
#userusbsd user       copy user directory from SD to USB
#tarback drive USB    dated tarball backup
#tarrestore drive USB dated tarball restore
#format USB size      format USB for ext4 (use dd tar xz of various size 4MB 8MB 16MB 32MB)

Friday, October 4, 2013

Petit Computer Journal #19

 Randomous Klondike Solitaire

Although normally I'd showcase my own games, this time I want to make an exception. There is a computer game that is extremely well done: Klondike Solitaire by Randomous.

Here's the link in Petit Computer Wikia:

I would like to mention the fact that this game is special in that it comes with special package where all the components are downloadable separately. That means you can play around with the program and even come up with your own special program. Look for "Klondike Depackaged"

I like the fact that I can change the playing card to my liking. You can use CHRED to do it. Even though you have to be careful since the card shape is hard-coded and you don't want to introduce any holes to the card, it still represents the power of open software.

For that reason, I'm showcasing the program here. I think this extremely simple, yet well-done program is worthy for your consideration.

It also represents an example on how to do SPRITE on the touch screen.

Thursday, October 3, 2013

Book Review #4

Raspberry Pi for Beginner bookazine

This magazine-as-a-book is part of LinuxUser&Developer bookazine series. Just like a magazine, it is filled with large glossy color, and features easy to read passages. The problem with the format is that there are lots of different articles exploring different ideas, but limited in length. So, it's much of an exploration of ideas, as opposed to books that dwell in implementation details. The closest thing I can think of is O'Reilly Getting Started series, except it's light on resources, and plenty of photos. With that in mind, I still enjoyed the bookazine tremendously.

It starts with the basics, what is Pi, what do you do with it, and so one. It seems like every book about Pi deals with it. Considering the volume, though, it's clear that this bookazine is intended for extreme novice. For that, I think this is a good first Raspberry Pi book. My interest lies in the middle section: Projects. It's here that I find articles about remote control car, solar powered pi, webcam server, and so on. Unfortunately, these are light on details. Which means two things:

  1. The issues explored are necessarily brief, focusing only on core features and functions.
  2. The problem solving, in case something goes wrong, is non-existent.

To be fair, point#2 is also light in other works, including technical books. But with longer text, I can usually research such troubles on the Internet. I'm having trouble picking up keywords to research the problem further. In the end, if the project is successfully modified, it is because I spent hours, if not days, researching the subject matter. I don't think that's a good book implementation. But it's certainly acceptable for magazine implementation.

In other words, is this bookazine format successful? If you think of it as fountain of knowledge, then no. If you look at it as fountain of ideas, then it succeeds admirably. So, if you're a new Raspberry Pi user or someone who's interested in knowing what Raspberry Pi is all about, then this bookazine is a good first Raspberry Pi book to start.

Tuesday, October 1, 2013

Raspberry Pi Journal #30


Rob Bishop of Raspberry Pi foundation just announced recently asking for Beta Testers for the newly crafted NOOBS 1.3

I can see that a lot of work has been done to make it extremely user-friendly and accessible. A very interesting take about it, is the fact that you can easily have multiple OS flavor in one SD card. Therefore, you can have one all-encompassing SD card that is suitable for general, scratch, headless, servers, and so on. This is very big news! An educator can now use just one SD card for teaching different discipline. Very convenient, and thank you for providing this functionality.

I'm ambivalent about it, though. I guess I'm more of the old school tar-ball method. My idea of doing minimal headless server method would be to just install a standard distro, then ruthlessly purge the unnecessary packages. Of course, it'll be done automatically with a script.

Speaking of which, there is still no switch to use external USB hard drive. Considering that SD card do have the very real issue of wear, I think attaching a USB hard drive would be recommended so as to prolong the life of the system. I will see if I can do something about it.

Maybe some script that says: reboot with USB harddrive, and reboot with internal SD card. One button backup/restore would be handy, too. I probably will use rsync on that one.

I currently have a script that I run at the end of the day. I call it "" that back ups my SD card to USB flashdrive, and updates my ToDo List. It's all very messy, so I will have to clean it up further.