Adding Google Analytics to your wordpress

So last night I decided to add the Google Analytics to my blog and see what the most rewarding post/s.

1. Visit www.google.com/analytics to sign up with your Google Account.

2. You need to accept some T&A before continuing the process.

3. Add a new Website, enter your domain name.

4. Now, Google will generate a tracking code for you to input into your webpage.

Something like this,

<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘XXXXXXXXX’, ‘auto’);
ga(‘send’, ‘pageview’);

</script>

 

To insert that into your wordpress blog, use the following plugin, https://wordpress.org/plugins/insert-headers-and-footers/

GoogleAnalytics

How to setup cocoapods in your Xcode

1. Create a Podfile in your xcode project root directory. A Podfile is a text blank text file.
2. Next add the libraries into your podfile.
pod ‘RESideMenu’

3. Now go to terminal, browse to the location of your Xcode project, enter the following.
pod install

4. You should have a .xcworkspace extension created, you should use this workspace project moving forward.

Setting Global Value in Objective C

Setting and getting value using a global singleton in objective c is a programming pattern that allow you store in the system memory.

There’s a lot of discussion regarding this design pattern both on the pros and cons, visit the following to read more. http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons

To Setup the Singleton Object in your Xcode project.

1. Create a class (.h/.m) and name them GlobalSingleton.

2. In the GlobalSingleton.h file, add the following section of codes.

#import <Foundation/Foundation.h>

 

@interface GlobalSingleton : NSObject

 

//This are the property you are going to store in the Singleton object

@property (nonatomic, retain) NSArray *array_SideViewOptions;

 

@property (nonatomic, retain) bool *offline;

 

+(GlobalSingleton*) getValues;

 

@end

 

Notice the Singleton Properties, these are the different type of properties you intend to store inside the object.

3. In the GlobalSingleton.m file, add the following section of the codes.

#import GlobalSingleton.h

static GlobalSingleton* singleton;

static dispatch_once_t pred;

@implementation GlobalSingleton

 

@synthesize offline;

@synthesize array_SideViewOptions;

 

+(GlobalSingleton*) getValues{

    

    dispatch_once(&pred, ^{

        singleton = [[GlobalSingleton alloc] init];

    });

    returnsingleton;

    

}

 

@end

Notice the synthesize portion, thats allow you have to do in future if you add more properties.

 

Using the Singleton – Setting Value.

#import “GlobalSingleton.h”


[GlobalSingleton getValues].array_SideViewOptions = [[NSArray alloc]initWithObjects:@“apple”,@”Spidy”,@”Settings”,@”Feedback”, nil];

Using the Singleton – Getting Value.

#import “GlobalSingleton.h”

array_SectionOne = [GlobalSingleton getValues].array_SideViewOptions;

 

 

Using Reachability to test for Internet Connectivity IOS

Any apps that you build today will require some form of internet connectivity.

Today’s app is getting more and more intuitive and should have the ability to check on the internet connective and prompt the user of the app.

To do that we will be using the following library, Reachability. https://github.com/tonymillion/Reachability

There are 2 ways to setup the app in your Xcode project.

Part 1 : Getting Reachability to your project

1. Manual

1.1 Check out a copy from the above github url, add the Reachability.h/.m file to your project

2. Cocoapod

2.1 Add the following line to your pod file, pod ‘Reachability’

2.2 Run pod install on terminal.

 

Part 2: Setting up the SystemConfiguration Framework.

1. Go to the Project -> Targets -> Build Phases tab.

2. Add SystemConfiguration.Framework into your project.

 

Part 3: Codes to set up Reachability to test internet connectivity.

AppDelegate.h 

Import the Reachability.h, at the very top of the file.

#import “Reachability.h”

AppDelegate.m

Within the method,

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Add the following codes

 Reachability *reachability = [ReachabilityreachabilityWithHostname:@”http://localhost:3000/”];

    

    reachability.reachableBlock = ^(Reachability *reachability) {

        NSLog(@”Network is reachable.”);

    };

    

    reachability.unreachableBlock = ^(Reachability *reachability) {

        NSLog(@”Network is unreachable.”);

    };

    

    // Start Monitoring

    [reachability startNotifier];

WireFrame: Balsamiq vs Moqups

Balsamiq

The tool ship with varies different version, there’s a subscription version online and a desktop version. The desktop version support both PC and Mac.

On first impression, balsamic allow you to quick design either a web page or mobile application. It ships with elements or controls that allow you to quickly drag and drop then with minimal fuse.

I really like Balsamiq for the near zero learning curve and the only cons is that you need to working on either a PC or MAC to use this.

VS

Moqups,

This is a subscription-based version, the learning curve and features are very similar to Balsamic.

As it is build on the latest HTML 5 technology, I can work on the wireframe on any iOS device via the Safari app. Obviously, trying to design it on a iPhone will be a challenge.

 

moqups.com

Custom Layout for Devise

Custom Layout in Devise, devise is an awesome gem that provides the quick and easy way for the rails app to have user authentication.

But you may be face with the need to add a custom layout to devise. There’s a couple of ways of doing so, but today I am going with the easiest way without bloating your codes.

In Application.rb in config, add the following section.


config.to_prepare do
Devise::RegistrationsController.layout "conversation"
end

This will apply the conversation layout to the Devise::RegistrationsController.

You will need to have the conversation.html.erb layout in the appviewslayouts folder.

Visit the following article to understand more on the layouts

http://www.carrotcoded.com/2015/05/03/layout-in-ruby-on-rails/

Layout in Ruby on Rails

Introduction

Layout in ruby on rails provide the flexibility to allow different views to come together and render as a page. Think iFrame but we without the cross-domain issue.

Layout are located in your project, appviewslayouts, by default you will only have application.html.erb

Layout will always have the  <%= yield %> tag, this will render the current controller/action.

What is this important?

Imagine this, you have a Landing Page for public users to visit the application and now you have a Dashboard Page where the users sign in.

These two pages will have different layout for sure. You will also want to ability to maintain them separately and maybe reuse some of the codes that you have developed as part of the project.

How do I then do it?

Taking the example above, say you have a Landing Page and a Dashboard page.

You will also have the controllers for them HomeController and DashboardController respectively.

Within the respective controller, after the class declaration, the first line end the following code

layout “public”

public will be the name of your layout file in the appviewslayouts folder.

application.html.erb is the default that will be applied to the rest without any additional setting.

Sample of the Layout for HomeController.

class HomeController < ApplicationController
layout "public"