Maintain the repository using Git

Refer to the thoughbot’s guide,
https://github.com/thoughtbot/guides/tree/master/protocol/git
and
http://www.ruanyifeng.com/blog/2015/08/git-use-process.html
and
https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository

From these two articles, We can know how to manager the repository using gig and the ways he maintains the repository. I paste all the content of his article below.

While one thing has to be paid attention to:

1 The adding or modifing on config file like config.js would be ignored. Check the file with
nano .gitigore
to see if it’s tracked and ignored.
2 Or
git add config.js -f
to add the files needed to commit.
3 when running
git commit –verbose
to track all the updates. The listed commit have to be uncomment, like
Changes to be committed:
modified: app.js

otherwise, changes won’t be executed.

Write a Feature

Create a local feature branch based off master.

git checkout master
git pull
git checkout -b
Rebase frequently to incorporate upstream changes.

git fetch origin
git rebase origin/master
Resolve conflicts. When feature is complete and tests pass, stage the changes.

git add –all
When you’ve staged the changes, commit them.

git status
git commit –verbose
Write a good commit message. Example format:

Present-tense summary under 50 characters

* More information about commit (under 72 characters).
* More information about commit (under 72 characters).

http://project.management-system.com/ticket/123
If you’ve created more than one commit, use git rebase interactively to squash them into cohesive commits with good messages:

git rebase -i origin/master
Share your branch.

git push origin
Submit a GitHub pull request.

Ask for a code review in the project’s chat room.

Review Code

A team member other than the author reviews the pull request. They follow Code Review guidelines to avoid miscommunication.

They make comments and ask questions directly on lines of code in the GitHub web interface or in the project’s chat room.

For changes which they can make themselves, they check out the branch.

git checkout
./bin/setup
git diff staging/master..HEAD
They make small changes right in the branch, test the feature on their machine, run tests, commit, and push.

When satisfied, they comment on the pull request Ready to merge.

Merge

Rebase interactively. Squash commits like “Fix whitespace” into one or a small number of valuable commit(s). Edit commit messages to reveal intent. Run tests.

git fetch origin
git rebase -i origin/master
Force push your branch. This allows GitHub to automatically close your pull request and mark it as merged when your commit(s) are pushed to master. It also makes it possible to find the pull request that brought in your changes.

git push –force-with-lease origin
View a list of new commits. View changed files. Merge branch into master.

git log origin/master..
git diff –stat origin/master
git checkout master
git merge –ff-only
git push
Delete your remote feature branch.

git push origin –delete
Delete your local feature branch.

git branch –delete

Network problem on the server

I use Asus notebook as the server installed with Ubuntu and ThinkPad with windows as workstation. SecureCRT is used to connect the server with the workstation. Since I want to have the static IP on the server, I have to modify the network config files on nano /etc/network/interfaces. Like the ones below.
Initially, it works. Server can maintain the static IP while days later, while network on server does not work very well. It is offline occasionally. Weird things happen, I ping the server on workstation, remote host reachable. And I can connect the server with secureCRT on workstation and visit server through ftp. while occasionally errors happen. While I ping the workstation from the server, result is that remote host unreachable. I restart the network with commands like

sudo /etc/network/init.d restart
sudo service network-manager restart
sudo ifconfig eth0 down && ifonfig eth0 up

problems remains. And the server seems become unstable and it develope to the situation that network interrupts thorougly. Then I have to comments all the configuration on the config file. Everything works properly. And the IP remains static booting everytime. I search on internet while I can not find the answer.

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#auto eth0
#iface eth0 inet static
# address 192.168.1.12
# netmask 255.255.0.0
# gateway 192.168.1.1
# broadcast 192.168.255.255
# dns-nameservers 223.5.5.5
#42.120.21.30

#wireless network
# auto wlan0
# iface wlan0 inet static
# netmask 255.255.255.0
# gateway 192.168.1.1
# address 192.168.1.108
# pre-up link set wlan0 up

Looking for an English teacher in Canton city(guangzhou)

I have been back to my home in Canton from for almost two months. Since I am so regret that we could not stay longer in Finland to let my kid to continue to attend the English kindergarten in Finland which my kid likes so much, I would like him to learn Foreign language in canton city. But he dislike the kindergarten here so much because he doesn’t like the education and environment of the school here at all and unwilling to go. Then I would like to set up an English club for him. But the biggest problem now is that I coudl not find the suitable teacher.

Are you a Native English speaker? Would you like to join me to set up this English club for the kids!

Mongodb

The system doesn’t response the link from the validate url, and no user has sign up as validate user. And from the code, I do not know which account name and password can be used as admin (actually not admin). Then I think that I should modify the property in the mongodb to change the property of active from false to true. Then the system will be deceived and consider the login name as a validate account.

Open the shell of mongodb:
sudo mongo

help command to see the executable comand:
help

show dbs show database names
show collections show collections in current database

use set current database
db.foo.find() list objects in collection foo

in this project:
use node_club_dev
db.users.find()

Then it shows all the records in collection users.

