Skip to content

Instantly share code, notes, and snippets.

@c9n
Created November 13, 2014 04:35
Show Gist options
  • Save c9n/4d21c3410d0cae2a6bf4 to your computer and use it in GitHub Desktop.
Save c9n/4d21c3410d0cae2a6bf4 to your computer and use it in GitHub Desktop.
shuffle
#!/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(' ')
@c9n
Copy link
Author

c9n commented Nov 13, 2014

./shuffle.rb | sh

@c9n
Copy link
Author

c9n commented Nov 20, 2014

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