Tuesday, January 20, 2015

PHP Tip - Getting location of visitor

Very often, you want to know the location of your web site visitor's, such as country, region, and other location information. You can do so via passing the IP address of the user to this free site: http://www.geoplugin.net/json.gp. It will then return you a JSON string containing detailed location information pertaining to the specified IP address.

To use this site in PHP, you can create a function, like the following:

function getLocationUsingIP($ip) {        
    $result = @json_decode(file_get_contents(
        "http://www.geoplugin.net/json.gp?ip=" . $ip));
    if($result && $result->geoplugin_countryName != null)
    {
        $location['region'] = $result->geoplugin_region;
        $location['city'] = $result->geoplugin_city;
        $location['country'] = $result->geoplugin_countryCode;
        $location['latitute'] = $result->geoplugin_latitude;
        $location['longitude'] = $result->geoplugin_longitude;
    }
    return $location;
}    

To call it, call the function by passing the IP address of the user (obtainable via $_SERVER[REMOTE_ADDR]):

    $location = getLocationUsingIP($_SERVER[REMOTE_ADDR]);    
    echo $location['region'] . "<br/>";
    echo $location['city'] . "<br/>";
    echo $location['country'] . "<br/>";
    echo $location['latitute'] . "<br/>";
    echo $location['longitude'] . "<br/>";

To learn more about PHP and MySQL programming, enrol in the WEB103 - Web Development using PHP and MySQL course (2-days).
Course Fee
S$1097 (nett; no GST)
If your company is sponsoring you for the training, your company can enjoy 400% tax deductions/ allowances and/or 60% cash payout for investment in innovation and productivity improvements under the Productivity and Innovation Credit (PIC) scheme. For more details, check out the Productivity and Innovation Credit page. 
Schedules
Start DateEnd DateDetailsCategory
Tue Feb 03 2015Wed Feb 04 2015PDF
Thu Mar 05 2015Fri Mar 06 2015PDF
Mon Apr 06 2015Tue Apr 07 2015PDF
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621  

If your company requires in-house training, you can contact us to customize the topics to meet your training requirements. We train worldwide! We have conducted customized classes in the United States, Norway, Denmark, Japan, China, Hong Kong, Taiwan, and Thailand.

IOS305 - Developing Secure iOS Applications

In this new course - IOS305 - Developing Secure iOS Applications, you will learn how to develop safe and secure iOS apps. You will learn:

* How to save user's credentials using the iOS KeyChain
* How to save the KeyChain data on iCloud so that user can access the same secured information on multiple devices
* How to securely save user's confidential data using symmetric and asymmetric encryption and encryption.
* How to consume a secure REST API service
* How to use Touch ID on the iPhone and iPad to authenticate users
* How to build secure user interfaces so that user's private information are protected
Course Fee
S$799 (nett; no GST)
If your company is sponsoring you for the training, your company can enjoy 400% tax deductions/ allowances and/or 60% cash payout for investment in innovation and productivity improvements under the Productivity and Innovation Credit (PIC) scheme. For more details, check out the Productivity and Innovation Credit page. 
Schedules
Start DateEnd DateDetailsCategory
Fri Feb 06 2015Fri Feb 06 2015PDF
Wed Apr 15 2015Wed Apr 15 2015PDF
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621  

If your company requires in-house training, you can contact us to customize the topics to meet your training requirements. We train worldwide! We have conducted customized classes in the United States, Norway, Denmark, Japan, China, Hong Kong, Taiwan, and Thailand.

Monday, January 19, 2015

Android Tip - Connecting to a Wireless Network Programmatically

If you want to programmatically set your Android device to connect to a particular wireless network, you can use the WifiConfiguration and WifiManager classes:

        EditText txtNetworkName = (EditText) 
            findViewById(R.id.txtNetworkName);
        EditText txtPassword = (EditText) 
            findViewById(R.id.txtPassword);

        WifiConfiguration wifiConfiguration = new 
            WifiConfiguration();
        wifiConfiguration.SSID = String.format("\"%s\"", 
            txtNetworkName.getText().toString());
        wifiConfiguration.preSharedKey = String.format("\"%s\"", 
            txtPassword.getText().toString());

        WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        int netId = wifiManager.addNetwork(wifiConfiguration);

        if (wifiManager.isWifiEnabled()) { //---wifi is turned on---
            //---disconnect it first---
            wifiManager.disconnect();
        } else { //---wifi is turned off---
            //---turn on wifi---
            wifiManager.setWifiEnabled(true);
        }
        wifiManager.enableNetwork(netId, true);
        wifiManager.reconnect();

The above code snippet connects to a WPA-secured wireless network. It first checks if WiFi is enabled, turn if on if it is not, and then connects to the specified network.

To do the above, you need the following permissions in your AndroidManifest.xml file:

    <!--you need this to check if wifi is enabled-->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!--you need this to use wifi to connect to a network-->
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

AND302 - Developing NFC Apps

