start up engineering notes

<pre>最近在学习start-up engineering 的公开课,做了一些notes,保持更新</pre>

notes


ssh to amazon server
chmod 400 mykepair.pem
ssh -i mykeypair.com ec2-54....compute.amazonaws.com
  • fast way
mkdir -p ~/.ssh
cp ~/downloads/skey.pem ~/.ssh/
chmod 400 ~/.ssh/skey.pem
chmod 700 ~/.ssh
nano ~/.ssh/config # edit the file as shown below
cat ~/.ssh/config
Host awshost1
HostName ec2-54-218-35-71.us-west-2.compute.amazonaws.com
 User ubuntu
 IdentityFile "~/.ssh/skey.pe
  • connect
ssh awshost1
ssh awshost1 uptime
list all environmental variables
env
common commands
echo $PATH
alias ll='ls -alrth'
sudo apt-get install -y git-core
which git
copy files between remote machines
scp -i keypair.pem hello.txt amazonserver:~/
scp hello.txt awshost1:~/
scp hello.txt awshost1:~/foo.txt
remote sync
rsync -avp something.txt awshost4:~/
...
rsync -avp something.txt awshost4:~/
...
install node and npm
$ sudo apt-get update
# Install a special package
$ sudo apt-get install -y python-software-properties python g++ make
# Add a new repository for apt-get to search
$ sudo add-apt-repository ppa:chris-lea/node.js
# Update apt-get’s knowledge of which packages are where
$ sudo apt-get update
# Now install nodejs and npm
$ sudo apt-get install -y nodejs
Hello world
#!/usr/bin/env node
console.log("Hello World");
Hello world 2
#!/usr/bin/env node
var fs = require(’fs’);
var outfile = "hello.txt";
var out = "Modify this script to write out something different.\n";
fs.writeFileSync(outfile, out);
console.log("Script: " + __filename + "\nWrote: " + out + "To: " + outfile);
Fibonacci
#!/usr/bin/env node
// Fibonacci
// http://en.wikipedia.org/wiki/Fibonacci_number
var fibonacci = function(n) {
if(n < 1) { return 0;}
else if(n == 1 || n == 2) { return 1;}
else if(n > 2) { return fibonacci(n - 1) + fibonacci(n - 2);}
};

 // Fibonacci: closed form expression
 // http://en.wikipedia.org/wiki/Golden_ratio#Relationship_to_Fibonacci_sequence
 var fibonacci2 = function(n) {
 var phi = (1 + Math.sqrt(5))/2;
 return Math.round((Math.pow(phi, n) - Math.pow(1-phi, n))/Math.sqrt(5));
 };
 // Find first K Fibonacci numbers via basic for loop
var firstkfib = function(k) {
var i = 1;
var arr = [];
for(i = 1; i < k+1; i++) {
arr.push(fibonacci(i));
}
return arr;
};
 // Print to console
 var fmt = function(arr) {
 return arr.join(" ");
 };
 var k = 20;
 console.log("firstkfib(" + k + ")");
 console.log(fmt(firstkfib(k)));
 
heroku
  • install git
sudo apt-get install -y git-core
which git
  • install heroku
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
which heroku
 heroku login
ssh-keygen -t rsa
heroku keys:add
  • deploy application to heroku
## Clone a sample repo and push to heroku
git clone https://github.com/heroku/node-js-sample.git
cd node-js-sample
heroku create
git push heroku master
The Cloud and IAAS/PAAS/SAAS

IAAS: (infrastructure as a service)AWS, Joyent, Rackspace Cloud
PAAS: (platform at a service)Heroku, DotCloud, Nodester, Google AppEngine
SAAS: (software as a service)Salesforce, Google Apps, Mint.com

dealing with links
wget -w 2 -r -np -k -p http://www.stanford.edu/class/cs106b
curl https://install.meteor.com | less #
split large files
split -d -l 1000 *ptt subset.ptt.
ll subset.ptt*
archive and compress file
mkdir genome
mv *ptt* genome/
tar -cvf genome.tar genome
gzip genome.tar
tar -xzvf genome.tar.gz
sed and awk
sed ’s/\r/\n/g’ windows-newline-file.csv
tail -n+4 *ptt | awk -F"\t" ’{print $2, $3, $3 + 5}’ | head
xargs and tee
find /etc -name ’*\.sh’ | xargs head -2
ls | tee list.txt
install screen
cd $HOME
wget raw.github.com/startup-class/dotfiles/master/.screenrc -O .screenrc
head .screenrc
screen
install emacs (wrapped in a setup.sh in startup class)
cd $HOME
sudo apt-get install -y git-core # if you haven’t already
git clone https://github.com/startup-class/setup.git
./setup/setup.sh
npm install -g jshint ## for javascript highlight
about git
sudo apt-get install -y git-core
mkdir myrepo
cd myrepo
git config --global user.name "John Smith"
git config --global user.email "example@stanford.edu"
git init
# Initialized empty Git repository in /home/ubuntu/myrepo/.git/
git status
echo -e ’line1\nline2’ > file.txt
git status
git add file.txt
git status
git commit -m "Added first file"
git log
echo -e "line3" >> file.txt
git status
git diff file.txt
git add file.txt
git commit -m "Added a new line to the file."
git log
git log -p
git log -p --color
  • github
git clone github.com/somelinks....master.git
git add ...
git commit -m "commit message"
git push origin master
ssh-keygen -t rsa -C "foo@stanford.edu"
ssh -T git@github.com
git push -u origin master 

<pre>
...
(to be continued)
...
</pre>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,219评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,363评论 1 293
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,933评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,020评论 0 206
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,400评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,640评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,896评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,597评论 0 199
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,327评论 1 244
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,581评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,072评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,399评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,054评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,083评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,849评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,672评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,585评论 2 270

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,100评论 18 139
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,305评论 5 6
  • GIT分布式版本控制系统最佳实践 这篇文章来自于老男孩教育高级架构师班12期的徐亮偉同学。 首先感谢老男孩架构师班...
    meng_philip123阅读 3,260评论 4 36
  • 又是一个周一,有点没有目标感的新的一天,不想和人说话,只想安静地做点不用动脑子的事情,想把案头的各种资料整理一下,...
    兮兮0225阅读 67评论 0 0
  • 懂你的人,是理解你的人,是体谅你的人,对你有爱心的人,一生能遇到一个懂你的人,很难,这也需要缘分,但要是遇到了,一...
    大象老师阅读 224评论 0 0