Skip to content

Instantly share code, notes, and snippets.

View radzhome's full-sized avatar

Rad W radzhome

  • Ottawa
View GitHub Profile
(metadata like "%Camp Nou%" or
metadata like "%Wembley%" or
metadata like "%Croke Park%" or
metadata like "%Twickenham%" or
metadata like "%Signal Iduna Park%" or
metadata like "%Stade de France%" or
metadata like "%Santiago Bernabéu%" or
metadata like "%Luzhniki%" or
metadata like "%San Siro%" or
metadata like "%Atatürk Olympic%" or
def restart_elasticsearch():
"""
Restart es from one place using this command
Restart one node at a time, starting with master
Wait till cluster is in yellow state before doing the next one
Usage:
fab restart_elasticsearch -H rad@search1.int.fanxchange.com
"""
first_host = env.hosts[0]
if '@' in first_host:
#!/usr/bin/env python
"""
Broker API log parser
https://help.datadoghq.com/hc/en-us/articles/209064386-How-to-collect-metrics-or-events-with-a-Custom-Log-Parser
"""
import datetime
import re
@radzhome
radzhome / mock_api_routes.py
Created February 24, 2017 00:21
orbital mocker flask
def orbital_mocker_api():
request_data = request.data
logging.debug("Orbital Mock API Request headers are: {}".format(request.headers))
logging.info("Orbital Mock got {} Request: {}".format(request.method, request_data))
data = '' # Response value
response_type = ''
if '<Request><Profile>' in request_data:
@radzhome
radzhome / dbcopy.sh
Created February 7, 2017 00:54
dbcopy.sh
#!/bin/bash
DBUSER=tempuser
DBPASS=tempuser
DB_OLD=nightly_test
DB_NEW=nightly_ttest
DBHOST=db2.int.fanxchange.com #localhost
while [[ $# > 0 ]]
do
@radzhome
radzhome / routes.py snippet
Created January 27, 2017 16:52
maxmind alert route flask
@your_app.route('/maxmind_alert', methods=['GET'])
def post_maxmind_alert():
"""
Get maxmind alerts
https://www.maxmind.com/en/alert_url
CARDER_EMAIL Email on order was flagged as high-risk email, as it was associated with another high-risk order
HIGH_RISK_IP IP address has been marked as a high-risk IP
HOSTING_PROVIDER IP is from High Risk Hosting Provider
POSTAL_VELOCITY IP address had high velocity of orders (e.g. different zipcodes on same IP address)
UPDATED_INFORMATION The transaction would be rated as higher risk based on updated information or analysis
@radzhome
radzhome / update_pypi.py
Last active January 29, 2017 16:28
local or s3 pypi upater v3
"""
Job can be run on mirror instance(s) to update local PyPi index
To use with S3, create ~/.boto or set BOTO_CONFIG when running:
[sudo] python update_pypi.py -r /tmp/requirements.txt
[sudo] BOTO_CONFIG=/etc/boto_pypi.cfg python update_pypi.py flask -b uat-pypi.bucket.name
"""
import json
import logging
import os
import uuid
@radzhome
radzhome / update_pypi_s3.py
Last active January 25, 2017 05:13
Update your pypi index in s3
"""
Job can be run on mirror instance(s) to update local PyPi index
To use with S3, create ~/.boto or set BOTO_CONFIG when running:
[sudo] BOTO_CONFIG=/etc/boto_pypi.cfg python update_pypi.py flask -b your-pypi-s3-bucket
"""
import json
import logging
import os
import uuid
import datetime
@radzhome
radzhome / update_pypi.py
Created January 18, 2017 19:58
local pypi index updater
import json
import logging
import os
from argparse import ArgumentParser
import requests
import BeautifulSoup
# Local pypi index path
PYPI_PATH = '/centos/pypi/web'
@radzhome
radzhome / minfraud_chargeback.py
Created October 28, 2016 02:41
minfraud chargeback api python example function
import base64
import json
import requests
FRAUD_SCORES = ('not_fraud', 'suspected_fraud', 'known_fraud')
def minfraud_submit_chargeback(license_key, user_id, chargeback_code, fraud_score, ip_address, transaction_id, force_prod=False):
"""
Submit a chargeback request to minFrauds chargeback API