IBM Bluemix MobileFirst Services Starter for Cordova Tutorial 教學

Create an account on https://new-console.ng.bluemix.net/
Search the template: MobileFirst Services Starter, and create it.
螢幕快照 2016-06-04 11.22.21

After that, download the source code from https://github.com/ibm-bluemix-mobile-services/bms-samples-cordova-helloworld

Before installing Cordova, you will require node.js which is downloaded from https://nodejs.org/en/

If you do not have Cordova installed, then type

npm install -g cordova

Update Cordova

sudo npm update -g cordova

Go to the directory of source code, add cordova platform

cordova platform add android
cordova platform add ios

Install the IBM Bluemix plugin
cordova plugin add ibm-mfp-core

Go to /project-dir/www/js/index.js, paste your route & GUID
route: https://your-proj-name/mybluemix.net
GUID: can be found in the first line of Cloud Foundry’s log in the panel

route: ""
GUID: ""

Open xcodeproj in /project-dir/platform/ios/
If it prompts to update latest swift version, cancel it.
Go to build settings tab and edit Objective-C Bridging Header
/your-proj/plugins/ibm-mfp-core/src/ios/Bridging-Header.h
Find Runpath search Path, and add
@executable_path/Frameworks

Build Cordova
cordova build
Then run
cordova run android

Run iOS platform on Xcode
yayconnected


Cloud Foundry

Install CF CLI from https://github.com/cloudfoundry/cli/releases

Install Bluemix CLI from http://clis.ng.bluemix.net/ui/home.html

If this error occurs

panic: Config error: open config.json: permission denied

type

sudo chmod -R 777 ~/.cf

If this error occurs

panic: no supported languages found []string{“zh_TW.UTF-8”}

go to ~/.cf/config.json

set “Local” : “zh-Hant”

Download your project source code

螢幕快照 2016-06-04 12.11.58

go to /proj-dir , type

bluemix login -a https://api.ng.bluemix.net

push your project

cf your-project-name

Now you are ready to build your own project.

ASO 阿蘇 Helicopter Tour in カドリー・ドミニオン

I always like to go to countryside to see the beauty of the Earth. I dreamed to appreciate it while flying in sky as a bird. At this time, as soon as I heard there was a helicopter tour around ASO mountain I couldn’t hide the excitement. All I wanted to do was take the ride and experience the splendid nature in sky.

First, the helicopter tour is located in Cuddly Dominion. Map
This is a zoo with over 2 hundreds bears as Showanshinzan Kumabokujo in Hokkaido. Tourists can feed bears with toast, bear food, and chicken (Only for brown bears).

IMG_6735
Brown Bears pleasing for food
IMG_6737
Japanese black bears

This slideshow requires JavaScript.

This slideshow requires JavaScript.

Fee

mini tour: 2 minutes. Adult ¥2900, Child ¥2500

米塚 tour: 4 minutes. Includes mountain. Adult ¥4800, Child ¥4500

volcano tour: 7 minutes. Includes volcano. Adult ¥7500, Child ¥7000

super tour: 10 minutes. Includes mountains, grassland, volcano. Adult ¥12500, Child ¥11500

IMG_6704
Me!

jQuery DataTables plugin with PHP and MS SQL

I hereby provided the code for server-side processing for PHP and MS SQL.

The environment I used was PHP 5.5 and MS SQL 2008

Since PHP 5.5 no longer supports mssql extension, hence, I used sqlsrv extension instead on Window.

<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
 
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
// add your columns here!!!
$aColumns = array( 'columnName1', 'columnName2' );
 
/* MSSQL Database infomation */
$host = 'localhost';
$connectionInfo = array("Database"=>"yourdb", "UID"=>"yourUser", "PWD"=>"yourPassword", "CharacterSet"=>"UTF-8");
$conn = sqlsrv_connect($host,$connectionInfo);
if($conn){
 //echo "Connection Established";
}else{
 echo "Connection could not be Established";
 die ( 'Can not connect to server' );
}
 
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
 
