Skip to content

Instantly share code, notes, and snippets.

View knifedge's full-sized avatar
🏠
Working from home

Manoj knifedge

🏠
Working from home
View GitHub Profile
var getCount = async (collectionName, query) => {
try {
var controllerHandle = await (getCollection(collectionName));
var result = await (count(query));
return result;
} catch (e) {
return e;
}
};
var getCollection = (collectionName) => {
return new Promise((resolve, reject) => {
database.collection(collectionName, function (error, controllerHandle) {
if (error) reject(error);
resolve(controllerHandle);
});
});
};
var getCollection = (collectionName, callback) => {
database.collection(collectionName, (error, controllerHandle) => {
if (error) return callback(error);
callback(null, controllerHandle);
});
};
var getCount = (collectionName, callback) => {
getCollection(collectionName,(error, controllerHandle) => {
if (error) return callback(error);
count(somequery, (error, result) => {
if (error) return callback(error);
callback(null, results);
});
});
};

Keybase proof

I hereby claim:

  • I am knifedge on github.
  • I am knifedge (https://keybase.io/knifedge) on keybase.
  • I have a public key ASB5rLWkFuJskc3oHkaZxakext4je6bL76FP20LpCLBNjAo

To claim this, I am signing this object:

@knifedge
knifedge / 2CheckDuplicate.c
Created July 20, 2016 07:00
duplicate in an array of size n with numbers from 1 through n-1.
#include <stdio.h>
#define N 5
int main(){
int array[N],i,Asum=0;
int sum = (N *(N-1))/2;
printf("Enter %d integer from 1 to %d,with one duplicate:"N.N-1);
for(i=0;i<N;i++){
scanf("%d",&array[i]);
Asum = Asum+array[i];
}