A blogspot journal showcasing computer programming, personal development, and other hobbies. Featuring Raspberry Pi, Petit Computer, and miscellaneous How-To.
Wednesday, January 8, 2014
Musing Journal #2
Schedule
It is amazing how a little planning can go a long way. I have been doing it ad-hoc, doing improvisation along the way. It works, but I noticed a lot of repetitions going on. So, the question is, if I can schedule my activities, will that help speed things up?
The answer is yes. What surprised me the most is the amount of time saved in doing so. My productivity quadruples! That's amazing. Therefore, for this year, I resolve to plan and follow through all my activities for the year.
So far, the result has been uneven. Some activities are easily done. Others, not so quick. The most important thing, however, is that the activities are done one after the other. There is no longer periods of indecision. That helps a lot.
I'm redoing all the directory pages and they will be in this format:
#N Title
Description
URL
Date
Sometimes, description is unnecessary. In those cases, I will omit the description. Also, there will be no more "ETA" notifications. I find that putting the date directly is sufficient. Obviously, if the date lies in the future, that means ETA.
I'm reserving News Directory for completed projects. It makes a handy reference if you just want to get to completed projects, instead of having to wade through my various journals.
Tuesday, January 7, 2014
Raspberry Pi Journal #44
Raspi #44
Prevent screen from blanking
If you want to show picture slide shows for hours on end, you probably run into a "feature" that is quite annoying: screensavers. The gist is that the program will interrupt your display to save your screen. It is a prudent action in order to stop your monitor from burning static images. The issue isn't as common as before, but even with the latest LCD display, it is still present. Therefore, having an automatic screen saver feature is desirable.
The problem is when we want the screen to burn all the time, such as displaying photo slide show. How do we disable the screen saver? I'm sorry to say that the system is very complex and that there is no single way to disable the screen saver.
I suppose you can kill the process, but that's not a desirable solution in the long run.
The trick here, is to let the computer know that you want the screen is up all the time. So, press a key in the keyboard or jiggle that mouse. A robot that shakes the mouse all the time seems ideal. Alternatively, put the mouse in a shake box.
However, we can do better than that. Even if the solution is hackish, we should do it all in software. There is such a thing, and it is:
pygame.event.get()
That's a python script. So far, that pygame is for Python 2.7. So we'll use that. Write a python program that will poll the keyboard/mouse event. Let's call it: unblank.py
- import pygame
- pygame.init()
- pygame.event.get()
And when you run this program:
python unblank.py
The screen saver process should terminate and the timer will restart. All you have to do is call it periodically and problem solved!
I'll just stick that line in my wallpaper rotation script
- #!/bin/bash
- for ((walltick=100;$walltick;walltick=$walltick-1))
- do
- PIC=$(ls wallpaper/*.jpg | shuf -n1)
- pcmanfm -w $PIC
- *python unblank.py*
- sleep 100
- done
- pcmanfm -w saber.png
- sleep 5
- exit 0
The whole process takes a couple second because python is not an insignificant process. So this answer is hackish and not very good.
And what do you know? It doesn't work! I would think that pygame.event.get() will reset the input, but apparently not. So, back to square one. The problem is, there are so many things that can be wrong, and you never know which one. That's very frustrating.
So, let's open up a window and see if that works. Here's the modified python script
- import pygame
- from time import sleep
- pygame.init()
- window=pygame.display.set_mode((32,24))
- while True:
- pygame.event.get()
- window.fill(pygame.Color(255,255,255))
- pygame.display.update()
- sleep(100.0)
Notice that this is an infinite loop, which is something I try to avoid. The problem is that it opens up a window, so I can do something to it, and that's not good. So, now, I'm running the script in the background, minimizing the window.
Minimizing the window needs to be done manually, which is a terrible solution. Worse, when I kill the process, the window still stays up! There's no way to terminate the window that I can see. Therefore, this command is useless:
- python unblank.py & pid=$!
- kill $pid
Because python script is killed yet the window is still up, there's no longer any way to close the window. It's definitely broken. So, now, I pull another shell just to run the program, keeping it in the background. That's another window open.
Of course, the right solution is to provide a refresh command, that we can use to reset the screensaver timer. How is it that we do not have such command?
Monday, January 6, 2014
Cooking Journal #20
Potato Chips
I know I did potato chips cooking last time. However, For this one, I use a special slicer board. Grab yourself a bag of Russel potatoes from your local supermarket and do it.
I fry them using medium heat, as usual. The whole process took 45 minutes. The way I do it is to just hold the slicer on top of the pan and just slice the potato right into the pan. I can usually fit 20 slices at a time. Then wait until they're done.
I like it when they're stops being yellow and starts to become golden, but not so much. I experimented with the thinnest slice and the second thinnest (1/32) and prefer the second thinnest. You may have a different preference.
The subsequent slices would cook faster due to the oil warms up as it goes. And that's the trouble. Whenever I do this, it's upwards one hour for the whole thing to finish. I usually just eat the first batch while the second batch is cooking, and so on.
I have to say that the end result is terrific! I thought that I'd need to use salt or something to make it taste good. I had Sriracha sauce prepared, but it turns out, I don't need it. That's right. I just eat it without salt or anything. They're that good!
So, if you're wondering whether or not you should invest in potato chip microwave thing, I'd say, no. This is good enough. I will admit that doing this takes a very long time, as it is not a hands-off operation. I need to watch the whole cooking process from start to finish.
Saturday, January 4, 2014
Nintendo Journal #20
Nintendo #20 Water Filter
Water filter. I bought this one with the idea of having one to take around the town. I don't really like it. It seems to work as advertised, but the bite piece is too solid for me. Hard to use, hard to clean. The cartridge filter is easy enough to replace, but properly cleaning the whole thing is a hassle. It basically just sits in the cupboard doing nothing.
Friday, January 3, 2014
Petit Computer Journal #32
Lottery Number Generator
A while ago, I wrote a simple Lottery Number Generator. It may interests you that it has these words in it: "...THEN A MIRACLE OCCURS" Of course, that was done as a joke, but in reality, choosing a bunch of random number isn't rocket science. Especially so, if the programming language provides a built-in random number generator, such as Petit Computer.
All of these talk about the biggest million jackpot ever got me fired up again, and well, I think it's time to update that program. This time, though, I want it to be an actual program that I can use. Speaking of which, there is more than one lottery, so I decided to write a customizable lottery number generator.
- CLS:CLEAR
- PNLTYPE "OFF"
- DIM MN[10]
- DIM MB[10]
- @INIT
- NT=15:'NUMBER OF TICKETS
- NS=2:'NUMBER OF SLOTS
- CS=0:'CURRENT SLOT
- MN[0]=75:'MAXNUM 1-75
- MB[0]=5:'NUMBER OF BALLS
- MN[1]=15
- MB[1]=1
- SE=0:'SELECTOR
- SSL=0:'SAVE SLOT
- DIR=0:'GOSUB @MSL
It's clear that I'm planning to have more than one slot. The old version only has one slot, and this one have more than one. I put in initial value for the most common configuration. Also notice that you can have more than one slot for saving. I do it via MEM$ for saving/loading.
- @LOOP
- VSYNC 1:B=BUTTON(1):TS=TCHST:TT=TCHTIME
- IF TS THEN GOTO @ROLL
- IF B AND 1 THEN SE=SE-1
- IF B AND 2 THEN SE=SE+1
- IF B AND 4 THEN DIR=-1:ON SE GOSUB @MNT,@MNS,@MCS,@MMN,@MMB,@MSL
- IF B AND 8 THEN DIR=1:ON SE GOSUB @MNT,@MNS,@MCS,@MMN,@MMB,@MSL
- IF B AND 64 THEN GOSUB @SAVER
- IF B AND 128 THEN GOSUB @LOADER
That's all for the user interface. There are 6 different actions you can take, and U/D refers to the different action. L/R refers to the value being changed. In truth, there's a simpler 2 dimensional way that you can do this, but I decided to stick with this generic form for now.
- COLOR 15
- PNLSTR 0,0,"LOTTERY GENERATOR"
- PNLSTR 0,1,"(C) 2013 HARRY M. HARDJONO"
- PNLSTR 0,3," NUMBER OF TICKETS: "+STR$(NT)+" "
- PNLSTR 0,4," NUMBER OF SLOTS: "+STR$(NS)+" "
- PNLSTR 0,5," CURRENT SLOT: "+STR$(CS)+" "
- PNLSTR 0,6," MAXNUM 1-"+STR$(MN[CS])+" "
- PNLSTR 0,7," MAXBALL 1-"+STR$(MB[CS])+" "
- PNLSTR 0,8," SAVE NAME:"+MM$+" "
- PNLSTR 0,20," TOUCH SCREEN TO ROLL"
- PNLSTR 0,21,"(X) TO SAVE (Y) TO LOAD"
- PNLSTR 0,23,MID$(MEM$,0,32)
- SE=(SE+6)%6
- PNLSTR 0,SE+3,">"
- GOTO @LOOP
And that's about it for the User Interface. There's really nothing new here. It's just displaying some variables, and that's about it.
- @MNT
- NT=(NT+DIR+21)%21
- RETURN
- @MNS
- NS=(NS+DIR+10)%10
- RETURN
- @MCS
- CS=(CS+DIR+NS)%NS
- RETURN
- @MMN
- MN[CS]=(MN[CS]+DIR+100)%100
- RETURN
- @MMB
- MB[CS]=(MB[CS]+DIR+10)%10
- RETURN
- @MSL
- SSL=(SSL+DIR+10)%10
- MM$="L"+STR$(SSL)+"TTOCFG"
- RETURN
As you can see, the structure is all the same. Therefore, I can very well use a 2 dimensional array to do the whole thing. Doing it this way is actually more complicated, although it does have the benefit of mindless coding. Ha! Mindless coding. Isn't that an oxymoron? Haha, joking aside, it's true that simply adhering to plan is on the low end of the difficulty scale.
- @ROLL
- CLS
- FOR I=0 TO NT-1
- COLOR 15
- ?RIGHT$(" "+STR$(I),2);
- FOR J=0 TO NS-1
- CNL$=""
- IF MB[J]<1 THEN MB[J]=1
- FOR K=0 TO MB[J]-1
- IF MN[J]<1 THEN MN[J]=1
- @THROW
- NUM$=" "+RIGHT$("00"+STR$(RND(MN[J])+1),2)
- IF INSTR(CNL$,NUM$)>=0 THEN GOTO @THROW
- CNL$=CNL$+NUM$
- NEXT K
- COLOR 12+FLOOR((I%10)/5)
- COLOR 4+FLOOR((I%10)/5)
- ? CNL$+" -";
- NEXT J
- ?" "
- NEXT I
- GOTO @LOOP
Then a miracle occurs...
In fact, it's just a simple string search. Everytime I roll a number, the number is checked via INSTR whether or not the it exists in the string. If so, roll another number, else add the number to the string. Pretty simple, yet devious at the same time. Normally, you use an array, associative array, or hash, depending on the language you're using.
- @SAVER
- MEM$=RIGHT$("00"+STR$(NT),2
- MEM$=MRM$+RIGHT$(STR$(NS),1)
- FOR J=0 TO 8:'MAX NS
- MEM$=MEM$+RIGHT$("00"+STR$(MN[J]),2)
- MEM$=MRM$+RIGHT$(STR$(MB[J]),1)
- NEXT J
- SAVE "MEM:"+MM$
- RETURN
- @LOADER
- LOAD "MEM:"+MM$
- NT=VAL(MID$(MEM$,0,2))
- NS=VAL(MID$(MEM$,2,1))
- FOR J=0 TO 8:'MAX NS
- MN[J]=VAL(MID$(MEM$,J*3+3,2))
- MB[J]=VAL(MID$(MEM$,J*3+3+2,1))
- NEXT J
- RETURN
Saving and loading are really just building the string and decoding it. You can see the string on the last line. I made several mistakes here, mainly because I didn't write anything down, and just winging it. I build a long string array because I'm multiplying it by the number of tickets, which is silly because one ticket is the same as the other. Another one is that I multiplied J by 8. Oops. How did that happen?
I was on my bed trying to sleep, so I guess that kind of mistakes can't be helped. Now that I think of it, such mistakes are laughable silly. I guess I shouldn't be programming when I'm trying to sleep. Nah. Who cares? Some people read books on their bed. I'm doing computer programming. That's that.
Thursday, January 2, 2014
Book Review #17
Book #17 Nasty People
Jay Carter
To call this little booklet a "seminal work in literature" maybe overselling it, but not by much.
I wonder what possesed me to pick up this little hardcover book dealing with one, just one, personality. And yet, as I read this book, I felt compelled to take it home with me, and I did. The fact that I can pick up this old book for $2.99 must have figured in the process. I read it, I took it home, and promptly forgot about it.
That is, until a few days later, when somebody who actually fit the description perfectly started berating me for parking at the same parking spot I've been parking for years. It's amazing as how perfect the description is. I use the techniques outlined in the book, and defused the person. The next day, I called the owner of the parking lot, explained the situation, and showed him the book. After the owner talked to the person, I showed him the pages where the characteristic matches. He was impressed. "You mean you pick this book just a few days ago?" Yup. Talk about lucky break!
So, I managed to solve the situation very well. I have since run across another person like that. In life, there are many such persons. Some are merely temporary. Others are more permanent. This book will not help such nasty person, called "invalidator", to lead a better life. But it will save you from grief whenever you meet with them. Highly recommended.
Labels:
17,
book,
conflict,
invalidator,
invalidators,
nasty,
people,
resolution,
review
Wednesday, January 1, 2014
Musing Journal #1
Happy New Year 2014
Today is the first day of the rest of my life. Sometimes, life needs a reset button. There's quite a lot of happening in 2013, and unfortunately, it's more bad than good. Well, the thing is, bad things will happen in life. The real question is, what are you going to do about it?
The first order of the day is to organize everything. I have been learning time management, project organization, and house organization. I now realize that the system I had for 2013 was woefully inadequate. Little wonder when I was so busy last year!
Fortunately, I have had sometime to reflect. November Nanowrimo showed me how totally unprepared I really was. So, for my resolution, I vow to organize my life so that everything I do will be like clock work and effortless.
Hopefully, in time, it will be better.
I also resolve to start my Personal Productivity Hour (PPH). This is basically a way to keep moving forward, one step at a time. The idea is to write down in a journal, one new thing to do, every day, in one hour. This is separate from work. This is for personal development.
You can have just about any project you want in there. The only requirement is that you need to have a different item in it every day. If you need more than one hour to complete the project, you can do "part 1", "part 2", "part 3" etc, outlining what you did different for each project.
You can also have "Learning" as a way to develop yourself further. And that's about it. Learning and Applying what you learned, is what PPH is all about.
Today is the first day of the rest of my life. Sometimes, life needs a reset button. There's quite a lot of happening in 2013, and unfortunately, it's more bad than good. Well, the thing is, bad things will happen in life. The real question is, what are you going to do about it?
The first order of the day is to organize everything. I have been learning time management, project organization, and house organization. I now realize that the system I had for 2013 was woefully inadequate. Little wonder when I was so busy last year!
Fortunately, I have had sometime to reflect. November Nanowrimo showed me how totally unprepared I really was. So, for my resolution, I vow to organize my life so that everything I do will be like clock work and effortless.
Hopefully, in time, it will be better.
I also resolve to start my Personal Productivity Hour (PPH). This is basically a way to keep moving forward, one step at a time. The idea is to write down in a journal, one new thing to do, every day, in one hour. This is separate from work. This is for personal development.
You can have just about any project you want in there. The only requirement is that you need to have a different item in it every day. If you need more than one hour to complete the project, you can do "part 1", "part 2", "part 3" etc, outlining what you did different for each project.
You can also have "Learning" as a way to develop yourself further. And that's about it. Learning and Applying what you learned, is what PPH is all about.
Labels:
1,
2014,
hour,
Journal,
management,
musing,
new,
organization,
personal,
productivy,
year
Subscribe to:
Posts (Atom)