Technical Issues I encountered using ionic with ios

By: Ryan Wong at

I’m going list out all technical issues I found while developing ionic framework application for ios.

1.What you see on the emulator is not exactly what you see in real ios device.

2.Make sure to load divs that have ng-show last on the page because the device loads these elements slower resulting in them showing when they shouldn’t.

3.When making your project in ios remember to get the following:

  • provisional profile
  • read device UDID
  • create App ID
  • rename your bundle in config.xml to match your xcode proj one.

4.You cannot use safari to inspect a built ipa app running on the device. Good luck debugging.

5.Really try not to use position absolute CSS on ios because the pixels are not same ratios.

How to run npm without sudo

By: Ryan Wong at

I found this script which will allow you run npm without being sudo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh

usage()
{
cat << EOF
usage: $0 [-d] [-v]

This script is intended to fix the common problem where npm users
are required to use sudo to install global packages.

It will backup a list of your installed packages remove all but npm,
then create a local directory, configure node to use this for global installs
whilst also fixing permissions on the .npm dir before, reinstalling the old packages.

OPTIONS:
-h Show this message
-d debug
-v Verbose
EOF
}


DEBUG=0
VERBOSE=0
while getopts "dv" OPTION
do
case $OPTION in
d)
DEBUG=1
;;
v)
VERBOSE=1
;;
?)
usage
exit
;;
esac
done

to_reinstall='/tmp/npm-reinstall.txt'

if [ 1 = ${VERBOSE} ]; then
printf "\nSaving list of existing global npm packages\n"
fi

#Get a list of global packages (not deps)
#except for the npm package
#save in a temporary file.
npm -g list --depth=0 --parseable --long | cut -d: -f2 | grep -v '^npm@\|^$' >$to_reinstall

if [ 1 = ${VERBOSE} ]; then
printf "\nRemoving existing packages temporarily - you might need your sudo password\n\n"
fi
#List the file
#replace the version numbers
#remove the newlines
#and pass to npm uninstall

uninstall='sudo npm -g uninstall'
if [ 1 = ${DEBUG} ]; then
printf "Won't uninstall\n\n"
uninstall='echo'
fi
if [ -s $to_reinstall ]; then
cat $to_reinstall | sed -e 's/@.*//' | xargs $uninstall
fi

defaultnpmdir="${HOME}/.npm-packages"
npmdir=''

read -p "Choose your install directory. Default (${defaultnpmdir}) : " npmdir

if [ -z ${npmdir} ]; then
npmdir=${defaultnpmdir}
else
if [ ! -d ${npmdir} ]; then
echo "${npmdir} is not a directory."
exit
fi
npmdir="${npmdir}/.npm-packages"
fi

if [ 1 = ${VERBOSE} ]; then
printf "\nMake a new directory ${npmdir} for our "-g" packages\n"
fi

if [ 0 = ${DEBUG} ]; then
mkdir -p ${npmdir}
npm config set prefix $npmdir
fi

if [ 1 = ${VERBOSE} ]; then
printf "\nFix permissions on the .npm directories\n"
fi

me=`whoami`
sudo chown -R $me ~/.npm

if [ 1 = ${VERBOSE} ]; then
printf "\nReinstall packages\n\n"
fi

#list the packages to install
#and pass to npm
install='npm -g install'
if [ 1 = ${DEBUG} ]; then
install='echo'
fi
if [ -s $to_reinstall ]; then
cat $to_reinstall | xargs $install
fi

envfix='
NPM_PACKAGES="%s"
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
'


fix_env() {
if [ -f "${HOME}/.bashrc" ]; then
printf "${envfix}" ${npmdir} >> ~/.bashrc
printf "\nDon't forget to run 'source ~/.bashrc'\n"
fi
if [ -f "${HOME}/.zshrc" ]; then
printf "${envfix}" ${npmdir} >> ~/.zshrc
printf "\nDon't forget to run 'source ~/.zshrc'\n"
fi

}

echo_env() {
printf "\nYou may need to add the following to your ~/.bashrc / .zshrc file(s)\n\n"
printf "${envfix}\n\n" ${npmdir}
}

printf "\n\n"
read -p "Do you wish to update your .bashrc/.zshrc file(s) with the paths and manpaths? [yn] " yn
case $yn in
[Yy]* ) fix_env;;
[Nn]* ) echo_env;;
* ) echo "Please answer 'y' or 'n'.";;
esac

rm $to_reinstall

printf "\nDone - current package list:\n\n"
npm -g list -depth=0

How to edit files in /var/www folder

By: Ryan Wong at

To edit files in your “/var/www” folder without making the directory 777 permission do the following:

1
2
3
sudo adduser <username> www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rwX /var/www

Remember to logout and log back in to take effect.

Setup Mongodb on ubunut14.04 32 bit

By: Ryan Wong at

MongoDb 3.0 doesn’t support 32 bit systems so you will need to use version 2.4

Here are the steps:

1
2
3
4
5
6
7
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

sudo apt-get update

sudo apt-get install --force-yes mongodb

Some UI for mongodb I found were:

Setup PHPMyAdmin on ubuntu

By: Ryan Wong at

Heres steps to install phpmyadmin on ubuntu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
sudo apt-get install phpmyadmin apache2-utils

sudo nano /etc/apache2/apache2.conf
#Include at bottom
Include /etc/phpmyadmin/apache.conf

sudo service apache2 restart

sudo nano /etc/phpmyadmin/apache.conf

<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
[...]

sudo nano /usr/share/phpmyadmin/.htaccess
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/.phpmyadmin.htpasswd
Require valid-user

#add users
sudo htpasswd -c /etc/apache2/.phpmyadmin.htpasswd username

sudo service apache2 restart

How to setup your sshkey to use in bitbucket or github

By: Ryan Wong at

Here are the steps:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ssh-keygen
myhost:~ username$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Created directory '/Users/username/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 username@myhost.local
The key's randomart image is:
+--[ RSA 2048]----+
|*o+ooo. |
|.+.=o+ . |
|. *.* o . |
| . = E o |
| o . S |
| . . |
| . |
| |
| |
+-----------------+
cat ~/.ssh/id_rsa.pub

Now you just need to type this code into your version control.

Installing node on ubuntu14.04

By: Ryan Wong at

This is how I installed node on ubuntu 14.04

1
2
3
4
5
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Now you get the latest version of node.