Skip to content

Instantly share code, notes, and snippets.

View hkasera's full-sized avatar

Harshita hkasera

View GitHub Profile
@hkasera
hkasera / validate-json.py
Last active September 26, 2016 21:54
A python script to validate json data
import sys
import json
myfile = sys.stdin
if myfile:
content = myfile.readlines()
for line in content:
try:
json.loads(line)
except Exception as e:
print "Invalid JSON"
@hkasera
hkasera / gist:d3cc64ffbb539621907e
Created February 5, 2016 17:38 — forked from anikalindtner/gist:9524950
Workshops/Mailinglists/Lists
@hkasera
hkasera / checkPrime.js
Created January 31, 2016 11:36
JavaScript Questions
var checkPrime = function(n) {
"use strict";
if (n === 1) {
return false;
}
var isPrime = true;
for (let i = 2; i < n;) {
if (n % i === 0) {
isPrime = false;
}
@hkasera
hkasera / Mutltiple_SSH.md
Last active September 29, 2018 02:45
How to use multiple github accounts?

I have two accounts on github, one is personal account and other is office account. I typically face this problem to manage pushing to different repos using these different accounts.

I found a great way of doing it without any hassle.

Step 1 : Generate different ssh keys for both the accounts

Suppose my personal id is jane@gmail.com and office account is jane@doe.com

Follow the steps mentioned here to generate ssh keys : https://help.github.com/articles/generating-ssh-keys/

@hkasera
hkasera / braceValidate.js
Created September 11, 2015 15:48
Validating a pair of braces
var a = "{{{}}}}";
var ts = [];
var mismatch = false;
for (var i = 0; i < a.length; ++i) {
if (a[i] === '{') {
ts.push('{');
}
if (a[i] === '}') {
if (ts.length == 0) {
mismatch = true;
@hkasera
hkasera / BST.java
Created September 5, 2015 11:03
Sorted Array to Binary Search Tree
class Node{
int val;
Node left;
Node right;
}
class Tree{
Node root;
}
@hkasera
hkasera / SinglyLinkedList.js
Created June 17, 2014 18:11
Singly Linked List and related operations in javascript
var Node = function (val) {
this.val = val || null;
this.next = null;
};
var SinglyLinkedList = function () {
this.head = null;
this.tail = null;
};
@hkasera
hkasera / binaryTree.js
Last active August 29, 2015 14:02
Binary Tree in Javascript
var BinaryTree = function (val) {
'use strict';
this.val = val || null;
this.left = null;
this.right = null;
};
BinaryTree.prototype.create = function (num) {
'use strict';
var i;
for (i = 0; i <= num; i = i + 1) {