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 os | |
| import json | |
| import requests | |
| from lxml import html | |
| def num_to_state(n): | |
| assert n <= 35 | |
| if n < 10: |
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 operator import itemgetter | |
| from threading import Thread | |
| try: | |
| from Queue import Queue | |
| except ImportError: | |
| from queue import Queue | |
| def concurrently(fns): |
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
| -module(message_ring). | |
| -compile(export_all). | |
| -export([]). | |
| %% Problem Statement: Write a ring benchmark. Create N processes in a | |
| %% ring. Send a message round the ring M times so that a total of N * | |
| %% M messages get sent. Time how long this takes for different values | |
| %% of N and M. |
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
| ### Hands on R session by Harshad Saykhedkar from today's Machine | |
| ### learning workshop (Fifth elephant Mumbai run-up event) | |
| --- | |
| R version 3.1.0 (2014-04-10) -- "Spring Dance" | |
| Copyright (C) 2014 The R Foundation for Statistical Computing | |
| Platform: i686-pc-linux-gnu (32-bit) | |
| R is free software and comes with ABSOLUTELY NO WARRANTY. |
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 d | |
| x = 10 | |
| def f(n): | |
| return x + n | |
| print 'f(2) called directly in module a [a.x = 10]' | |
| print f(2) |
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
| (defn consume-until-timeout | |
| [ms ch f init & args] | |
| (let [tmt (timeout ms)] | |
| (go (loop [ret init] | |
| (if-let [v (first (alts! [ch tmt]))] | |
| (recur (apply f ret [v])) | |
| ret))))) | |
| (comment |
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 time | |
| from functools import wraps | |
| def throttle_greedy(wait): | |
| def decorator(fn): | |
| state = {'last_call_at': None} | |
| @wraps(fn) | |
| def wrapper(*args, **kwargs): |
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
| <?php | |
| // defining resource-levels as arrays | |
| return array( | |
| 'exam' => array( | |
| 'levels' => array( | |
| 'view', | |
| 'create', | |
| 'edit', | |
| 'delete' |
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
| <?php | |
| class DummyCacheBackend implements CacheBackend { | |
| public function get($key) { | |
| return array(); | |
| } | |
| public function set($key, $value) { | |
| return; |
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
| The no. of lines in erlang implementation is half that in python! | |
| Observe how pattern matching alone gets rid of the selector functions |
OlderNewer