Skip to content

Instantly share code, notes, and snippets.

Avatar

Saurabh Bhatnagar sanealytics

View GitHub Profile
View sample_function_sql.py
def get_elt_queries():
"""Gets parameterised queries for ELT"""
return {
# Parameters: service
'input_data': """
select
data,
added_ts
from
XXX.TABLE
@sanealytics
sanealytics / get_service_trace_id_function.py
Last active Jun 20, 2020
Deployed function to get service trace id
View get_service_trace_id_function.py
# Deployed function
def get_service_trace_id(request):
if (request.method != 'POST'):
abort(403)
if (request.headers['content-type'] != 'application/json'):
raise NameError("ERROR: JSON content-type expected")
request_json = request.get_json(silent=True)
if not request_json or "service" not in request_json:
raise NameError("Please provide parameter 'service' name, 'instance' name optional")
View get_service_trace_id_example.py
from requests import post
import json
GET_TID_URI='https://XXXX/get_service_trace_id'
TID_SERVICE_NAME='my_service'
TID_SERVICE_VERSION='1.0' # Automate this in CI/CD and read it in
TID_SERVICE_INSTANCE='default' # Get from Google environment variables
# For example
# TID_SERVICE_INSTANCE=f'{request.headers["X-Appengine-Queuename"]}-{request.headers["X-Appengine-Taskname"]}'
@sanealytics
sanealytics / tf_idf.sql
Created Jan 7, 2020
TF/IDF in Bigquery SQL
View tf_idf.sql
-- calculate td/idf
create or replace view scratch.v_elt_calculate_tf_idf
as
with
params as (
select 3 as MIN_TOK,
5 as MAX_RNK,
CURRENT_DATETIME() as added_ts,
100 as MIN_TF
),
View PodFile
target 'virevol' do
pod 'Stripe', '~> 11.2.0'
inherit! :search_paths
# Install additional dependencies
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
@sanealytics
sanealytics / package.json
Created Nov 28, 2018
react native dependencies
View package.json
"dependencies": {
"firebase": "^5.3.0",
"prop-types": "^15.6.2",
"react": "^16.3.1",
"react-native": "^0.55.4",
"react-native-contacts": "^2.2.2",
"react-native-elements": "^0.19.1",
"react-native-fast-image": "^5.1.0",
"react-native-gifted-chat": "^0.4.3",
"react-native-git-upgrade": "^0.2.7",
View xcode build logs
Scanning folders for symlinks in /Users/saurabh/Documents/virevol3/node_modules (17ms)
Found Xcode workspace virevol3.xcworkspace
Launching iPhone 6 (iOS 12.0)...
Building using "xcodebuild -workspace virevol3.xcworkspace -configuration Debug -scheme virevol3 -destination id=80A84958-6B3F-41F1-85B3-01FA8D619375 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/saurabh/Documents/virevol3/ios/build
note: Using new build system
View Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
# Specify Workspace
workspace 'virevol3'
target 'virevol3' do
pod 'Stripe', '~> 11.2.0'
inherit! :search_paths
pod 'Firebase/Core'
@sanealytics
sanealytics / ImageViewer.js
Created Sep 17, 2018
ImageViewer pinch generate
View ImageViewer.js
import React, { Component } from 'react';
import { StyleSheet, View, Image } from 'react-native';
import {
PanGestureHandler,
State,
PinchGestureHandler,
TapGestureHandler,
} from 'react-native-gesture-handler';
import Animated, { Easing } from 'react-native-reanimated';
@sanealytics
sanealytics / PinchAnimated.js
Last active Aug 25, 2018
Zoom into image and generate images in the zoomed in area
View PinchAnimated.js
import React, { Component } from 'react';
import { StyleSheet, View, Image, } from 'react-native';
import {
PanGestureHandler,
State,
PinchGestureHandler,
TapGestureHandler,
} from 'react-native-gesture-handler';
import Animated, { Easing } from 'react-native-reanimated';
You can’t perform that action at this time.