Skip to content

Instantly share code, notes, and snippets.

View prtkkmrsngh's full-sized avatar

Prateek Kumar Singh prtkkmrsngh

  • Gurugram, India
View GitHub Profile
@moshmage
moshmage / withinRadius.js
Last active April 18, 2022 09:22
compares two objects lat/lon and returns true if within provided kms
/**
* is One Point within Another
* @param point {Object} {latitude: Number, longitude: Number}
* @param interest {Object} {latitude: Number, longitude: Number}
* @param kms {Number}
* @returns {boolean}
*/
function withinRadius(point, interest, kms) {
'use strict';
@pulkitsinghal
pulkitsinghal / container.js
Last active September 19, 2019 22:40
Hooks for loopback file storage: after/before uploads, downloads etc.
/**
* Want to search github for sample code?
* Use the following `search criteria` in the github.com `search box` and then select `Code` from the search results:
* container upload remote language:javascript path:/common/models
*/
module.exports = function(Container) {
Container.beforeRemote('**', function(ctx, unused, next) {
console.log('4: good');
console.log('5: ctx.methodString', ctx.methodString);
@penguinboy
penguinboy / Object Flatten
Created January 2, 2011 01:55
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;