I hereby claim:
- I am sporsh on github.
- I am sporsh (https://keybase.io/sporsh) on keybase.
- I have a public key whose fingerprint is 2657 83C9 C0CD A7D3 00FA 9114 8A18 E5D2 F087 D6B5
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
require "presentation" | |
p_file = ARGV[0] || "presentations.txt" | |
v_file = ARGV[1] || "votes.txt" | |
def load_presentations(filename) | |
result = {} | |
open(filename) { |file| | |
while entry = file.gets | |
m_obj = /^(\d+):([^:]+):([^:]+)/.match(entry) |
class ReadOnlyProxy(object): | |
def __init__(self, target): | |
self._target = target | |
def __getattribute__(self, name): | |
target = object.__getattribute__(self, '_target') | |
return getattr(target, name) |
require 'open-uri' | |
class UrlFetcher | |
def fetch(url) | |
begin | |
open(url) { |stream| stream.read } | |
rescue SocketError, OpenURI::HTTPError, URI::InvalidURIError, Errno::ENOENT | |
nil | |
end | |
end |
require "nokogiri" | |
require "uri" | |
class HtmlParser | |
def parse(source, html_string) | |
uri = URI.parse(source) | |
html_doc = Nokogiri::HTML(html_string) | |
anchors = html_doc.xpath('//a[@href!="" and not(starts-with(@href, "#"))]') | |
links = anchors.map { |elem| | |
elem.attribute('href').value |
[alias] | |
ci = commit | |
lg = log --abbrev-commit --format='%C(yellow)%h %Cblue%aN %Cgreen%ar %Creset%s' | |
co = checkout | |
st = status | |
loglocal = log --abbrev-commit --format='%Cgreen* %C(yellow)%h %Cblue%aN %Cgreen%ar %Creset%s' FETCH_HEAD.. | |
logremote = "!f() { git fetch&&\ | |
git log --abbrev-commit --format='%Cred* %C(yellow)%h %Cblue%aN %Cgreen%ar %Creset%s' ..FETCH_HEAD;\ | |
}; f" | |
changes = "!f() { echo 'REMOTE CHANGES:\n---------------';\ |
from twisted.internet import defer | |
import threading | |
import Queue | |
from twisted.python import failure | |
def blocking_call_from_thread(reactor, f, *args, **kwargs): | |
"""Calls a twisted function from a thread and blocks until | |
the deferred has called back. | |
If the function did not return a deferred, raise an exception. | |
""" |
from threading import Thread, Event | |
class Backend(object): | |
reactor_started = Event() | |
def start(self, timeout=None): | |
print "Starting backend..." | |
self._thread = Thread(target=self._start_reactor) | |
self._thread.start() | |
self.reactor_started.wait(timeout) |
from twisted.internet.protocol import Protocol | |
import re | |
class ShellProtocol(Protocol): | |
"""Define a generic shell-like protocol: | |
[login-prompt [input-echo]] | |
[password-prompt] [input-echo]] | |
[greeting] | |
[prompt] | |
[input-echo] |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Astigmatism eye test</title> | |
<style> | |
canvas { | |
position: fixed; | |
top: 0; |