Nov 22, 2014
TechnologySet Proxy
The proxy setting method is the same as in Linux, just add following lines into the ~/.bashrc:
# Set the proxy
alias unsethome='unset http_proxy https_proxy ftp_proxy ftps_proxy'
alias set2383='unsethome;export http_proxy=http://xxx.xx.xx238:2383;export https_proxy=http://xxx.xx.xx238:2383;export ftp_proxy=http://xxx.xx.xx238:2383;export ftps_proxy=http://xxx.xx.xx238:2383'
So next time simply run set2383 then you could set the proxy for terminal based programs.
Package Management
brew is a very good package management tool for MAC, install it via:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install packages like following:
$ brew install wget
After installation the wget becomes available for using:
Yosemite:~ Trusty$ which wget
/usr/local/bin/wget
Brew Installed Packages
Use brew to install frequently used tools:
$ brew install wget tree
Git Configuration For Proxy
Since I worked under the proxy in office, so I need to configure a tunnel which could makes me go through the firewall:
Yosemite:Code Trusty$ git config --global user.name "xxxx"
Yosemite:Code Trusty$ git config --global user.email "xxxx@gmail.com"
Yosemite:Code Trusty$ cat ~/.gitconfig
[user]
name = xxx
email = xxx@gmail.com
Compile the connect.c via:
$ pwd
/Users/Trusty/Code/proxy
$ gcc -o connect connect.c
Configure the file via:
Yosemite:proxy Trusty$ cat sock5.sh
#!/bin/bash
/Users/Trusty/Code/proxy/connect -H 1xx.x.xx.2xx:2xxx "$@"
Yosemite:proxy Trusty$ chmod 777 *
Add the following part in your ~/.gitconfig:
[core]
gitproxy = /Users/Trusty/Code/proxy/socks5.sh
Now open a new terminal and git from a test repository via:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-git
Cloning into 'linux-git'...
remote: Counting objects: 3857384, done.
remote: Compressing objects: 100% (5000/5000), done.
^Cfatal: index-pack failed95/3857384), 436.00 KiB | 152.00 KiB/s
See? You really acrossed the firewall and reached Linus Torvalds’ git tree.
iterms2 Colorscheme
Default iterm2 is ugly, so we need to download the good style of colorschemes,
iterm2colorschemes.com
Also you could select whatever you like from the screen-shots.
Hit cmd+i then you got whatever you want import.
sudo tips
For keeping the current environment, just do following:
$ sudo visudo
Defaults env_keep += "http_proxy https_proxy ftp_proxy ftps_proxy"
Restart or open a new terminal, now your sudo command won’t fail because of the proxy configuration.
Make Alias to Chromium
The default installation of applications in mac maybe at the random place, so we have to make alias for whatever application we want to call in shell, like following:
alias chromium="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 2>/dev/null"
So next time you could directly call chromium for testing. Notice, 2>/dev/null means we don’t care about the stderr out.
Call Console in Chromium
Simply call cmd+opt+i, mapping to keyboard is win+alt+i.
List Disk Usage
Since “fdisk -l” is illegal options in MACOS, we have to use following command for displaying the disk usage:
$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *64.0 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage 63.2 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS Hard *62.8 GB disk1
Logical Volume on disk0s2
FBBDE745-2F1F-4B7A-8870-A9031F6E24CD
Unencrypted
Wallpapers
macOSx have lots of wallpapers, we could fetch it via:
scp -r /Library/Desktop\ Pictures/ xxx@10.0.0.221:/home/xxx
Then all of the pictures are now in remote machines.
updatedb
For equivalent to Linux’s updatedb, simply run:
sudo /usr/libexec/locate.updatedb
Nov 22, 2014
TechnologyThis series is the note for learning 30days30skills, the origin web pages could be found at:
http://segmentfault.com/a/1190000000349384
All of these operations should be done under MACOS rather than linux.
Day 1 - bower
First install nodejs from following position:
nodejs.org/download/
Git could be installed from APPStore.
Set npm proxy before you do everything, cause I operate under the proxy based network:
npm config set proxy http://xxx.xxx.xxx.xx:xxxx
npm config set https-proxy http://xxx.xxx.xxx.xx:xxxx
Install bower:
$ set2383 #(For setting the proxy)
sudo npm install -g bower
Using bower for install the jquery packages:
$ pwd
/Users/Trusty/Code/jQuery
$ set2383 #(For setting the proxy)
$ bower install jquery
Query the installed package information(This need to be done after you set the git configuration on proxy, because I worked under the proxy):
Yosemite:jQuery Trusty$ bower list
bower check-new Checking for new versions of the project dependencies..
jQuery /Users/Trusty/Code/jQuery
└── jquery#2.1.1 extraneous
Uninstall packages via:
Yosemite:jQuery Trusty$ bower uninstall jquery
bower uninstall jquery
Yosemite:jQuery Trusty$ ls
bower_components simpleHtml.html simpleHtml.html~
Yosemite:jQuery Trusty$ tree
.
├── bower_components
├── simpleHtml.html
└── simpleHtml.html~
1 directory, 2 files
use bower init for creating packages:
Yosemite:jQuery Trusty$ bower init
? name: blog
? version: 0.0.1
? description:
? main file:
? what types of modules does this package expose?: globals
? keywords: blog written
? authors: xxx <xxx@gmail.com>
? license: MIT
? homepage:
? set currently installed components as dependencies?: Yes
? add commonly ignored files to ignore list?: Yes
? would you like to mark this package as private which prevents it from being accidentally published to the registry?: No
{
name: 'blog',
version: '0.0.1',
authors: [
'xxx <xxx@gmail.com>'
],
moduleType: [
'globals'
],
keywords: [
'blog',
'written'
],
license: 'MIT',
ignore: [
'**/.*',
'node_modules',
'bower_components',
'test',
'tests'
]
}
Then if you installed new packages, it will automatically calculate the dependencies and write to the json.
Yosemite:jQuery Trusty$ bower install bootstrap --save
Day 2 AngularJS
Issue
Seems all of the tests has been passed expect the last one, it complains:
Error: error:areq
Bad Argument
Argument 'BookCtrl' is not a function, got undefined
The reason is because the global constructor function is not allowed to use and use it with ng-controller since Angular’s version upper than 1.3.x.
Solution
Specify the AngularJS version when installing it.
$ bower list
bower check-new Checking for new versions of the project dependencies..
AngularJS /Users/Trusty/Code/30Days/AngularJS
├── angular#1.3.3 extraneous (1.3.4-build.3611+sha.e9b9421 available)
└─┬ bootstrap#3.3.1 extraneous
└── jquery#2.1.1
Yosemite:AngularJS Trusty$ bower install "angular#<1.3"
bower angular#<1.3 not-cached https://github.com/angular/bower-angular.git#<1.3
bower angular#<1.3 resolve https://github.com/angular/bower-angular.git#<1.3
bower angular#<1.3 download https://github.com/angular/bower-angular/archive/v1.2.27.tar.gz
bower angular#<1.3 extract archive.tar.gz
bower angular#<1.3 resolved https://github.com/angular/bower-angular.git#1.2.27
bower angular#<1.3 install angular#1.2.27
Now re-view the index5.html in the browser, everything will be OK.
Another Solution
Modify the code into following:
<!DOCTYPE html>
<html ng-app>
<head>
<title>Bookshop - Your Online Bookshop</title>
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container" ng-controller="BookCtrl">
<h2>Your Online Bookshop</h2>
<input type="search" ng-model="criteria">
<ul class="unstyled">
<li ng-repeat="book in books | filter:criteria | orderBy :'name'">
<span>{{book.name}} written by {{book.author | uppercase}}</span>
</li>
</ul>
</div>
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script>
function BookCtrl($scope){
$scope.books = [
{'name': 'Effective Java', 'author':'Joshua Bloch'},
{'name': 'Year without Pants', 'author':'Scott Berkun'},
{ 'name':'Confessions of public speaker','author':'Scott Berkun'},
{'name':'JavaScript Good Parts','author':'Douglas Crockford'}
]
}
angular.module('ng').config(function($controllerProvider) {
$controllerProvider.allowGlobals();
});
</script>
</body>
</html>
I don’t know how to set the global for seperated js file, but the above example works.
Nov 21, 2014
TechnologyFor sharing the project and holding the status of developing Rohc project, I set this gitlab project.
Installation
The detailed guildeline is from following URL:
https://www.digitalocean.com/community/tutorials/how-to-set-up-gitlab-as-your-very-own-private-github-clone
But have some modifications.
Modification
Write permission problem:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby
Solved via:
$ sudo chmod -R 777 /usr/local/bin
$ sudo chmod -R 777 /usr/local/rvm
We met modernizr missing problem, do following for avoiding this:
$ sudo wget http://rubygems.org/downloads/modernizr-2.6.2.gem
$ sudo -u git -H gem install modernizr
Also you have to modify following modules in Gemfile and Gemfile.lock:
in Gemfile, line 164, change "modernizr", "2.6.2" to "modernizr-rails", "2.7.1"
in Gemfile.lock, line 292, change modernizr (2.6.2) to modernizr-rails (2.7.1)
in Gemfile.lock, line 626, change modernizr (= 2.6.2) to modernizr-rails (= 2.7.1)
Then run:
sudo -u git -H bundle install --deployment --without development test postgres aws
You could continue with your settings.
After setting we may met smtp configuration problem, simply modify the following configuration file:
$ pwd
/home/git/gitlab
$ cat ./config/environments/production.rb
# config.action_mailer.delivery_method = :sendmail
# # Defaults to:
# # # config.action_mailer.sendmail_settings = {
# # # location: '/usr/sbin/sendmail',
# # # arguments: '-i -t'
# # # }
# config.action_mailer.perform_deliveries = true
# config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'nwsxxx.xxx.xxxxxx.com',
:port => 25,
:domain => '1xx.2xx.xxx.xxx'
#:domain => '1xx.2xx.xxx.xxx',
#:authentication => :plain,
#:user_name => 'gitlab@yourserver.com',
#:password => 'yourPassword',
#:enable_starttls_auto => true
}
Existing problem
The smtp method won’t send out the letters to the external users, I mean the email could only be used intranet not internet.
Git command
Using different branches for holding code:
[root@Linux01 twal]# pwd
/root/code/rohctest/twal
[root@Linux01 twal]# git branch
Dev_For_ECCMU/ECCM2
DirectoryBasedTestcases
eccm2
* master
[root@Linux01 twal]# git checkout eccm2
Switched to branch 'eccm2'
[root@Linux01 twal]# git branch
Dev_For_ECCMU/ECCM2
DirectoryBasedTestcases
* eccm2
master
So now you are in the eccm2 branch, do:
$ export TUT_CFG_FILE=/root/code/gencfg_114/wal_tuni_ipconn53.cfg
$ ./rohcFun11.py
If you want to test on eccmu, simply brach back to master via:
$ git checkout master
$ export TUT_CFG_FILE=/root/code/gencfg_117/wal_tuni_ipconn53.cfg
$ ./rohcFun11.py
Push all of the branches to the remote repository:
$ git push --all
Nov 20, 2014
TechnologyFixed IP
First configure the IP for Yosemite on router, since the Archlinux takes the 221, Yosemite may use 220 for its fixed ip.
ArchLinux Setting
I use ArchLinux as the synergy server, so first install synergy via:
$ sudo pacman -S synergy
I want to place Yosemite at the right of the ArchLinux, So just configure the /etc/hosts like following.
$ tail /etc/hosts
# For setting Synergy
10.0.0.220 Yosemite.lan Yosemite
Configuration:
[root@kkkkttt kkkt]# cp /etc/synergy.conf.example /etc/synergy.conf
For easily configure the synergy, download qsynergy.
$ sudo pacman -S qsynergy

