View merge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge(streams): | |
# Keep track of the least value in each stream. | |
head = [stream.next() for stream in streams] | |
while len(head): | |
# Yield the least value of all streams. | |
next = min(head) | |
yield next | |
index = head.index(next) | |
try: | |
# Get next value from that stream. |
View newcomments.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $url = "https://news.ycombinator.com/newcomments"; | |
sub html { | |
`curl get $url 2>/dev/null`; | |
} | |
printf "# %s", `date`; |
View reservoir.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import random as rand | |
def reservoir1(stream): | |
i = 1 | |
choice = None | |
for value in stream: | |
if rand() * i < 1: | |
choice = value | |
i = i + 1 | |
return choice |
View catalan.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def catalan(): | |
"""Yields catalan numbers: 1 1 2 5 14 42 132...""" | |
n = 0 | |
c = 1 | |
while 1: | |
yield c | |
n = n+1 | |
c = c * 2 * (2*n-1) / (n+1) | |
# print the first ten catalan numbers |
View graph.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"polys":[{"fillColor":"110-hsb(0.1820702975615859,0.7,1)-hsb(0.38207029756158595,0.9,1)","vertices":[{"x":0.0380517503805175,"y":0.25799086757990863},{"x":0.11643835616438353,"y":0.25722983257229837},{"x":0.13318112633181123,"y":0.21232876712328766},{"x":0.1582952815829528,"y":0.27853881278538817},{"x":0,"y":0.2808219178082192},{"x":0.1537290715372907,"y":0},{"x":0.33409436834094364,"y":0.2808219178082192},{"x":0.1811263318112633,"y":0.27929984779299843},{"x":0.20319634703196343,"y":0.21232876712328766},{"x":0.2161339421613394,"y":0.25494672754946723},{"x":0.29147640791476404,"y":0.258751902587519},{"x":0.1552511415525114,"y":0.04033485540334855}]}],"particles":[]} |
View original.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var notification = navigator.mozNotification; | |
if (notification && notification.requestRemotePermission) { | |
// Ask the user to allow notifications. | |
var request = notification.requestRemotePermission(); | |
request.onsuccess = function() { | |
var url = request.result; | |
console.log('New push URL: ' + url); | |
// We got a new push URL, store it on the server. | |
jQuery.post('/push-urls/', {url: url}); | |
}; |
View gist:2244383
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeURL(firstname,lastname) { | |
var name = firstname + lastname; | |
if (!name) { | |
return null; | |
} else { | |
return name; | |
} | |
} |
View moon.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body style="background: black"> | |
<a href="http://inamidst.com/stuff/notes/csspx"> | |
<img src="http://upload.wikimedia.org/wikipedia/en/thumb/c/c9/Moon_nearside_LRO.jpg/170px-Moon_nearside_LRO.jpg" style="width:24.3px;height:24.3px"> | |
</a> |
View ssh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import thor | |
thor.ssh() |
View Custom.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#mw-page-base, #mw-head-base, #content, | |
#mw-head, #mw-panel, #footer { | |
display: block !important; | |
} | |
#mw-sopaOverlay { | |
display: none !important; | |
} |
NewerOlder