1. git clone repository_url
Get code from server.
2. git add [.|-A]
Add local changes to be committed
3. git commit -m "msg"
Commit changes with a commit message, code on server is not changed after commit.
4. git fetch
Get the latest code from the server
5. git rebase
Play the latest changes fetched from the server to local code
6. git add . ; git rebase --continue
If there is conflict during git rebase, after solving the conflict, continue to rebase
7. git push
Push local commits to server, code on server is changed after push
Keep Learning
Friday, July 11, 2014
Change database port and enable remote access
For Ubuntu system,
MySQL Database:
Change config file
vi /etc/mysql/my.cnf
1. change 'port' under Basic Setting [mysqld] to the desired port
2. comment out binding address
Run SQL command to enable 'user' access mysql database using 'password' with all privileges:
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password';
MongoDB change port:
Change mongodb config file:
vi /etc/mongodb.conf
Check open ports: sudo netstat -anltp
Saturday, April 5, 2014
Ubuntu apt-get Install Error
When running apt-get install, got following error.
/var/lib/dpkg/info/ebtables.postinst: 6: /var/lib/dpkg/info/ebtables.postinst: update-rc.d: not found dpkg: error processing ebtables (--configure): subprocess installed post-installation script returned error exit status 127
After lots of search, finally find a solution that works for my problem:
First remove the relative files in /var/lib/dpkg/info, then reinstall
$ sudo rm ebtables* $ sudo apt-get -f install ebtables
Run OpenStack on Ubuntu
You can install DevStack on your ubuntu VM or PC to learn its features.
Notes:
"Error: unable to connect to node 'rabbit@xxx': nodedown" try to start server:
Here I have an old laptop installed with Ubuntu server 12.04.
If you haven't installed git yet, you need to install it.
$ sudo apt-get install gitDownload and install devstack:
$ git clone https://github.com/openstack-dev/devstack.gitConfigure local.conf There is a sample local.conf under devstack/samples directory. Go to samples directory and copy it to devstack/ directory.
$ cp local.conf ../
Go to devstack/ directory and edit local.conf. A simple configuration can be found here[[local|localrc]] FLOATING_RANGE=192.168.1.224/27 FIXED_RANGE=10.11.12.0/24 FIXED_NETWORK_SIZE=256 FLAT_INTERFACE=eth0 ADMIN_PASSWORD=supersecret MYSQL_PASSWORD=iheartdatabases RABBIT_PASSWORD=flopsymopsy SERVICE_PASSWORD=iheartkslRun devstack
$ ./stack.sh
Now you can access and explore your openstack dashboard via the IP of your host machine. User name is "admin" and the password is what configured in the about local.conf file.Notes:
"Error: unable to connect to node 'rabbit@xxx': nodedown" try to start server:
$ sudo rabbitmq-server start
Thursday, April 3, 2014
Codes Fusion: Setup newest Hadoop 2.x (2.2.0) on Ubuntu
Codes Fusion: Setup newest Hadoop 2.x (2.2.0) on Ubuntu: In this tutorial I am going to guide you through setting up hadoop 2.2.0 environment on Ubuntu. Prerequistive $ sudo apt-get install op...
Some notes:
1. If multiple java version are installed and default version isn't 1.7, use following command to manually switch to 1.7.
2. When running start-dfs.sh, lots of exception like: Could not resolve hostname *: Name or service not known.
After add following to /usr/local/hadoop/etc/hadoop/hadoop-env.sh, problem solved. Solution is found from here.
Some notes:
1. If multiple java version are installed and default version isn't 1.7, use following command to manually switch to 1.7.
$ sudo update-alternatives --config java
2. When running start-dfs.sh, lots of exception like: Could not resolve hostname *: Name or service not known.
After add following to /usr/local/hadoop/etc/hadoop/hadoop-env.sh, problem solved. Solution is found from here.
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
3. DataNode is not started.
I encountered this because I formatted namenode twice before I started the service. After I delete the current folder under the namenode and datanode, and again format the namenode, all services are started successfully.
Wednesday, April 2, 2014
Setup Wifi for Ubuntu Server without Cable Connection
For the first time, try to install Ubuntu Server 12.04 on an idle notebook, but found it is a lot of trouble to setup the wifi network without cable connection.
Step 1: First thing to check,
Step 2: Use lspci command to find your network controller.
Step 3: Go to find the corresponding driver package(.deb file) and download on a computer that has network connection.
Step 4: Without cable connection, you can use the USB stick to transfer the driver installation package. Using mount command to help you out. More details here
Step 5: Install driver.
Step 6: Edit your network interfaces file under /etc/network and set up the static IP address (so you can reach it by ssh or ftp). A detailed explanation for each field can be found here
wpa_passphrase your_essid your_ascii_key
For example,
Step 7: Now restart network and test your network connectivity using ping.
Step 1: First thing to check,
$ iwconfigyou should expect to see "wlan0" in the list. If not, it means there is something missing. In my case, the Ubuntu Server doesn't come with the wifi card driver for my PC.
Step 2: Use lspci command to find your network controller.
$ lspci ...... 04:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01) ......In my cast, it is BCM4312.
Step 3: Go to find the corresponding driver package(.deb file) and download on a computer that has network connection.
Step 4: Without cable connection, you can use the USB stick to transfer the driver installation package. Using mount command to help you out. More details here
//Create the Mount Point(a directory, e.g. usb) $ sudo mkdir /media/usb
//Find your usb device, something like /dev/sdb1 $ sudo fdisk -l
//Assume your device is /dev/sdb1, the filesystem is FAT16 or FAT32 $ sudo mount -t vfat /dev/sdb1 /media/usb -o uid=1000,gid=1000,utf8,dmask=027,fmask=137Now go to the mount directory and copy package to local disk.
//copy file from usb directory to local $ sudo cp /media/usb/package_name.deb /local_pathThen unmount the usb device.
//unmount your device $ sudo umount /media/usb
Step 5: Install driver.
//go to the package file directory and install $ sudo dpkg -i package_name.debAfter reboot you should see the wlan0 in your iwconfig list.
Step 6: Edit your network interfaces file under /etc/network and set up the static IP address (so you can reach it by ssh or ftp). A detailed explanation for each field can be found here
$ vi interfacesBasically, you need to set up following info:
auto wlan0 iface wlan0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 192.168.1.1 8.8.8.8 wpa-ssid <your_network> wpa-psk <your_hex_key>You need to get your paraphrased key for wpa-psk field via command:
wpa_passphrase your_essid your_ascii_key
For example,
$ wpa_passphrase "mywifi" "123123123" network={ ssid="mywifi" #psk="123123123" psk=6300c5dc74f4634edb78d8abd42903d87e2da04d1d4ac4d7843f542fa4d61d91 }The hex key generated here is what you need to provide for wpa-psk field.
Step 7: Now restart network and test your network connectivity using ping.
$ sudo /etc/init.d/networking restart
Wednesday, March 26, 2014
Launch Android App from Web Link in Browser
Most app have its official website, and you may want users to install or open your app if it is already installed when they visit the website. Here is a common solution using the intent-filter with http scheme.
In your android app, add this intent-filter in your AndroidManifest.xml so it can intercept HTTP URL and launch your app.
But you might want it to be more intelligent that if the app is installed, it launches the app directly without popup dialog. To achieve this goal, you can change the http scheme and use a custom scheme that will not be caught by other apps, and give the link your custom scheme URL (e.g. myUniqueScheme://myapp).
In your android app, add this intent-filter in your AndroidManifest.xml so it can intercept HTTP URL and launch your app.
<activity android:name="MyMainActivity" android:label="@string/app_name" android:launchmode="singleTask" android:screenorientation="portrait" android:windowsoftinputmode="adjustPan"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.LAUNCHER"/> <data android:scheme="http" android:host="myapp.com" android:path="download"/> </intent-filter> </activity>In this example, when you click a link with URL "http://myapp.com/download", a dialog will popup and let you choose to open it with the browser or your app if the app with this intent-filter is installed. If the app is not installed, the link will open in the browser by default.
But you might want it to be more intelligent that if the app is installed, it launches the app directly without popup dialog. To achieve this goal, you can change the http scheme and use a custom scheme that will not be caught by other apps, and give the link your custom scheme URL (e.g. myUniqueScheme://myapp).
<data android:scheme="myUniqueScheme" android:host="myapp"/>However, this could cause problem when the app is not installed, it cannot redirect user to the download webpage. After a lot of search, finally I find a solution from stackoverflow regarding how to handle custom url scheme. However, the solution provided couldn't work on Chrome browser. And I make some changes by using intent for Chrome browser, so it can open the Play Store and search your app if it is not installed. In the javascript webpage, add following function:
function openOrDownloadURL() { var AppURL = "myUniqueScheme://myapp"; var DownloadURL = "http://myapp.com/download"; if (navigator.userAgent.match(/Android/)) { if (navigator.userAgent.match(/Chrome/)) { window.location = "intent://myapp/#Intent;scheme=myUniqueScheme;package=com.myapp;end" } else { var iframe = document.createElement("iframe"); iframe.style.border = "none"; iframe.style.width = "1px"; iframe.style.height = "1px"; iframe.onload = function() { window.location = DownloadURL; }; iframe.src = AppURL; document.body.appendChild(iframe); } } else { // Not Android mobile window.location = DownloadURL; } }For hyperlink, change the url to javascript:
<a href="javascript:openOrDownloadURL();"> Open App </a>Now in both Chrome and Android browser by clicking the link, the app can be launched directly if it is installed. If the app is not installed, in the Android browser, it will redirect to the given download url; in the Chrome browser, it will launch Play Store and search the app by package name.
Subscribe to:
Posts (Atom)