Skip to content

Instantly share code, notes, and snippets.

View tommorris's full-sized avatar

Tom Morris tommorris

View GitHub Profile
prefix foaf: <http://xmlns.com/foaf/0.1/>
select distinct ?person ?givenName ?surname
where {
?person a foaf:Person;
foaf:givenName ?givenName;
foaf:surname ?surname .
}
LIMIT 200
def nested_map(f, maybe_iterable):
if hasattr(maybe_iterable, '__iter__'):
return [nested_map(f, x) for x in maybe_iterable]
else:
return f(maybe_iterable)
@tommorris
tommorris / gist:11169138
Created April 22, 2014 07:51
Infinite scrolling implemented in C
#include <stdio.h>
#include <stdlib.h>
int main() {
while (1) {
void *ptr;
ptr = malloc(10);
}
}
val words = List("Victoria", "Coren", "is", "barking", "up", "the", "wrong", "tree", "with", "this", "iPad", "example")
val longestWord = (x: List[String]) => x.sort(_.length > _.length).head
println(longestWord(words))
try:
data = get_from_database()
except ConnectionException:
return None
else:
return data
$ curl -I http://4.mshcdn.com/wp-content/uploads/2011/01/iPad-One-Year-Anniversary-Infographic.jpg
HTTP/1.1 200 OK
Date: Thu, 27 Jan 2011 11:06:38 GMT
Server: Apache
Last-Modified: Wed, 26 Jan 2011 22:24:14 GMT
ETag: "12581b0-310eb-49ac74afb5f80"
Accept-Ranges: bytes
Content-Length: 200939
Content-Type: image/jpeg
Cache-Control: private, max-age=259200
{
"items": [
{
"properties": {
"name": [
"Swingline\\u00ae 747\\u00ae Classic Desktop Staplers"
],
"photo": [
"http://www.staples-3p.com/s7/is/image/Staples/s0021414_sc7?$std$"
],
val src = Source.fromFile("/Users/tom/google_export.txt")
val data = src.getLines().map(_.split("\t")).toList
val ie_pre_9 = data.filter(_(0).toFloat < 9)
val ie_pre_9_shit_screens = ie_pre_9.filter(_(1).split("x")(0).toInt < 1024)
ie_pre_9_shit_screens.foldLeft(0)((x: Int, y: Array[String]) => x + y(2).toInt)
select gil_wiki, count(*) from globalimagelinks where gil_to in (select img_name from image where img_user = 642738) group by gil_wiki;
+-------------------+----------+
| gil_wiki | count(*) |
+-------------------+----------+
| afwiki | 1 |
| arwiki | 5 |
| arzwiki | 1 |
| azwiki | 1 |
| bgwiki | 2 |
| cawiki | 4 |
### Keybase proof
I hereby claim:
* I am tommorris on github.
* I am tommorris (https://keybase.io/tommorris) on keybase.
* I have a public key whose fingerprint is 8CD9 EC2D 0876 1B61 A0FC 090F 9C11 DBDE E42D 0DB0
To claim this, I am signing this object: