This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = {192: u'A', 193: u'A', 194: u'A', 195: u'A', 196: u'A', 197: u'A', | |
199: u'C', 200: u'E', 201: u'E', 202: u'E', 203: u'E', 204: u'I', | |
205: u'I', 206: u'I', 207: u'I', 209: u'N', 210: u'O', 211: u'O', | |
212: u'O', 213: u'O', 214: u'O', 216: u'O', 217: u'U', 218: u'U', | |
219: u'U', 220: u'U', 221: u'Y', 224: u'a', 225: u'a', 226: u'a', | |
227: u'a', 228: u'a', 229: u'a', 231: u'c', 232: u'e', 233: u'e', | |
234: u'e', 235: u'e', 236: u'i', 237: u'i', 238: u'i', 239: u'i', | |
241: u'n', 242: u'o', 243: u'o', 244: u'o', 245: u'o', 246: u'o', | |
248: u'o', 249: u'u', 250: u'u', 251: u'u', 252: u'u', 253: u'y', | |
255: u'y'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function performs the fetch from cache portion of the functionality needed to cache ajax | |
* calls and still fulfill the jqXHR Deferred Promise interface. | |
* See also $.ajaxPrefilter | |
* @method $.ajaxTransport | |
* @params options {Object} Options for the ajax call, modified with ajax standard settings | |
*/ | |
$.ajaxTransport("json", function(options){ | |
if (options.localCache) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# Test celery's rate_limit | |
Tested version of python | |
$ python --version | |
Python 2.7.11 | |
## Requirements | |
$ pip install celery==3.1.23 | |
$ pip install SQLAlchemy==1.0.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import hashlib | |
import hmac | |
import simplejson as json | |
def base64_url_decode(inp): | |
padding_factor = (4 - len(inp) % 4) % 4 | |
inp += "="*padding_factor | |
return base64.b64decode(unicode(inp).translate(dict(zip(map(ord, u'-_'), u'+/')))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from django.apps import apps | |
from django.conf import settings | |
from django.core.management.base import BaseCommand | |
from django.db import connections | |
from django.db.migrations.autodetector import MigrationAutodetector | |
from django.db.migrations.executor import MigrationExecutor | |
from django.db.migrations.state import ProjectState | |
from django.db.utils import OperationalError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prefilter for caching ajax calls - adapted from | |
* https://github.com/paulirish/jquery-ajax-localstorage-cache, made to work with jqXHR Deferred Promises. | |
* See also $.ajaxTransport. | |
* New parameters available on the ajax call: | |
* localCache : true, // required if we want to use the cache functionality | |
* cacheTTL : 1, // in hours. Optional | |
* cacheKey : 'post', // optional | |
* isCacheValid : function // optional - return true for valid, false for invalid | |
* @method $.ajaxPrefilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This has been edited to work with python3. Some of the tested combinations will not work in python2. | |
import pandas as pd | |
df = pd.DataFrame({'text': [str(i % 1000) for i in range(1000000)], | |
'numbers': range(1000000)}) | |
import pickle | |
# Python 3 has no cPickle | |
#import cPickle | |
import json | |
from functools import partial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import re | |
# https://trac-hacks.org/ticket/11050#comment:13 | |
_illegal_unichrs = ((0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F), | |
(0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF), | |
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), | |
(0x3FFFE, 0x3FFFF), (0x4FFFE, 0x4FFFF), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TransactionsList(ListAPIView): | |
""" | |
List all transactions for currently logged in user, paginated by 25 | |
page -- page number | |
ordering -- yoddle_amount, created, yoddle_description, reverse order ie. -yoddle_amount | |
""" | |
model = Transaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Attention(Module): | |
""" | |
Computes a weighted average of channels across timesteps (1 parameter pr. channel). | |
""" | |
def __init__(self, attention_size, return_attention=False): | |
""" Initialize the attention layer | |
# Arguments: | |
attention_size: Size of the attention vector. | |
return_attention: If true, output will include the weight for each input token | |
used for the prediction |
OlderNewer