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
$words = explode(" ",$trendResults['model_words']); | |
$weights = explode(" ",$trendResults['model_weight']); | |
$word_weights = array(); | |
for ( $i = 0; $i <= sizeof($words); $i += 1) { | |
$word_weights[$i] = $weights[$i]; | |
} | |
arsort($word_weights); | |
$wordLimit = 4; | |
$idxs = array(); | |
foreach($word_weights as $index => $weight){ |
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 colorcycle(steps): | |
colors = [colorsys.hsv_to_rgb(i / 1.1 / steps, 1, 1) for i in range(steps)] | |
return ['#%02x%02x%02x' % (r * 255, g * 255, b * 255) for r,g,b in colors] |
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 foo(): | |
... raise StopIteration | |
... | |
>>> list(foo()) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "<stdin>", line 2, in foo | |
StopIteration | |
>>> def foo(): | |
... raise StopIteration |
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
ALTER TABLE `fact`.`news_events_clue` MODIFY COLUMN `article_id` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, | |
MODIFY COLUMN `relation` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, | |
MODIFY COLUMN `primary_parameters` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, | |
MODIFY COLUMN `optional_parameters` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, | |
MODIFY COLUMN `sentence` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, | |
MODIFY COLUMN `version` VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; |
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
#ifndef BOOST_SERIALIZATION_UNORDEREDMAP_HPP | |
#define BOOST_SERIALIZATION_UNORDEREDMAP_HPP | |
#include <boost/unordered_map.hpp> | |
#include <boost/config.hpp> | |
#include <boost/serialization/utility.hpp> | |
#include <boost/serialization/collections_save_imp.hpp> | |
#include <boost/serialization/collections_load_imp.hpp> |
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 Foo: | |
def __init__(self): | |
self.bar = lambda: Foo.bar(self) | |
@staticmethod | |
def bar(self=None): | |
print 'called with self: %s' % 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 Foo: | |
def __init__(self): | |
self.bar = lambda: Foo.bar(self) | |
@staticmethod | |
def bar(self=None): | |
print 'called with self: %s' % 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
from threadpool import ThreadPool | |
import random | |
import gevent | |
import gevent.pool | |
iterations = 1000000 | |
max_stack_depth = 50 | |
def source(tp): | |
for i in xrange(0, iterations): |
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 gevent | |
import gevent.pool | |
import multiprocessing | |
def child_runner(): | |
p = multiprocessing.Process(target=child) | |
p.start() | |
print gevent.getcurrent() | |
def child(): |
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 gevent | |
import gevent.pool | |
import multiprocessing | |
SPAWN_COUNT = 5 | |
def child_runner(): | |
p = multiprocessing.Process(target=child) | |
p.start() | |
print gevent.getcurrent() |
OlderNewer