Tuesday, April 11, 2017
Friday, March 24, 2017
Edit $PATH After Anaconda Installed If 'conda' Command Can't Be Found
Anaconda is a Python package utility which contains many great packages for scientific and mathematical computation. Users just install it once and it’s all set.
Problem after installation:
The ‘conda’ command can’t be found after Anaconda installed.
Solution:
Edit the paths file in the user’s root directory according to the shell used( bash or zsh).
if using bash shell, edit .bashrcfile.
if using zsh shell, edit .zshrcfile.
Add the following line to the end of the file and save.
export PATH="$HOME/anaconda/bin:$PATH"
Reopen the terminal and it’s all done!
Thursday, March 23, 2017
Docker Command Note
Version
$docker --version
Docker version 1.12.0, build 8eab29e$
docker-compose --version
docker-compose version 1.8.0, build f3628c7$
docker-machine --version
docker-machine version 0.8.0, build b85aac1docker pull ubuntu:14.04download latest ubuntu imagedocker imageslist all imagesdocker rundeamon mode :
docker run -d -p 80:80 [ubuntu(image name)] --name webserver nginx
-d : Run container in background and print container ID
-p : Publish a container’s port(s) to the host
80: out/ 80: in
–name : Assign a name to the container
nginx : IMAGEinteractive mode :
docker run -it ubuntu:14.04 | bash
(啟動一台 ubuntu instance,並且切入bash模式)
-i: interactive mode, 讓操作者擁有互動模式
-t: terminal, 讓操作者可以使用終端機操作 instance
docker psshow containers just running
docker ps -ashow all containers (default shows just running)docker startstart one or more stopped containersdocker stopstop one or more running containersdocker killkill one or more running containersdocker rmremove one or more containersdocker rmiremove one or more imagesdocker port xxxxlist port mappings or a specific mapping for the running container
Ubuntu Commands
- sudo apt-get update
- sudo apt-get dist-upgrade
Saturday, March 4, 2017
Python And Jupyter Installation
Install Python in Mac OS X
1. Using brew is the fastest way.
python2
> brew install python
python3
> brew install python3
2. Check The Version
> python --version
Python 2.7.10
> python3 --version
Python 3.5.1
3. Check The Location of Python and Setup The Path
Mac OS X has built-in Python 2.7. By using ‘which’ command to check the location where Python installed, you can find out whether is it the system built-in python.
> which python
usr/bin/python ⇒ system built-in
In order to access to the correct version of Python installed, we need to add /usr/local/bin to $PATH.
You can use vim to edit the /etc/paths
> sudo vim /etc/paths
make sure that /usr/local/bin is before /usr/bin.
or just…
> export PATH=/usr/local/bin:$PATH
Close the terminal and reopen it again to make sure all the settings are effective.
Then check the location of Python again.
> which python
/usr/local/bin/python
> which python3
/usr/local/bin/python3
Done!
If you always using Python 3, you can edit the setting:
> vim ~/.bash_profile
and add:
alias python="python3"
Installing Jupyter
Python2
> pip install jupyter
Python3
> pip3 install jupyter
After installation, using following command to start jupyter.
> jupyter notebookTuesday, February 14, 2017
Building iOS Map Applications in Swift 3 (2)
- Add CoreLocation.framework to BuildPhases -> Link Binary With Libraries (no longer necessary as of XCode 7.2.1)
- Add import CoreLocation to your class - probably ViewController.swift
- Add CLLocationManagerDelegate to your class declaration
- Add
NSLocationWhenInUseUsageDescription and
NSLocationAlwaysUsageDescription
to plist - Initialize location manager :
locationManager = CLLocationManager()
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
get User Location By:func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
var userLocation:CLLocation = locations[0] as! CLLocation
let long = userLocation.coordinate.longitude;
let lat = userLocation.coordinate.latitude;
//Do What ever you want with it
}
Tuesday, January 17, 2017
Close iOS Keyboard Using Swift
1. Close the virtual keyboard while finishing typing at any textField
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
2. Close the virtual keyboard while one or more fingers touch down in a view or window
Assume that finish typing in passwordFiled.@IBOutlet weak var passwordField: UITextField!
Add passwordField.delegate = self to function viewDidLoad.override func viewDidLoad() {
super.viewDidLoad()
passwordField.delegate = self
}
Add a function touchesBegan.override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
self.passwordField.resignFirstResponder()
super.touchesBegan(touches, with:event)
}
That’s it!