Skip to content

Instantly share code, notes, and snippets.

Avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / auth.py
Created Oct 9, 2019
Example of using fulfil authentication in a flask app
View auth.py
@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 / date_time_tz_mess.py
Created Aug 19, 2016
Difference between using pytz.localize and datetime.replace
View date_time_tz_mess.py
from datetime import date, time, datetime
import pytz
pacific = pytz.timezone('US/Pacific')
eastern = pytz.timezone('US/Eastern')
def get_naive_date_time():
date_start = date(2016, 9, 16)
time_start = time(10, 0)
@sharoonthomas
sharoonthomas / change_db_owner.sh
Created Jun 11, 2012 — forked from gingerlime/change_db_owner.sh
Postgresql - Changing ownership on all tables
View change_db_owner.sh
#!/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 Jan 5, 2018
Update supplier inventory from third party shopify store
View README.md

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 / FULFIL_CLA
Last active Mar 20, 2019
Contributor License Agreement (CLA)
View FULFIL_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 Dec 28, 2018
Benchmark postgres servers
View postgres-benchmark.sh
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 Nov 20, 2018
Utilize Fulfil API to download complete Activity Stream Data history
View pull_fulfil_activity_stream.py
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 / update_supplier_prices.py
Last active Sep 26, 2018
Update the supplier prices over API by reading a CSV file with sku, supplier_name and price
View update_supplier_prices.py
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 / read_report.py
Created Aug 29, 2018
Reading Fulfil interactive reports from API
View read_report.py
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 / get_weight.py
Created Mar 2, 2018
Find weight from scale using python and usb
View get_weight.py
# -*- 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
You can’t perform that action at this time.