Skip to content

Instantly share code, notes, and snippets.

View hkasera's full-sized avatar

Harshita hkasera

View GitHub Profile
@hkasera
hkasera / mongo-struc.js
Created March 6, 2014 10:12
A script for mongo shell to get the collection structure.
var conn = new Mongo();
db = conn.getDB(<DB_NAME>);
var cursor = db.<COLLECTION>.find();
var items = [];
items = cursor.toArray();
var dbstruc = {};
for (var i = 0; i < items.length; ++i) {
var target = items[i];
getKP(target,dbstruc);
}
@hkasera
hkasera / names.json
Last active September 29, 2020 04:49
Team Names
[
"xterm-inate",
"DEADBEEF",
"hackslash",
"SQL Injectors",
"Hexspeak",
"The Brogrammers",
"GitHub Says What?",
"Bits Please",
"SaaStar",
private boolean sumsToTarget(int[] arr, int k) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[] { map.get(complement), i };
}
map.put(nums[i], i);
}
throw new IllegalArgumentException("No two sum solution");
private boolean sumsToTarget(int[] arr, int k) {
HashSet values = new HashSet();
for (int i = 0; i < arr.length; i++) {
if (values.contains(k - A[i])) return true;
values.add(A[i]);
}
return false;
}
private boolean sumsToTarget(int[] arr, int k) {
Arrays.sort(arr);
int lhs = 0, rhs = arr.length - 1;
while (lhs < rhs) {
int sum = arr[lhs] + arr[rhs];
if (sum == k)
return true;
else if (sum < k)
lhs++;
else rhs--;
private boolean sumsToTarget(int[] arr, int k) {
Arrays.sort(arr);
for (int i = 0; i < arr.length; i++) {
int siblingIndex = Arrays.binarySearch(arr, k - A[i]);
if (siblingIndex >= 0) {
// Found it!
if (siblingIndex != i || (i > 0 && arr[i-1] == arr[i]) || (i < arr.length - 1 && arr[i+1] == arr[i]))
{ return true; }
}
}
@hkasera
hkasera / TwoSumBruteForce.java
Last active June 1, 2020 23:37
Two Sum problem variations
private boolean sumsToTarget(int[] arr, int k) {
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] + arr[j] == k) {
return true;
}
}
}
return 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 / model-1.pkl
Created November 15, 2017 02:22
Model Store
This file has been truncated, but you can view the full file.
ccopy_reg
_reconstructor
p0
(csklearn.pipeline
Pipeline
p1
c__builtin__
object
p2
Ntp3
@hkasera
hkasera / peers.ur
Last active October 19, 2017 20:49
RPC example
table peers : { A : client, B : channel ( string ) , C : string}
PRIMARY KEY A
table random : {C : string}
sequence seq
fun increment a = nextval seq
fun main () =