Skip to content

Instantly share code, notes, and snippets.

View omarryhan's full-sized avatar

Omar Ryhan omarryhan

View GitHub Profile
import argparse
import sys
from datetime import datetime, timezone
from smtplib import SMTP_SSL as SMTP
from email.mime.text import MIMEText
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.api_core import protobuf_helpers
def roman_numerals_to_decimal(strParam):
# code goes here
roman_numerals_order = ['I', 'V', 'X', 'L', 'C', 'D', 'M']
roman_numerals_mapping = {
roman_numerals_order[0]: 1,
roman_numerals_order[1]: 5,
roman_numerals_order[2]: 10,
roman_numerals_order[3]: 50,
roman_numerals_order[4]: 100,
# sudo apt install webp imagemagick parallel
# I ran this on 59 very high quality PNGs and my processor was maxing out for about a minute or so. I have an Intel Core-i7-8750H.
cd folder-with-huge-ass-png-files
# convert to webp in the same folder
parallel -eta cwebp {} -o {.}.webp ::: *.png
# Run resize commands in parallel (on many processes/threads). Adjust numbers to taste.

Keybase proof

I hereby claim:

  • I am omarryhan on github.
  • I am omarryhan (https://keybase.io/omarryhan) on keybase.
  • I have a public key ASCs7tEYxwWyNtBjbc9hbgiq4pGFK5U9zpsBEWPJhTxwcgo

To claim this, I am signing this object:

@omarryhan
omarryhan / coinbase_commerce.py
Created January 3, 2019 06:11
Coinbase Commerce Python Validation
@coinbase_bp.route('/service/coinbase/hook', methods=['GET', 'POST', 'UPDATE', 'DELETE'], name='coinbase_hook', version=1)
async def webhook(request):
secret = request.app.config.COINBASE_WEBHOOK_SHARED_SECRET
payload = request.json
if not payload.get('event'):
return response.json(dict(
code=200, # We need coinbase to stop sending this message wether its valid or not
message='Invalid Event'
))
@omarryhan
omarryhan / Sanic-Gino-Alembic migrations Setup
Last active May 30, 2020 15:49
Sanic/Gino/Alembic migrations
# Do the first 6 steps only once.
1. pip install --user alembic
2. bash: ``cd {{my_project}} && alembic init alembic``
3. bash: ``text_editor {{my_project}}/alembic.ini``
4. Change: "sqlalchemy.url = postgres://{{username}}:{{password}}@{{address}}/{{db_name}}"
5. bash: ``text_editor {{my_project}}/alembic/env.py``
6. Now, import your metadata/db object from your app.:
# {{my_project}}/{{my_project_dir}}/app.py