This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getCollection("your_collection").find( | |
{ | |
"start_time": { "$lte": 900 }, // time stored as int | |
"end_time": { "$gte": 479 } | |
}, | |
{ | |
"start_time": 1, "end_time": 1 // projection | |
} | |
) | |
// credits https://stackoverflow.com/questions/26876803/mongodb-find-date-range-if-overlap-with-other-dates/26877645 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.head = None | |
def display(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/widgets.dart'; | |
// from below link | |
// https://github.com/dancamdev/effectively_scale_UI_according_to_different_screen_sizes/blob/master/lib/SizeConfig.dart | |
class SizeConfig { | |
static MediaQueryData _mediaQueryData; | |
static double screenWidth; | |
static double screenHeight; | |
static double blockSizeHorizontal; | |
static double blockSizeVertical; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRandomInt(lower, upper) { | |
return Math.floor(Math.random() * (upper - lower + 1)) + lower; | |
} | |
console.log(getRandomInt(1,100)); | |
// expected output: a number between 1 and 100 | |
console.log(Math.random()); | |
// expected output: a number between 0 and 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"USD": { | |
"symbol": "$", | |
"name": "US Dollar", | |
"symbol_native": "$", | |
"decimal_digits": 2, | |
"rounding": 0, | |
"code": "USD", | |
"name_plural": "US dollars" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { gregorianToJulian, julianToHijri } from './hijri-util-date.js'; | |
/** | |
* Gregorian to Hijri | |
* * First convert to Julian | |
* * then convert to hijri | |
*/ | |
const futureDate = dayjs('2019-10-24').add(1, 'year'); | |
// .format('YYYY-MM-DD'); | |
const y = futureDate.year(); | |
const d = futureDate.day(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use DataStructures\LinkedList; | |
$linkedList = new LinkedList(); | |
$linkedList->inserFirst(10); | |
$linkedList->inserFirst(20); | |
$linkedList->insertLast(40); | |
$linkedList->insertLast(30); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = express(); | |
// define your custom routes here | |
app.use('/test', (req, res) => { | |
res.status(200).json({ message: 'your test route' }); | |
); | |
// 500 - Any server error - at the end | |
app.use((err, req, res, next) => { | |
return res.status(500).json({ error: err.toString() }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This makes two connections, one to a tcp server, one to an http server (both in server.js) | |
// It fires off a bunch of connections and times the response | |
// Both send strings. | |
const net = require(`net`); | |
const http = require(`http`); | |
function parseIncomingMessage(res) { | |
return new Promise((resolve) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Anything { | |
public function include() { | |
} | |
} |