Skip to content

Instantly share code, notes, and snippets.

View gauravat16's full-sized avatar
💭
working

Gaurav Sharma gauravat16

💭
working
View GitHub Profile
@gauravat16
gauravat16 / ActivityName.java
Last active December 6, 2022 22:54
[Android] Add Context Menu to RecyclerView
//Import Statements
public class ActivityName extends AppCompatActivity {
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@gauravat16
gauravat16 / SortedTriplet.java
Created November 25, 2018 07:30
Get a triplet i, j, k. i<j<k & arr[i]<arr[j]<arr[k]
/*
* Copyright (c) 2018. Gaurav Sharma, All rights reserved.
*/
package practice;
public class SortedTriplet {
private static boolean hasTriplet(int[] arr) {
/**
@gauravat16
gauravat16 / UIApplication.java
Last active May 10, 2019 17:21
Spring Session with Redis
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
@EnableRedisHttpSession
@EnableEurekaClient
@SpringBootApplication
public class UIApplication {
@gauravat16
gauravat16 / build.gradle
Last active May 10, 2019 09:56
dependencies for UI Service
dependencies {
compile 'org.springframework.boot:spring-boot-starter-data-redis'
compile("org.springframework.boot:spring-boot-starter-cache")
implementation('org.springframework.session:spring-session-data-redis')
}
@gauravat16
gauravat16 / bootstrap.properties
Created May 10, 2019 10:02
Redis Properties for UI Application
spring.cache.type=redis
spring.redis.host=<ip-address>
spring.redis.port=<Redis port>
@gauravat16
gauravat16 / SecTokenPreReq.js
Last active November 8, 2019 08:35
Postman Security Token Pre-req Script
/*
Header for your request
*/
header = { 'content-type': 'application/json'};
/*
Converts the Request to a Obejct.
*/
@gauravat16
gauravat16 / BloomFilter.java
Last active April 18, 2020 16:13
Bloom-Filter
package bloomfilter;
public interface BloomFilter {
void addData(String data);
boolean isPresent(String data);
String getInfo();
}
package bloomfilter;
import java.util.Arrays;
import java.util.BitSet;
public abstract class AbstractBloomFilter implements BloomFilter {
protected BitSet bitSet;
protected int expectedElements = -1;
protected double falsePosProbability = -1;
package bloomfilter;
import bloomfilter.hash.Murmur3;
public class BasicBloomFilter extends AbstractBloomFilter {
public BasicBloomFilter(int size) {
super(size);
}
package bloomfilter.test;
import bloomfilter.BasicBloomFilter;
import bloomfilter.BloomFilter;
import java.util.Arrays;
import java.util.Random;
public class BloomFilterTest {