Skip to content

Instantly share code, notes, and snippets.

View VarunVats9's full-sized avatar
🏠
Working from home

VarunVats9

🏠
Working from home
View GitHub Profile
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
public class RequestEntry {
private LocalDateTime localDateTime;
public RequestEntry(final LocalDateTime localDateTime) {
localDateTime.toEpochSecond(OffsetDateTime.now().getOffset());
this.localDateTime = localDateTime;
@VarunVats9
VarunVats9 / userfeed.md
Created February 25, 2019 05:24
Readme
  1. Run the application : a) Either do --> java -jar path_to_userfeed.jar b) Or if have maven --> mvn spring-boot:run

  2. Once done, run a curl command (POST) localhost:8080/setup?userId=1 [This will set the friends (follower) list (2, 3) for this user.]

  3. Now, you can create posts for this user, run a curl command (POST) localhost:8080/post a) This requires JSON to be send as requestBody, for example : { "userId" : 1

package com.practice.codingblocks;
import java.util.HashMap;
import java.util.HashSet;
public class SlidingWindow {
private static int maximumWindowSum(int[] arr, int k) {
Reference:
https://opensourceconnections.com/blog/2013/07/24/understanding-how-cql3-maps-to-cassandras-internal-data-structure-sets-lists-and-maps/
// Column-Family
-----------------------------------------------------------------------------------------------
ID Last First Bonus
1 Doe John 8000
2 Smith Jane 4000
3 Beck Sam 1000
@VarunVats9
VarunVats9 / es-1.json
Last active May 29, 2020 14:09
Elasticsearch - term, range, prefix, wildcard, regex
// Term queries don't analyze the query, just search for the exact term in the inverted index >>>>>>>>>
"query": {
"term": {
"name": "Framework"
}
}
}
GET /product/_search
{
@VarunVats9
VarunVats9 / es-2.json
Created February 26, 2020 14:45
Elasticsearch - date, operator, match_phrase, multiple fields
// Add another field
PUT /product/_mapping >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"properties": {
"date": {
"type": "date",
"format": "yyyy-MM-dd"
}
}
}
@VarunVats9
VarunVats9 / es-3.json
Created February 26, 2020 17:57
Elasticsearch - must, and, should, must_not, filter, query
// MATCH == SHOULD
GET /product/_search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"query": {
"match": {
"name": "Spring Title"
}
}
}
@VarunVats9
VarunVats9 / es-api.json
Created February 26, 2020 18:00
Elasticsearch - mapping, index, get, update, delete, bulk, multiple action, search, search boolean
// Elasticsearch API
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html
// Typeless API
https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0
// Mapping >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PUT /product
{
"mappings": {
@VarunVats9
VarunVats9 / es-4.json
Last active February 29, 2020 17:44
Elasticsearch - join queries, has_parent, has_child
// Mapping
PUT /department >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"mappings": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"department": "employee"
}