Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update

  • Loading branch information...
commit 74841a26e299de81c1f098b47b9ca0d339756f39 1 parent 2a6031d
@mafei198 authored
Showing with 12 additions and 140 deletions.
  1. +10 −0 auto_cache_model/erlang_learn
  2. +2 −140 daily_commands.note
View
10 auto_cache_model/erlang_learn
@@ -0,0 +1,10 @@
+1.面向并发编程
+2.面向进程编程
+3.进程字典的使用加大了进程状态转移的难度.
+4.消息的接收先后顺序严格按照发送顺序来定.
+
+使用state的好处, 在进程crash或者转移状态到新进程时, 拷贝state非常方便.
+疑问? 如果state比较大是否会带来频繁开辟内存空间的性能问题
+
+参考资料解释: 进程之间不存在消息丢失的危险,
+ 但是在依赖网络环境的时候可能会丢失.
View
142 daily_commands.note
@@ -1,140 +1,2 @@
-用户国际分布统计:
-User.where("updated_at > ?",1.day.ago).group(:locale).count
-返回样例:<OrderedHash {"cn"=>5, "jp"=>65, "zh_hant"=>257, "en"=>3340}>
-
-付费用户率:
-user_count = User.where("updated_at >= ?",1.days.ago).count
-order_count = Order.where("created_at >= ?",1.days.ago).group(:user_id).count.keys.count
-up=order_count/user_count.to_f
-
-安装zsh 和oh-my-zsh解决终端不能显示输入中文问题
-sudo apt-get install zsh
-curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
-
-a=Message.where(:subject => ['Exploration subject','探险报告']).where("created_at >= ?", 1.day.ago).select("count(*) as ecount,user_id").group(:user_id).having("ecount >= 50").order('ecount DESC')
-
-删除重复创建的fleets:
-planet_ids = []
-fleet_ids=[]
-User.find_each do |u|
- u.planets.each do |planet|
- if planet.fleets.count > 21
- puts planet.id
- planet_ids << planet.id
- end
- end
-end;nil
-Planet.where(:id => planet_ids).each do |planet|
- planet.fleets.each_with_index do |f,index|
- if index >= 21
- fleet_ids << f.id
- end
- puts "fleet_id:#{f.id},name:#{f.fleet_name},amount:#{f.amount}"
- end
-end;nil
-Fleet.where(:id => fleet_ids).delete_all
-
-User.find_each do |u|
- u.planets.each do |planet|
- if planet.buildings.count != 13
- puts planet.id
- end
- end
-end;nil
-
-User.find_each do |u|
- u.planets.each do |planet|
- Resource.update_produce_perhour(planet,Time.now)
- end
-end;nil
-
-h={}
-User.where("updated_at < ?",14.days.ago).each{|u|num = u.quest_events.count;if h[num].nil?;h[num]=1;else h[num] += 1;end};nil
-h.each{|k,v|h[k] = (v*100/User.where("updated_at < ?",14.days.ago).count.to_f).round(2)}
-sort_h = {}
-22.times do |index|
- if h[index+1].nil?
- h[index+1] = 0
- end
- puts "任务index: #{index+1} 百分比: #{h[index+1]}%"
-end
-
-total_dark = 0
-total_user = 0
-User.where("updated_at < ?",14.days.ago).each do |u|
- if u.quest_events.find_by_quest_index(22).present?
- total_dark += u.dark_matter_count
- total_user += 1
- end
-end;nil
-total_dark/total_user.to_f
-
-#前50名探险详情
-User.order("score DESC").limit(50).each{|user|times = user.messages.where("subject in ('探险报告', 'Exploration subject', '遠征報告', '탐험보고', '探險報告') and created_at >= ?",1.day.ago).count; if times > 10; puts "rank:#{user.rank} times:#{times}";end};nil
-
-#清理僵尸用户
-User.new_zombies.each{|u|u.planets.each{|planet|if planet.planet_position.nil?;u.update_attributes :zombie=> true;break;end}};nil;User.auto_remove_zombies;nil
-
-#批量杀死进程
-(`ps aux|grep resque-1.19`).split("\n").map{|row|row.split(" ")[1]}.each{|pid|eval("`kill -9 #{pid}`")}
-
-#统计任务完成率
-================================================
-#2月
-h={}
-users =User.where("created_at > ? and created_at < ? and refresh_at <= ?",DateTime.new(2012,2,1), DateTime.new(2012,2,2),DateTime.new(2012,2,16));nil
-users.each{|u|num = u.quest_events.count;if h[num].nil?;h[num]=1;else h[num] += 1;end};nil
-h.each{|k,v|h[k] = (v*100/users.count.to_f).round(2)}
-(0..25).each do |i|
- if h[i].blank?
- h[i] = 0
- end
-end
-hh=h.sort{|a,b|a[0] <=> b[0]}
-hh.each do |arr|
- puts "#{arr[1]}"
-end
-
-================================================
-#4月
-h={}
-users =User.where("created_at > ? and created_at < ? and refresh_at <= ?",DateTime.new(2012,4,10), DateTime.new(2012,4,11),DateTime.new(2012,4,25));nil
-users.each{|u|num = u.quest_events.count;if h[num].nil?;h[num]=1;else h[num] += 1;end};nil
-h.each{|k,v|h[k] = (v*100/users.count.to_f).round(2)}
-(0..25).each do |i|
- if h[i].blank?
- h[i] = 0
- end
-end
-hh=h.sort{|a,b|a[0] <=> b[0]}
-hh.each do |arr|
- puts "#{arr[1]}"
-end
-
-================================================
-
-
-
-hh.each do |arr|
- puts "用户领取任务数: #{arr[0]} 百分比: #{arr[1]}%"
-end
-
-======================玩家平均留存时间============================
-zombie_users = User.where(:zombie => true).limit(1000);nil
-amount = zombie_users.count
-live_days = zombie_users.select("sum(DATEDIFF(updated_at, created_at)) as days").first.days.to_i
-puts "----amount:#{amount}"
-puts "----live_days:#{live_days}"
-if amount == 0
- av_day = 0
-else
- av_day = live_days/amount
-end
-av_day
-
-===========================================
-users = User.where("created_at >= ? and created_at <= ?", Date.new(2012,4,10), Date.new(2012,5,10) );nil
-user_count = users.count
-user_7 = users.where("DATEDIFF(refresh_at,created_at) >= 7").count
-user_30 = users.where("datediff(refresh_at,created_at) >= 30").count
-user_90 = users.where("datediff(refresh_at,created_at) >= 90").count
+#see the port use
+sudo netstat -antup
Please sign in to comment.
Something went wrong with that request. Please try again.