I hereby claim:
- I am iepathos on github.
- I am iepathos (https://keybase.io/iepathos) on keybase.
- I have a public key ASD9gj36Xvfv8VyEEwuWO1EpimNbmXS9Hk5Yqzs7XICj7wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| ''' | |
| Simple socket server using threads | |
| ''' | |
| import socket | |
| import sys | |
| HOST = '' # Symbolic name, meaning all available interfaces | |
| PORT = 8888 # Arbitrary non-privileged port | |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import SocketServer | |
| class MyTCPHandler(SocketServer.BaseRequestHandler): | |
| """ | |
| The RequestHandler class for our server. | |
| It is instantiated once per connection to the server, and must | |
| override the handle() method to implement communication to the |
| # Dictionaries are inherently orderless, but lists are ordered! | |
| import collections | |
| d = { '123': { 'key1': 3, 'key2': 11, 'key3': 3 }, | |
| '124': { 'key1': 6, 'key2': 56, 'key3': 6 }, | |
| '125': { 'key1': 7, 'key2': 44, 'key3': 9 } } | |
| results_list = [] | |
| sort_by_dict = {} |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from flask.ext.script import Manager, Command, Option | |
| from app import app, db | |
| import os | |
| import imp | |
| from migrate.versioning import api | |
| from config import SQLALCHEMY_DATABASE_URI |
| import random, sys | |
| """ | |
| Miller Rabin Probabilistic Primality Test | |
| """ | |
| def miller_rabin_pass(a, s, d, n): | |
| a_to_power = pow(a, d, n) | |
| if a_to_power == 1: | |
| return True | |
| for i in xrange(s-1): |
| from math import sqrt | |
| """ | |
| Fast factorization algorithm. Uses tuples instead of lists | |
| and sqrt over exponentiation. | |
| """ | |
| def factors(n): | |
| return set(x for tup in ([i, n//i] | |
| for i in range(1, int(sqrt(n))+1) if n % i == 0) for x in tup) |
| #urls.py | |
| from django.conf import settings | |
| urlpatterns = patterns('', | |
| url(r'^favicon.ico/$', lambda x: HttpResponseRedirect(settings.STATIC_URL+'ico/favicon.ico')), #google chrome favicon fix | |
| ) | |
| # base.html | |
| <link rel="shortcut icon" href="{{ STATIC_URL }}ico/favicon.ico"> |