In python yield can be used to transfer information in both directions.
yield 'hello'
will generate (vs return) the string "hello", whereas
red_1 | red_2 | red_3 | red_4 | red_5 | red_6 | red_7 | red_8 | blue_1 | blue_2 | blue_3 | blue_4 | blue_5 | blue_6 | blue_7 | blue_8 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
X | 8.06 | 19.7 | 25.2 | -19.5 | -13.3 | -2.2 | 25.3 | 0 | -78.2 | -2.2 | -54.9 | 8.3 | 33.9 | -42.8 | -39.0 | 0 | |
Y | 1465.7 | 1505.5 | 1462.2 | 1476.8 | 1435.9 | 1402.9 | 1361.6 | 0 | 1500.1 | 1483.2 | 1446.9 | 1423.3 | 1.33.5 | 1372.6 | 1433.6 | 0 | |
Thrown | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |
In Play | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
from logging import Handler | |
import logging | |
""" | |
Usage: | |
@log_handler.on_error() | |
def main_function(): | |
log.debug("You won't see this until later") | |
log.info("You'll see this immediately") |
<?php | |
define('POSITIVE', 1); | |
define('NEGATIVE', -1); | |
define('DB_CONFIG_FILE', '/path/to/mysql.json'); | |
/* MySQLi module does not have this function by default */ | |
function mysqli_field_name($result, $field_offset) { | |
$properties = mysqli_fetch_field_direct($result, $field_offset); | |
return is_object($properties) ? $properties->name : null; | |
} |
ELO_DEFAULT = 1500 | |
ELO_K_FACTOR = 16 | |
def expected(Ra, Rb): | |
# https://en.wikipedia.org/wiki/Elo_rating_system | |
Ea = (1.0 / (1.0 + pow(10.0, (Rb-Ra)/400.0))) | |
return Ea, 1-Ea | |
@bot.add_command('!challenge') | |
@gen.coroutine |
In [1]: b = object() | |
In [2]: import json | |
In [3]: json.dumps(b) | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-3-8c425ddada75> in <module>() | |
----> 1 json.dumps(b) |
def is_pal(some_int): | |
reverse = list(str(some_int)) | |
reverse.reverse() | |
reverse = int(''.join(reverse)) | |
return some_int == reverse | |
def main(): | |
start = 999 |
FROM python:2.7 | |
MAINTAINER Mikhail Simin | |
ENV USE_REDIS true | |
ENV USE_SLACK true | |
ADD alphabot /app/alphabot | |
RUN pip install -e /app/alphabot | |
ADD requirements.txt /app/requirements.txt | |
RUN pip install -r /app/requirements.txt |
The two functions (akt
and mkvin
) in this gist allow for a quick way to create end activate python's virtual environments
mkvin
will create a new virtual environment in $HOME/virtualenvironments
directory with the name of the directory you're in.
For example:
[mikhail@MadRussian git]$ mkdir projectzero
[mikhail@MadRussian git]$ cd projectzero
[mikhail@MadRussian projectzero]$ mkvin
Based on https://gist.github.com/2206527 this script loops through databases and tables and creates individual files that are uploaded to S3.