Skip to content

Instantly share code, notes, and snippets.

View shaikh-shahid's full-sized avatar
🌎
Building Decentralized Web

Shahid Shaikh shaikh-shahid

🌎
Building Decentralized Web
View GitHub Profile
var async = require('async');
async.series([
function(callback) {
// some async task
callback();
},
function(callback) {
// some async task
callback();
var async = require('async');
async.waterfall([
function(callback) {
// some code to execute
// in case to go to next function provide callback like this.
callback(null,valueForNextFunction);
// Got some error ? Don't wanna go further.
// Provide true in callback and execution will stop.
//callback(true,"Some error");
var async = require('async');
var emails = ["[email protected]","[email protected]"];
async.each(emails,function(singleEmail,callback) {
// Emailer code
// singleEmail will be one value at a time.
},function(err,data) {
// Once all done, comes here.
});
var async = require('async');
var emails = ["[email protected]","[email protected]"];
async.eachLimit(emails,1000,function(singleEmail,callback) {
// Emailer code
// singleEmail will be one value at a time.
},function(err,data) {
// Once all done, comes here.
});
var async = require('async');
var emails = ["[email protected]","[email protected]"];
async.each(emails,function(singleEmail,callback) {
async.waterfall([
function(callback) {
// code to send email.
callback(null,Flag);
},
function(emailSentOrNot,callback) {
var async = require('async');
async.forEach(someData,function(singleData,callback){
async.series();
//OR
async.paralle();
//OR
async.waterfall();
},function(err,data) {
// final callback
var async = require('async');
// Send email
var sendEmail = function(email,callback) {
console.log("Sending email to "+email);
callback(null);
}
// create a queue object with concurrency 2
var q = async.queue(sendEmail,2);
Go to DigitalOcean and <a href="https://m.do.co/c/31513addbd1b" target="_blank">login</a> to your account, create one if not already.
Create new Droplet ( Server ) and choose latest Ubuntu. Refer the image below for reference.
<img src="https://codeforgeek.com/wp-content/uploads/2016/12/dropet-1024x517.gif" alt="digitalocean droplet" width="640" height="323" class="aligncenter size-large wp-image-2763" />
DigitalOcean will create new Droplet and send you an e-mail containing the credentials to log-in your Server. You can use <strong>SSH</strong> or putty ( For Windows User ) to login to your Server.
Once you are logged on, do the system update first using the following command.
@shaikh-shahid
shaikh-shahid / beefree.js
Created March 30, 2017 11:20 — forked from andrei-tofan/beefree.js
Fetch access token from beefree api
/**
* NodeJS beefree.io integration
*/
const https = require('https');
const querystring = require('querystring');
/**
* Fetch access token from beefree api
*/
<html>
<head>
<title>Express HTML</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div style="margin:100px;">