本周活动内容:
Android的触摸事件消息传递机制
涉及知识点:
- dispatchTouchEvent
- onInterceptTouchEvent
- onTouchEvent
- View,ViewGroup的继承关系
简介:
本周活动内容:
Android的触摸事件消息传递机制
涉及知识点:
简介:
暂定于本周五晚上(2014年3月14日)召开2014年3月理事会。
本次理事会议题:本学期的活动规划;小范围招新规划;合格的临时成员转正。
各组长请可以先与自己组员沟通,取得初步人选。理事会上进行讨论。正式组员会给更多资源支持以及参与项目机会。
2012年季逸超的一个视频,对于我们学校的同学们了解如何创新还是很有借鉴意义的。
本学期末考试完毕后,我们将举行一次集体活动。内容为:
日期待定。
ifLab成立已经将近一学期,通过这段时间对活动、学习的观察以及和同学的交流,我对当前同学如何学习技术以及职业定位有了一些想法。把这些想法整理在这里,分享给各位成员和组长。黄伟之前提出各位组长都写一个本学期工作总结,这个就算是我个人的一份总结,不针对于某个小组。
ifLab的定位是信息科技IT。我们是一个垂直专业的院校,学校名字即蕴含了我们的专业定义,信息科技=>Information Technology。大多数同学今后的职业定位是在IT这个领域。当前的就业形势非常严峻,大家要把自己的大学时间尽快纳入将来的职业规划中,使自己将来就业具有竞争力。
如何做好职业规划?职业规划要结合职业发展空间、职业待遇和个人兴趣。我们目前在校学习的课程都是基础课程,可能并不能充分的反映将来要干什么。有一个简单的方法:大家到各个专业招聘网站,比如英才网,51job去搜索IT领域的职位,看看哪些职位的薪水最高;再从这些薪水最高的职位里面选择一个自己感兴趣的;之后分析要达到这些职位的要求,你需要在大学课程之外学习什么技术能力,具备什么项目经验;之后再分配时间去学习这些技术,争取参与项目的机会。经过职业规划的成长比没有方向的野蛮成长更有效率。
团队是学习技术的好方式。我们学校有一个牛人叫季逸超,自己一个人能开发出浏览器,成为macworld演讲人,牛人可以不需要团队。但是大部分同学不是牛人,不能一个人钻研一个问题花很久的时间解决,要纳入团队中来学习。很多技术问题通过有经验的同学一点就透。ifLab内部可以成立各种技术方向的团队,在团队内部有充分的分享交流,不论年级和性别,在技术方向上有经验的同学向初学者传授技术和方法,帮助初学者尽快入门提高,带动更多的初学者。大三可以辅导大一,大一的可以辅导研究生,目的是让技术和知识可以流动起来。
在实际的工作中,一个项目也是很多人团队合作的结果。一般的分工有项目经理、产品经理、UI、UE、美工、架构师、前台coder、后台coder、服务器系统管理、DBA等等。我们在团队中学习,也要学习通过团队合作来完成项目,每个人分配一个或者多个角色,共同完成一个目标。
使用互联网一流的工具,了解互联网最新资讯。要主动的使用各种主流的、新的互联网服务和移动应用,比如Gmail 、GitHub、Dropbox、Trello、Skydrive、微博、微信等;经常通过PingWest、Techcrunch这些IT媒体来了解最新的IT趋势和技术。使用一流的网络服务和工具,你才能做出一流的产品。
学习发展趋势的技术。每种技术和编程语言都有自己的生命周期,TIOBE每年都会公布排行榜。有些技术在发展期,以后会有更多的就业机会和发展空间,那么我们就要选择这些方向去学习。比如现在还可以学习Java,因为企业开发和Android开发都用到Java,也可以学习Python,因为很多云计算软件基于Python。1999年的时候会HTML就能有上万的月薪,企业应用很多都用PowerBuilder开发,但是现在PB基本已经没人用,HTML已经变成了一项全民基本技能。
锻炼身体提高效率。程序员被戏称为IT民工和IT狗,因为工作压力确实非常大。同样的我们同学学习压力也很大,在日常课程之外还要学习技术,经常一学习就是几个小时。在这种情况下,能否保持学习时间和提高学习效率非常重要。身体素质决定了这两个因素,在智商同等的情况下,技术学习的竞争就是身体素质的竞争。我建议大家每天都用一定的时间锻炼,才能保证学习时间和效率。
本学期的考试期已到。如果对考试不是很有把握的成员同学,请暂停技术学习,专心复习备考。
12月2日晚的讲座上,朱荣泽为云计算小组的同学介绍了云计算和openstack的概念,并演示了他所在公司UnitedStack的产品最新开发进展。在场同学随后进行了提问和交流。
云计算方向是创联几个小组中学习难度最高的方向,OpenStack需要大量的操作系统、网络、编程方面的基础学习才能入门,当然也意味着如果能坚持学习到一定程度,就业时会有非常丰厚的回报。
计算机学院的一些研究生也参加了讲座,活动结束后和小组成员进行了进一步了解和沟通。
对于大部分本科同学而言,云计算小组的学习主要在于云计算基础知识的学习和相关技术入门。对于有一定研发能力和编程基础的研究生而言,云计算小组提供一个技术交流和开发的环境。我们欢迎能有更多的研究生同学加入,形成一个具有贡献代码能力的OpenStack团队。
时间:2013-12-4(周三)3:00PM
地点:小营校区1-1-309
主讲:黄彦飞(老师)
主题:网站架构的发展演变
内容:
12月2日(周一)晚19:00,我们将邀请业界专家在健翔桥校区2-2-215举办“云计算与openstack ”讲座,欢迎大三、大四同学以及研究生参加。
本次讲座将介绍云计算的基本概念;最流行的开源云计算平台OpenStack;我校OpenStack的应用情况;创联云计算小组的学习情况。
讲座嘉宾介绍:
OpenStack Folsom版核心贡献工程师TOP 20。
StackLab项目管理员。曾在Sina OpenStack团队工作,现于UnitedStack任职。
OpenStack存储项目Cinder的主要代码贡献者之一,对Gluster,Sheepdog, Ceph等开源存储系统有较深入的研究。
Discourse是一个“下一代,为下个十年互联网所打造的百分百开源讨论平台。”,由问答网站Stackoverflow和StackExchange的联合创始人,同时也是著名博客Coding Horror的博主 Jeff Atwood创造。
在实际使用中,Discourse需要和本地现有的用户系统整合。目前Discourse并没有提供解决方案。
我们通过oauth2的plugin,搭建oauth2服务器实现了Discourse和用户系统的整合,并将整合代码开源。
本文由云计算组长朱劲寿贡献。
1.0 系统环境:
uname -a Linux dev2 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
1.1 使用非root账号登陆(安全起见,不建议使用root),如果没有,自行创建。
sudo adduser bistu sudo adduser bistu sudo
1.2 更新linux
sudo apt-get update && sudo apt-get -y upgrade
1.3 安装 Discourse 所需的包文件
sudo tasksel install openssh-server sudo tasksel install mail-server sudo tasksel install postgresql-server
安装邮件服务的时候,选择“Satellite system” 或者“Internet Site” ,读者自己决定 ,然后在下一步输入你自己的域名,我用的是d.iflab.org
继续安装其它所需的包文件:
sudo apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev redis-server libpq-dev gawk curl pngcrush
果你希望用 linux 本身发送邮件,则需安装 sendmail(具体设置方法请自行查阅):
sudo apt-get install sendmail
1.4 设定主机名称修改hosts:
bistu@Discourse:~$ cat /etc/hostname Discourse
cat /etc/hosts 127.0.0.1 localhost Discourse 222.249.250.91 Discourse d.bistu.edu.cn d.iflab.org
1.5 安装最新版的 Nginx
更新软件源:
cat <<'EOF' | sudo tee -a /etc/apt/sources.list deb https://nginx.org/packages/ubuntu/ precise nginx deb-src https://nginx.org/packages/ubuntu/ precise nginx EOF
加入 nginx 密钥:
curl https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
安装nginx :
sudo apt-get update && sudo apt-get -y install nginx
1.6 安装RVM
\curl -s -S -L https://get.rvm.io | sudo bash -s stable sudo adduser $USER rvm newgrp rvm . /etc/profile.d/rvm.sh rvm requirements
1.7安装 Ruby 2.0 和打包程序
rvm install 2.0.0 gem install bundler
2.安装Discourse
2.1 创建discourse用户,专门用于安装 discourse 论坛。
sudo adduser --shell /bin/bash discourse sudo adduser discourse rvm
为用户 discourse 赋予操作数据库的权限:
sudo -u postgres createuser -s discourse sudo -u postgres psql -c "alter user discourse password 'your password';"
新建www目录并赋予discourse权限
sudo mkdir /var/www sudo chown discourse.discourse /var/www
切换到 discourse 用户:
sudo su - discourse
2.2下载并安装 discourse 源码
cd /var/www git clone git://github.com/discourse/discourse.git cd discourse git checkout latest-release bundle install --deployment --without test
最后这一步耗时较长,请耐心等待,大家可以更换ruby的源。安装完毕后,就可以开始配置 discourse 了。
2.3 修改 Discourse 的相关配置文件
cd discourse/config cp database.yml.production-sample database.yml cp redis.yml.sample redis.yml cp discourse.pill.sample discourse.pill cp environments/production.rb.sample environments/production.rb
2.3.1 修改 database.yml
nano database.yml
需要修改的内容包括:
用户名
密码
主机名
实际上,你还可以修改数据库的名称,不过这里不建议新手修改。 本文修改后的 database.yml 如下,请结合你的实际情况加以修改:
production: adapter: postgresql database: discourse_prod username: discourse # if using username/password auth password: [你自己设定的密码] # if using username/password auth # host: dbhost # if not localhost pool: 5 # size of DB connection pool *per process* timeout: 5000 # db_id: 0 # database ID if hosting multiple sites host_names: - d.iflab.org # Update this to be the domain of your production site test: adapter: postgresql database: discourse_test # username: discourse_test # password: 123123123123 min_messages: warning host: localhost pool: 5 timeout: 5000 host_names: - test.localhost
2.3.2 修改 discourse.pill
nano discourse.pill
需要修改的内容包括:
将 rails_root 设为 /var/www/discourse
删除# Running bluepill as a user? Use:这一行下面那行的注释符号
本文修改后的 discourse.pill 如下,请结合你的实际情况加以修改:
rails_env = ENV['RAILS_ENV'] || "production" rails_root = ENV['RAILS_ROOT'] || "/var/www/discourse" user = ENV["DISCOURSE_USER"] || ENV['USER'] || 'discourse' group = ENV["DISCOURSE_GROUP"] || ENV['GROUP'] || 'www-data' num_webs = ENV["NUM_WEBS"].to_i > 0 ? ENV["NUM_WEBS"].to_i : 4 # to debug use #Bluepill.application("your_app", :foreground => true) do |app| # Running bluepill as a user? Use: Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |app| # Running bluepill as root? Use: #Bluepill.application("discourse") do |app| # getting this to work was a nightmare # bundle exec spawns a process totally messing with the demonize option # so we suck the environment out and set it up first bootup_bundle = [ "#{ENV['HOME']}/.rvm/bin/rvm/bootup_bundle", "/usr/local/rvm/bin/rvm/bootup_bundle", `which bootup_bundle`.strip, ].each do |location| if File.exist? location break location end end # XXX if none match, bootup_bundle is set to the array if bootup_bundle app.environment = `env -i BUNDLE_GEMFILE=#{rails_root}/Gemfile #{bootup_bundle} exec env`.lines.inject({}) do |env_hash,l| kv = l.chomp.split('=',2) env_hash[kv[0]] = kv[1] env_hash end end app.environment ||= {} # Load .env file if there is one if File.exist? "#{rails_root}/.env" File.read("#{rails_root}/.env").split("\n").each do |l| kv = l.chomp.split('=',2) app.environment[kv[0]] = kv[1] end end # Force RAILS_ENV to the value specified in the environment of the bluepill invocation app.environment['RAILS_ENV'] = rails_env app.gid = group app.uid = user app.working_dir = rails_root sockdir = "#{rails_root}/tmp/sockets" File.directory? sockdir or FileUtils.mkdir_p sockdir num_webs.times do |i| app.process("thin-#{i}") do |process| process.start_command = "bundle exec thin start -e production -t 0 --socket #{sockdir}/thin.#{i}.sock --pid #{rails_root}/tmp/pids/thin#{i}.pid --log #{rails_root}/log/thin-#{i}.log --daemonize" # Alternatively, you can start with a port number instead of a socket. If you do that, then you MUST update # the upstream section in the nginx config to match. # The nginx.sample.conf file assumes you're using sockets. # process.start_command = "bundle exec thin start -e production -t 0 -p #{9040 + i} -P #{rails_root}/tmp/pids/thin#{i}.pid -d" process.pid_file = "#{rails_root}/tmp/pids/thin#{i}.pid" process.start_grace_time = 30.seconds process.stop_grace_time = 10.seconds process.restart_grace_time = 10.seconds process.group = "thins" process.uid = user process.gid = group process.daemonize = false process.stdout = process.stderr = "#{rails_root}/log/thin#{i}.log" # Thanks to: https://www.garrensmith.com/2012/09/24/Staying-up-with-Unicorn-Upstart-Bluepill.html # If the amount of memory is exceeded 3 times out of 5, restart process.checks :mem_usage, :every => 1.minutes, :below => 750.megabytes, :times => [3, 5] end end #debug instance # app.process("thin-debug") do |process| # process.start_command = "bundle exec thin start -e development -t 0 -p 10040 -P #{rails_root}/tmp/pids/thin-debug.pid -l #{rails_root}/log/thin-debug.log" -d" # process.pid_file = "#{rails_root}/tmp/pids/thin-debug.pid" # process.start_grace_time = 30.seconds # process.stop_grace_time = 10.seconds # process.restart_grace_time = 10.seconds # process.group = "thins" # process.uid = user # process.gid = group # process.daemonize = false # process.stdout = process.stderr = "#{rails_root}/log/thin-debug.log" # end app.process("sidekiq-worker") do |process| pidfile = "#{rails_root}/tmp/pids/sidekiq-worker.pid" process.start_command = "/usr/bin/env PIDFILE=#{pidfile} RAILS_ENV=#{rails_env} bundle exec sidekiq -L #{rails_root}/log/sidekiq.log" process.pid_file = pidfile process.start_grace_time = 30.seconds process.stop_grace_time = 10.seconds process.restart_grace_time = 10.seconds process.uid = user process.gid = group process.daemonize = true end end
2.3.3 修改 secret_token.rb 文件
为了保证站点的安全,需要生成密钥会话令牌。
cd /var/www/discourse
rake secret
将生成的密钥记下来,打开 config/initializers/secret_token.rb 文件
nano config/initializers/secret_token.rb
执行以下步骤:
清空该文件中的所有已有内容
将下面这行代码拷贝到该文件中,用刚才生成的密钥代替 [TOKEN] 部分
Discourse::Application.config.secret_token = "[TOKEN]"
2.3.4 修改 production.rb 文件,设定邮件发送方式
Discourse 中,系统邮件是非常重要的,它涉及到激活用户、修改邮箱、修改密码等多项功能。
如果你已经有了邮件服务器,则可以通过 smtp 服务发送系统邮件:
修改 config/environments/production.rb 文件:
nano config/environments/production.rb
修改其中有关邮件发送的部分,本文中如下:
# you may use other configuration here for mail eg: sendgrid config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "yours", :port => 25, :domain => 'd.iflab.org', :user_name => 'iflab', :password => 'yours', :authentication => 'plain', :enable_starttls_auto => true } if ENV.key?('SMTP_URL') config.action_mailer.smtp_settings = begin uri = URI.parse(ENV['SMTP_URL']) params = { :address => uri.host, :port => uri.port, :domain => (uri.path || "").split("/")[1], :user_name => uri.user, :password => uri.password, :authentication => 'plain', :enable_starttls_auto => true } CGI.parse(uri.query || "").each {|k,v| params[k.to_sym] = v.first} params rescue raise "Invalid SMTP_URL" end else config.action_mailer.delivery_method = :sendmail config.action_mailer.sendmail_settings = {arguments: '-i'} end
2.4 初始化数据库:
cd /var/www/discourse createdb discourse_prod RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production rake db:migrate RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production rake assets:precompile
2.5 配置服务环境
2.5.1 配置 Nginx
切换到 bistu 用户
sudo su - bistu
编辑 nginx.conf
sudo nano /etc/nginx/nginx.conf
在 http 部分加入下面一行:
server_names_hash_bucket_size 64;
如果该linux 上只有 discourse 一项服务,则禁用默认的 nginx 站点:
sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled
编辑 discourse.conf
sudo cp /var/www/discourse/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf sudo nano /etc/nginx/conf.d/discourse.conf
将 server_name 改为你自己的主机名。
根据实际情况修改 socket 和 root 的路径,本文中如下:
upstream discourse { server unix:/var/www/discourse/tmp/sockets/thin.0.sock; server unix:/var/www/discourse/tmp/sockets/thin.1.sock; server unix:/var/www/discourse/tmp/sockets/thin.2.sock; server unix:/var/www/discourse/tmp/sockets/thin.3.sock; } server { listen 80; gzip on; gzip_min_length 1000; gzip_types application/json text/css application/x-javascript; server_name d.iflab.org; sendfile on; keepalive_timeout 65; location / { root /var/www/discourse/public; location ~ ^/t\/[0-9]+\/[0-9]+\/avatar { expires 1d; add_header Cache-Control public; add_header ETag ""; } location ~ ^/assets/ { expires 1y; add_header Cache-Control public; add_header ETag ""; break; } proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; # If the file exists as a static file serve it directly without # running all the other rewite tests on it if (-f $request_filename) { break; } if (!-f $request_filename) { proxy_pass https://discourse; break; } } }
重启 nginx 服务:
sudo /etc/init.d/nginx reload
2.5.2 安装并配置 Bluepill
Discourse 官方使用 bluepill 来管理所有 discourse 的相关服务,省去了很多麻烦。
切换到 discourse 用户
sudo su - discourse
安装并配置 bluepill
gem install bluepill echo 'alias bluepill="NOEXEC_DISABLE=1 bluepill --no-privileged -c ~/.bluepill"' >> ~/.bash_aliases rvm wrapper $(rvm current) bootup bluepill rvm wrapper $(rvm current) bootup bundle
注销并重新登录以激活 bluepill
logout ssh discourse@localhost
到这里,discourse 就安装完成了,可以通过下面的命令行来启动:
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=4 bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill
为了让 discourse 每次开机就能自动运行,还需要在 crontab 里写入 bluepill 服务:
crontab -e
@reboot RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=4 /usr/local/rvm/bin/bootup_bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill
2.6 创建管理员
登录你的 discourse 论坛地址,并注册一个用户,本文中注册的邮件地址为 [email protected]。
然后再次用 discourse 用户登录 linux,执行以下命令:
ssh [email protected] cd /var/www/discourse RAILS_ENV=production bundle exec rails c me = User.find_by_username_or_email('[email protected]') me.activate me.admin = true me.save
2.7 启用中文支持
目前,Discourse 已经可以支持中文界面,使用管理员账户登录后,点击右上角的管理员名称进入设置界面,然后再点击右上角的小扳手 Admin 进入系统管理界面,在第二项 Settings 中,把 default_locale 从默认的 en 更改为 zh_CN,然后返回论坛主界面,按 Ctrl+F5 刷新浏览器缓存,中文界面就出来了。
3 更新
鉴于 discourse 更新很快,建议每隔几天就执行一次更新。
用 discourse 用户登录 linux,执行以下命令:
ssh [email protected] bluepill stop cd /var/www/discourse git checkout master git pull git fetch --tags bundle install --without test --deployment RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production rake db:migrate RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production rake assets:precompile bluepill start
如果启动失败并出现重试,则按 Ctrl+C 中止,然后执行以下两条命令重启 bluepill 服务:
bluepill quit RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=4 /usr/local/rvm/bin/bootup_bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill