Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / explanation.md
Created October 10, 2024 01:19
delivery times = happier customers = better repurchase rates ?? May be

Shipment Analysis Query Explanation

This SQL query performs an in-depth analysis of shipment data, focusing on delivery times, customer behavior, and carrier performance. The query is structured in three main parts: two Common Table Expressions (CTEs) and a final SELECT statement.

This was inspired by a post by Mehtab Karta.

CleanShot 2024-10-09 at 21 19 15

Prerequisites

@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.

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 / 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',
@sharoonthomas
sharoonthomas / FULFIL_CLA
Last active March 20, 2019 10:29
Contributor License Agreement (CLA)
# Fulfil.IO Open Source Projects Individual Contributor License Agreement
Thank you for your interest in contributing to Fulfil.IO Open Source Projects ("We" or "Us").
This contributor agreement ("Agreement") documents the rights granted by contributors to Us. To make this document effective, please sign it and send it to Us by electronic submission, following the instructions at . This is a legally binding document, so please read it carefully before agreeing to it. The Agreement may cover more than one software project managed by Us.
## 1. Definitions
"You" means the individual who Submits a Contribution to Us.
@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 / pull_fulfil_activity_stream.py
Created November 20, 2018 19:22
Utilize Fulfil API to download complete Activity Stream Data history
import requests
import pandas as pd
from pandas.io.json import json_normalize
import numpy as np
import os
import json
from google.cloud import storage, bigquery
import datetime
import time
from multiprocessing.pool import ThreadPool
@sharoonthomas
sharoonthomas / read_report.py
Created August 29, 2018 15:18
Reading Fulfil interactive reports from API
from datetime import date
from fulfil_client import Client
fulfil = Client('<subdomain>', '<apikey>')
# Fetch the report instance
# The name can be obtained from the URL
report = fulfil.interactive_report('account.invoice.revenue_by_month.ireport')
# Trigger execution with the fields
@sharoonthomas
sharoonthomas / update_supplier_prices.py
Last active September 26, 2018 20:54
Update the supplier prices over API by reading a CSV file with sku, supplier_name and price
import os
import csv
import sys
from decimal import Decimal
from fulfil_client import Client
client = Client(
os.environ.get('FULFIL_SUBDOMAIN'),
os.environ.get('FULFIL_API_KEY'),
@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