Then store its configuration to the /etc/synergy.conf.
Start the server and enable the server.
# systemctl enable synergys@mary
# systemctl start synergys@mary
Yosemite Setting
Download the SynergyKM from http://synergykm.com/, and configure the SynergyKM connected to 10.0.0.221.
Also you have to check Start at login
Now place the Yosemite at the left of the ArchLinux, your mouse and keyboard could be freely switching from 2 machines.
Nov 18, 2014
TechnologyTOP Result
Via top we saw:
2615 mysql 20 0 949.7m 450.7m 0.0 5.7 0:02.62 S mysqld
This caused too much memory be wasted while my blog uses the static pages.
Solution: I will use a light-weighted web-server.
Disable xampp
Disble and remove the service of xampp via following command:
[root@kkkktt kkk]# systemctl stop xampp.service
[root@kkkktt kkk]# systemctl disable xampp.service
Removed symlink /etc/systemd/system/multi-user.target.wants/xampp.service.
lighttpd
Install via following command and test its configuration:
$ sudo pacman -S lighttpd
[kkk@~]$ ls /etc/lighttpd/lighttpd.conf
/etc/lighttpd/lighttpd.conf
[kkk@~]$ lighttpd -t -f /etc/lighttpd/lighttpd.conf
Syntax OK
Test the webpages:
[kkk@/srv]$ sudo echo 'TestMe!' > /srv/http/index.html
[kkk@/srv]$ chmod 755 /srv/http/index.html
[kkk@/srv]$ sudo systemctl start lighttpd
[kkk@/srv]$ sudo systemctl enable lighttpd
Created symlink from /etc/systemd/system/multi-user.target.wants/lighttpd.service to /usr/lib/systemd/system/lighttpd.service.
Use your browser for navigating the http://127.0.0.1, then you could visit this test page.
OctoPress Changes
Add following lines into the rakefile:
system "jekyll"
# Use rsync for syncing the server directory with the public directory
system "rsync -vzrtopgu -progress /home/kkk/code/octo/heroku/Tomcat/public/* /srv/http"
Then everytime when you type rake generate, after generate the static website, the rsync will automatically sync the public folder with remote web server folder /srv/http.