Skip to content

Instantly share code, notes, and snippets.

[{
$match: {
status: {$ne: "cancelled"},
createdAt: {$gt: ISODate('2024-03-31')}
}
},
{
$group: {
_id: { day: { $dayOfMonth: "$createdAt"}, year: { $year: "$createdAt" } },
totalAmount: {$sum: "$revisedOrderTotal"}

CSS Loader

@agaase
agaase / coverIframes
Last active September 18, 2019 18:57
This jquery extended function covers all the iframes inside an element with a transparent div and dispatches any "click"(only click) to the iframe. This is a workaround for the case when you dont want an iframe to swallow touch events on the page and is normally valid in the case of inline ads.
$.fn.coverIframes = function(){
$.each($("iframe",this),function(i,v){
var ifr = $(v);
var wr = $("<div id='wr"+new Date().getTime()+i+"' style='z-index: 999999; opacity: 0; position:absolute; width:100%;'></div>");
ifr.before(wr);
wr.height(ifr.height());
wr.click(function(event){
var iframe = ifr.get(0);
var iframeDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
// Find click position (coordinates)
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/mauriciosantos/Buckets-JS/master/dist/buckets.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/mauriciosantos/Buckets-JS/master/dist/buckets.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@agaase
agaase / gist:6648737
Created September 21, 2013 08:57
isonscreen - A simple jquery function to check if the element is visible on screen.
$.fn.isOnScreen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
@agaase
agaase / longest_valid_parentheses
Created May 16, 2017 16:24
Given a string consisting of opening and closing parenthesis, find length of the longest valid parenthesis substring.
//http://practice.geeksforgeeks.org/problems/longest-valid-parentheses/0
var seq = [1,0,1,0,1,1]
var counts = [];
var stack = [];
for(var i=seq.length-1;i>=0;i--){
var val = seq[i];
if(val){
stack.push(val);
}
if(!val){
@agaase
agaase / word_break_dict
Created May 16, 2017 16:12
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.
//http://practice.geeksforgeeks.org/problems/word-break-part-2/0
var candidates = [];
var dict = ["snake", "snakes", "and", "sand", "ladder"];
var input = "snakesandladder";
for(var i=0;i<input.length;i++){
debugger;
var chAtI = input.charAt(i);
if(candidates.length){
@agaase
agaase / max_abs_diff.js
Created May 13, 2017 14:18
Max absolute difference between two sub contiguous arrays
//Solution to problem here - http://practice.geeksforgeeks.org/problems/max-absolute-difference/0
var findCombination = function(arr){
debugger;
var comb = [];
if(arr.length>1){
comb.push(arr);
comb = comb.concat(findCombination(arr.slice(1,arr.length)));
comb = comb.concat(findCombination(arr.slice(0,arr.length-1)));
return comb;
}else{
@agaase
agaase / max_abs_diff.js
Created May 13, 2017 14:18
Max absolute difference between two sub contiguous arrays
//Solution to problem here - http://practice.geeksforgeeks.org/problems/max-absolute-difference/0
var findCombination = function(arr){
debugger;
var comb = [];
if(arr.length>1){
comb.push(arr);
comb = comb.concat(findCombination(arr.slice(1,arr.length)));
comb = comb.concat(findCombination(arr.slice(0,arr.length-1)));
return comb;
}else{