Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / change_db_owner.sh
Created June 11, 2012 16:34 — forked from gingerlime/change_db_owner.sh
Postgresql - Changing ownership on all tables
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
@sharoonthomas
sharoonthomas / README.md
Created July 17, 2023 15:00
A pytest example to see if the Enum members are sorted by value

Sometimes you just want the StrEnums in python to be sorted by their values to avoid duplicates and also to ensure that the code is maintainable.

This test takes the selected files and then runs a test using AST to see if the enum members are sorted by the member values.

If not the test fails.

@sharoonthomas
sharoonthomas / get_weight.py
Created March 2, 2018 01:00
Find weight from scale using python and usb
# -*- coding: utf-8 -*-
"""
scale.py
Utilities to fetch weight from weighing scales
:copyright: (c) 2016-2018 by Fulfil.IO Inc.
:license: see LICENSE for details.
"""
from collections import namedtuple
@sharoonthomas
sharoonthomas / cached_property.py
Created January 25, 2012 01:02
Python cached property implementation
class cached_property(object):
"""A decorator that converts a function into a lazy property. The
function wrapped is called the first time to retrieve the result
and then that calculated result is used the next time you access
the value::
class Foo(object):
@cached_property
def foo(self):
@sharoonthomas
sharoonthomas / bitbucket.py
Created June 4, 2011 04:54
Script to display all issues in all projects/repositories of bitbucket
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Get all your bitbucket issues at once-Fetches/Displays your bitbucket issues
-
:copyright: (c) 2011 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
-
The username and password for this program can be set in multiple ways.
-
1. Set environment variable
@sharoonthomas
sharoonthomas / conftest.py
Created June 3, 2015 09:28
Example code using pytest with tryton tests
# -*- coding: utf-8 -*-
"""
tests/conftest.py
:copyright: (C) 2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import os
import time
import calendar

Keybase proof

I hereby claim:

  • I am sharoonthomas on github.
  • I am sharoonthomas (https://keybase.io/sharoonthomas) on keybase.
  • I have a public key whose fingerprint is 764C 51C1 03D6 9EC6 7E38 7B03 EDBC 869F 2524 2CB0

To claim this, I am signing this object:

@sharoonthomas
sharoonthomas / postgres-benchmark.sh
Created December 28, 2018 22:45
Benchmark postgres servers
touch /etc/apt/sources.list.d/pgdg.list
echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get install -y postgresql-10
# now go to pgtune for config
@sharoonthomas
sharoonthomas / README.md
Created January 5, 2018 16:43
Update supplier inventory from third party shopify store

Supplier Inventory Feed

Usage

  • Your supplier uses shopify.
  • They are willing to expose inventory over Shopify API giving you a private app API key and Password.
  • You are using fulfil and has product suppliers defined.

How this works

@sharoonthomas
sharoonthomas / auth.py
Created October 9, 2019 12:30
Example of using fulfil authentication in a flask app
@blueprint.route('/login', methods=['GET', 'POST'])
def login():
"""
If there is no login, redirect the user to the authorization url
"""
oauth_session = get_oauth_session()
next = flask.request.args.get('next')
authorization_url, state = oauth_session.create_authorization_url(
redirect_uri=flask.url_for(
'.authorized',