Skip to content

Instantly share code, notes, and snippets.

@kanikash4
kanikash4 / latLongCheck
Created August 23, 2024 07:04
Check if latitude and longitude is of India
val longitude = map.getAsOrElse[String]("$payload.longitude}", "0.0").toDouble
val latitude = map.getAsOrElse[String]("$payload.latitude}", "0.0").toDouble
if((longitude<68.17) || (longitude>97.41) || (latitude<7.96) || (latitude>35.50)) && (longitude!=0.0) && (latitude!=0.0))
{"BLOCK"}
else
{"PASS"}
@kanikash4
kanikash4 / ReadFileLineByUsingBufferedReader.java
Last active July 2, 2024 12:12
This script will help to find the keywords in the java projects with filename and line number for all the extension files
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
import java.lang.reflect.Array;
import java.io.IOException;
public class ReadFileLineByUsingBufferedReader {
static String keywordsFile[] = {"java", "xml", "conf", "config", "yaml", "yml", "properties", "prop"};
@kanikash4
kanikash4 / Subl not found in mac os
Created March 13, 2020 07:48
Adding symlink to open sublime from terminal
Solving with the Symbolic link:
Irrespective of any version, it will help:
symbolic link and use the subl command, as $PATH and different versions within the installation folder may differ from one and other, so here is the simplest way to set up the symlink without having problem with quotation, versions, path etc.
1. Open Finder in your system, locate your Sublime Text app within the Applications folder.
2. Right click on the App, then `Show Package Contents`.
3. Navigate up to: Contents -> SharedSupport -> bin, look for subl file.
4. Copy this file subl.
@kanikash4
kanikash4 / MysqlError2002.mysql
Created June 7, 2018 17:31
Mysql Error: ERROR 2002 (HY000)
Mysql installed but throwing error while using command `mysql -u root -p`
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
But while checking in `/tmp/mysql.sock` there is no mysql in tmp
Perform the following steps:
1. sudo chown -R _mysql:mysql /usr/local/var/mysql
It will prompt for system password, enter the password.
@kanikash4
kanikash4 / linkedListCycle.java
Created March 13, 2018 18:10
detect a loop in linked list using slow and fast pointer
boolean hasCycle(Node head) {
boolean result = false;
if (head == null) {
result = false;
}
else {
Node slowp = head;
Node fastp = head;
while (fastp != null && fastp.next != null && slowp != null) {
@kanikash4
kanikash4 / deleteMergedOpenBranches.js
Last active January 31, 2018 12:06
Delete open but merged branches from production environment
# Delete a single open branch but merged branch from production environment
git push origin :remotes/origin/<branch_name>
#Delete all open but merged branches from production environment
for i in `git branch -r --merged production | grep -v "production" | awk -F / '{print $2}'`; do git push origin :$i; done
# check remaining branches count
git branch -a | wc -l
@kanikash4
kanikash4 / cronTab.js
Created November 28, 2017 17:22
Linux crontab: [~]$crontab
crontab: command used to schedule and run tasks in the background at defined regular intervals.
Format:
* * * * * *
( MIN HOUR DOM MON DOW CMD )
where:
MIN- minute -0-59
@kanikash4
kanikash4 / linkedListReverse.js
Last active October 10, 2017 18:38
Javascript: Reverse a Linked list
var list = {
name : 'I',
next : {
name : 'AM',
next : {
name : 'KANIKA',
next : {
name : 'SHARMA'
}
}