Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthias Sieber manonthemat

View GitHub Profile
@manonthemat
manonthemat / top_history.rb
Created Nov 18, 2013
function to sort a shell history file and print out the lines of commands that has been executed the most
View top_history.rb
def sortCommands(histFile, limit=10)
file = open(histFile, 'r')
lines = file.readlines
file.close
freqs = Hash.new(0)
lines.each do |line|
freqs[line] += 1
end
a = freqs.sort_by {|k, v| -v}[0..limit]
i = 0
View gist:7063263
import urllib2
import random
import difflib
import datetime
def fetch(url):
"""Fetches requested url, returns lines in list"""
response = urllib2.urlopen(url)
lines = response.readlines()
return lines