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
#install mongodb | |
# Step 1 - Import the public key used by the package management system | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 68818C72E52529D4 | |
# Step 2 - Create source list file MongoDB | |
#Create a MongoDB list file in /etc/apt/sources.list.d/ with this command: |
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
/* | |
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
*/ | |
var http = require('http'), | |
fs = require('fs'), | |
util = require('util'); | |
http.createServer(function (req, res) { | |
var path = 'video.mp4'; |
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 'dart:async'; | |
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
import 'package:flutter_sqflite_app/model/user.model.dart'; | |
class ApiService { | |
static final BASE_URL = "https://xxxxxxxx.herokuapp.com"; | |
static final LOGIN_URL = BASE_URL + "/auth/v1/users/login"; |
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
/* | |
{ | |
"status": true, | |
"message": "Message", | |
"statusCode": 200, | |
"data": { | |
"access_token": "mytoken here" | |
} | |
} | |
*/ |
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 express = require('express'); | |
const logger = require('morgan'); | |
const cookieParser = require('cookie-parser'); | |
const bodyParser = require('body-parser'); | |
const multer = require('multer'); | |
const index = require('./routes/index'); | |
const app = express(); |
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
let persons = [ | |
{ name: 'John', age: 25, gender: 'male'}, | |
{ name: 'Doe', age: 35, gender: 'male'}, | |
{ name: 'Nayla',age: 18, gender: 'female'}, | |
{ name: 'Alex', age: 21, gender: 'female'}, | |
{ name: 'Jane', age: 22, gender: 'male'} | |
]; | |
let age = persons.filter((person)=>{ | |
return person.gender === 'male'; |
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
let arr = [1,2,3,4,5]; | |
/// with initial value | |
let result = arr.reduce((accumulator,currentValue,currentIndex,array)=>{ | |
console.log(`result: ${accumulator}, current value: ${currentValue}, index: ${currentIndex}, array: ${array} `); | |
return accumulator + currentValue; | |
},0); | |
///OUTUT: | |
result: 0, current value: 1, index: 0, array: 1,2,3,4,5 | |
result: 1, current value: 2, index: 1, array: 1,2,3,4,5 | |
result: 3, current value: 3, index: 2, array: 1,2,3,4,5 |
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
let arr = [1,2,3,4,5]; | |
let result = arr.reduce((accumulator,currentValue)=>{ | |
return accumulator + currentValue; | |
}); | |
console.log(result); /// 15 |
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
let numbers = [1,2,3,4,5,6,7,8,9,10]; | |
// using for loop | |
let evenNumbers = []; | |
for(let i=0; i<numbers.length; i++){ | |
if(numbers[i] % 2 === 0) evenNumbers.push(numbers[i]); | |
} | |
console.log(evenNumbers); | |
// using filter | |
let evenNumbers = numbers.filter(item=> item % 2 === 0); |
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
let newDepartments = departments.filter(department=>{ | |
return department.student<=5000; | |
}); | |
//output: | |
[ | |
{ name: 'EEE', student: 2000}, | |
{ name: 'CSIT', student: 5000}, | |
{ name: 'ME', student: 4500}, | |
{ name: 'LAW', student: 2500} | |
] |