Last active
December 15, 2015 17:49
-
-
Save kongliangzhong/5298834 to your computer and use it in GitHub Desktop.
miscellaneous
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### github related ##### | |
---- emacs gist ---- | |
git://github.com/defunkt/gist.el.git | |
# What's new in 1.0 ? | |
gist.el now maintains a local cache so as to not go to the gist server every now and then. | |
multi-files gist support (indicated by a '+' in the gist list) | |
improved gist-list buffer, based on tabulated-list.el (same codebase as package.el) New keybindings: | |
g : reload the gist list from server | |
e : edit current gist description | |
k : delete current gist | |
+ : add a file to the current gist | |
- : remove a file from the current gist | |
in-place edition. While viewing a gist file buffer, you can: | |
C-x C-s : save a new version of the gist | |
C-x C-w : rename some file | |
dired integration. From a dired buffer, you can: | |
@ : make a gist out of marked files (with a prefix, make it private) | |
-------------------- | |
---- git with github ---- | |
## first time init: | |
1) sudo apt-get install git-core git-doc git-gui | |
2) ssh-keygen -t rsa -C "xxxxx..." | |
3) git config --global user.name "xxx" | |
4) git config --global user.email "xxx@xxx" | |
5) git config --global github.user "xxx" | |
6) git config --global github.token "############" | |
7) git init | |
8) git add . | |
9) git commit | |
10) git remote add <name> git@github.com:kongliangzhong/<repo-name>.git | |
11) git push -u <name> master | |
## pull a repository from git to local directory: | |
1) mkdir proj-name | |
2) cd proj-name | |
3) git init | |
4) git pull https://github.com/twitter/finagle.git | |
## after init, update files: | |
0. git add *** | |
1. git commit -a | |
2. git push | |
------------- | |
########################## | |
########## GIT ########### | |
-- git branch and merging: | |
--> git branch: list branches. | |
--> git branch name : create new branch. | |
--> git checkout branchName: switch to branch. | |
--> git checkout -b newBranchName: create branch and switch to it. | |
--> git merge branchName: merge branch. | |
--> git branch -d branchName: delete branch. | |
-- git fetch , commit, push: | |
--> git pull --rebase origin master | |
--> git fetch origin master | |
--> git fetch && rebase origin/remote-branch-name | |
-- merge multiple commits as one: | |
--> git rebase -i origin/master | |
-- discade local changes: | |
answer 1. git stash save --keep-index | |
answer 2. git checkout -- . | |
answer 3. git clean -df & git checkout . | |
-- discade local commit: | |
1. if you don't want to keep the changes: git reset --hard HEAD~1 | |
(same as: git reset --hard HEAD^) | |
this will change files to perior state. | |
2. cancel last local commit: git reset --soft HEAD~1 | |
same as git reset HEAD~1 | |
-- restoring lost commit: | |
if you did git reset --hard HEAD~1 and you want to restore it: | |
step1: git fsck --lost-found | |
step2: git reflog | |
step3: git merge b4b8f31 // last is the sha1 of commit shown by reflog | |
-- reslove: Pull is not possible because you have unmerged files: | |
--> step1: git fetch origin | |
--> step2: git reset --hard origin/master | |
-- commit specific commit: | |
step1: use git rebase -i to re-orgnize commit. | |
step2: git push <remote> <commit-sha>:<remote-branch>, will push all the commit before this commit. | |
e.g. git push origin 2a770c125abfb4eb26a86ebd342dcc00533f3420:refs/for/master | |
-- add external difftool meld to git: | |
git config --global diff.tool meld | |
########################## | |
### GitLab ### | |
1) default install path on ubuntu: /var/opt/gitlab | |
2) install gitlab on ubuntu12.04: | |
Download the Omnibus package and install everything: | |
wget https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_7.6.1-omnibus.5.3.0.ci.1-1_amd64.deb | |
sudo apt-get install openssh-server | |
sudo apt-get install postfix # Select 'Internet Site', using sendmail instead also works, exim has problems | |
sudo dpkg -i gitlab_7.6.1-omnibus.5.3.0.ci.1-1_amd64.deb | |
Configure and start GitLab: | |
sudo gitlab-ctl reconfigure | |
Browse to the hostname and login: | |
Username: root | |
Password: 5iveL!fe | |
For troubleshooting and configuration options please see the Omnibus GitLab readme | |
3) start and stop gitlab service: | |
sudo gitlab-ctl start/stop | |
4) migrate note(from old git repository to gitlab): | |
a) clone the old repo onto a dev machine: git clone --mirror git@github.com:me/myrepo.git | |
b) create a blank repo on the new gitlab. add user access to the repo. | |
c) add the new repo as a remote on the dev machine: cd myrepo.git; git remote add newRepo git@gitlab.com:me/myrepo.git | |
d) push everything back to the new repo: git push --mirror newRepo | |
############## | |
### openoffice libreoffice calc | |
## combine two columns formula: =A1&"="&B1 // A and B is the column name. | |
### install jboss-7.1 on ubuntu 13.04 ### | |
1) download jboss: | |
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip | |
2) unzip: | |
sudo unzip jboss-as-7.1.1.Final.zip -d /usr/share/ | |
3) for security reasons, create a new user to run jboss: | |
sudo adduser jboss | |
4) sudo chown -fR jboss.jboss /usr/share/jboss-as-7.1.1.Final/ | |
5) su - jboss | |
6) add management user: | |
cd /usr/share/jboss-as-7.1.1.Final/bin | |
./add-user.sh | |
### jenkins on ubuntu ### | |
1) install | |
2) stop/restart: sudo /etc/init.d/jenkins stop/restart | |
####### | |
### deploy with glu ### | |
1) prepare: publish war/jar on nexus. | |
####################### | |
### linkedin glu 5.5.3 ### | |
## set up without https: | |
1) cd /tmp/glu | |
2) keys setup: def keys = null // use http, not https. | |
3) prepare meta model file. | |
4) generate distributions: | |
$GLU_HOME -D -o ./dists ./glu-meta-model.json.groovy | |
5) setup distributions. use scipts in dists/bin/install-all.sh | |
config scp credentials first: ssh-copy-id user@host | |
glu error 1001. connection error. | |
## setup with keys in tutorial: | |
1) rm -rf /tmp/glu/* ; cd /tmp/glu | |
2) generate distributions: // use keys in tutorial. or you can generate your own keys. | |
$GLU_HOME/bin/setup.sh -D --keys-root $GLU_HOME/models/tutorial/keys -o ./dists ./glu-meta-model.json.groovy | |
3) start zookeeper on each host: cssh host1 host2 ... | |
cd GLU_INSTALL_PATH | |
./org.linkedin.zookeeper.../bin/zookeeperctl.sh start | |
4) config zookeeper: | |
cd /tmp/glu | |
$GLU_HOME/bin/setup.sh -Z -o ./dists ./glu-meta-model.json.groovy | |
5) start agent in each host: cssh ... ; cd ~/glu; ./bin/agentctl.sh start | |
6) test setup so far: | |
/<path to outputFolder>/agent-cli/org.linkedin.glu.agent-cli-<version>/bin/agent-cli.sh -s https://<agent host>:12906/ -m / | |
7) start console: | |
### errors handle: | |
1) 1001: communication error: check all your /etc/hosts files. make sure all agent's computer name and ip are configured in each agent host's /etc/hosts file.. | |
## install glu with generated keys: | |
1) generate keys: $GLU_HOME/bin/setup.sh -K | |
then copy output keys def to meta-model. | |
2) create meta-model file. | |
3) generate distributions: | |
$GLU_HOME/bin/setup.sh -o ./dist -D <path-to-meta-model-file> | |
4) install distributions to each agent: | |
config scp credentials with: ssh-copy-id user@host | |
use dists/bin/install-all.sh to transfer distributions to each host. | |
5) start zookeeper on each agent: | |
<path-glu-install>/<zookeeper-dir>/bin/zookeeperctl.sh start | |
6) configuring zookeeper cluster: | |
$GLU_HOME/bin/setup.sh -o ./dists -Z <path-to-meta-model-file> | |
7) start glu agents on each agent-host: | |
8) test setup so for: | |
<agent-cli>/bin/agent-cli.sh -s https://<agent-host>/:12906 -m / | |
9) start the console, and login. default user/password: admin/admin | |
########################## | |
### ZOOKEEPER ### | |
1) connect to zookeeper use zkClient.sh: | |
################# | |
### SSH RELATED ### | |
1) manage multi ssh keys in .ssh: | |
specify ssh identity file in .ssh/config file. for example: | |
Host git.unionpaysmart.com | |
Hostname git.unionpaysmart.com | |
IdentityFile ~/.ssh/upsmart_rsa | |
IdentitiesOnly yes | |
################### | |
###### PKI/SSL ###### | |
## create openssl keys: | |
1) mkdir -p pki/keys; cd pki/keys | |
2) openssl req -new -newkey rsa:1024 -nodes -out ca.csr -keyout ca.key | |
3) openssl x509 -trustout -signkey ca.key -days 1825 -req -in ca.csr -out ca.pem | |
4) echo "02" > ca.srl | |
## Create a server certificate and keystore: | |
1) keytool -genkey -dname "cn=zhongkl" -alias emo -keyalg RSA -keystore $EMO_DIR/emokeystore -keypass 123456 -storepass 123456 | |
2) keytool -import -keystore $EMO_DIR/emokeystore -file ca.pem -alias selfca | |
3) config tomcat to support ssl: | |
<Connector port="8443" maxHttpHeaderSize="8192" | |
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" | |
enableLookups="false" disableUploadTimeout="true" | |
acceptCount="100" scheme="https" secure="true" | |
clientAuth="false" sslProtocol="TLS" | |
keystoreFile="$EMO_DIR/emokeystore" | |
truststoreFile="$EMO_DIR/emokeystore" | |
keystorePass="$PASS" | |
truststorePass="$PASS" | |
keyAlias="emo" | |
/> | |
startup tomcat, and https should work fine. | |
## Set Up Client Authentication: | |
change tomcat conf/server.xml: clientAuth="true" | |
restart tomcat. https not work. that is fine. | |
1) openssl req -new -newkey rsa:1024 -nodes -out client1.req -keyout client1.key -subj '/C=US/ST=California/CN=emoclient/EMAILADDRESS=myexpressoemail@mymailhost.com' | |
2) openssl x509 -CA ca.pem -CAkey ca.key -CAserial ca.srl -req -in client1.req -out client1.pem | |
3) openssl pkcs12 -export -in client1.pem -inkey client1.key -out client1.p12 -name "Sample Client Cert" | |
4) copy file client1.p12 to client, and import to browser. | |
now tomcat start page in SSL should work fine. | |
##################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment