This file contains hidden or 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 React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import axios from 'axios'; | |
| class FetchDemo extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| posts: [] |
This file contains hidden or 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
| randomArray = Array.from({length: 10}, () => Math.floor(Math.random() * 40)); | |
| console.log("Random: ",randomArray); | |
| var even = [];var odd = []; | |
| processArray(randomArray) | |
| async function processArray(data) { | |
| for(const item of data){ | |
| // console.log(item) | |
| await asyncCall(item) |
This file contains hidden or 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
| module.exports = function(sequelize, Sequelize) { | |
| var User = sequelize.define('user', { | |
| id: { autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER}, | |
| firstname: { type: Sequelize.STRING,notEmpty: true}, | |
| lastname: { type: Sequelize.STRING,notEmpty: true}, | |
| username: {type:Sequelize.TEXT}, | |
| about : {type:Sequelize.TEXT}, | |
| email: { type:Sequelize.STRING, validate: {isEmail:true} }, | |
| password : {type: Sequelize.STRING,allowNull: false }, |
This file contains hidden or 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
| if(process.argv.length < 3){ | |
| console.log('target file path is required.') | |
| process.exit(1) | |
| } | |
| var target = process.argv[2] | |
| console.log('file: ' + target) | |
| var fs = require('fs') | |
| fs.readFile(target, function (err, data) { |
This file contains hidden or 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
| 'use strict' | |
| const timeout = ms => new Promise(res => setTimeout(res, ms)) | |
| function convinceMe (convince) { | |
| let unixTime = Math.round(+new Date() / 1000) | |
| console.log(`Delay ${convince} at ${unixTime}`) | |
| } | |
| async function delay () { |
This file contains hidden or 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
| PS3='Select your choice: ' | |
| options=("Quit" "pm2 restart App_Backend" "Option 2" "Option 3") | |
| select opt in "${options[@]}" | |
| do | |
| case $opt in | |
| "Quit") | |
| break | |
| ;; | |
| "pm2 restart App_Backend") | |
| pm2 restart App_Backend/server/server.js --name=GIG_backend |
This file contains hidden or 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 redisClient = redis.createClient(REDIS_URL); | |
| const listeners = Object.create(null); | |
| function addListener(channel, listener) { | |
| if (!listeners[channel]) { | |
| listeners[channel] = []; | |
| redisClient.subscribe(channel); | |
| } | |
| listeners[channel].push(listener); |
This file contains hidden or 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
| router.post('/addUserSocialProfile', function (req, res) { | |
| var profileData = req.body.social; | |
| var data = {};var output = [];var changed = 0;var now = new Date(); | |
| processObject(profileData) | |
| async function processObject(profileData) { | |
| for(var key in profileData){ | |
| // console.log(item) | |
| await asyncCall(key, profileData[key]) |
This file contains hidden or 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
| /** | |
| * Generates number of random geolocation points given a center and a radius. | |
| * @param {Object} center A JS object with lat and lng attributes. | |
| * @param {number} radius Radius in meters. | |
| * @param {number} count Number of points to generate. | |
| * @return {array} Array of Objects with lat and lng attributes. | |
| */ | |
| function generateRandomPoints(center, radius, count) { | |
| var points = []; | |
| for (var i=0; i<count; i++) { |
This file contains hidden or 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 items = [1, 2, 3, 4, 5, 6]; | |
| // do something that takes time with the item | |
| function f1(item) { | |
| console.log('[f1] received', item); | |
| return new Promise(function(resolve, reject) { | |
| setTimeout(resolve, 1000); | |
| }); | |
| } |
OlderNewer