This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ModelName": "Example from Alex Debrie (re:Invent 2019)", | |
"ModelMetadata": { | |
"Author": "Ratul Saha", | |
"DateCreated": "Dec 09, 2019, 9:29 PM", | |
"DateLastModified": "Dec 10, 2019, 12:36 AM", | |
"Description": "" | |
}, | |
"DataModel": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"TableFacets": [ | |
{ | |
"FacetName": "GetUserProfile (A1)", | |
"KeyAttributeAlias": { | |
"PartitionKeyAlias": "UserId", | |
"SortKeyAlias": "ProfileId" | |
}, | |
"NonKeyAttributes": [ | |
"Username", | |
"Full name", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH query1 AS ( | |
SELECT | |
'china' AS country_code, | |
origin, | |
ROUND(SUM(IF(fcp.start <=1000, fcp.density,0)) / SUM(fcp.density),5) AS SEB_native | |
FROM | |
`chrome-ux-report.country_cn.201712`, | |
UNNEST(first_contentful_paint.histogram.bin) AS fcp | |
WHERE | |
origin = 'https://www.amazon.cn' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SUM(fcp.density) | |
FROM | |
`chrome-ux-report.chrome_ux_report.201710`, | |
UNNEST(first_contentful_paint.histogram.bin) AS fcp | |
WHERE | |
origin = "https://www.google.co.in" | |
AND effective_connection_type.name = "3G" | |
AND fcp.END <= 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TreeNode(Object): | |
def __init__(self,x): | |
self.val = x | |
self.left = None | |
self.right = None | |
class ListNode(Object): | |
def __init__(self,x): | |
self.val = x | |
self.next = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr, target = [1,2,3,4,5], 4 | |
start, end = 0, len(n)-1 | |
while start <= end: | |
mid = (start+end)/2 | |
if arr[mid] == target: | |
return mid # The value is found | |
else: | |
if arr[mid] < target: | |
start = mid+1 | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counter = 0 | |
while counter <= 5: | |
print counter, | |
counter += 1 | |
else: | |
print "loop exited normally" | |
# Output: 0 1 2 3 4 5 loop exited normally | |
for i in range(5): | |
print i, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#List traversal | |
range(start, stop, hop) | |
range(n) # [0,1,...,n-1] | |
range(1,n) # [1,...,n-1] | |
range(1,n,2) # [1,3,5,...,n-1] if n is even, or [1,3,5,...,n-2] if n is odd | |
range(n,-1,-1) # [n,n-1,n-2,...,0] | |
range(len(arr)) # Provides indices of an array arr | |
range(len(arr)-1,-1,-1) # Provides indices of arr backwards | |
# List slicing |