If execute the command:
db.users.findAndModify({query:{“loginname”:”admin”},update:{“receive_at_mail” : true, “receive_reply_mail” : true, “active”:true},upsert: false})

It will produce errors:
Error: findAndModifyFailed failed: {
“errmsg” : “exception: E11000 duplicate key error index: node_club_dev.users.$loginname_1 dup key: { : null }”,
“code” : 11000,
“ok” : 0
}
at Error ()
at DBCollection.findAndModify (src/mongo/shell/collection.js:636:15)
at (shell):1:10 at src/mongo/shell/collection.js:636

Saying that duplicate key error.
So change to
db.users.findAndModify({query:{“loginname”:”admin”},update:{ “email” : “ff.dd@tom.com”,”loginname”:”admin”,”active”:true}})

Adding the loggin name to the modify field, then error disappear, and the property changed.

nodemailer

mail.js in common folder is used to send the validate email. After registering the user account or login in the system, system will send a verify email to validate the email. But the destiny mailbox can not recieve any validate email from the system.

And the console of the server print the below error information:
{ [Error: read ECONNRESET]
code: ‘ECONNRESET’,
errno: ‘ECONNRESET’,
syscall: ‘read’,
stage: ‘data’ }
errors happens!

The messages should come from
console.log(err);
console.log(‘errors happens!’);

