Skip to content

Instantly share code, notes, and snippets.

@darkrishabh
darkrishabh / Script.java
Created September 3, 2014 17:49
Add two number in String format in JAVA - using Script Engine
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
import java.util.Scanner;
class Script{
public static void main(String args[])throws IOException
{
Scanner me = new Scanner(System.in);
System.out.println("Enter 2 numbers:");
String numOne = me.nextLine();
@darkrishabh
darkrishabh / main.cpp
Created December 8, 2014 01:32
BST Traversal and Insertion
#include <iostream>
using namespace std;
struct BSTNode{
int value;
BSTNode* left;
BSTNode* right;
};
@darkrishabh
darkrishabh / Solution.java
Created December 8, 2014 01:56
Valid-BST JAVA code for Hacker rank Problem - https://www.hackerrank.com/challenges/valid-bst
import java.util.ArrayList;
import java.util.Scanner;
class Node<T> {
public int value;
public Node left;
public Node right;
public Node(int value) {
@darkrishabh
darkrishabh / DFAMin.java
Created December 8, 2014 03:00
DFA Minimization - Hopcroft Karp Algorithm
/*
* Copyright (c) 2014. This Project is the requirement of the course at NYIT-Old Westbury and should not be used in any commercial or personal use unless permitted by the author of the code. This code is the property of Rishabh Mehan and he holds the rights to re-distribute and re-use this code.
*/
/**
* Created by rishabh on 12/7/14.
**/
import java.util.*;
// final.cpp : main project file.
#include "stdafx.h"
#ifdef _CH_
#pragma package <opencv>
#endif
#ifndef _EiC
#include "cv.h"
#include "highgui.h"
@darkrishabh
darkrishabh / Delete Git Branches not on Remote
Created May 8, 2015 04:10
Deletes all the branches not on remote
git checkout master && git branch -l | sed 's/* master//' > /tmp/gitlocal.txt && git branch -r | sed 's/origin\///' > /tmp/gitremote.txt && grep -Fxv -f /tmp/gitremote.txt /tmp/gitlocal.txt | xargs git branch -d
@darkrishabh
darkrishabh / Hashtag.js
Last active May 31, 2018 20:45
JAVASCRIPT: Find all the hastags in a string (eg INPUT="Hi #my#name is #Bond #JamesBond" OUTPUT = ["my", "name", "Bond", "JamesBond"])
var _ = require('lodash');
function HashTags(text) {
var adding = false;
var d = "";
var t = "";
return _.filter(_.map(text, function (c, k) {
if (c === '#' || (c === ' ')) {
if (adding) {
t = d;
d = "";
@darkrishabh
darkrishabh / bootstrap.min.css
Created November 6, 2017 19:42
Paper Bootstrap 3
@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700");/*!
* bootswatch v3.3.7
* Homepage: http://bootswatch.com
* Copyright 2012-2016 Thomas Park
* Licensed under MIT
* Based on Bootstrap
*//*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
@darkrishabh
darkrishabh / bootstrap.min.css
Last active November 6, 2017 19:42
Paper Bootstrap 3
@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700");/*!
* bootswatch v3.3.7
* Homepage: http://bootswatch.com
* Copyright 2012-2016 Thomas Park
* Licensed under MIT
* Based on Bootstrap
*//*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
@darkrishabh
darkrishabh / test.js
Last active September 29, 2020 06:26
getCurrentLocation = async () => {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
(position) => {
resolve({
latitude: parseFloat(position.coords.latitude),
longitude: parseFloat(position.coords.longitude),
latitudeDelta: 5,
longitudeDelta: 5,
})