Skip to content

Instantly share code, notes, and snippets.

View trigger.py
import codecs
import logging
import os
import os.path as P
from gensim.models import FastText
from gensim.models.callbacks import CallbackAny2Vec
class EpochSaver(CallbackAny2Vec):
'''Callback to save model after each epoch and show training parameters '''
View check.py
"""Check whether each line contains tab-separated decodable JSON."""
import sys
import json
import logging
logging.basicConfig(level=logging.ERROR)
for i, line in enumerate(sys.stdin, 1):
try:
View chargrep.py
#!/usr/bin/env python
#
# Check if a file contains a set of chars
#
import argparse
import logging
import sys
import time
import collections
import unittest
View rcc.py
#
# reddit comment cleaner
# Delete my comments from a particular subreddit
#
import argparse
import getpass
import praw
import logging
logging.basicConfig(level=logging.DEBUG)
View keybase.md

Keybase proof

I hereby claim:

  • I am mpenkov on github.
  • I am mpenkov (https://keybase.io/mpenkov) on keybase.
  • I have a public key whose fingerprint is A022 9250 8FCD 119E C2BA 95E3 2A45 33DE C003 2C03

To claim this, I am signing this object:

View strength.html
<style>
#chart svg {
height: 400px;
}
/* http://stackoverflow.com/questions/18530459/nvd3-js-bigger-points-in-a-line-chart */
.nvd3 .nv-groups .nv-point {
stroke-opacity: 0.2 !important;
stroke-width: 10px;
}
@mpenkov
mpenkov / qunit-1.11.0.css
Last active Aug 29, 2015
Coding for Interviews: The Staque
View qunit-1.11.0.css
/**
* QUnit v1.11.0 - A JavaScript Unit Testing Framework
*
* http://qunitjs.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
@mpenkov
mpenkov / coins.py
Last active Aug 29, 2015
Coding for Interviews: Dynamic Programming
View coins.py
import copy
def coinChangePossibleSolutions(amount, denominations):
"""Return the total number of ways of obtaining the specified amount using an unlimited number of coins of the specified denominations."""
#
# The cache keeps a mapping of amounts to a set of arrangements of coins.
# We use set to keeps solutions unique.
# Each arrangement is represented as a tuple, since the mutable lists aren't hashable and cannot be kept in the above set.
#
cache = {}
@mpenkov
mpenkov / fiddle.html
Last active Jan 1, 2016
Coding for Interviews: Bit Manipulation
View fiddle.html
<body>
<p>Decimal: <input type="text" id="txtDecimal" value="5"><input type="submit" id="btnGoDecimal" value="Go"></p>
<p>Binary (MSB first): <input type="text" id="txtBinary" value="101"><input type="submit" id="btnGoBinary" value="Go"></p>
<p>
Bit position (LSB is zero): <input type="number" id="numBit" value="0" min="0" max="128"><input type="submit" id="btnGet" value="Get">
<input type="submit" id="btnSet0" value="Set to 0"><input type="submit" id="btnSet1" value="Set to 1">
</p>
<p id="pResult"></p>
</body>