NFC (Near Field Communication) is one of the most under-used features of Android. Despite its usefulness, a lot of users are unaware of the power of NFC and how to use it to enhance the user experience. In this case, you will learn what NFC is, how to create apps that reads and writes information to tags, and how to automate your daily tasks using NFC. In addition, you will also learn ho
w to exchange data between Android devices using Android Beam.
Course Fee
S$699 (nett; no GST)
If your company is sponsoring you for the training, your company can enjoy 400% tax deductions/ allowances and/or 60% cash payout for investment in innovation and productivity improvements under the Productivity and Innovation Credit (PIC) scheme. For more details, check out the Productivity and Innovation Credit page. 
Schedules
Start DateEnd DateDetailsCategory
Fri Jan 09 2015Fri Jan 09 2015PDF
Mon Feb 23 2015Mon Feb 23 2015PDF
Thu Apr 09 2015Thu Apr 09 2015PDF
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621

Sunday, January 18, 2015

iOS Tip - Detecting Screen Capture

In iOS 7 onwards, you can programmatically detect if the user captures the screen using the Home and Lock buttons to take a screen shot. When the user takes a screen capture, the OS fires the UIApplicationUserDidTakeScreenshotNotification notification. Thus, all you have to do is to handle register for this notification and do whenever you want to do when this notification is fired. The following shows an example:

    override func viewDidLoad() {
        super.viewDidLoad()
        
        NSNotificationCenter.defaultCenter().addObserverForName(
            UIApplicationUserDidTakeScreenshotNotification,
            object: nil,
            queue: NSOperationQueue.mainQueue())
            {
                notification in
                println("Screen shot taken!")
            }

    }

Note that this notification is fired only after the screen shot is taken. 

IOS302 - Advanced iOS - Apple Watch Programming Course


Apple is slated to release the Apple Watch this quarter. To prepare for the wave of the next generation of wearable apps, this is the best time to get started with Apple Watch programming! Join us in this 1-day course on Apple Watch programming and see how you can create your next killer app!

P.S. The prerequisite for the course is IOS101 - Foundation of iPhone Programming. 
Course Fee
S$1297 (nett; no GST)
Schedules
Start DateEnd DateDetailsCategory
Fri Jan 16 2015Fri Jan 16 2015PDF
Fri Feb 27 2015Fri Feb 27 2015PDF
Wed Mar 11 2015Wed Mar 11 2015PDF
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621

Monday, January 12, 2015

Developing a Selfie Remote-Control App in iOS Using Bluetooth Low Energy


Wei-Meng Lee speeds through the easy setup of a remote-control app employing Bluetooth LEs on Apple's iOS. Using an inexpensive TI SensorTag for remote control, you can prompt your gadget remotely to perform a variety of tasks. Here, you'll learn how to set up your device and system to take 'selfie' photographs, even when you're nowhere near your iPhone.
Bluetooth Low Energy (Bluetooth LE) is getting a lot of attention lately due to its support in various devices and gadgets. Thanks in no small part to the advent of the IoT (Internet of Things), Bluetooth LE is poised to change the way you build applications that interact with external devices and gadgets. Although Bluetooth LE is just starting to get developers' interest, Apple actually had support for Bluetooth LE very early on, starting from the iPhone 4S.
In this article, rather than walk you through the details of Bluetooth LE programming, I'll show you how to build a selfie remote-control app quickly, using the Bluetooth LE APIs in iOS 6 and later, with a cheap $25 device for the remote control.
Want to learn more about Bluetooth Low Energy using iOS? Come and join us in the next run of the IOS301 - Advanced iOS - Programming Bluetooth Low Energy course:
Course Fee
S$699 (nett; no GST)
Schedules
Start DateEnd DateDetailsCategory
Fri Jan 02 2015Fri Jan 02 2015PDF
Thu Mar 12 2015Thu Mar 12 2015PDF
Wed Apr 08 2015Wed Apr 08 2015PDF
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621  

Sunday, January 11, 2015

IOS305 – 1-Day Developing Secure iOS Applications

In this one-day course, you will learn how to write secure iOS applications. You will learn how to save user data securely on your iPhone, and how to perform authentication within your application using custom authentication and using Apple’s Touch ID.

Topics
• Implementing local authentication on your application
• Using Touch ID for authentication
• Cryptography in iOS
    o Hashing
    o Encryption/Decryption
• Saving passwords in Keychain
• Sharing Keychain with Apps made by your team
• Obtaining Passwords from the user
• Connecting to a secure Web service
• iOS File system Security
• Security Best Practices

Wednesday, January 07, 2015

AND101 - Consuming REST Services in your Android App

In the AND101 Foundation of Android Programming course, you will now learn how to consume REST services in your iOS apps. In addition, the course is now taught using Android Studio, the recommended IDE for Android development.

Check the course schedule now!

IOS101 - Consuming REST Services in your iOS App

In the IOS101 Foundation of iPhone Programming course, you will now learn how to consume REST services in your iOS apps. In addition, the course is now taught using Swift as the programming language.

Check the course schedule now!

Tuesday, January 06, 2015

WEB103 - Web Development using PHP and MySQL - Developing RESTful Services

