Skip to content

Instantly share code, notes, and snippets.

@tsnow
Last active August 29, 2015 14:01
Show Gist options
  • Save tsnow/116c8de46d505b334ecb to your computer and use it in GitHub Desktop.
Save tsnow/116c8de46d505b334ecb to your computer and use it in GitHub Desktop.
Tmux Top 20 Watched Github Repositories Pair Programming Session Interview Setup

Testing-Server Setup

Set up a user with the candidate's last name, and a sha1 password.

ssh root@$server_ip
useradd $last_name
exit
ssh $last_name@$server_ip

Run tmux, C-b " to horizontal split windows, C-b % to vertical split windows, open top20.rb in a nano window, open tmux-cheat-sheet in a nano window make sure that yajl-ruby is gem installed.

apt-get install ruby-dev
gem install bundler
gem install yajl-ruby

Testing Server Teardown

ps auxwww | grep $lastname | grep -e "^$lastname" | awk '{print $2}' | xargs kill
userdel $lastname

Email

Send an email at least 1 hour prior to the session.

Hello {{FirstName}},

It would be helpful for our session today if you could read up on the following page: http://www.githubarchive.org/

It would also be helpful if you could set up an ssh terminal session to our pair programming server. Type tmux attach once you're connected.

-{{InterviewerName}}

SSH Instructions By Platform

OS X / Linux: ssh {{lastname}}@{{IP}} password: {{password}}

Windows: The PuTTY utility can be used to create ssh sessions: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Username: {{lastname}} Host: {{IP}} Password: {{password}}

source 'https://rubygems.org'
gem 'yajl-ruby'
Top 20 Watched Github Repositories
----------------------------------
We want to use Github Archive data to see how popular repositories are at particular times.
Let's start with 2012-03-11 for the 12:00 hour.
Print the top 20 repository names, by how frequently people 'watch' them.
Here are the top 2, for example:
$ ./top20
tommoor/tinycon - 4 event(s)
twitter/bootstrap - 3 event(s)
...
tmux Commands
--------------
Change window: Ctrl-b o
Exit: Ctrl-b d
nano Commands
-------------
Save: Ctrl-o
#!/usr/bin/env ruby
require 'open-uri'
require 'zlib'
require 'yajl'
require 'json'
gz = open('http://data.githubarchive.org/2012-03-11-12.json.gz')
js = Zlib::GzipReader.new(gz).read
Yajl::Parser.parse(js) do |event|
puts JSON.pretty_generate(event)
puts "Return the top 20 repository.owner/repository.name's by WatchEvent count.
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment