Skip to content

Instantly share code, notes, and snippets.

View codebanesr's full-sized avatar
🌿
Make a small contribution to the world

shanurrahman codebanesr

🌿
Make a small contribution to the world
View GitHub Profile
@codebanesr
codebanesr / default.conf
Last active May 22, 2022 19:49
Nginx test configuration
gzip on;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
# Browser preferred language detection (does NOT require AcceptLanguageModule)
map $http_accept_language $accept_language {
default en;
~*^en en;
~*^ar ar;
}
@codebanesr
codebanesr / gist:495b431cc9ff74fb79c958d4de68e564
Last active August 11, 2021 21:30
Output for a single movie
{
"_id" : "HO00001421",
"theatres" : [
{
"_id" : ObjectId("61143e628284301a1db96afd"),
"title" : {
"text" : "Paw Patrol: The Movie",
"translations" : []
},
"genreIds" : [
@codebanesr
codebanesr / patients.js
Last active July 8, 2021 03:07
Codementor session
const document_create = async (req, res, next) => {
try {
console.log("routeLog", "document_create");
console.log(req.body, "body")
const CPMRN = req.params.CPMRN;
const encounters = req.params.encounters;
const tags = req.body.props.tags;
const attributes = req.body.props.attributes;
@codebanesr
codebanesr / docker-compose.yml
Created October 19, 2020 08:46
Grafana-influx-db
version: '2'
services:
influxdb:
container_name: influxdb
image: docker.io/bitnami/influxdb:1-debian-10
environment:
- 'INFLUXDB_ADMIN_USER_PASSWORD=influxdb'
- 'K6_INFLUXDB_USERNAME=admin'
ports:
switch (data.type) {
case 'offer':
// Doctor will initiate the offer
// console.log('msg received', Object.keys(this.connections), data, connection.userData);
// if UserB exists then send him offer detail
// TODO: if patient has joined then send the offer. else send message that patient not available
// to check patient has joined
// get oversides connection
if (aptData && aptData.userConnectionId) {
// get connectionId of patient and send offer

Promises! Aren't they wonderful

Promises give you hope of your wishes being granted somewhere in the future. Everyone has been promised by someone at some point in their life, and that's a sure thing. The only problem is promises aren't always fulfilled.

We make promises when we claim to do something in the future and javascript promises are the same. Promises always result in fulfillment or rejection. Enough talk, lets begin coding.

let mommysPromise = new Promise((resolve, reject)=>{
	setTimeout(()=>resolve("Buys a birthday present!"), 2000)

Please go through the post of bind before proceeding, this article will make much more sense. The difference between bind and apply is apply doesnot return a new function, it instantly calls the function that is being bounded to the object.

Here is the object we will be using for demonstrating the use of apply

var object = {
  firstName: "pika",
  lastName: "chu",
 

Lets say pokemon world was real and we are pokemon catchers

let pokemonBall = function() {
  console.log(this.name, this.powers)
}
pokemonBall()

What will be the output of the above function. undefined! But what if we had a pokemon, with a real name and powers!. So lets go ahead and catch a pokemon. But how do we do that?

Sending images/Files/Binary Stream over websockets/socketio

Connect to the socket

this.socket = io(environment.socketUrl, {
  "transports": ["polling", "websocket"]
});

Start listening for the file upload event

watchForChange() {
  this.validateForm.valueChanges.subscribe(change=>{
    CobrowsingformComponent.mysequenceNumber = CobrowsingformComponent.mysequenceNumber+10;
    const msg = {
      nextsequenceNumber: CobrowsingformComponent.mysequenceNumber,
      uniqueId: CobrowsingformComponent.uniqueId,
      change
    }