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
""" | |
This is a simple benchmark that tests the performance of several | |
locking implementations. Each example implements a connection | |
pool that provides `get_connection()` to retrieve a connection | |
from the pool and `release()` to return a connection back to the | |
pool. | |
The `test()` function creates an instance of `pool_class` and | |
creates `num_threads` `threading.Thread` instances that simply call | |
`pool.get_connection()` and `pool.release()` repeatedly until |
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 purify(numbers): | |
return [i for i in numbers if i % 2 == 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
# pub.py | |
import json | |
import redis | |
import time | |
r = redis.StrictRedis() | |
channels = range(1000) | |
messages_per_channel = 1000 |
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 wtforms | |
class DummyPostData(dict): | |
def getlist(self, key): | |
v = self[key] | |
if not isinstance(v, (list, tuple)): | |
v = [v] | |
return v |
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": "tab_label", | |
"settings": ["highlight_modified_tabs"], | |
"parents": [{"class": "tab_control", "attributes": ["dirty"]}], | |
"fg": [120, 170, 250] | |
}, | |
// QUICKPANEL SELECTED HIGHLIGHT | |
{ |
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 os | |
import sublime_plugin | |
class NewFilePopupCommand(sublime_plugin.WindowCommand): | |
def run(self): | |
self.build_directory_tree() | |
self.window.show_quick_panel(self.labels, self.directory_selected) | |
def build_directory_tree(self): |
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 TemplateWidget(object): | |
"Uses a template to render the widget" | |
def __init__(self, template, get_value_callable=None): | |
self.template = template | |
self.get_value_callable = get_value_callable | |
def __call__(self, field, **kwargs): | |
kwargs.update({'field': field}) | |
if self.get_value_callable: | |
kwargs['value'] = self.get_value_callable(field) |
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 | |
require_once('workflows.php'); | |
$w = new Workflows(); | |
function get_icon($weather) { | |
$icon = ''; | |
switch($weather): | |
case 'Chance of Rain': $icon = 'icons/007.png'; break; | |
case 'Chance of Snow': $icon = 'icons/014.png'; break; |
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 time | |
from redis import ConnectionPool, Redis | |
class WaitingConnectionPool(ConnectionPool): | |
"Connection Pool that blocks if a connection is not available" | |
def make_connection(self): | |
while True: | |
if self._created_connections >= self.max_connections: | |
time.sleep(0.01) | |
self._created_connections += 1 |
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
Tech | |
Smartphones | |
Tablets | |
PCs | |
Accessories | |
iOS | |
Android | |
Windows | |
Windows Phone | |
Mac OS |
NewerOlder