This file contains hidden or 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 greenlet import greenlet | |
| print "\n\nSwitching between greenlets" | |
| def test1(): | |
| print "In test 1 - a" | |
| gr3.switch() | |
| print "In test 1 - b" |
This file contains hidden or 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 gevent import Greenlet | |
| import gevent | |
| class MyNoopGreenlet(Greenlet): | |
| def __init__(self, number, seconds): | |
| Greenlet.__init__(self) | |
| self.number = number | |
| self.seconds = seconds | |
| print "Initialized greenlet with number:%i seconds:%i" % \ |
This file contains hidden or 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 select | |
| import socket | |
| import sys | |
| import Queue | |
| # Create a TCP/IP socket | |
| server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| server.setblocking(0) | |
| # Bind the socket to the port |
This file contains hidden or 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 socket | |
| import sys | |
| messages = [ 'This is the message. ', | |
| 'It will be sent ', | |
| 'in parts.', | |
| ] | |
| server_address = ('localhost', 10000) | |
| # Create a TCP/IP socket |
This file contains hidden or 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 tornado.web | |
| import tornado.gen | |
| import time | |
| from functools import partial | |
| import os | |
| from concurrent.futures import ThreadPoolExecutor | |
| def long_blocking_function(index, sleep_time): | |
| print "Entering run counter:%s" % (index,) |
This file contains hidden or 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
| [user] | |
| name = vikram singh | |
| email = simplyvikram@gmail.com | |
| [credential] | |
| helper = osxkeychain | |
| [core] | |
| editor = vim | |
| [merge] | |
| tool = p4mergetool |
This file contains hidden or 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
| # http://nbviewer.ipython.org/urls/gist.github.com/ChrisBeaumont/5758381/raw/descriptor_writeup.ipynb | |
| # http://pyvideo.org/video/1760/encapsulation-with-descriptors | |
| class NonNegativeValue(object): | |
| __counter = 0 | |
| def __init__(self): | |
| prefix = self.__class__.__name__ |
This file contains hidden or 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 lzw_encode(text): | |
| """Compress a string to a list of output symbols.""" | |
| # Build the dictionary. | |
| dict_size = 256 | |
| dictionary = dict((chr(i), i) for i in xrange(dict_size)) | |
| w = "" | |
| result = [] | |
| for c in text: |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| type Asset interface { | |
| AssetType() string | |
| GetBase() Base | |
| SetBase(b Base) | |
| } | |
| type Base struct { |
This file contains hidden or 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 math import sqrt | |
| class Point(object): | |
| def __init__(self, x, y): | |
| self.x = x | |
| self.y = y | |
| def __str__(self): |
OlderNewer