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 = '.'
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 */
@maksymx
maksymx / subnet.py
Created March 28, 2016 12:01 — forked from nboubakr/subnet.py
A simple python script converts a Classless Inter-Domain Routing (CIDR)-formatted IP address into an IP range and netmask.
#!/usr/bin/env python
# python subnet.py 200.100.33.65/26
import sys
# Get address string and CIDR string from command line
(addrString, cidrString) = sys.argv[1].split('/')
# Split address into octets and turn CIDR into int
addr = addrString.split('.')
@maksymx
maksymx / db.create.user.js
Created February 10, 2016 08:21 — forked from veysiertekin/db.create.user.js
Mongo DB - usefull tricks
// select db
use test;
// create a user with db role(s) (http://docs.mongodb.org/manual/reference/built-in-roles/)
db.createUser( { user: "test", pwd: "changeit", roles: [ { role: "dbOwner", db: "test" } ] } );