Skip to content

Instantly share code, notes, and snippets.

View anacrolix's full-sized avatar
🚀
Factorio

Matt Joiner anacrolix

🚀
Factorio
View GitHub Profile
class g:
def __init__(self):
self.s = "f"
def __call__(self, c=None):
if c is None:
self.s += "o"
return self
else:
return self.s+c
def f(c=None):
usage = chunk(redis_cli('hgetall', key+':'+date), 2)
usage = map(lambda x: x[:1]+(int(x[1]),)+x[2:], usage)
usage = sorted(usage, key=lambda x: x[1], reverse=True)
module StaleUpdater exposing (..)
type alias StaleUpdater =
{ stale : Bool
, updating : Bool
}
new : StaleUpdater
@anacrolix
anacrolix / blah.go
Created January 15, 2016 17:54
example using piece store
package main
import (
"bytes"
"crypto/tls"
"database/sql"
"encoding/hex"
"flag"
"html/template"
"io"
def alternates_even_odd(x):
x = iter(x)
try:
while True:
if next(x)%2:
return False
if not next(x)%2:
return False
except StopIteration:
return True
mkdir ~/whatToDownload ~/torrentfs
someServiceThatLetsYouModifyFolder ~/whatToDownload &
torrentfs ~/whatToDownload ~/torrentfs &
httpFileServer ~/torrentfs
package append
import "testing"
var result []T
const size = 10000
type T int
@anacrolix
anacrolix / ourlang.md
Created October 7, 2012 03:47
Ideal language

Syntax

  • Infix?
  • Whitespace-aware, but not required (implicit {})

Features

  • Static single assignment
@anacrolix
anacrolix / reddit-open.py
Created September 27, 2012 05:20
Opens front page on reddit for the given subreddit
#!/usr/bin/env python3
import argparse
import http.cookies
import io
import json
import pprint
import urllib.request
import webbrowser
@anacrolix
anacrolix / striter.py
Created September 26, 2012 14:35
A Python IO class wrapping an iterable of strings.
import io
class StringIteratorIO(io.TextIOBase):
def __init__(self, iter):
self._iter = iter
self._left = ''
def readable(self):
return True