Skip to content

Instantly share code, notes, and snippets.

Avatar

Riegie Godwin Jeyaranchen riegie

  • Pine
  • Toronto
View GitHub Profile
View generate-cartesian-product.py
from itertools import product
policy_statuses = ['processing', 'active', 'pending-suspension', 'suspended', 'pending-cancellation', 'cancelled']
vehicle_statuses = ['processing', 'active', 'inactive']
inactive_user = [True, False]
failed_payments = [0,1,2,3]
expiring_user = [True, False]
View argparsecheetsheet.py
import argparse
parser = argparse.ArgumentParser()
### Positional
parser.add_argument('positional1')
parser.add_argument('positional2', help="positional argument 2")
parser.add_argument('positional3', help="positional argument 3 type int", type=int)
### Optional
parser.add_argument("--optional1", help="optional argument 1")
parser.add_argument("--optional2", help="optional argument 2", action="store_true")
@riegie
riegie / Virtual Environment Setup for Python 3
Last active May 9, 2019
Create virtual environments with venv in Python 3
View Virtual Environment Setup for Python 3
Python3 Virtual Environment Setup
Requirements
* Python 3
$ brew install python3
Creation of virtual environment:
$ python3 -m venv /path/to/new/virtual/environment
@riegie
riegie / boto-elastic-transcoder-manager-example.py
Created Feb 22, 2018 — forked from mingrammer/boto-elastic-transcoder-manager-example.py
Python script for AWS Elastic Transcoder with boto api
View boto-elastic-transcoder-manager-example.py
# -*- coding: utf-8 -*-
import hashlib
import boto3
class ETSManager:
"""
@todo: manages and provides the ets services
@riegie
riegie / gistlog.yml
Created Feb 20, 2018 — forked from askilondz/gistlog.yml
Adaptive Streaming with MPEG-DASH and HLS using AWS
View gistlog.yml

Adaptive Streaming has become the neccessity for streaming video and audio. Unfortantely, as of this post, there isn't a whole lot of tutorials that accumulate all of the steps to get this working. Hopefully this post achieves that. This post focuses on using Amazon Web Services (AWS) to transcode for HLS and DASH and be the Content Delivery Network (CDN) that delivers the stream to your web page. We'll be using Video.js for the HTML5 player as well as javascript support libaries to make Video.js work with HLS and DASH.

So Here's what you need:

Set up three S3 buckets

@riegie
riegie / shopify_webhook.py
Created Apr 4, 2017 — forked from gavinballard/shopify_webhook.py
Python view decorator for the HMAC verification of a Shopify Webhook.
View shopify_webhook.py
import hashlib, base64, hmac, json, settings
def shopify_webhook(f):
"""
A decorator thats checks and validates a Shopify Webhook request.
"""
def _hmac_is_valid(body, secret, hmac_to_verify):
hash = hmac.new(body, secret, hashlib.sha256)
hmac_calculated = base64.b64encode(hash.digest())
@riegie
riegie / django_auth.js
Created Sep 8, 2016 — forked from tianchu/django_auth.js
How to authenticate Django users in node.js
View django_auth.js
/*
* Authenticate Django users in node.js.
*
* Django is great for many projects, while node.js does some fantastic
* jobs that Django couldn't. For example, you may have a Django app
* managing your user accounts and another real-time service or application
* running on Node, then you probably will need to read Django user session
* to authenticate users in the Node project.
*
* This gist is not production ready yet, but it demonstrates how could it
View models.py
# This code is under the MIT license.
# Inspired by this StackOverflow question:
http://stackoverflow.com/questions/3295405/creating-django-objects-with-a-random-primary-key
import struct
from Crypto.Cipher import DES
from django.db import models
def base36encode(number):