/* DB table to use */
$sTable = "Your Table";
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
 
/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}
 
 
/* Ordering */
$sOrder = "";
if ( isset( $_POST['order'] ) )
{
 $sOrder = "ORDER BY ";
 if ( $_POST['columns'][0]['orderable'] == "true" )
 {
 $sOrder .= "".$aColumns[ intval( $_POST['order'][0]['column'] ) ]." ".
 ($_POST['order'][0]['dir']==='asc' ? 'asc' : 'desc');
 }
}
 
/* escape function */
function mssql_escape($data) {
if(is_numeric($data))
return $data;
$unpacked = unpack('H*hex', $data);
return '0x' . $unpacked['hex'];
}
 
/* Filtering */
$sWhere = "";
if ( isset($_POST['search']['value']) && $_POST['search']['value'] != "" ) {
$sWhere = "WHERE (";
for ( $i=0 ; $i<count($aColumns) ; $i++ ) {
$sWhere .= $aColumns[$i]." LIKE '%".addslashes( $_POST['search']['value'] )."%' OR ";
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ')';
}
/* Individual column filtering */
for ( $i=0 ; $i<count($aColumns) ; $i++ ) {
if ( isset($_POST['columns'][$i]) && $_POST['columns'][$i]['searchable'] == "true" && $_POST['columns'][$i]['search']['value'] != '' ) {
if ( $sWhere == "" ) {
$sWhere = "WHERE ";
} else {
$sWhere .= " AND ";
}
$sWhere .= $aColumns[$i]." LIKE '%".addslashes($_POST['columns'][$i]['search']['value'])."%' ";
}
}
 
/* Paging */
$top = (isset($_POST['start']))?((int)$_POST['start']):0 ;
$limit = (isset($_POST['length']))?((int)$_POST['length'] ):5;
$sQuery = "SELECT TOP $limit ".implode(",",$aColumns)."
FROM $sTable
$sWhere ".(($sWhere=="")?" WHERE ":" AND ")." $sIndexColumn NOT IN
(
SELECT TOP $top $sIndexColumn FROM
$sTable $sOrder
)
$sOrder";
$rResult = sqlsrv_query($conn, $sQuery);
if($rResult === false){
 die(sqlsrv_errors(SQLSRV_ERR_ERRORS));
}
 
/* Data set length after filtering */
$sQueryCnt = "SELECT * FROM $sTable $sWhere";
$rResultCnt = sqlsrv_query($conn, $sQueryCnt );
$iFilteredTotal = sqlsrv_num_rows( $rResultCnt );
 
/* Total data set length */
$sQuery = "
SELECT COUNT(id)
FROM $sTable
";
$rResultTotal = sqlsrv_query($conn, $sQuery );
$aResultTotal = sqlsrv_fetch_array($rResultTotal, SQLSRV_FETCH_NUMERIC);

$iTotal = $aResultTotal[0];
 
 
/* Output */
$output = array(
"draw" => intval($_POST['draw']),
"recordsTotal" => $iTotal,
"recordsFiltered" => $iFilteredTotal,
"data" => array()
);
 
 
while ( $aRow = sqlsrv_fetch_array( $rResult, SQLSRV_FETCH_ASSOC) )
{
 $row = array();
 for ( $i=0 ; $i<count($aColumns) ; $i++ )
 {
 /* General output */
 $row[$aColumns[$i]] = $aRow[ $aColumns[$i] ];
 }
 $output['data'][] = $row;
}
 
echo json_encode( $output );
 
?>

 

Intel Galileo 2 with USB WiFi Dongle (RT3070)

The WiFi dongle I am using here is Edimax EW-7711UMn

Here I will talk about how to use it on Intel Galileo 2

prerequisite

Install Linux on Intel Galileo 2

Establish communication through terminal

Step 1.

This USB Wifi dongle is supported by Intel Galileo 2, so we don’t need to install driver.

Just plugin it on the board.

$ iwconfig

Find the dongle identifier as “wlp0s20f3u1”

螢幕快照 2015-10-11 21.00.31

The example here is based on WPA WiFi Router

killall wpa_supplicant
ifconfig wlp0s20f3u1 up
wpa_passphrase "YOUR ESSID" "YOUR PASSWORD" > /tmp/wpa.conf 
wpa_supplicant -BDwext -i YOURWIFIIDENTIFIER -c/tmp/wpa.conf

Then you will see “Successfully initialized wpa_supplicant”

If it appears “ifconfig: SIOCSIFFLAGS: Operation not possible due to RF-kill”, when you are entering “ifconfig wlp0s20f3u1 up”.

rfkill unblock all

You can scan to search nearby SSID

iwlist YOURWIFIIDENTIFIER scan

Make a file “udhcpc.sh” in /etc as below code

#!/bin/sh
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
  deconfig)
    /sbin/ifconfig $interface 0.0.0.0
    ;;

  renew|bound)
    /sbin/ifconfig $interface $ip $BROADCAST $NETMASK

    if [ -n "$router" ] ; then
      echo "deleting routers"
      while route del default gw 0.0.0.0 dev $interface ; do
        :
      done

      for i in $router ; do
        route add default gw $i dev $interface
      done
    fi

   echo -n > $RESOLV_CONF
    [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
    for i in $dns ; do
     echo adding dns $i
      echo nameserver $i >> $RESOLV_CONF
    done
    ;;
esac
exit 0

Then run

udhcpc -i YOURWIFIIDENTIFIER -p /var/run/udhcpc.pid -S -s /etc/udhcpc.sh

You will see like this

螢幕快照 2015-10-11 21.15.59

It works now!!

Intel Galileo 2 Linux installation

This tutorial is about how to running Linux on Intel Galileo 2 without FTDI to USB Converter.

In the end, we will be able to develop APP on Intel XDK

Instead of FTDI converter, we use wired connection to a DHCP enabled router.

Requirements:

  • Intel Galileo 2
  • micro USB to USB converter
  • micro SD card (above 2 GB)
  • RJ45 ethernet cable

Step 1.

prepare micro SD card

download the latest image file from http://iotdk.intel.com/images/iot-devkit-latest-mmcblkp0.direct.bz2 and extract it

format your memory card as MS-DOT (FAT) format

using shell command to unmount the card

diskutil unmountDisk disk3s

replace “disk3s” from your own disk Identifier which you can find in Disk Utility.app

using shell command to install the image file

sudo dd bs=8m if=iot-devkit-version-mmcblkp0.direct of=/dev/disk3s

replace “disk3s” as before

This may take serval minutes.

Step 2.

insert the micro SD on Galileo 2

connect the ethernet cable and the usb cable to your DHCP router and your computer respectively.

power it up.

Open Arduino APP on your computer
using the below code to detect your network status


 void setup() {
 Serial.begin(9600);
 //It’ll not continue until you send an ‘a’ through the serial monitor
 while(Serial.read()!='a'){
 Serial.println("hello");
 delay(1000);
 }
 //Display ifconfig result to serial monitor
 system("ifconfig > /dev/ttyGS0");
 }
 void loop() {
 }
 

Upload it, and open Serial Monitor in Arduino APP.

send a string “a”

螢幕快照 2015-10-11 13.38.28

You can find your IP Address as 192.168.0.118

Step 3.

use the below shell script in Terminal

 ssh root@192.168.0.118 

It will ask you “Are you sure you want to continue connecting (yes/no)? yes”
Then you can use this script to check your IoT develop kit version

  cat /etc/version 

Step 4.

Install Intel XDK on your computer

create a template using OnBoardLED

螢幕快照 2015-10-11 13.49.31

At the drop down list – select a device.

add manual connection

Address as the IP address you got

and the user name is root

Press the button Install/Build (The second button near the drop down list)

and press the button run (The fourth button from left)

You will be able to see the LED on board blinking

Luxembourg Adventure – Luxembourg

Luxembourg is not only a country but a capital of its country surrounded by Belgium, France, and Germany. After Brussels and Strasburg, Luxembourg city is the third capital of European Union. The highest GDP in the world 114,512$ the second biggest commercial center after US. Geography: One of the smallest sovereign nation in Europe. A population is 55 thousands. How to go to Luxembourg? I took the TER from Strasbourg, which took about 2 hours. What was the first impression in Luxembourg? TGV-route-map It wasn’t as small as I thought. Its terrain wasn’t flat! There were many valley within the city. It was first a castle, which was easy to defense thanks to advantage of lots of cliffs. As I walked around the city, I could see numerous of bridges. Under these bridges usually is where old town located. My hotel is Luxembourg Youth Hostel, which located in one of the valleys. It wasn’t very far from the main train station, however, trolling a suitcase in such rock roads, and ascended, descended was really painful. IMG_1509


Luxembourg Youth Hostel Website: Click As a hostel, it is really comfortable to stay. I was staying with 3 friends. We had a room with a toilet and a shower. Be aware to take your own towels and lockers, if not, you have to pay some money to rent it. This hostel has no kitchen. They server breakfast, lunch and dinner, which in my opinion it is the cheapest food you can find in Luxembourg, each meal around 9.9 euro. Each person per night is around 25 euro. On the way to train station, there are a lot of shops, supermarkets, which you can buy food there as well.


Where to visit? This city is based on its castle, which was first built at AD 963. It is a UNESCO world heritage. There are two circular walk you can take.

  • Wenzel Circular Walk
    • A tour through time and space, connecting the Upper and Lower towns: “Bock” promontory, Old Town, Wenceslas ring wall, Alzette valley with its unique fortifications. The Council of Europe has rated this walking tour as an “outstanding” cultural itinerary.
  • Vauban Circular Walk
    • The Vauban Circular Walk, named after the famous French fortress builder, Sébastien le Prestre de Vauban (1633-1707), leads visitors through parts of the fortifications from the 17th, 18th and 19th centuries.

for more information – click IMG_1524 IMG_1541

Monument of Remembrance

The centrepiece of the monument is a 21-metre-tall granite obelisk. Atop of the obelisk stands a gilded bronze statue of a lady, representing Nike, goddess of victory, or “Queen of Freedom” (Friddenskinnigin in Luxembourgish), holding out a laurel wreath as if placing it upon the head of the nation. At the foot of the obelisk are two (ungilded) bronze figures, representing those Luxembourgish soldiers that volunteered to serve for France; one lies at the base of the statue, having died in service of his country, whilst the other sits, mourning his dead compatriot. (From Wikipedia)

IMG_1543

Interesting to see all the bridge was under maintenance. Lots of constructional materials were lying under it.

IMG_1576

Friends were swinging! When we were about to leave, two police officers came. One asked us what we were up to here, while the other was sniffing around like we were taking drugs and he wanted to find an evidence. They frightened us. We were just enjoying swinging when no kid was playing there.

IMG_1611

Musée Draï Eechelen

It is all about history.

IMG_1612

Philharmonie Luxembourg

check some programs here. Maybe you might be interested to enjoy a feast of music.


Summary After staying in Luxembourg for three days, I almost explored all the outdoor tourist attractions by only walking. This city in my opinion, it doesn’t have really clean streets, however, the streets are mostly wide. Some places are still in construction around Europe Union Zone. The most interested thing to me was its spectacular geographic position. Seeing huge bridges anywhere, lots of plantation under bridges, like a big park! Walking under bridges is like I escaped from the busy city. Bridges are a great combination of middle-age buildings, modern buildings, and the mother nature.


巴黎迪士尼樂園 攻略篇

巴黎迪士尼為全球第四座迪士尼樂園,歐洲第一座。興建於1992年4月12日 位於 Marne-la-Vallée,位於該TGV車站的正前方,走路不需三分鐘即可入園。 三次在該車站轉乘火車,都儘儘只能站在門外遠觀XD。趁著放假,終於有空進去啦! 買票?英文官方網站 可在官網線上訂購,但本人剛好有著ISIC學生證,現正有著迪士尼促銷套票優惠,原價139歐元以89歐元購得兩天通票! 此通票能任意進入Walter Disney Studio 以及主要的公園。

Disney TIcket

第三次前往迪士尼樂園!十五年前去了日本,八年前去了香港。這次進入迪士尼樂園有種返老還童的感受,尤其是看到跟以前一樣的爆米花盒! 去之前不妨確認一下,有哪些設施在維護:連結 像我這次去Space Mountain 居然在維護!!頗可惜的! 既然是全歐洲唯一的一個迪士尼,又可謂全歐洲第一的遊樂園,人潮擁擠!入園第一件事,確認想玩什麼,搶先拿FastPass。利用門票背面的QR code,一個人只能限拿一張FastPass。 此迪士尼有兩個園區。

002

圈圈標記我所玩過的

Walter Disney Studio這個園區,展示較多Marve的海報XD,除了海報之外,似乎看不到什麼Marvel了 此區展示較多的迪士尼動畫電影,例如有海底總動員,汽車總動員。 最值得一看的大概就屬 汽車總動員的特技表演,刺激的特技演出,上演空中飛車,逼真的槍戰,彷彿在片場般。 藉由兩位主持人,其實就是正副導演,他們解說拍片的過程,如何運用這些特技,及不同的攝影機視角,合成出電影中刺激的片段。聽不懂法文沒關係,其中一個導演會負責翻譯成英文。 這個園區中,最刺激的莫屬於Hollywood Tower,其實呢就是大怒神。只是可以在下落前,欣賞到迪士尼精心的佈景。個人覺得其實不太高,並以間斷的方式,自由落下。另外Aerosmith的雲霄飛車是園區最讚的雲霄飛車了!雖然在黑暗中,什麼都看不到,但音樂很好聽,並且有360度的軌道。

IMG_4031IMG_4025001

主要的園區則是分為 Fantasy Land, Discovery Land, Adventure Land, Frontier Land.

最刺激的遊樂設施都位於 Adventure Land, Frontier Land分別各一個雲霄飛車,印第安那瓊斯及Big mountain adventure

印第安那瓊斯的雲霄飛車有360度的旋轉!但刺激程度卻不及Big mountaion adventure,Big mountain adventure速度較快,彎道多,軌道較長,並有全黑的隧道。

身為星戰迷的我,最期待的就是這個啦!

X-Wing

IMG_4092

該體驗是類似於4D,乘坐於運輸船,感受星際間遨遊的快感。雖然設備過時,也比不上其他設施的刺激威,但就是那種復古的風味,吸引著星戰迷!

2015年的夏天,主題是冰雪奇緣Frozen,每天都有Elsa和Anna乘坐馬車,在園裡遊行。

在 The Chaparral Theater 能看到冰雪奇緣的表演唷,但只限定假日喔。

IMG_4138

IMG_4107


交通

可在各地車站搭車前往 Marne-la-Valée TGV ,出站直接就是迪士尼樂園的入口囉

通常前往的火車班次不多,並為一大早。並可在此車站搭乘歐洲之星。


住宿

迪士尼本身有提供五個住宿旅館,但不提早訂可能訂不太到,價格也較高。

不妨可以透過訂房網站,查查附近的飯店,像我這次就居住在Hipark Serris。從火車站都有接駁車到飯店。50路公車,大概每一小時一班,不太一定,只要說你是要前往飯店,就是免費的喔,此班公車還經過 Adagio, Élysée.  巴士時刻表