The WEB103 - Web Development using PHP and MySQL course will now include coverage of how to develop RESTful services using PHP!

You will learn the fundamentals of how REST services are designed and created, and what's more, you will learn how to consume the REST service that you have created using:
1. A client-side app using JavaScript
2. A server-side app using PHP
3. A mobile app using iOS
4. A mobile app using Android

Click the button below to check the schedule.

Sunday, January 04, 2015

Two New Courses on Writing Secure iOS and Android Apps

Come this Feb, there will be two brand new courses on writing secure iOS and Android apps:


IOS305

Advanced iOS - Developing Secure iOS Apps (S$799)




AND301
Advanced Android - Developing Secure Android Apps (S$799)


More information will be released shortly. Reserve your seats now!

Learn Web Development using PHP and MySQL

While most of the attentions have been placed on mobile development in recent years, server-side development has always played an important role in mobile-enabling enterprise applications. One of the favourite tools for server-side development is PHP.

PHP is an easy to learn language and is freely available for most web servers and platforms. Together with the world's most popular open source database - MySQL, PHP powers some of the world's most popular web sites, such as Facebook, Google, Yahoo, and more.

In this course, you will learn how to develop web applications using PHP and MySQL. This course is lab intensive, and at the end of the course you would be able to create the following applications:

1. A membership system where users can login, or register as a new user.
2. An online polling application
3. An AJAX applications connected to a PHP application
4. A JSON Web services
5. iOS and Android applications that consumes a JSON service developed using PHP and MySQL


In addition, this course would also cover how to get started with Amazon Elastic Cloud (EC2), and how to deploy the applications you have built onto Amazon EC2.

Check the course schedules below!

Saturday, January 03, 2015

Course Calendar for 2015 is now out!

You can now view the complete course calendar for 2015 and search for specific course by clicking on the following button. More courses will be added shortly!

Tuesday, December 23, 2014

Using reserved word in Swift methods

If you attempt to call a method that uses a Swift reserved word in its method name, you will get an error. For example, the NSURLProtectionSpace class has an initializer that takes in an argument with the protocol label:

 var protectionSpace = NSURLProtectionSpace(
            host: url,
            port: 80,
            protocol: "http",
            realm: nil,

            authenticationMethod: nil)

As the protocol is a Swift reserved word, this will cause a problem for the compiler. To fix this, enclose the protocol word with a pair of back-quotes (``), like this:

 var protectionSpace = NSURLProtectionSpace(
            host: url,
            port: 80,
            `protocol`: "http",
            realm: nil,

            authenticationMethod: nil)

Sunday, December 21, 2014

New Course - IOS304 – 2-Day Advanced iOS 8 Programming

In this two-day course, you will learn the new APIs available in iOS 8. iOS 8 includes a sleuth of new APIs to make apps development easier and more powerful. In this course, you will focus on four key areas – app extension programming, Touch ID authentication, server-side database development using CloudKit, and using the Handoff APIs to synchronize the user activities on multiple devices.

Topics
• Programming App Extensions o Creating Today extensions (widgets)
     o Sharing content with other apps
     o Creating Actions o Document Providers
• Touch ID Programming
     o Enabling Touch ID authentication in your application
• Using CloudKit
     o Creating databases in iCloud using the CloudKit Dashboard
     o Accessing databases from iCloud
• Using the Handoff API
    o Syncing user activities between Mac OS X and iOS

Course Fee
S$1,297 (nett; no GST)

Date
16-17 Feb 2015

Venue
Bayview Hotel
Singapore

Tuesday, December 16, 2014

Foundation of iPhone Programming course on 29-30 Dec 2014 is confirmed!

The Foundation of iPhone Programming course on the 29-30 Dec 2014 is confirmed! You will also get a crash course in Swift, plus two very useful and nicely laminated Swift cheat sheets! 

Download your own Swift Cheat Sheets:
http://weimenglee.blogspot.sg/2014/11/swift-cheat-sheets-download-today.html

Course Calendar
http://weimenglee.blogspot.sg/p/blog-page.html
Venue
Bayview Hotel
Singapore

Course Fee
S$1,097 (nett; no GST)

Tuesday, December 02, 2014

Article - Using Objective-C and Swift together in iOS Apps

As an addendum to my previous article about the role of Swift in iOS app development, we now take a look at how Swift and Objective-C can be used together in iOS apps. Despite Apple’s intention to replace the Objective-C language using Swift, it is not practical in the short term simply due to the fact that developers are deeply entrenched in Objective-C. Rather than force Swift down the developer’s throat, Apple has made it easy to allow Objective-C to interoperate with Swift. In this article, I run through a couple of simple examples to illustrate first how you can use Swift within an Objective-C project, and then how to include Objective-C within a Swift project.

Read the article here.

iOS courses are all updated to use Swift

My iOS courses are all fully updated to use Swift. When you attend the Foundation of iPhone Programming course, you will also get two nicely laminated Swift Cheat Sheets.  Use these cheat sheets to help you migrate your existing code to Swift. If you are a beginning iOS developer, these cheat sheets will save you lots of time.

Want your own cheat sheets? Download them here.