🤹♂️
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/python -u | |
""" | |
Python port of PHP serialize() and unserialize() | |
by Samuel Cochran <[email protected]> | |
I couldn't find a nice, fairly efficient implementation of serialize/unserialize for Python... so I wrote one. I didn't use str().partition because I wanted Python <2.5 compatibility. | |
TODO: Performance review. There's an awful lot of string copying. >.> |
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
<?php | |
/** | |
* Really simple, concise and fairly efficient bencode/bdecode functions | |
* for manipulating BitTorrent metadata within PHP. | |
* Lookout for a C PHP extension coming to a server near you! | |
* by Samuel Cochran <[email protected]> | |
*/ | |
function bdecode($stream) { |
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
# Simple routes implementation in Python | |
# TODO: Decouple from app framework | |
# TODO: Reverse routes | |
import re | |
from exceptions import HTTPException, HTTPNotFound, HTTPMethodNotAllowed | |
class Route(object): | |
''' Turns a textual route into a usable dispatching route. ''' |
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 formatrfc2822datetime(value=None, usegmt=False): | |
"""Returns a date string as specified by RFC 2822 section 3.3., e.g.: | |
Fri, 09 Nov 2001 01:08:47 +0900 | |
Optional value may be a datetime value. Timezone is respected. | |
""" | |
# Note: we cannot use strftime() because that honors the locale and RFC | |
# 2822 requires that day and month names be the English abbreviations. | |
if value is None: |
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 random | |
__all__ = ('corpus', 'words', 'lorem') | |
''' | |
Simple Lorem Ipsum generator for python with some probabilistic punctuation smarts. | |
The corpus is the full text of De finibus bonorum et malorum/Liber Primus from wikisource: | |
http://la.wikisource.org/wiki/De_finibus_bonorum_et_malorum/Liber_Primus |
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
require 'active_support/all' | |
class Blah | |
def foo | |
'foo!' | |
end | |
end | |
module Things | |
def self.included(base) |
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
require 'active_support/all' | |
class Blah | |
def foo | |
'foo!' | |
end | |
end | |
module Things | |
def self.included(base) |
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
class A | |
def a | |
end | |
def b | |
end | |
alias c b | |
end |
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
module Enumerable | |
def thing | |
'blah' | |
end | |
end | |
[].thing | |
# => "blah" |
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
class A | |
def initialize | |
puts "A initialized" | |
end | |
end | |
module B | |
def initialize_with_b | |
puts "B initialized" | |
end |
OlderNewer