Skip to content

Instantly share code, notes, and snippets.

Mikhail Simin mikhail

Block or report user

Report or block mikhail

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mikhail / class.mysql.php
Created May 13, 2019
MySQL abstraction library
View class.mysql.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;
def expected(Ra, Rb):
Ea = (1.0 / (1.0 + pow(10.0, (Rb-Ra)/400.0)))
return Ea, 1-Ea
View gist:39ab2253767619512bbe17c9b2bc7d7a
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 /
Created Apr 17, 2018
Palindrome power
def is_pal(some_int):
reverse = list(str(some_int))
reverse = int(''.join(reverse))
return some_int == reverse
def main():
start = 999
mikhail / Dockerfile
Created Nov 12, 2016
Private alphabot docker file
View Dockerfile
FROM python:2.7
MAINTAINER Mikhail Simin
ADD alphabot /app/alphabot
RUN pip install -e /app/alphabot
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
mikhail /
Last active Jan 29, 2016
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 /
Created Aug 27, 2015
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 /
Last active Aug 29, 2015
Automatic Github changelog

Doing a proper version release requires documenting all the things you've changed. Frequently 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])
mikhail /
Last active Sep 25, 2015
Working with forks, branches, and pull requests

Helper scripts for git

When working with forks & branches for features and pull requests I often find myself needing common actions, like

  1. Create a new branch, and I don't care what it's named
  2. Update the last commit, and keep the commit message
  3. List all the branches I have with some description of what that branch is

Below are the scripts to do just that.

mikhail /
Last active Jun 13, 2019
Python Generators and Yielding

Python Generators and Yielding

In python yield can be used to transfer information in both directions.

yield 'hello'

will generate (vs return) the string "hello", whereas

You can’t perform that action at this time.