Skip to content

Instantly share code, notes, and snippets.

View pocha's full-sized avatar

Ashish Sharma pocha

View GitHub Profile
import { initializeTestEnvironment } from "@firebase/rules-unit-testing"
import { setLogLevel } from "firebase/firestore"
const FIREBASE_PROJECT_ID = "xxxx"
export const USER_COLLECTION = "users-main"
export const APPLICATION_COLLECTION = "applications"
export const ASHISH_ID = "xxxx"
export const BETTS_ID = "xxxx"
export const ZUKA_ID = "xxxx"
import { assertFails, assertSucceeds } from "@firebase/rules-unit-testing"
import {
getDoc,
setDoc,
collection,
doc,
connectFirestoreEmulator,
CollectionReference,
DocumentData,
@pocha
pocha / lru-cache-ttl-priority.md
Last active September 17, 2022 23:24
LRU cache with TTL & priority

Design LRU Cache with TTL & priority

An interview question that is becoming popular (apparently British Petroleum folks have been asking in their interview) is design LRU cache. The catch is - each item has a TTL & a certain priority specified while the key, value is put into the cache. The eviction policy when cache is full is in the order

  • evict all (or just the oldest expired value) based on TTL, if this makes space, good enough
  • if nothing to evict as nothing has expired, remove the one with the lowest priority
  • if there are multiple items with the lowest priority, remove the one that was accessed the first

The problem is pretty hard to even come up with a solution in an hour. You also need to write code of whatever solution you could find. The tradition LRU cache is designed as hashmap & a doubly linked linkedlist. Doubly linked linkedlist helps because the access time of keys are linear & you need to move the accessed key to the top of the linked list & remove the oldest item.

In this cas

AnOpenLetter V2.0

Aim - people should be able to

  1. Create & edit post
  2. Post creation elements - heading, date, time & location of event, concerned department/brand/officer identifier, post details, image attachment
  3. The system should tweet to concerned officer/brand after post creation
  4. User should be able to post updates/responses. It all should appear as timeline one after another including comments. Each update/comment/edit to the post should get tweeted to concerned officer. The officer's reply to the tweet should also show up in the timeline.
  5. Post should be creatable using mobile phone

Hybrid App for WiFi connectivity & Data accounting

Hybrid - as this app needs porting to other platforms. Basically - the UI part needs to be in hybrid (phonegap/ionic) - the core parts anyway need to be done in native (as phonegap plugins)

Work scope - PoC app preferably working on an Android phone

This app is going to be open source & (mostly) will be used for a free WiFi Gujrat Govt project . Details at https://gil.gujarat.gov.in/tendercms/TenderDocs/2017123145318973.pdf

If interested to work on this project - drop me a word at pocha.sharma at gmail / 9 5 3 8 3 8 4 5 4 5

@pocha
pocha / leetcode-answers.md
Last active April 3, 2018 11:48
Algo-DS interview prep in a glance. Leetcode questions & their answers compiled in one place.

1. Two Sum

Total Accepted: 372574
Total Submissions: 1273263
Difficulty: Easy
Contributors: Admin

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution.

###Question###

Describe the most significant/impactful continuous improvement project that you have led? (What was the catalyst to this change and how did you go about it?

###Answer###

Problem Statement

This is about Griggi, a side project I & my partner have been working on since Mid 2015 . The motivation behind the project came to me when I use to travel to my hometown & the lack of broadband in my home made me think if I could haved used the WiFi of my neighbour in an abuse free way & without the hassle of disturbing them / asking them the WiFi password

@pocha
pocha / TestNG Griggi setup
Last active September 14, 2016 06:11 — forked from anonymous/TestNG Griggi setup
TestNG Griggi setup
Install IDE
https://eclipse.org/downloads/packages/eclipse-ide-java-developers/mars2
Install testNG plugin for eclipse:
http://testng.org/doc/download.html
Verify if plugin is installed:
http://wiki.eclipse.org/FAQ_How_do_I_find_out_what_plug-ins_have_been_installed%3F
If its first time with Eclipse, you need to add JRE to the project as well . Without this, you will see errors like java.lang.Object not resolved because java isnt accessible.
def flatten(a)
out = []
if !a.kind_of?(Array)
puts "not an array"
return -1
end
a.each do |val|
out += _flatten(val)
end
out