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
from twisted.internet.protocol import Protocol, ClientCreator | |
from twisted.internet import reactor | |
class TestProtocol(Protocol): | |
def connectionMade(self): | |
self.transport.write("1234" * 1048576) | |
self.transport.loseConnection() | |
def connectionLost(self, reason): | |
reactor.stop() |
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
#include <stdio.h> | |
void hello() { | |
printf("Hello, World\n"); | |
hello(); | |
} | |
int main() { | |
hello(); | |
return 0; |
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
# Omitting typical SQLAlchemy setup | |
class User(Base): | |
__tablename__ = "users" | |
id = Column(Integer, primary_key=True) | |
username = Column(String(32)) | |
# ... | |
class Users(object): | |
def __getitem(self, username): |
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 get_event(request, event_id): | |
event = get_object_or_404(Event, pk=event_id) | |
user = request.user | |
if not event.is_access_allowed(user): | |
raise PermissionDenied() | |
return event | |
def takes_event(base_argname="event"): | |
id_argname = "%s_id" % base_argname |
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 User(Base): | |
__tablename__ = "users" | |
id = Column(Integer, primary_key=True) | |
username = Column(String(32)) | |
# ... | |
users = Collection(DBSession, User, "username") | |
root = {"users": users} | |
# or root = users |
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 DictLike(object): | |
def __contains__(self, key): | |
try: | |
ignored = self[key] | |
return True | |
except KeyError: | |
return False | |
has_key = __contains__ | |
def get(self, key, default=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
#include <iostream> | |
using namespace std; | |
class Expr { | |
public: | |
virtual ~Expr() { } | |
virtual int eval() = 0; | |
}; | |
class Literal : public Expr { |
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
type | |
TExpr = object ## abstract base class for an expression | |
TLiteral = object of TExpr | |
x: int | |
TPlusExpr = object of TExpr | |
a, b: ref TExpr | |
method eval(e: ref TExpr): int = | |
quit "to override!" |
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
public class PrintLoop { | |
public static void main(String[] args) { | |
for (int i = 0; i < 10; i++) | |
System.out.println("iteration " + i); | |
} | |
} |
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
server { | |
listen 80; | |
server_name www.raddevon.com; | |
location / | |
rewrite ^(.*)$ http://raddevon.com$1; | |
} | |
} |
OlderNewer