Skip to content

Instantly share code, notes, and snippets.

View maksymx's full-sized avatar
🐍
I may be slow to respond.

Maksym L maksymx

🐍
I may be slow to respond.
View GitHub Profile
@maksymx
maksymx / sqlalchemy_replica.py
Created July 14, 2020 20:24 — forked from jasonwalkeryung/sqlalchemy_replica.py
SQLAlchemy read replica wrapper
"""This is not the full code. We do a lot of stuff to clean up connections, particularly for unit testing."""
import sqlalchemy
from sqlalchemy.orm import Query, Session, scoped_session, sessionmaker
CONFIG_KEY_SQLALCHEMY_BINDS = 'SQLALCHEMY_BINDS'
CONFIG_KEY_SQLALCHEMY_RO_BINDS = 'SQLALCHEMY_READ_ONLY_BINDS'
class Config:
# These default values are for testing. In a deployed environment, they would be three separate instances.
SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/branded_dev'
@maksymx
maksymx / aws_ssm_get_parameter.md
Created July 2, 2019 12:21 — forked from ruanbekker/aws_ssm_get_parameter.md
Getting Secrets from SSM using GetParameter Example with Python and Boto3

Bash Environment Example with SSM to get Parameter Values using GetParameter:

IAM Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1517398919242",
@maksymx
maksymx / bucketSort.py
Created February 16, 2019 10:10 — forked from joaofeitoza13/bucketSort.py
Bucket Sort python code.
import random
import math
import timeit
import matplotlib.pyplot as plt
timeBubble = []
timeSelection = []
timeInsertion = []
timeQuick = []
timeMerge = []
@maksymx
maksymx / astar.py
Created July 30, 2018 14:30 — forked from jamiees2/astar.py
A* Algorithm implementation in python.
# Enter your code here. Read input from STDIN. Print output to STDOUT
class Node:
def __init__(self,value,point):
self.value = value
self.point = point
self.parent = None
self.H = 0
self.G = 0
def move_cost(self,other):
return 0 if self.value == '.' else 1
@maksymx
maksymx / dlAttachments.py
Created March 28, 2018 13:36 — forked from baali/dlAttachments.py
Python script to download all gmail attachments.
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
@maksymx
maksymx / imaging.py
Created December 13, 2017 17:34
Image resize + upload to s3
import os
from io import BytesIO
import boto3
from PIL import Image
from django.conf import settings
def store_in_bucket(data, key, content_type, public_read=False):
boto3.client('s3').put_object(
@maksymx
maksymx / PASCAL.sublime-build
Last active August 8, 2023 14:21
Sublime Text build system for Pascal project
{
"cmd": ["fpcbuild.bat", "$file"], "quiet": true
}
import urllib2
from multiprocessing.dummy import Pool as ThreadPool
urls = [
'http://www.python.org',
'http://www.python.org/about/',
'http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html',
'http://www.python.org/doc/',
'http://www.python.org/download/',
'http://www.python.org/getit/',
@maksymx
maksymx / main.py
Created April 22, 2017 18:52 — forked from miloharper/main.py
A two layer neural network written in Python, which trains itself to solve a variation of the XOR problem.
from numpy import exp, array, random, dot
class NeuronLayer():
def __init__(self, number_of_neurons, number_of_inputs_per_neuron):
self.synaptic_weights = 2 * random.random((number_of_inputs_per_neuron, number_of_neurons)) - 1
class NeuralNetwork():
def __init__(self, layer1, layer2):
@maksymx
maksymx / userChrome.css
Created February 24, 2017 08:56 — forked from AnthonyDiGirolamo/userChrome.css
thunderbird custom style for message and folder pane list
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
/* Set Font Size In Folder Pane */
#folderTree >treechildren::-moz-tree-cell-text {
/*font-family: Lucida Sans !important;*/
font-size: 12pt !important; }
/* Set Font Size In Thread Pane */