Category Archives: Configurations

Freeze Screen in Chrome Debugger for popover Inspection

https://stackoverflow.com/questions/17931571/freeze-screen-in-chrome-debugger-devtools-panel-for-popover-inspection

  • Browse to the desired page
  • Open the dev console – F12 on Windows/Linux or option + ⌘ + J on OSX
  • Select the Sources tab in chrome inspector
  • In the web browser window, hover over the desired element to initiate the popover
  • Hit F8 on Windows/Linux (or fn + F8 on OSX) while the popover is showing. If you have clicked anywhere on the actual page F8 will do nothing. Your last click needs to be somewhere in the inspector, like the sources tab
  • Go to the Elements tab in inspector
  • Find your popover (it will be nested in the trigger element’s HTML)

Should IBOutlet be weak or strong?

https://stackoverflow.com/questions/7678469/should-iboutlets-be-strong-or-weak-under-arc/7729141#7729141

…the outlets to subviews of the view controller’s view can be weak, because these subviews are already strongly owned by the top-level object of the nib file.

However, when an Outlet is defined as a weak pointer and the pointer is set, ARC calls the runtime function:

This adds the pointer (object) to a table using the object value as a key. This table is referred to as the weak table. ARC uses this table to store all the weak pointers of your application. Now, when the object value is deallocated, ARC will iterate over the weak table and set the weak reference to nil.

Alternatively, ARC can call:

Then, the object is unregistered and objc_destroyWeak calls again:

This book-keeping associated with a weak reference can take 2–3 times longer over the release of a strong reference. So, a weak reference introduces an overhead for the runtime that you can avoid by simply defining outlets as strong.

git commands

https://tortoisegit.org/docs/tortoisegit/tgit-dug-conflicts.html

Switch Branch

> git checkout -b

Show origin of current git directory

> git remote show origin

* remote origin
Fetch URL: https://ricky_tsao@gitcn.epam.com:4443/ricky_tsao/joiner-app-backend.git
Push URL: https://ricky_tsao@gitcn.epam.com:4443/ricky_tsao/joiner-app-backend.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for ‘git pull’:
master merges with remote master
Local ref configured for ‘git push’:
master pushes to master (up to date)

Resolving Conflicts

During a merge, the working tree files are updated to reflect the result of the merge. Once in a while, you will get a conflict when you merge another branch, cherry-pick commits, rebase or apply a stash: Among the changes made to the common ancestor’s version, non-overlapping ones (that is, you changed an area of the file while the other side left that area intact, or vice versa) are incorporated in the final result verbatim. When both sides made changes to the same area, however, Git cannot randomly pick one side over the other, and asks you to resolve it by leaving what both sides did to that area. Whenever a conflict is reported you need to resolve it!

The conflicting area is marked in the file like this (also cf. the section called “HOW CONFLICTS ARE PRESENTED”):

The code from your current branch is on top, the code from the branch you are merging in is on the bottom

The contents after the first marker originate from your current working branch. After the angle brackets, Git tells us where (from which branch) the changes came from. A line with “=======” separates the two conflicting changes.

Mac: Install MySQL and use Terminal to use it

ref – http://www.cyberciti.biz/faq/mysql-command-to-show-list-of-databases-on-server/

Determine Kernal bit 32 or 64 for Mac


See whether you have the 32 or 64 bit processor

Go download the mysql dmg file from mysql’s developer page:

http://dev.mysql.com/downloads/mysql/

dmg_file_install

Locate the DMG file compatible for your machine and download it

mysql_mac

Let’s double click on the .dmg file, and double click the .pkg file to install it. Leave all the default options and continue through the installation wizard.

sql_installing

At a certain point, you’ll be given a default password. copy and paste it into a note editor because you’ll need it for the first log in, later in time.

Once you logged in the first time, you will be prompted to create a new password.

default_pwd

Go to your preferences, and you’ll see the SQL icon. Click on it and start the SQL server

