Skip to content

Instantly share code, notes, and snippets.

View sanealytics's full-sized avatar

Saurabh Bhatnagar sanealytics

View GitHub Profile
Starting prompt
Me:
Hi, I'm trying to solve a puzzle.
The board is laid out like a chess board, but with hexagons.
So first row is 8.
Second row is 8 but slightly to the side because of how hexagons stack.
The third row is 8 but slightly to the left because of how hexagons stack.
and so on.
@sanealytics
sanealytics / tf_idf.sql
Created January 7, 2020 04:43
TF/IDF in Bigquery 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
),
@sanealytics
sanealytics / PinchAnimated.js
Last active May 18, 2021 19:21
Zoom into image and generate images in the zoomed in area
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';
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 June 20, 2020 18:21
Deployed function to get service trace id
# 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")
@sanealytics
sanealytics / get_service_trace_id_example.py
Created June 20, 2020 16:31
Getting a service trace id
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"]}'
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 November 28, 2018 22:54
react native dependencies
"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",
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
@sanealytics
sanealytics / Podfile
Created September 28, 2018 20:53
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'