Skip to content

Instantly share code, notes, and snippets.

View Viveckh's full-sized avatar
👨‍💻
Grind Mode

(EJ) Vivek Pandey Viveckh

👨‍💻
Grind Mode
View GitHub Profile
@Viveckh
Viveckh / hiplot_fetchers.py
Created February 18, 2020 00:58
HiPlot Experiment Fetcher for loading local csv experiments
import hiplot as hip
def fetch_local_csv_experiment(uri):
# Only apply this fetcher if the URI starts with webxp://
PREFIX="localcsvxp://"
if not uri.startswith(PREFIX):
# Let other fetchers handle this one
raise hip.ExperimentFetcherDoesntApply()
from metaflow import Flow, get_metadata
# Print metadata provider
print("Using metadata provider: %s" % get_metadata())
# Load the analysis from the GenreStatsFlow.
run = Flow('GenreStatsFlow').latest_successful_run
print("Using analysis from '%s'" % str(run))
genre_stats = run.data.genre_stats
from metaflow import FlowSpec, step, catch, retry, IncludeFile, Parameter
class GenreStatsFlow(FlowSpec):
"""
A flow to generate some statistics about the movie genres.
The flow performs the following steps:
1) Ingests a CSV into a Pandas Dataframe.
2) Compute quartiles for each genre in parallel
3) Save a dictionary of genre specific statistics.
@Viveckh
Viveckh / metaflow-linear-example.py
Last active January 22, 2020 23:15
Example of a Metaflow Linear DAG
from metaflow import FlowSpec, step
class LinearFlow(FlowSpec):
"""
A flow to verify you can run a basic metaflow flow.
"""
# Global initializations here
@Viveckh
Viveckh / laganMessageSchema.jsonc
Last active August 29, 2019 11:57
Dating App - Firebase Realtime Database Schema - Messages
"messages": {
"$chat_id": {
// Only users who are on this chat can read/write
".read": "root.child('chats/' + $chat_id + '/members/' + auth.uid).exists()",
".write": "root.child('chats/' + $chat_id + '/members/' + auth.uid).exists()",
"$message_id": {
// the object to write must have required nodes, and also an existing msg can't be rewritten
".validate": "!data.exists() && newData.hasChildren(['message', 'author', 'timestamp'])",
@Viveckh
Viveckh / laganUserSchema.jsonc
Last active August 29, 2019 11:57
Dating App - Firebase Realtime Database Schema - User
"users": {
// Anyone who is authenticated can read user info
".read": "auth.uid != null",
"$uid": {
// But a user can only update their own info
".write": "auth.uid === $uid",
// At least the name of the user should be provided to set
".validate": "newData.hasChildren(['name'])",
@Viveckh
Viveckh / laganRulesRoot.jsonc
Last active August 29, 2019 11:56
Dating App - Firebase Realtime Database Schema - Root
{
"rules": {
// default rules are false if not specified
// setting these to true would make ALL CHILD PATHS readable/writable
".read": false,
".write": false,
// We will populate these schemas one by one
"users": {},
"swipes": {},
@Viveckh
Viveckh / laganSwipeSchema.jsonc
Last active August 29, 2019 11:56
Dating App - Firebase Realtime Database Schema - Swipes
"swipes": {
"$uid": {
// Only the user to whom this swipe node pertains to can read and update it by default
".read": "auth.uid === $uid",
".write": "auth.uid === $uid",
".validate": "root.child('users/' + $uid).exists()",
"$candidate_uid": {
// A user can read another user's swipe details only for the record that applies to them
".read": "auth.uid === $candidate_uid",
@Viveckh
Viveckh / laganMatchSchema.jsonc
Last active September 21, 2023 10:05
Dating App - Firebase Realtime Database Schema - Matches
"matches": {
"$uid": {
// Only the user to whom this match node pertains to can read it by default
".read": "auth.uid === $uid",
".validate": "root.child('users/' + $uid).exists()",
"$match_uid": {
// A user can read another user's match details only for the record that applies to them
".read": "auth.uid === $match_uid",
@Viveckh
Viveckh / chatSchema.jsonc
Last active August 29, 2019 12:04
Dating App - Firebase Realtime Database Schema - Chat
"chats": {
"$chat_id": {
// only members can read the node
".read": "root.child('chats/' + $chat_id + '/members').hasChild(auth.uid)",
// If members not added yet, then any authenticated user can write. If members added already, then only members can write
".write": "(!root.child('chats/' + $chat_id).hasChild('members') && auth != null )|| root.child('chats/' + $chat_id + '/members').hasChild(auth.uid)",
// Creating a new chat room requires to have member node
".validate": "!data.exists() && newData.hasChildren(['members'])",