preferences_mysql

start_mysql

Working with SQL in terminal

Open up the terminal.
Then go to the location:


cd /usr/local/mysql/bin

You’ll see all your mysql run commands in there.


/usr/local/mysql/bin/mysql -u root -p

enter your password

Showing all Database(s)

Let’s see all the databases in the SQL server.

mysql> show databases;

+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| sys |
+——————–+
4 rows in set (0.00 sec)

mysql>

Switch to Database

There are 4 databases so far. Let’s choose one and see what kind of tables are in there.

mysql> use mysql
Database changed
mysql> show tables;

Create a Database

But, we want to create our own custom database. Let’s do so.

mysql> CREATE DATABASE MyLocalDB;
Query OK, 1 row affected (0.03 sec)

Then create a table inside of our database

mysql> use MyLocalDB
Database changed

mysql> CREATE TABLE Persons
-> (
-> PersonID int,
-> LastName varchar(255),
-> FirstName varchar(255),
-> Address varchar(255),
-> City varchar(255)
-> );
Query OK, 0 rows affected (0.35 sec)

Insert a row into your table

mysql> insert into Persons (PersonID, LastName, FirstName, Address, City) values (‘123’, ‘Saor’, ‘Rick’, ‘132 Nowhere street’, ‘Liberty Hall’);
Query OK, 1 row affected (0.07 sec)

Import another project/framework (ADAL) into your project

ref – http://www.insert.io/frameworkios8xcode6/

Let’s say we want to get a project called ADAL from the git repository and then add it to our project as an external framework for us to use.

First, let’s get the project:

git submodule add https://github.com/AzureAD/azure-activedirectory-library-for-objc adal
cd adal
git checkout tags/2.1.0

Optionally, later don’t forget to add this framework to your git, and push it.

cd ..
git add adal
git commit -m “Use ADAL git submodule at 2.1.0”
git push

Locate the ADAL project folder

the adal folder will be downloaded into your root git directory. (the one with the .git hidden folder)
You will see the ADAL project. Inside, you’ll see several folders. Locate the main ADAL folder with the source files by looking for a .xcodeproj file, along with src folder and its header/implementation files.

source_files

Drag the project over

Make sure you drag the .xcodeproj file over to your project space. Open it and you’ll see the src folders and what not. Look in the Products folder. You will see the ADAL.framework. That is what we’ll be importing into our project.

drag_project_over

Select your Target, then Build Phases, then click on Link Binary With Libraries

Also, in Target, then Build Phases, then Target Dependencies, make sure you add the ADAL framework as well

target_link_library

Click on the ADAL framework and import it.

select_it

Make sure you’ve imported the framework. The run the project.

framework_should_appear

Inserting some code

Finally, in your ViewControllelr.m, import the header file and you should get no errors.

add some define strings for the table names in our azure cloud

Let’s create a service so the view controller can communicate with the cloud tables

Set up the service with the table name and query

dyld: Library not loaded

http://stackoverflow.com/questions/24993752/os-x-framework-library-not-loaded-image-not-found

After you’d made sure there are no errors, if you run into an image not found error, it just means that in your Target, General, Embedded Binaries, click the ‘+’ button and add the ADAL ios framework from its original directory. (NOT the one you dragged into your project)

add_embedded_binaries

Using Cocoapods

ref – http://stackoverflow.com/questions/23755974/cocoapods-pod-install-takes-forever

How to install CocoaPods and setup with your Xcode project

https://www.raywenderlich.com/156971/cocoapods-tutorial-swift-getting-started

Install cocoapods

First, install pod:

The verbose option logs progress as the process runs, allowing you to watch the process instead of seeing a seemingly “frozen” screen.

Note: If you have previously installed pod and want to do a re-install do this:

Create a xCode project

Open Terminal and navigate to the directory that contains your project by using the cd command:

cd ~/Path/To/Folder/YourProject

