Skip to content

Instantly share code, notes, and snippets.

View kissgyorgy's full-sized avatar

György Kiss kissgyorgy

View GitHub Profile
@kissgyorgy
kissgyorgy / crypto_lib_matrix.txt
Last active March 18, 2017 11:45
Pyton Crypto lib matrix
Subdomain Marked OpenSSL OpenSSL Certifi OSCrypto urllib3
expired.badssl.com ❌ ❌ ❌ ❌ ❌
wrong.host.badssl.com ❌ ❌ ❌ ❌ ❌
self-signed.badssl.com ❌ ❌ ❌ ❌ ❌
untrusted-root.badssl.com ❌ ❌ ❌ ❌ ❌
revoked.badssl.com ❌ ✅ ✅ ✅ ✅
incomplete-chain.badssl.com ⚠ ❌ ❌ ✅ ❌
sha256.badssl.com ✅ ✅ ✅ ✅ ✅
1000-sans.badssl.com ✅ ✅ ✅ ✅ ✅
10000-sans.badssl.com ✅ ❌ ❌ ✅ ❌
@kissgyorgy
kissgyorgy / brainfuck.py
Created February 24, 2017 22:40
Python: Brainfuck interpreter
from collections import deque
def brain_luck(code, input):
code = clean_code(code)
input = deque(ord(c) for c in input)
data = [0] * 100
data_pointer = 0
code_pointer = 0
opening_bracket_indexes = []
@kissgyorgy
kissgyorgy / python2_nonlocal.py
Created February 1, 2017 00:04
Python: hack instead of nonlocal keyword in Python2
def fibonacci():
a, b = [1], [0]
def fibo():
a[0], b[0] = b[0], a[0] + b[0]
return a[0]
return fibo

Keybase proof

I hereby claim:

  • I am kissgyorgy on github.
  • I am kissgyorgy (https://keybase.io/kissgyorgy) on keybase.
  • I have a public key ASB2_e3aiEAjngE65LHAW9ZcLAKC-aZgSf5y69Dyun4FjQo

To claim this, I am signing this object:

@kissgyorgy
kissgyorgy / pizzapicker.py
Last active January 8, 2019 17:15
Python: Randomly choose a pizza from a Pizza place's webpage
#!/usr/bin/env python3
import random
from lxml import etree
import requests
import urllib3
def main(url):
# It serves over SSLv3 which requests doesn't accept on bionic
response = requests.get(url, verify=False)
@kissgyorgy
kissgyorgy / leftpad.py
Created June 8, 2016 20:36
Python: leftpad without stdlib
def leftpad(string, length):
if len(string) >= length:
return string
spaces_to_add = length - len(string)
return ' ' * spaces_to_add + string
@kissgyorgy
kissgyorgy / test_coverage.sh
Created April 15, 2016 15:34
Only apply Django database migrations if there are new ones.
if [[ $(manage.py showmigrations -p | grep "\[ \]") ]]; then
coverage run --source=. --omit="*/migrations/*,manage.py" -m py.test -v --create-db --junitxml=junit.xml
coverage xml --ignore-errors
else
coverage run --source=. --omit="*/migrations/*,manage.py" -m py.test -v --junitxml=junit.xml
coverage xml --ignore-errors
fi
@kissgyorgy
kissgyorgy / pizza_calculator.py
Created February 27, 2016 13:13
Python: pizza calculator calculates which is bigger
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import math
first_size = float(raw_input('Első pizza mérete (cm): '))
first_pieces = int(raw_input('Első pizza darabszáma: '))
second_size = float(raw_input('Második pizza mérete (cm): '))
second_pieces = int(raw_input('Második pizza darabszáma: '))
@kissgyorgy
kissgyorgy / pizzapicker.py
Created December 6, 2015 15:40
Random pizza picker from website
# -*- coding: utf-8 -*-
import random
from lxml import etree
import requests
def main(url):
response = requests.get(url)
root = etree.HTML(response.content)
@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active April 21, 2025 11:44
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")