Skip to content

Instantly share code, notes, and snippets.

@Jonty
Jonty / sort.py
Last active Dec 25, 2015 — forked from ntlk/sort.py
View sort.py
import sys
lines = sys.stdin.readlines()
lines.sort(reverse = ('-r' in sys.argv))
print ''.join(lines)
View uniq.py
import sys
def process_lines(lines):
for index, line in enumerate(lines):
last_line = lines[index - 1]
if line != last_line:
sys.stdout.write(line)
process_lines(sys.stdin.readlines())
View this_is_a_bit_more_readable.rb
def just_one_kind_of_response?(item, controller)
case controller
when 'actions'
if item.comments.blank? || item.suggestions.blank?
return true
end
when 'thoughts'
if item.comments.blank? || item.suggestions.blank?
View gchart-pie.py
#!/usr/bin/python
import sys
labels = []
values = []
for line in sys.stdin:
bits = line.strip().split(' ')
value = bits.pop(0)
label = ' '.join(bits)