Nov 22, 2014
TechnologyIn fact this series is not only for customization of the surface pro, it becomes the written-tips for what I’ve installed on my ArchLinux. So later all of the necessary packages installation I will record them here.
1. postgres
Install via:
sudo pacman -S postgresql
Start postgresql service:
$ sudo systemctl start postgresql
Now begin to configurate the postgres:
$ sudo -i -u postgres
[postgres@kkkttt ~]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'
[postgres@kkkttt ~]$ createuser --interactive
Enter name of role to add: kkkt
Shall the new role be a superuser? (y/n) y
Test of create temp db via:
[kkkt@/usr/lib/systemd/system]$ createdb kkkttmp
2. dhclient
Sometime we really need this dhclient for debugging. Especially when you want to get the specified port address.
sudo pacman -S dhclient
3. dnscrypt-proxy
At most of the times the dns will be pulluted, so need this guy for sending the encrypted quest and get the response the safe DNS provider.
sudo pacman -S dnscrypt-proxy
4. cmake
For making some opensource projects:
sudo pacman -S cmake
5. cbatticon
This little tool is for displaying battery status at the tray, install it via:
sudo pacman -S cbatticon
Add it to the singleview/dualview/triview setting files.
6. nitrogen
For setting up different picture at startup.
$ sudo pacman -S nitrogen
Add following line into the startup file:
$ nitrogen --restore
7. nmap
For scannning all of the living machine in the LAN.
sudo pacman -S namp
Scan via:
nmap -sP 192.168.1.*
Nov 22, 2014
TechnologyJust for recording the steps, later I will use it for re-installation.
1. Insert the FlashDisk, re-partition the harddisk, and install the system. After everything is OK, restart.
2. Choose start from HardDisk(ignore the caches and eject kext), Now the system will ask you for configuration, Select US-keyboard/Canada, after entering the system, simply change the language from Italian to English.
Install Clover to the Harddisk. The default installtion will failed, then you have to manually mount the EFI partition, and copy the EFI/ folder under the “/” directory to EFI partition.
Copy the DSDT and SSDT from the Surface downloaded folder. config.plist from http://www.insanelymac.com/forum/topic/301884-guide-surface-pro-1st-gen-yosemite-clean-installation/page-2#entry2077531
Use kdrop for dropping the kext files under Surface/ folder, don’t install yosemite specified. Ignore the apple’s framebuffer.
Then restart. This time we could remove the flashdisk to let SurfacePro start by itself.
3. After restarted, remove the EFI in / folder(Not the EFI folder!!!), then dropped the Yosemited specifed kext. Restart.
4. Install the dp kext, and replace the dp related config.plist, Restart.
5. Install the ethernet card, mine have the USB ethernet adapter and also USB wireless adapter, install the ethernet adapter first, mine is AX8872 usb adapter, simply download the package from webiste, install it. Then restart.
Restart and the system becomes not stable, it seems the AX8872 harms the system.
Re-dropped the Yosemite specified KEXT, for try. After re-dropped, restart the system.
Seems no effect, OK,finally we remove the EFI and re-copy the EFI into the system( Go back to step 2, recover the EFI and re-dropped the kexts excpect Yosemite specified), and restart.
Now the video seems OK, re-dropped the yosemite specified kexts, then restart.
Now Usb Ethernet Adapter is OK. Enable the ssh and now we could remotely sent files to it.
Install the USB Wireless adapter’s driver via: TL-WN725N_v2_USB_MacOS10.8.zip
, this one is simply downloaded for r8188eu chipset, mine is “fast” but it’s actually the copy of TP-LINK WN725N.
Since we replaced the EFI with the original EFI, we have to re-dropped the framebuffer and replace the dsdt file and replace the EFI’s config.plist for supporting DP output. Now restart.
Notice, normally if you replaced the dsdt file, the restart procedure may be pretty long, and it possibly runs into error cases.
6. Fortunately we runs into the correct case, so last step we install the NullEthernet driver. This driver enables your ethernet card acts like a built-in card, thus you could visit app store. First you dropped the kext, then you use a tool named MaciASL for editing the dsdt file, patched the “patch.txt”, save to dsdt, and restart.
6-1 Bad Luck, the system got very slow again, so go back to Step 2, remove the installed EFI, then re-dropped the kexts excepts the Yosemite and others, restart.
6-2 The video goes OK, continue for dropping yosemite specified Kexts, then restart.
6-3 At this moment we still could not reached App store, so installed the DisPlay Port patches, and re-start.
6-4 Finally we could re-install the NullEthernet Drivers. But wait!!! Because this time I installed the fucking injector. This package causes the system un-stable again. And it seems the system is pretty slow, but we still got login window, simply go to /S/L/E, and remove the installed NUllEthernetInjector.kext. Then use disk utils for checking the volumn and repare the permission.. REstart to see the effect.
6-5 No recover, go back to 6-1 ~ 6-3.
6-6 Install the NullEthernet.kext, and applied the pathes, restart and wait for result.
6-7 Failed, I doubt if it’s because the wireless and ethernet adapter both OK, so remove wireless, and do the experiment again.
6-8 This time didn’t replace the dp , But installed the NullEthernet and applied the patch. Then delete all of the configuration of the network card, and also removed all of the devices and the configuration file under the /L/Preferences/Systemconfig/network.plist OK.
Nov 22, 2014
TechnologyHeroku Postgres
I wrote the weather app which holds at:
http://python-weather-app.herokuapp.com
At around half a year it grows around 7MB, so I begin to think of how to back it and migrate to other platforms.
Following is the steps for viewing and operation on postgres database:
$ heroku login
$ heroku config
$ heroku addons | grep POSTGRES
$ heroku pg:info
Backup
Install the addons of pgbackups for backing up the existing databases:
$ heroku addons:add pgbackups
$ heroku pgbackups:capture
Use following command for store the backup locally:
$ curl -o latest.dump `heroku pgbackups:url`
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U Trusty -d weatherdb latest.dump
View the data
Using following commands for viewing the data:
$ psql weatherdb
weatherdb=# \dt;
List of relations
Schema | Name | Type | Owner
--------+-------------+-------+-------
public | avg_weather | table | Trusty
public | user | table | Trusty
public | weather | table | Trusty
(3 rows)
weatherdb=# select * from weather;
weatherdb=# select * from avg_weather;
By this you could dump all of the datas which already held in this postgres database.
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.