Skip to content

Instantly share code, notes, and snippets.

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 '''
"""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:
#!/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
@mpenkov
mpenkov / main.py
Created January 19, 2016 05:16
dispatch.py
#
@mpenkov
mpenkov / rcc.py
Last active December 19, 2015 14:17
#
# reddit comment cleaner
# Delete my comments from a particular subreddit
#
import argparse
import getpass
import praw
import logging
logging.basicConfig(level=logging.DEBUG)
@mpenkov
mpenkov / keybase.md
Created February 5, 2015 06:27
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:

<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 August 29, 2015 13:57
Coding for Interviews: The Staque
/**
* 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 August 29, 2015 13:56
Coding for Interviews: Dynamic Programming
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 January 1, 2016 10:39
Coding for Interviews: Bit Manipulation
<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>