Skip to content

Instantly share code, notes, and snippets.

@agrif
agrif / minecraft-overviewer-9999.ebuild
Created April 5, 2012 02:27
games-misc/minecraft-overviewer-9999
EAPI=3
PYTHON_DEPEND="2:2.6"
inherit git-2 python distutils
DESCRIPTION="Generates large resolution images of a Minecraft map."
HOMEPAGE="http://overviewer.org/"
EGIT_REPO_URI="git://github.com/overviewer/Minecraft-Overviewer.git http://github.com/overviewer/Minecraft-Overviewer.git"
@agrif
agrif / dcpu16asm.py
Created May 25, 2012 00:44
a python assembler / emulator for Notch's DCPU-16
#!/usr/bin/python
import sys
from optparse import OptionParser
class Argument(object):
def __init__(self):
self._length = 0
self._extra = 0
self._repr = 'unknown'
import sys
import urllib
import urllib2
import json
def short_url(url):
if not url:
return None
apiurl = 'https://www.googleapis.com/urlshortener/v1/url'
fastcgi_pass unix:/var/www/org/overviewer/django.socket;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
def contains_even_number(l):
for elt in l:
if elt % 2 == 0:
print "list contains an even number"
break
else:
print "list does not contain an even number"
print "something else at the end"
def contains_even_number(l):
;; returns t if the number is prime, nil otherwise
(defun is-prime (n prev-primes)
(not (find-if
(lambda (p)
(eq (mod n p) 0))
prev-primes)))
;; returns all primes between start and end - 1 inclusive
;; prev-primes should be a list of primes before start, if start > 2
(defun primes-between (start end &optional prev-primes)
(defun bottles (start &optional n)
(unless n
(setq n start))
(defun plur (i &optional capitalize)
(cond ((eq i 0) (if capitalize
"No more bottles of beer"
"no more bottles of beer"))
((eq i 1) "1 bottle of beer")
((eq i -1) "~a bottles of beer" start)
(defun bottles (start &optional n)
(unless n
(setq n start))
(defun plur (i &optional capitalize)
(cond ((eq i 0) (if capitalize
"No more bottles of beer"
"no more bottles of beer"))
((eq i 1) "1 bottle of beer")
((eq i -1) "~a bottles of beer" start)
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
15M 3226M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
71758 5153K ACCEPT all -- lo any anywhere anywhere
8340 1257K DROP all -- any any anywhere anywhere ctstate INVALID
1732 109K ACCEPT icmp -- any any anywhere anywhere icmp echo-request ctstate NEW
980K 71M UDP udp -- any any anywhere anywhere ctstate NEW
543K 32M TCP tcp -- any any anywhere anywhere tcpflags: FIN,SYN,RST,ACK/SYN ctstate NEW
197K 18M REJECT udp -- any any anywhere anywhere reject-with icmp-port-unreachable
391K 23M REJECT tcp -- any any anywhere anywhere reject-with tcp-
agrif@anduril:~/devel/experiments/oil$ python
Python 2.6.6 (r266:84292, May 28 2011, 19:49:25)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import OIL
>>> i = OIL.Image.load("input.png")
>>> i
<Image object at 0x1004100d8>
>>> i.get_size()
(800, 600)