Moved to: https://github.com/EmanueleMinotto/crystal
Read more: https://github.com/EmanueleMinotto/crystal/wiki
| # coding=UTF-8 | |
| from __future__ import division | |
| import re | |
| # This is a naive text summarization algorithm | |
| # Created by Shlomi Babluki | |
| # April, 2013 | |
| class SummaryTool(object): |
| import re | |
| import random | |
| def vtoc_idx(s): | |
| match_obj = re.search(r'[aeiou][^aeiou]', s.lower()) | |
| if match_obj: | |
| return match_obj.start() + 1 | |
| else: | |
| return None |
| <?php | |
| function pre_print_r($var){ | |
| echo "<pre>"; | |
| print_r($var); | |
| echo "</pre>"; | |
| } | |
| function Bigrams($word){ |
| <?php | |
| $decrease = function($self, $number) { | |
| if ($number >= 0) { | |
| echo $number . PHP_EOL; | |
| $self($self, --$number); | |
| } | |
| }; | |
| $decrease($decrease, 10); |
| <?php | |
| //set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); // optional | |
| spl_autoload_register(function ($class) { | |
| $file = preg_replace('#\\\|_(?!.+\\\)#','/', $class) . '.php'; | |
| if (stream_resolve_include_path($file)) | |
| require $file; | |
| }); |
| <?php | |
| function RESTful($root, $convention = '_%s') | |
| { | |
| $root = rtrim(str_replace('\\', '/', realpath($root)), '/'); | |
| $segments = preg_replace('~/+~', '/', trim(substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])), '/')); | |
| foreach (range(0, count($segments = explode('/', $segments))) as $i) | |
| { | |
| if (is_file(sprintf('%s/%s.php', $root, $path = implode('/', array_slice($segments, 0, $i)))) === true) |
| from math import log, floor, pow | |
| class MinMaxHeap(object): | |
| """an implementation of min-max heap using an array, | |
| which starts at 1 (ignores 0th element) | |
| """ | |
| def __init__(self, array=[]): | |
| super(MinMaxHeap, self).__init__() |
| $ -> | |
| result = [] | |
| count = 0 | |
| # Loop through each reel | |
| $('.reel-outer'). each -> | |
| $this = $(this) | |
| index = $this.index() | |
| spinPlus = 0 |