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
from io import BytesIO | |
from PIL import Image, ImageDraw, ImageFont | |
import requests | |
def get_x(img, draw, font, text): | |
img_w, _ = img.size | |
text_w, _ = draw.textsize(text, font=font) | |
return int((img_w - text_w) / 2) |
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
local ret_status="%(?:%{$fg_bold[white]%}🔧 :%{$fg_bold[red]%}🗡 %s)" | |
PROMPT='%{$fg_bold[green]%}%p%{$fg[cyan]%}%c $(git_prompt_info)$(virtualenv_prompt_info)% ${ret_status} %{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_colori%}" | |
ZSH_THEME_VIRTUALENV_PREFIX="%{$fg_bold[blue]%}" | |
ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color%} " |
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
from google.appengine.api import datastore_types | |
from mock import patch | |
from freezegun import freeze_time as _freeze_time | |
from freezegun.api import FakeDatetime | |
class freeze_time(object): | |
def __init__(self, *args, **kwargs): | |
self._gae_patch = patch( | |
'google.appengine.ext.db.DateTimeProperty.data_type', |
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 pyparsing as pp | |
token = pp.Word(pp.alphanums + '_-.') | |
command = pp.OneOrMore(token) | |
separators = ['1>>', '2>>', '>>', '1>', '2>', '>', '<', '||', | |
'|', '&&', '&', ';'] | |
separator = pp.oneOf(separators) |
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
from functools import wraps | |
class Partial: | |
def __init__(self, fn, args, kwargs): | |
self._fn = fn | |
self._args = args | |
self._kwargs = kwargs | |
def __call__(self, replacement): |
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 ast | |
class EllipsisPartialTransform(ast.NodeTransformer): | |
def __init__(self): | |
self._counter = 0 | |
def _get_arg_name(self): | |
"""Return unique argument name for lambda.""" | |
try: |
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
(ns math-6.core | |
(:require [clojure.math.numeric-tower :refer [abs]])) | |
(def boundaries (range -100 100)) | |
(defn- get-cs-after-second | |
[c-before-before c-before] | |
(when-let [c (mod c-before-before c-before)] | |
(if (zero? c) | |
[0] |
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
from collections import namedtuple | |
import timeit | |
import matplotlib.pyplot as plt | |
ComplexityLogEntry = namedtuple('ComplexityLogEntry', ('size', 'time')) | |
class BaseComplexityAssumption(object): | |
title = '' |
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
#include <iostream> | |
#include <sstream> | |
#include <regex> | |
using namespace std; | |
class Validator { | |
public: | |
Validator(istream &in) : in_(in) {} |
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
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
def _py_backwards_merge_dicts(dicts): | |
result = {} | |
for dict_ in dicts: | |
result.update(dict_) |