Skip to content

Instantly share code, notes, and snippets.

View johntbush's full-sized avatar

john bush johntbush

View GitHub Profile
@johntbush
johntbush / gist:7f2ba8d7c4771664693e2b416869a8cf
Last active August 7, 2017 19:35
sample rating metrics from CDC message
{
"type": "update",
"msg": {
"env_id": "af44d7ff-c069-482b-aee8-82f0a562ca99",
"env_name": "HPi EMEA Prod",
"database": "HPiProd",
"sql_dns": "HPiProdSQL.traxtech.com",
"table": "EXCEPTIONS",
"updated_date": "2017-08-07T18:15:14Z",
"is_delete": false,
@johntbush
johntbush / gist:2c9817717f20a74a180480d5bb349820
Last active August 7, 2017 19:35
rating metrics from source
{
"type" : "source",
"data" :{
"VendLabl": "TNT",
"FbId": "FBLL1000681002182280595",
"FbNId": 3.2013620087288801E18,
"BilledAmt": 2.52,
"BilledCurrency": "EUR",
"RatedAmt": 2.52,
"RatedCurrency": "EUR",
@johntbush
johntbush / pandas_load_test.py
Created April 22, 2017 03:35
pandas_load_test
import pandas as pd
import timeit
import numpy as np
import StringIO
import io
def generate_csv(width,height):
df = pd.DataFrame(np.random.randint(0, 1000000, size=(height, width)))
def p(implicit i:Int) = print(i)
implicit val v=2
p
p(1)
//legal
def pp(a:Int)(implicit i:Int) = println(a,i)
def pp(a:Int)(implicit i:Int, b:Long) = println(a,i,b)
def pp(implicit i:Int, b:Long) = println(i,b)
@johntbush
johntbush / pm.scala
Last active March 30, 2017 17:35
pattern matching tutorial
/*
A pattern match includes a sequence of alternatives, each starting with the keyword case.
Each alternative includes a pattern and one or more expressions, which will be evaluated
if the pattern matches. An arrow symbol => separates the pattern from the expressions.
*/
def matchTest(x: Int): String = x match {
case 1 => "one"
case 2 => "two"
val optionHelloWorld = Option("Hello World")
val optionNil:Option[String] = None
Option(null)
if (optionHelloWorld.isDefined) optionHelloWorld.get
if (optionNil.isEmpty) "nothing here"
if (optionHelloWorld.isDefined) optionHelloWorld.get else "nothing here"
{
"RateDetails": {
"FbId": "FBLL1000691004813140001",
"LineNum": 3,
"RateScac": "KWEO_Onesource",
"TemplateId": "41228.40293",
"ICSNum": "663485",
"RatingCategory ": "RatedEqualsBilledUnvalidated",
"RatingDetails": "Rated at 12 USD Flat using AirOceanAccessorials in ICS 663485 for KWEO_Onesource for accessorial for this shipment EffectiveDate (10/25/2016 12:00:00 AM), ChargeCode (DFO), Qualifier (ORIGIN HANDLING AND DOCUM), OriginPort_Airport (THBKK), OriginCity (PHET BURI), OriginCountry (TH), OriginPostalCodeRange (10110), DestinationPort_Airport (CNSHA), DestinationCity (SHANGHAI), DestinationCountry (CN), DestinationPostalCodeRange (200131), ServiceLevel (LCL), ServiceScope (LCL), WeightRange (1000), QuantityRange (1). This is rated equals billed at 12 USD ..These are unknown missing LocationID, Subcarrier, OriginState, OriginZone, OriginRegion, DestinationState, DestinationZone, DestinationRegion, EquipmentType, FlowIndentifier, MileageBandRange.These are undefined Qualifier (ORIGIN HANDLI
import requests
import json
def reimport(id):
r = requests.get("{}/config/{}".format(sheets_api, id)).json()
data = r['data']
print str('loaded: ' + str(data))
requests.delete("{}/config/{}".format(sheets_api, id))
partitionkeys = data['partitionkeys']
default = data['default']
{
"concept" : "bill weight qualifier",
"description" : "normalize the FB_WT_QUAL field that is part of the FRGHT_BL ",
"rules" : [
{
"field" : "AL_CNTRY_CODE_ORIG",
"rules" : [
{
"type":"expr",
"expression" :"AL_CNTRY_CODE_ORIG IN ('US','USA','UNITED STATES')",
/****** Object: StoredProcedure [DNorm].[usp_Data_ModeDerivation] Script Date: 12/21/2016 12:36:54 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
use NormLogic
Go