Skip to content

Instantly share code, notes, and snippets.

View arahmanali's full-sized avatar
💭
Travelling is an ultimate thing to heal yourself

A Rahman Ali arahmanali

💭
Travelling is an ultimate thing to heal yourself
View GitHub Profile
@arahmanali
arahmanali / mongoose-ref-model-service.js
Last active March 12, 2020 22:38
Mongoose nested query on Model by field by its referenced model.
/*
Find all companies that people with lastname "Robertson" have founded
*/
var mongoose = require('mongoose');
var PersonSchema = new mongoose.Schema {
firstname: String,
lastname: String
};
var Person = mongoose.model('Person', PersonSchema);
@arahmanali
arahmanali / mongoose-sum-fields.js
Last active June 19, 2022 10:08
Mongoose sum and group model's field.
/* fetch all users user_totaldocs and user_totalthings values and want to sum those variables.*/
var userSchema = mongoose.Schema({
local : {
...
...
user_id : String,
user_totaldocs : Number,
user_totalthings : Number
....
///////////////////////////////////////////////////////
// $ node txt-to-json-parser.js [file_you_want_to_parse]
///////////////////////////////////////////////////////
var fs = require('fs');
var arr = []
var file_name = process.argv[2];
var stream = fs.createReadStream(file_name + '.txt', { flags: 'r+', encoding: 'utf-8' });
var buf = '';
///////////////////////////////////////////////////////
// $ node unique-json-parser.js [file_you_want_to_parse]
///////////////////////////////////////////////////////
var fs = require('fs');
var file_name = process.argv[2];
var obj = {}
fs.readFile(file_name + '.json', { encoding: 'utf8' }, function(err, obj) {
@arahmanali
arahmanali / NodeJs-Modules-R&D.txt
Last active June 29, 2016 03:38
NodeJs for Queues / Cron Jobs / Clusters / ORMs
Nodejs for Queues:
=================
https://github.com/caolan/async
https://www.npmjs.com/package/queue
https://github.com/Automattic/kue
https://github.com/OptimalBits/bull
https://github.com/twitter-archive/kestrel
https://github.com/nullobject/bokeh
https://github.com/NodeRedis/node_redis
@arahmanali
arahmanali / download_egghead_videos.md
Created January 15, 2017 16:03 — forked from ldong/download_egghead_videos.md
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@arahmanali
arahmanali / index.html
Last active July 23, 2017 08:19
RxJs Basic Example // source http://jsbin.com/cihibak
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>RxJs Basic Example</title>
</head>
<body>
<button>Click me</button>
@arahmanali
arahmanali / dataURItoBlob.js
Created September 21, 2017 08:02 — forked from davoclavo/dataURItoBlob.js
Convert dataURI to Blob so large images do not crash the browser. Based on: http://stackoverflow.com/questions/10412299 and http://stackoverflow.com/questions/6850276
/*
The MIT License (MIT)
Copyright (c) 2016 David Gomez-Urquiza
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@arahmanali
arahmanali / m3u8.md
Created October 18, 2018 17:11 — forked from primaryobjects/m3u8.md
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.