Friday, June 14, 2013

A poor lad's guide to install raspberry pi with no keyboard and no monitor

Gone are the days where I have the luxury of time, space and also the infrastructure. Long before I set foot in London, I was surrounded by 2x 23" HIPS LCD screens, 2 laptops, a few Us' of servers, and a few desktop tower of CPUs', all in my office, and not forgetting the departmental level techno arsenal that comes with each and every possible combination of connectors, cables, peripheral cards, and also the techno foundry lined with power tools, component racks, etc. Playing with my raspberry pi then is not much of an issue. I have the monitors, keyboards, mouses, wifi, cables, a cushy job that pays, comfy office, swimming pool, gym, MacDonald's, KFC, Starbucks, etc, you named it.

For now, I am only as good as draped in loin cloth. The only possession I have is my laptop, and a mouse, and my newly acquired raspberry pi. I left my pi back then, knowing that I might not have the lux to enjoy the fun with it. So, it is going to be a paradigm shift for me on how to start to play with my new raspberry pi model b without a monitor and also without a keyboard (note:it is phrased such a way to be picked up by the search engine). Knowing that the raspberry pi comes with a SSH daemon started when it boots, this I can use to connect via PUTTY to do some configs from my laptop.

The objective is to configure my raspberry pi without a monitor, without a keyboard, such that my pi will auto login to the GUI, because I do not have a keyboard to type in user name password, and also to type startx on the console for the GUI; connect to available WiFi (again, keyboard is needed to enter wifi credentials), ready with a virtual keyboard (can't afford keyboard, ARGGHHH) at every opportunity I could get my paws on a monitor. I got the HDMI cables for a mere £1.99.

*using nano, Press Ctrl-X to exit, and then follow the on screen instruction to save the file*
Part1 getting ready to configure raspberry pi
1. Prep a straight cat5 cable to connect the laptop and also the pi
2. Configure laptop's ethernet to 192.168.0.1/24
3. plug in the SD card loaded with raspbian-wheezy to the laptop's SD card.
4. locate cmdline.txt in the root directory of the SD card. Make a backup copy of it.
5. append to cmdline.txt with "ip=192.168.0.2" without the quotes at the end of the line. save.

6. plug the SD card into pi and turn on. Fire up PUTTY to SSH into 192.168.0.2
You shall be greeted with this screen










Part2 Configure auto login, auto start GUI, auto connect WiFi (to any SSIDs' that are available to me )
First thing first, the order of configuring this 3 components can be done in any order. I prefer to start to configure for WiFi First. This section requires you to connect to pi via SSH.
1. the command to get to the wifi config file: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
2. append the network related parameters corresponding to the wireless network with the block of code "network {....}". as per the screen shot, my SSID is "Edge", I painted red over my password. Use your own parameters. Replicate the network block to as many SSID you want to include.













3. type in the command sudo nano /etc/network/interfaces follow by the code as per the screenshot.
















4. Reboot the pi with sudo shutdown -r now
LO and BEHOLD, you will be greeted with this screen. (*fingers crossed*)
















5. Just to ensure the pi is connected to the internet (I have my WiFi network configured prior to configuring the pi), perform a ping as per the screenshot below to verify the connectivity.









6. Here, I am configuring for the autologin using the command sudo nano /etc/inittab , follow by the additional code highlighted in the red box as per the screenshot below

















7. Here, I am configuring for the auto start the GUI using the command sudo nano /etc/rc.local , follow by the additional code highlighted in the red box as per the screenshot below















Part3. Internet goodness
1. The very first thing to do with rasberry pi connected to the Internet, is to update the raspbian with this command sudo apt-get update
2. The next thing is to install the virtual keyboard with this command sudo apt-get install matchbox
3. if you have any other software to install, this is the time to do it.

part4. Enjoy
Now i am going commando with my newly configured raspberry pi. you can do the same too!
*note: the 42" LED Toshiba TV, PS3 and controllers, iron, and 5.1 surround speakers are not mine to begin with* I am just another poor and jobless lad, struggling to make ends meet as a starving student.














Can you spot the virtual keyboard used to login to the wifi wall garden (UK only)?

Monday, June 3, 2013

google chrome extension message passing, change manifest version 2 from version 1

I am exploring on how to make a google chrome extension (GCX) to experiment with an idea, and learnt a great deal from various internet resources.

For starters, I have used this dev page https://developer.chrome.com/extensions/getstarted.html and it only took me 10mins to get a hang of what is google chrome extension is all about. The whole notion of GCX that deviates from the usual C++/java methodology on compiling, linking, debugging etc is really a new experience.

Each extension has the following files: (to place in a folder on the local drive during dev)
1. A manifest file (similar to the function of *.h files needed for a code that calls library to function properly)
2. One or more HTML files (the "page" the extension used to process data unless the extension is a theme)
Optional: One or more JavaScript files (to handle interaction between the user, web page and also the browser in the form of message passing)
Optional: Any other files your extension needs—for example, image files

To get the bulk of the workings of GCX, I learn from the dev overview to have a system's level point of view https://developer.chrome.com/extensions/overview.html

Now, come the complicated part. My idea is for a user to interact with the page, without interacting with the page at all. sounds vague? Basically, the purpose is to automate a user's interaction with a page through the browser to a backend processing server. after spending a few hours of reading, I came to realise that I might need to do message passing and also content script.

I skim through many tutorials but the one listed below is very detailled and comprehensive. Thus, become my tutorial of choice to learn content script, background page and also message passing
http://vikku.info/programming/chrome-extension/get-selected-text-send-to-web-server-in-chrome-extension-communicate-between-content-script-and-background-page.htm
For this tutorial to work properly, i have installed XAMPP with some dummy php code to handle the $POST data

Somewhat, the code from the tutorial above does not worked as per expected. I followed the tutorial word for word and yielded not functioning result. In my observations, the CGX does show up with errors on chrome->tools->extensions, and "inspect popup" was grey out. To make the matter worst, the right click context menu supposed to show "send to server" but not displayed. There is no ways of troubleshooting or getting around with it. After a few days of reading from various sources, CGX dev pages included, I finally came across the reason why it does not work and made few fixes for it to work properly.

The main reason for it not to work is the change in version 2 manifest from version 1 for chrome browser version >=18 as detailed in this page http://developer.chrome.com/extensions/manifestVersion.html#manifest-v1-changes
There are dev page that describe the process of changing to manifest ver 2 http://developer.chrome.com/extensions/tut_migration_to_manifest_v2.html

Changing the manifest to v2 alone will not solve the problem. The reason was because inline scripts were made a violation with this error thrown Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:". To fix this, the script from background.html is moved to a *.js file.

manifest.json


background.html


bg.js


myscript.js and popup.html remain the same as the tutorial

i hope this update will eliminate the wild goose hunt that I have experienced from the above tutorial. Excellent tutorial nonetheless.

Tuesday, January 29, 2013

A walk through on using tweets with Java

Work in progress..... watch this space






Sunday, January 13, 2013

Fussy Fried Chicken with Complicated Chips

I finished my class at 9pm and took the tube from King's Cross. By the time i reach my pad, It was late into the night about 10pm. I only had a miserable and cold dinner that consist of a danish cinnamon roll and a coffee at 6pm. Hunger pang was calling and I am resisting the temptation to go to KFC. KFC close at 11pm here..... I am supposed to do some work, but unconscious surfing on the Internet brought me to this video.

I went to the bed hungry, and dream of fried chicken........... The next few days, I am on auto pilot mode to get ready to fry chicken... lol.

The recipe was loosely referred to the video posted. I only have thyme, oregano and sage in the cupboard. Just have make do with it. The recipe calls for buttermilk, which I can't find any at the local store. Probably it is not popular across the trans-atlantic sea. I used the substitute that consist of 1cup milk + 1 table spoon of vinegar. 

Then, I deboned 3 pieces of chicken thighs, but gave up on the 4th. The feeling of cutting meat with a dull knife really make my hair stand and sending chills down the spine.

Fried chicken to me is not difficult, done that many times prior to my setup, but to fry it moist in the inside and crispy on the outside it requires perfect execution and discipline. If not, the end results are not consistent. 

The chicken pieces are marinade overnight, sous vide with my setup at 64.5 degC for 3 hours. Chilled with cold water and waiting to be fried.

Mix 5 table spoon of flour with 1/2 teas spoon of each spices available on hand, and 1/2 teas spoon of salt. I added another 1/2 teaspoon of chilli power for the extra "shiok" -ness.  


Mix the flour and spices until even. DO NOT ADD WATER.
The sous vide -ed chicken pieces are ready to be dredged with the spiced-flour.
After the heavy powdering, set aside. It is still not pretty yet... but behold........

Heat up oil. The oil must remain consistent at 175degC to fry the chicken. Anticipating some temperature drop with my heavily powdered en sous vide chicken pieces with the frying, the oil is heated to 188.3 degC.
Drop in the chicken pieces and make sure the oil covers them thoroughly. Fry for about 5 minutes or till the preferred golden brown. Since the chicken cooked en sous vide, it is not recommended to cook the chicken in the hot oil for too long. If the internal temperature is continuously climbing above 65degC, the chicken will be dry and "stringy" linearly to the temperature. How to describe stringy? It is the fibers of chicken that will stuck in between the teeth when eating. sous vide chicken are so tender, there is no effort needed to chew. Flash frying the sous vide chicken pieces is to give it a nice aroma and also stunning colour that no human being can resist. 

I have to admit it, I stole some of the chicken before it is ready to be serve.... hehehe

Fried chicken is never complete without fried chicken drumsticks... Eat with your hands! Sink your teeth into the oh-so-tender drumstick! Hear the crunchy sound! Smell the aroma of the spices! Taste the texture. I can't go on further nor take a video of me eating it. It will be so inhumane to tempt others.

Extra flour laying somewhere? no worries, mix with binding agent of choice (water/milk/beer) and FRY!!! Extra serving of crackling.

I still have some 2/3 completed complicated chips from last week, well hidden inside the freezer. Time to dig it out! no need to thaw, just fry directly in oil at 190degC.

The vegetables are there just to give a contrast in colour. 





Saturday, January 12, 2013

[FYP] Engineering Show 2013

This year, I can't participate physically at Engineering Show. However, my projects and padawans were there!! RAWWRRR...... To me, doing projects are akin to labour of love. I can't really describe in words the emotion, nor the experience.... I can only tell you something. Adrenaline is pumping when we had to fix a problem on the spot under pressure with lots of eyes peering. Dopamine is the only reward we had, if the problem got fixed. Most importantly is the managing of anxiety, stress and setbacks. What doesn't kill you, only makes you stronger.


Our Entry to Ruggedized Computer Competition for military use
http://www.dsta.gov.sg/index.php?option=com_content&task=view&id=8925&Itemid=1627




IoT inspired automatic furniture.
use our app on iphone to move furniture over the Internet.