Skip to content

Instantly share code, notes, and snippets.

View pasenor's full-sized avatar

Georgy Frolov pasenor

  • Jerusalem, Israel
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pasenor
pasenor / hamcrest_match_api_error.py
Last active December 8, 2015 09:26
match json error description with hamcrest
#coding: utf-8
from copy import deepcopy
import re
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest import assert_that
from webob import Response
# Это хранится в конфиге:
error_skeleton = {
@pasenor
pasenor / jsonschema_all_required.py
Last active December 8, 2015 09:24
validate a json schema considering all fields required regardless of what's in the 'required' list
from jsonschema import Draft4Validator
from jsonschema.exceptions import ValidationError
myschema = {
'type': 'object',
'properties': {
'required_property': {
'type': 'string',
},
'optional_property': {
@pasenor
pasenor / PartialEntityMatcher.ipynb
Last active December 8, 2015 18:36
PartialEntityMatcher.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pasenor
pasenor / gist:a0d6307976d4f5e969972d15e25682a3
Last active August 28, 2017 10:23 — forked from tiarno/gist:8a2995e70cee42f01e79
find PDF font info with PyPDF2, example code
from PyPDF2 import PdfFileReader
from pprint import pprint
def walk(obj, fnt, emb):
'''
If there is a key called 'BaseFont', that is a font that is used in the document.
If there is a key called 'FontName' and another key in the same dictionary object
that is called 'FontFilex' (where x is null, 2, or 3), then that fontname is
embedded.
@pasenor
pasenor / count_lines.py
Last active September 17, 2017 19:29
count lines of code in a project
# Counting lines of code in a project
# Usage: python3 count_lines.py /path/to/project/src .cpp .h .py
# (if no extensions are specified, will count across all files)
import os
from collections import defaultdict
line_filters = {}
for ext in ('java', 'cpp', 'cc', 'cxx', 'c', 'h', 'hpp'):
line_filters[ext] = lambda line: line.strip().endswith(b';')
@pasenor
pasenor / name_test.py
Last active September 4, 2023 11:22
Разбор ФИО в именительном падеже
from collections import namedtuple
from yargy import (
rule,
and_, or_, not_,
Parser
)
from yargy.interpretation import fact
from yargy.predicates import (
eq, gram
@pasenor
pasenor / Install NVIDIA Driver and CUDA.md
Created March 24, 2019 10:07 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@pasenor
pasenor / reflect.py
Created August 20, 2019 05:41 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@pasenor
pasenor / Dockerfile
Created December 17, 2019 15:04
alpine mysql
FROM alpine:3.8 as build
ENV CXXFLAGS -std=c++98
RUN apk add --no-cache \
gcc g++ musl-dev make libc6-compat cmake \
unixodbc-dev zlib-dev openssl-dev ncurses-dev bison \
wget