Archive for Development

Getting Twitter output to work with node-red

Recently I was redo-ing some older code with feed RSS to Twitter, decided to go for node-red since it is simple and I have a node-red setup in the Google Cloud Compute Engine.

I couldn’t get the Twitter output to work, the AUTH part in the UI always complaining error 401, the node-red-node-twitter module tries to do a callback AUTH and it fails.

Digging more seems Twitter has discontinue the on the site callback oAUTH method recently.

Notice the module that was installed with the node-red was very very old (0.1.1) and there seems to be some recently update (because of the change), so I update that module to the latest version and it solve my issue.

By going into /usr/local/lib/node_modules/node-red, editing the config.json and change the dependency from 0.1.* to 1.*, sudo npm update node-red-node-twitter updated the module as expected.

You will also need the consumer key and access token key pair for the AUTH UI in node-red, you can generate them in https://dev.twitter.com/apps/

After installing node-red-node-twitter@1.0.1, I am given input field to put in my consumer key, secret and access token, secret and I am able to use the Twitter output.

REF
GitHub – node-red – problem authenticating with twitter
NPM – node-red-node-twitter

Casting media from terminal to Chromecast.

I would like to setup a cronjob to play RTHK hourly news to my Google Home in the morning, there are many many ways of doing this but here is a simple one.

I already had cronjob running to fetch current RTHK hourly news to a local archive as mp3 file from http://news.rthk.hk/rthk/ch/news-bulletins.htm

By using node-castv2-client, task done in no time.

Installation
$ sudo npm install -g castv2-client

The sample code uses mdns to discover all Chromecast device, I am having issue install mdns for unknown reason, but well I already know my IP address of the Google Home anyway, so I comment the discovery part out, hard coded my Google Home IP address, change the URLs or media, title and cover image, then fire up the js file and it is done.

Links
node-castv2-client
GitHub – A Chromecast client based on the new (CASTV2) protocol

Excel popup issue on opening csv file with extension xls

I am currently working on some files with csv data in a xls file, and Excel popup an alert everytime it tries to open it.

“The file you are trying to open, ‘[filename]’, is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?”

Clicking Yes simply open the file, and No to quit.

This annoying popup is “stealing” focus of windows and gives me problem on my scripts.

A bit of searching comes with a Registy edit to suppress this popup.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Security]
“ExtensionHardening”=dword:00000000

This works with Office 2010 and it solved my problem, kind of…

Link
MSDN Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site: http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx

Google Chrome Web Store – Developer Dashboard upload error.

chrome webstore upload err

I was trying to upload a Chrome Extension for my work, and I encounter this problem the whole morning, trying to get help but cannot find much, from the error of upload? url I was thinking it was related to server error…

A few refresh even lead me to error pages like:
chrome webstore down
and
chrome webstore err

Took me a very long time to look for solution, it turns out the problem was in the zipped archive there was a hidden Thumb.db inside and this is the reason why the upload was not successfully.

A bit of a nagging to Google, please AT LEAST provide some kind of error message instead of a loading forever screen, and some (failed) error in developer console.

Getting temperature from Raspberry Pi

I am currently developing some code for sensors to use with my Raspberry Pi, it came to my interest to get some temperature data from the Pi, a quick search give me a very good result.

Actually there are temperature sensors on the Pi

run
/opt/vc/bin/vcgencmd measure_temp
>temp=42.2’C

Added to cronjob
/opt/vc/bin/vcgencmd measure_temp >> ~/rpi_temp.log

This will append data to the log file.

Links
Overclocking – Raspberry Pi User Forum

Cross domain AJAX call in JQuery

Currently I am working with a company about a site, due to policy, I do not have FTP access, but I will have to get a JSON from my own server (for testing).

Cross-domain AJAX call is not allowed by most modern browser due to security issue (same-origin policy), it does trouble me a bit since my habit of dirty coding all the time, and especially in case of this situation….

A bit of Googling ALWAYS comes in handy:
StackOverFlow – JQuery ajax cross domain

By using JSONP I am able to do cross-domain AJAX get now, good and great to make a post of it!

References
Wikipedia – JSONP

Blocking input when executing AutoHotkey scripts.

When we are doing some UI automation with AutoHotkeys script, we really would not like other user to be able to move / input which may result in errors.

By using:

BlockInput, on
Sleep, 2000
BlockInput, off

We would be able to block user input while Autohotkey still be able to work with the system (MouseMove, x, y etc)

I thought it works well till B tell me that it was not working on his box, I retested it and no it was not working on the new installed x64 win7 too (I am sure it was working before, on a x32 win7…)

It turns out it was related to UAC in Win7, scripts has to be run with Admin rights to get BlockInput working (it was not documented on the API ref.).

A bit of Google gave me some solutions:

Howtogeek – Add “Run as Administrator” for AutoHotkey Scripts in Windows 7 or Vista

Make the scripts into exe (compile scripts), setup registry to force autohotkey to run as Admin fixes the problem.

Links
Blockinput not working under windows vista

MPEG2 hardware decode license for Raspberry Pi.

It is just great for developers / manufacturers to listen to how the user thinks and use their products.

A Few word from the officials

If you’ve been following this website since we launched it last summer, you’ll probably be aware that we had to make some hard decisions about exactly what we could include on the Raspberry Pi if we were to meet our extremely low target price. One of the things that we had to regretfully dismiss as an option was an MPEG-2 decode licence for every unit. Providing that licence would have raised the price of every Raspberry Pi by roughly 10%, and we simply weren’t able to justify that when we held it up against the educational goals of the Foundation. Our initial expectation was that most of you would buy the Raspberry Pi for educational purposes, and that you wouldn’t mind that MPEG-2 wasn’t available. Our bad.

At GBP2.4 (only USD3.8, or HKD30), now our beloved RaspberryPi can enjoy full hardware decode with MPEG2 support, which is very important for my usage in DVB TV solutions!

New video features! MPEG-2 and VC-1 decode, H.264 encode, CEC support – http://www.raspberrypi.org/archives/1839

Place your order now to show support! I ordered mine~~~

MPEG-2 license key http://www.raspberrypi.com/mpeg-2-license-key/

1525: Order placed, confirmation received.
1712: License Key received.

That is quick!

P.S:
Seems I will need to upgrade firmware of GPU / recompile my custom kernel for the new MPEG2 decode to work (at least August 8th or newer releases based on post #1883) and I am a bit busy to do so, I shall leave it for the mean time till I am a bit more free to do so…
Links:
Raspberry Pi Discussion Forum – You wanted MPEG-2? You’ve got it!

ARMania – my ARM based devices.

Recently I have obtained different ARM based hardware for different usage / reasons, it always interested at these boards for different usages, and recently thanks to mates and friends, I have the chance and time to finally put some effort to it to do what I want.

Here are a few idea I would like to make use of these board.

  1.  A DVB-TH streaming server.
      I do own a slingbox, but the idea of a native app + extra cost on every client + the price of the slingbox isn’t something that interested me, what I would like to do is a HTML5 based DVB-TH streaming service, which I can stream DVB content to my devices in browser with HTML5.
  2. A home server monitor system.
      I recently am into Arduino, I would like to build a Web base sensors, video, sound system with it, which I can log example temperature, noise level, and some basic home automation with it.
  3. A old console emulator.
      I have been wanted to do this for long, who doesn’t love to play Mario Brothers now??

I have a different sets of devices on hand to do all of the above, but which goes which and which does the best?

Android device MK802



1200MHz CPU 1000MB RAM

This is an Android device which also support Ubuntu Linux 12.04 from the TF Card slot, honest currently it is very limited early build, I did try to run a few console emulator on Android port, too bad the speed wasn’t really up to my standard (<30fps), and there isn’t a big difference (A bit better) for emulators on Linux port, maybe due to lack of OpenGL and poor GFX drivers, I do have higher hope on this device since its higher CPU clock speed and more memory, I suggest it should get better when a better build of Android / Linux is being developed.

http://www.engadget.com/2012/06/09/linux-lands-on-mk802-mini-pc/

Raspberry Pi


ARM1176JZF-S 700 MHz CPU 256MB RAM

Just got it today in the morning, I think I will try idea 1 and 3.
http://www.raspberrypi.org

TP-Link WR703N



Atheros AR7240 CPU (400Mhz) 32MB RAM

This device was meant to be a wireless router with a USB port, with custom firmware thanks to team openwrt, I was able to get basic DVB-TH streaming by mumudvb (no transcoding due to limited CPU resources and memory) with a custom build of openwrt, and I think this should be prefect for my idea 3, A home server system with Arduinos, USB webcam and so on because of its low power consuming.

The hard part on getting work done on WR703N was the OS, openwrt is not full linux, and I do have to go all way round to compile the whole build in order to get extra drivers and app support, compare to the above 2 which many apps / solutions has already been done and ready to use by apt-get install.
http://www.tp-link.com.cn/PAGES/product-detail.asp?d=225

Conclusions
With all current test, to my surprise which turns out the old console emulation was the part which all these 3 devices didn’t handle that well (which mainly because poor GFX and CPU processing power and drivers support), and if transcoding is needed on DVB streaming, more processing power shall be needed, which leaves me to think of fall back to ATOM base x86 solutions.

Finally started to use jQuery…

Lazy me…..I should have dev my own…

But since I would like my code more “follow-able” for others, well seems not much choices, I know my own code are not read-able at all….
XD