Next, enter the following command:

Go into the root directory of the project.

This creates a Podfile for your project.
Finally, type the following command to open the Podfile using Xcode for editing:

Note: You shouldn’t use TextEdit to edit the Podfile because it replaces standard quotes with more graphically appealing typeset quotes. This can cause CocoaPods to become confused and throw errors, so it’s best to use Xcode or another programming text editor to edit your Podfile.

The default Podfile looks like this:

Delete the # and space before platform, and delete the other lines starting with #.
Your Podfile should now look like this:

This tells CocoaPods your project is targeting iOS 9.0 and will be using frameworks instead of static libraries.
In order to use CocoaPods written in Swift, you must explicitly include use_frameworks! to opt into using frameworks. If you forget to include this, and CocoaPods detects you’re trying to use a Swift CocoaPod, you’ll get an error when you try to install the pods.

Installing your Dependency

It’s finally time to add your first dependency using CocoaPods. Add the following to your Podfile, right after use_frameworks!:

This tells CocoaPods you want to include Alamofire version 4.4.0 – the latest, stable version at the time of writing this tutorial – as a dependency for your project.
Save and close the Podfile.

You now need to tell CocoaPods to install the dependencies for your project. Enter the following command in Terminal, after ensuring you’re still in the directory containing your project and Podfile:

You should see output similar to the following:
Analyzing dependencies
Downloading dependencies
Installing Alamofire (4.4.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use YourProject.xcworkspace for this project from now on.
Open the project folder using Finder, and you’ll see CocoaPods created a new YourProject.xcworkspace file and a Pods folder in which to store all the project’s dependencies.

Adding LumberJack via source code to your project

ref – http://code.tutsplus.com/tutorials/cocoalumberjack-logging-on-steroids–mobile-15287

Go to CocoaLumberJack’s site and download their source code here

Unzip the LumberJack project and take a look at the LumberJack class folder’s source files.

lumberjack-class-directory

Import LumberJack’s Source files

Start a new xCode project.

Drag the listed files:

  • DDLog.h/.m
  • DDASLLogger.h/.m
  • DDTTYLogger.h/.m
  • DDFileLogger.h/.m
  • DDLegacyMacros.h
  • DDLegacyMacros.h

lumberjack-drag_to_proj

from the LumberJack project’s class folder, and into your project.

Creating the PCH file

Long ago, if there is a utility class that a developer needs for every of his source files, its very tiring for them to import that utility .h file in every of their source file. Hence, Prefix.pch was invented.

It is a precompiled header. It implicitly is included at the start of every source file. In other words, it’s like as if each source file adds:

Hence, you can easily include lumberjack’s functionality in all of your source code by using PCH file.

File >> New >> File
lumberjack-create-pch-file

Other >> PCH file

lumberjack-create-pch-file-2

use “Logging-PrefixHeader.pch”
make sure you check the checkbox for adding it to our target.

lumberjack-pch-file-3

Add

inside the ifndef statements.

Then at the end of the file, add

Your Logging-PrefixHeader.pch file should look like this:

Project Build Settings

Then in your Project, select your Target, Build Settings, and in the search box, type prefix. Scroll down and you’ll see Apple LLVM 7.0 – Language.

In Prefix Header, enter your .pch file name. In our case it would be Logging_PrefixHeader.pch.

Using the code

Add the following imports for DD in your AppDelegate.m file:

Then also in AppDelegate.m, insert the code as shown below:

Build and run the project. You should now see the log messages in your console.

Go to your Logging-PrefixHeader.pch file, highlight the macro LOG_LEVEL_VERBOSE, right click, and select “Jump To Definition”. Use all the different MACROS for setting what kind of log messages you want to see.

Installing xCode Colors Plugin

Install xCode color plugin by following the directions provided here.

Make sure you restart xCode.

Open up your project and in AppDelegate.m:

You should now see that your log messages are color-coded.