Skip to content

Instantly share code, notes, and snippets.

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")
@mikhail
mikhail / class.mysql.php
Created May 13, 2019 20:41
MySQL abstraction library
<?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;
}
@mikhail
mikhail / elo_for_ping_pong.py
Last active August 8, 2018 00:21
Elo for ping pong
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)
@mikhail
mikhail / pal_power.py
Created April 17, 2018 18:00
Palindrome power
def is_pal(some_int):
reverse = list(str(some_int))
reverse.reverse()
reverse = int(''.join(reverse))
return some_int == reverse
def main():
start = 999
@mikhail
mikhail / Dockerfile
Created November 12, 2016 17:37
Private alphabot docker file
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
@mikhail
mikhail / README.md
Last active January 29, 2016 22:38
Quick handling of python's virtualenv

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
@mikhail
mikhail / publish.py
Created August 27, 2015 15:44
Git -> WordPress draft publisher
#!/usr/bin/env python
import logging
import md5
import optparse
import os
import re
import subprocess
import sys
from wordpress_xmlrpc import Client, WordPressPost
@mikhail
mikhail / README.md
Last active August 29, 2015 14:24
Automatic Github changelog

Doing a proper version release requires documenting all the things you've changed. Frequently CHANGELOG.md is used for these purposes.

Unless you are maintaining that file throughout the changes it can become a hassle. Luckily you can leverage GitHub's issue tracking and PR system to manage that for you. If you use GitHub's milestones like you would versions then you have all the data there for you. However, you're stil left with the collection and formatting of the changes.

The script below automatically grabs that data for you and creates a markdown output. I've been successfully using it for our Kingpin project for several releases. Here's the sample use:

$ ./get_changelog Nextdoor/kingpin 0.2.0
## Version 0.2.0
 * #174: Add actor 'initialization context' support. ([@diranged])