in function of
transport.sendMail(data, function (err)
in the file of
mail.js

I solve the problem in the following steps:
1 google the error, seems that is relates to dns problem,
ping http://www.baidu.com and the smtp server:smtp.126.com
it can reach the destination.
Then I change the DNS server from 8.8.8.8 to another applicable DNS server.
But errors still exist.
2 Check the config file:config.js
correct the errors, and try many other smtp server, problem still exists.
3 google it, saying that smtp.126.com smtp server has to be connected with special access code. Then I Register it and got the authorized code and password. Then modify the config file.

Then the system can send the validate email properly. But when linking the url to verify the email, server does not response.

Note: Sometimes, the server occasionaly occurs the ping promble, occasionaly, it can get through http://www.baid.com and smtp.126.com and even can not reach the router 192.168.1.101 and the workstation on the same network while it can be visited by ftp and ssh with other work station. So strange!

CNnode club

Cn nodeclub project has started since last year in Finland. At that time, it can run on the ubuntu server and visited by browser with :3000
But it yet was not able to have posts on.
Now go on this project at the stage, before I find a job or maybe after getting a job then as a part time interest.

Notice that following the structions to install node,the packages needed and redis-server and mongodb. Errors still exists and node can not run properly.

The method solving the problems is to reinstall all the rely packages with npm, install a lower version of node, such as v0.10.40 with nvm. Then it works. As I know, at least v0.12.6 deosn’t work properly.

Steps to start the program:
1 start redis-server:
sudo redis-server
2 start mangodb
sudo mangod
3 list the existing node version:
nvm ls
4 use the proper version of node:
nvm use v0.10.40
5 start the program
node app.js

NodeClub listening on port 3000
God bless love….
You can debug your app with http://192.168.1.105:3000

ftp server set up in Ubuntu with upload funtion

I continue to use my Ausus x45v notebook as server and write codes on my IBM notebook. Then problems come out: how can I share the file. Easy, set up the ftp. server to share the file.

vsftpd is a easy tool to set up the ftp server in Ubuntu. It is easy to find the official documents from the help of ubuntu.com
https://help.ubuntu.com/lts/serverguide/ftp-server.html

To install the ftp server:
sudo apt-get install vsftpd

To set the ftp directory /federer for sharing:
sudo usermod -d /federer ftp

edit and set the configuration file:
sudo nano /etc/vsftpd.conf:

To make the ftp server writable:
write_enable=YES
anon_upload_enable=YES

Then restart to make the config file effective:
sudo restart vsftpd

Ftp server can be visited, But uploading function is prohibit.

Following the guide below, Adding some security users deosn’t work either.

How to setup FTP server on ubuntu 14.04 ( VSFTPD )

Problem still exists.

At last, I solve the problem by doing this:
sudo chmod a-w /federer

The reason is that, property of folder /federer is read only!
It has to be changed to writable first!

Note, the commands for adding ftp users:
sudo useradd -d /home/ftp -M ftpuser
sudo passwd ftpuser

http://www.cnblogs.com/CSGrandeur/p/3754126.html

Back from Finland and stay at Canton China home

I am back to home Canton China and hunting for job now. During these days I find that Nodejs is a really hot topic in the back-end development career. While hunting for the job as hardware development engineer, the area where I have over 6 six years of work experience, I would like to develope my skills in Nodejs development and phonegap development. Of course, I still like to work as hardware engineer. Maybe, I aslo would like to develop my business: import and export products to and from China.

But at the moment, I have set up the server at home to continue Nodejs project starting in Finland half year agao.

Set up Samba file server on Ubuntu 14.04.02 LTS

Monitor of my laptop doesn’t perform well that it makes me my eyes tired even watch in a short period. But the PC displays really well and it runs in a quite fast speed. So I also need to code on PC and run on server on laptop. Sama server comes out natually.

I follow the guides from

https://help.ubuntu.com/lts/serverguide/samba-fileprint-security.html

and

http://www.liberiangeek.net/2014/07/ubuntu-tips-create-samba-file-server-ubuntu-14-04/

and

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/StandAloneServer.html#id2574171

Like this:

sudo nano /etc/samba/smb.conf

In this file, we’ll want to add Samba global configuration directives block below.

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no

The configuration block above defines how security is managed, which server name to use to connect and the workgroup that’s assigned to the server.

When you’re done entering the global config block above save the file and exit.

  • Creating Samba Shares

Now that we’ve installed Samba and set it’s global configuration, let’s go and create the directory we’ll want to share with everyone.

sudo mkdir -p /home/nodeshare

After the directory is created, make sure to change the ownership of it to nobody. This allows everyone to have access to it. To do that, run the commands below.

cd /home
sudo chmod -R 0755 nodeshare
sudo chown -R nobody:nogroup nodeshare/

  • Enabling Samba Shares For Allaccess Directory

The next step now is to define the allaccess directory in Samba configuration file to enable all access via Samba. To do that, type the share block below to allow full access to everyone using Samba or SMB protocol.

[nodeshare]
path = /home/nodeshare
browsable = yes
writable = yes
guest ok = yes
read only = no

Now Samba configuration should should look like the block below. Samba global block and all access defined.

[global]
workgroup = TAMK
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no
#============================ Share Definitions ==============================
[nodeshare]
path = /home/nodeshare
browsable =yes
writable = yes
guest ok = no
read only = no

Restart Samba by running the commands below.

sudo service smbd restart

Save the file and try to access the nodeshare share from a Windows client. To do that click the Run box and type \\ubuntu\nodeshare or \\ubuntu_ip\nodeshare

the folder can be accessed. But it indicates that there are no permissions to write.

I log in as ubuntu sudo user name and password and access the files and dirctories and change the ownership of it to nobody. But problem remains.

and I comment already the command in the samba config file:

valid users= %S

which disable the function of only ‘usrename’ can connect to \\server\username

But problems still.

At last I solve it set the path to

path = /home/username

or

path = /home/

Then the files and directories under home or my username can be read and written by my PC. The only directories which belong to default created like Documents and Downloads can be implemented. Those folders that are created by myself can not be written yet.

I doublt it is caused by the file access previlige problem.But sudo chmod and sudo chown list above should be implementable. But problem stays still.

Set up a ubuntu 14.04.02 LTS Node.js server

There are tons of essays or tutorials available that introduce how to set up a ubuntu Node.js server. For me, the workable way is:

to Install through NVM which stands for “Node.js version manager”

Here is the detail from:

To start off, we’ll need to get the software packages from our Ubuntu repositories that will allow us to build source packages. The nvm script will leverage these tools to build the necessary components:

sudo apt-get update
sudo apt-get install build-essential libssl-dev

Once the prerequisite packages are installed, you can pull down the nvm installation script from the project’s GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:

curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh

This will download the script and run it. It will install the software into a subdirectory of your home directory at

~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.

Here, for me, I use /home/federer/.profile instead of ~/.profile since my home file path is  /home/federer. Both should be OK.

To gain access to the nvm functionality, you’ll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:

source ~/.profile

Now that you have nvm installed, you can install isolated Node.js versions.

To find out the versions of Node.js that are available for installation, you can type:

nvm ls-remote
v0.11.12
v0.11.13
...
V0.12.7

As you can see, the newest version at the time of this writing is v0.11.13. You can install that by typing:

nvm install 0.11.13

For me, I install v0.12.6

Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:

nvm use 0.11.13

For me, I use v0.12.6

When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:

node -v
 
v.0.12.6

If you have multiple Node.js versions, you can see what is installed by typing:

nvm ls

If you wish to default one of the versions, you can type:

nvm alias default 0.11.13

This version will be automatically selected when a new session spawns. You can also reference it by the alias like this:

nvm use default

Each version of Node.js will keep track of its own packages and has npm available to manage these.

You can have npm install packages to the Node.js project’s ./node_modules directory by using the normal format:

npm install express

If you’d like to install it globally (available to the other projects using the same Node.js version), you can add the -g flag:

npm install -g express

This will install the package in:

~/.nvm/node_version/lib/node_modules/package_name

Installing globally will let you run the commands from the command line, but you’ll have to use link the package into your local sphere to require it from within a program:

npm link express

You can learn more about the options available to you with nvm by typing:

nvm help
nvm help

Conclusion

As you can see, there are a quite a few ways to get up and running with Node.js on your Ubuntu 14.04 server. Your circumstances will dictate which of the above methods is the best idea for your circumstance. While the packaged version in Ubuntu’s repository is the easiest, the nvm method is definitely much more flexible.

Note: for me, other two methods list on this page do not work, so I just use NVM

And everytime reboot the system, it has to command to boot the node server. though there should be some setting to boot the node server automatically:

nvm use 0.12.6