Created
November 13, 2014 04:35
-
-
Save c9n/4d21c3410d0cae2a6bf4 to your computer and use it in GitHub Desktop.
shuffle
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
#!/usr/bin/env ruby | |
app = `cat app_rec.lst | awk '{ print $1 }'`.split("\n").shuffle | |
og = `cat online_game_rec.lst | awk '{ print $1 }'`.split("\n").shuffle | |
sg = `cat single_game_rec.lst | awk '{ print $1 }'`.split("\n").shuffle | |
mag = 1 | |
output = [] | |
for i in 1..60 | |
if mag > 4 | |
mag = 1 | |
end | |
if mag == 1 or mag == 3 | |
output.push(app.pop) | |
elsif mag == 2 | |
output.push(og.pop) | |
else | |
output.push(sg.pop) | |
end | |
mag = mag + 1 | |
end | |
puts 'redis-cli -h localhost' | |
puts 'lpush app:shuffle ' + output.join(' ') |
expand -t 1 app_hot.lst | awk '{printf(""%s"\n", $0);}' | xargs redis-cli hset app:personalize default
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./shuffle.rb | sh