├── Day01 ├── async_sync.js ├── cats.txt ├── helloWorld.js ├── homework.js ├── intro.html ├── jobs.json ├── loremipsum.txt └── utility.js ├── Day02 ├── Procfile ├── daily_task.json ├── package.json └── personal_board.js ├── Day03 ├── lord_fungus_mungus.json └── mongoclient.js ├── Day04 ├── Clustering │ ├── cluster_sample_1.js │ ├── cluster_sample_2.js │ └── cluster_sample_3.js ├── mocha_with_browser │ ├── index.html │ ├── sum.js │ └── sum.test.js └── testing │ ├── mathForKids.js │ ├── package.json │ └── test │ └── test.js ├── Day05 ├── create_dummy.js ├── streaming_1.js ├── with_events.js ├── with_pipe.js └── with_readFile.js ├── Day06 └── EnBiEy │ ├── package-lock.json │ ├── package.json │ ├── public │ └── images │ │ ├── curry.gif │ │ ├── howard.gif │ │ └── lebron.gif │ ├── server.js │ └── src │ └── views │ ├── classic.html │ └── index.pug ├── Day07 ├── models │ ├── player.js │ └── team.js ├── package-lock.json ├── package.json └── server │ ├── MainServer.js │ ├── PlayerServer.js │ └── TeamServer.js ├── Day08 ├── app.js ├── package-lock.json ├── package.json ├── public │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── js │ │ ├── bootstrap.min.js │ │ └── jquery.slim.min.js ├── src │ ├── routes │ │ └── bookRoutes.js │ └── views │ │ ├── book.ejs │ │ ├── books.ejs │ │ └── index.ejs └── views │ └── index.html ├── Day09 ├── index.html ├── index.js ├── main.js ├── package-lock.json └── package.json ├── Day10 ├── client │ └── node │ │ ├── index.js │ │ └── product.proto ├── package.json └── server │ ├── Product.js │ ├── index.js │ └── product.proto ├── Day11 ├── appv1.js ├── appv2.js ├── images │ ├── sample_1.jpg │ ├── sample_2.jpg │ ├── sample_3.jpg │ ├── sample_4.jpg │ └── sample_5.jpg ├── index.html ├── package.json ├── scripts │ └── jquery.js ├── simpleCert.pem ├── simpleKey.pem └── style │ └── style.css ├── Day12 ├── app.js ├── index.html └── package.json └── README.md /Day01/async_sync.js: -------------------------------------------------------------------------------- 1 | //var fs=require("fs"); 2 | 3 | // Birinci örnek (Bloklama yok) 4 | // fs.readFile('loremipsum.txt',function(err,data){ 5 | // if(err) return console.error(err); 6 | // console.log(data.toString()+"\n\n"); 7 | // }); 8 | // console.log("### Program sonu ###\n"); 9 | 10 | // ikinci örnek (Bloklama söz konusu) 11 | //var loremData=fs.readFileSync('loremipsum.txt'); 12 | //console.log(loremData.toString()+"\n\n"); 13 | //console.log("*** Bitmeyen kod yapmışlar ***\n"); 14 | 15 | 16 | var fs = require("fs"); 17 | 18 | var readCallback = function (err, content) { 19 | if (err) { 20 | console.log(err.message); 21 | return; 22 | } 23 | var lines = content.toString().split("\n"); 24 | lines.forEach(l => { 25 | console.log(l); 26 | }); 27 | } 28 | 29 | fs.readFile('cats.txt', readCallback); 30 | console.log("### Program sonu ###\n"); -------------------------------------------------------------------------------- /Day01/cats.txt: -------------------------------------------------------------------------------- 1 | blue cat 2 | red cat 3 | gold cat 4 | green cat 5 | black cat 6 | gray cat 7 | garfield -------------------------------------------------------------------------------- /Day01/helloWorld.js: -------------------------------------------------------------------------------- 1 | var http = require('http') 2 | var url = require('url') 3 | var fs=require('fs') 4 | var utility = require('./utility') 5 | 6 | http.createServer(function (req, res) { 7 | res.writeHead(200, { 'Content-Type': 'text/html' }) 8 | res.write("
Try this! ;)
") 15 | } 16 | else { 17 | res.write("your nickname is " + q.nick + "
") 18 | res.write("or " + utility.reverse(q.nick) + "
") 19 | } 20 | res.end(); 21 | }).listen(5002); 22 | 23 | http.createServer(function (request, response) { 24 | fs.readFile("intro.html", function (err, data) { 25 | if (err) { 26 | console.log("[Error]:%s,%s",Date(),err.message) 27 | res.status(404).send('Not found') 28 | response.end() 29 | } 30 | else{ 31 | response.writeHead(200, { 'Content-Type': 'text/html' }) 32 | console.log("[Request]:%s,intro.html",Date()) 33 | response.write(data.toString()); 34 | response.end(); 35 | } 36 | }); 37 | }).listen(5003); -------------------------------------------------------------------------------- /Day01/homework.js: -------------------------------------------------------------------------------- 1 | /* 2 | Ön gereksinimler 3 | npm install express 4 | npm install body-parser 5 | */ 6 | 7 | var express = require('express'); 8 | var app = express(); 9 | var bodyparser = require('body-parser'); 10 | var fs = require('fs'); 11 | app.use(bodyparser.json()); 12 | 13 | // HTTP Get 14 | app.get('/api/jobs', function (request, response) { 15 | fs.readFile('jobs.json', 'utf8', function (err, data) { 16 | console.log('%s:%s', Date(), request.url); 17 | response.end(data); 18 | }); 19 | }); 20 | 21 | app.get('/api/jobs/:jobId', function (request, response) { 22 | console.log('%s:Requested job id %s',Date(),request.params.jobId); 23 | response.status(200); 24 | // Bu kısım sizde :) 25 | response.end(); 26 | }); 27 | 28 | // HTTP Post 29 | app.post('/api/addJob', function (request, response) { 30 | console.log('%s:%s', Date(), request.url); 31 | console.log(request.body); 32 | response.status(200).send('Job has been added'); 33 | // Bu kısım sizde :) 34 | response.end(); 35 | }); 36 | 37 | // HTTP Delete Burası da sizde 38 | // HTTP Update Burası da sizde 39 | 40 | var server = app.listen(5006, function () { 41 | console.log('Sunucu dinlemde'); 42 | }); -------------------------------------------------------------------------------- /Day01/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti 10 | quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia 11 | deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. 12 | Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere 13 | possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis 14 | aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum 15 | rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus 16 | asperiores repellat.
17 |18 | https://nodejs.org/en/">For more details... 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Day01/jobs.json: -------------------------------------------------------------------------------- 1 | { 2 | "job1": { 3 | "title": "just read", 4 | "duration": "4 books per month", 5 | "id": 12 6 | }, 7 | "job2" : { 8 | "title" : "be smile", 9 | "duration" : "to everyone", 10 | "id": 23 11 | }, 12 | "job3" : { 13 | "title" : "learn node.js", 14 | "duration" : "in 30 days", 15 | "id": 35 16 | }, 17 | "job4" : { 18 | "title" : "play basketball", 19 | "duration" : "2 times per week", 20 | "id": 35 21 | } 22 | } -------------------------------------------------------------------------------- /Day01/loremipsum.txt: -------------------------------------------------------------------------------- 1 | "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat." -------------------------------------------------------------------------------- /Day01/utility.js: -------------------------------------------------------------------------------- 1 | exports.reverse=function(input){ 2 | return input.split('').reverse().join('') 3 | } -------------------------------------------------------------------------------- /Day02/Procfile: -------------------------------------------------------------------------------- 1 | web: node personal_board.js -------------------------------------------------------------------------------- /Day02/daily_task.json: -------------------------------------------------------------------------------- 1 | { 2 | "task1": { 3 | "title": "Finish front-end login control test", 4 | "category": "Testing", 5 | "status": "todo", 6 | "id": 22325 7 | }, 8 | "task2": { 9 | "title": "Back button issue", 10 | "category": "Bug Fix", 11 | "status": "in progress", 12 | "id": 12342 13 | }, 14 | "task3": { 15 | "title": "Connect with SSO Service", 16 | "category": "Service Integration Development", 17 | "status": "epic", 18 | "id": 14345 19 | }, 20 | "task4": { 21 | "title": "Design of web app's help page", 22 | "category": "Front-end Development", 23 | "status": "todo", 24 | "id": 18123 25 | }, 26 | "task5": { 27 | "title": "Complete wheter api service", 28 | "category": "Service API Development", 29 | "status": "epic", 30 | "id": 48545 31 | } 32 | } -------------------------------------------------------------------------------- /Day02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fierce-earth-61739", 3 | "version": "1.0.0", 4 | "description": "a simple rest api for homeworks", 5 | "main": "homework.js", 6 | "dependencies": { 7 | "express": "^4.16.2" 8 | }, 9 | "devDependencies": {}, 10 | "scripts": { 11 | "start": "node personal_board.js", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://git.heroku.com/fierce-earth-61739.git" 17 | }, 18 | "keywords": [ 19 | "daily", 20 | "tasks", 21 | "scrum", 22 | "board", 23 | "node.js", 24 | "express", 25 | "rest" 26 | ], 27 | "author": "burak selim senyurt", 28 | "license": "ISC" 29 | } -------------------------------------------------------------------------------- /Day02/personal_board.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var fs = require('fs'); 4 | 5 | // HTTP Get 6 | app.get('/api/tasks', function (request, response) { 7 | fs.readFile('daily_task.json', 'utf8', function (err, data) { 8 | console.log('%s:%s', Date(), request.url); 9 | response.end(data); 10 | }); 11 | }); 12 | 13 | var server = app.listen(process.env.PORT || 8080, function () { 14 | console.log('Sunucu dinlemde'); 15 | }); -------------------------------------------------------------------------------- /Day03/lord_fungus_mungus.json: -------------------------------------------------------------------------------- 1 | { 2 | "primary_info": { 3 | "weapon": "lazer cannon", 4 | "motto": "go go gooo", 5 | "movie": "star wars - Jedi the last" 6 | }, 7 | "max_point": 385, 8 | "min_point": 35, 9 | "matches": [ 10 | { 11 | "game_day": 1, 12 | "vs": "lord rikken", 13 | "player_score": 200, 14 | "opponent_score": 145 15 | }, 16 | { 17 | "game_day": 2, 18 | "vs": "evelyn", 19 | "player_score": 189, 20 | "opponent_score": 485 21 | }, 22 | { 23 | "game_day": 3, 24 | "vs": "moka pinku", 25 | "player_score": 21, 26 | "opponent_score": 18 27 | }, 28 | { 29 | "game_day": 4, 30 | "vs": "draymmeor", 31 | "player_score": 53, 32 | "opponent_score": 56 33 | } 34 | ], 35 | "current_rank": 3, 36 | "nickname": "lord fungus mungus", 37 | "player_id": "21454834" 38 | } -------------------------------------------------------------------------------- /Day03/mongoclient.js: -------------------------------------------------------------------------------- 1 | var MongoClient = require('mongodb').MongoClient; 2 | 3 | function createCollection(url, name) { 4 | console.log("db create process..."); 5 | MongoClient.connect(url, function (err, db) { 6 | if (err) throw err; 7 | var dbOwner = db.db("remote"); 8 | dbOwner.createCollection(name, function (err, res) { 9 | if (err) throw err; 10 | console.log("collection created!"); 11 | db.close(); 12 | }); 13 | }); 14 | }; 15 | 16 | function getAllGamers(url) { 17 | console.log("processing..."); 18 | return new Promise(function (resolve, reject) { 19 | 20 | console.log("connecting..."); 21 | 22 | MongoClient.connect(url, function (err, db) { 23 | var dbo = db.db("remote"); 24 | var query = {}; 25 | console.log("fetching..."); 26 | dbo.collection("gamers") 27 | .find(query) 28 | .toArray(function (err, result) { 29 | if (err) { 30 | reject(err); 31 | } else { 32 | console.log("we have gamers now...") 33 | resolve(result) 34 | } 35 | db.close(); 36 | }); 37 | }); 38 | }) 39 | }; 40 | 41 | function insertDesigner(url,content){ 42 | console.log("inserting..."); 43 | MongoClient.connect(url,function(err,db){ 44 | if(err) throw err; 45 | var dbOwner=db.db("remote"); 46 | dbOwner.collection("designers").insertOne(content,function(err,res){ 47 | if(err)throw err; 48 | console.log("a new designer inserted"); 49 | console.log("ID : %s",res.insertedId); 50 | db.close(); 51 | }); 52 | }); 53 | }; 54 | 55 | function insertDesigners(url,content){ 56 | console.log("inserting..."); 57 | MongoClient.connect(url,function(err,db){ 58 | if(err) throw err; 59 | var dbOwner=db.db("remote"); 60 | dbOwner.collection("designers").insertMany(content,function(err,res){ 61 | if(err)throw err; 62 | console.log("%i documents inserted",res.insertedCount); 63 | db.close(); 64 | }); 65 | }); 66 | }; 67 | 68 | function main() { 69 | url = "mongodb://username:password@cluster0-shard-00-00-m2yq0.mongodb.net:27017/admin?replicaSet=Cluster0-shard-0&ssl=true" 70 | var designers=[ 71 | {fullName:"blue man",country:"ingland",system:"oceanic continent",expLevel:256}, 72 | {fullName:"Reddick",country:"red sun",system:"world",expLevel:128}, 73 | {fullName:"mari dö marş",country:"pari",system:"moon",expLevel:45} 74 | ]; 75 | insertDesigners(url,designers); 76 | 77 | //var vanDyk={fullName:"Yurri van dayk de la rossa",country:"green age",system:"Tatuin",expLevel:980}; 78 | 79 | //insertDesigner(url,vanDyk); 80 | 81 | //createCollection(url,"designers"); 82 | 83 | /* 84 | getAllGamers(url).then(function (result) { 85 | console.log(result); 86 | }, function (err) { 87 | console.log(err); 88 | }); 89 | */ 90 | console.log("mongodb examples...") 91 | }; 92 | 93 | main(); 94 | -------------------------------------------------------------------------------- /Day04/Clustering/cluster_sample_1.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | 3 | if (cluster.isMaster) { 4 | console.log('Master process ' + process.pid); 5 | for (var i = 0; i < 4; i++) { 6 | console.log('Worker #' + i + ' is starting.'); 7 | cluster.fork(); 8 | } 9 | 10 | cluster.on('fork', function (worker) { 11 | console.log('\tfork event (worker ' + worker.process.pid + ')'); 12 | }); 13 | 14 | cluster.on('online', function (worker) { 15 | console.log('\tonline event (worker ' + worker.process.pid + ')'); 16 | }) 17 | 18 | cluster.on('exit', function (worker) { 19 | console.log('\texit event (worker ' + worker.process.pid + ')'); 20 | }); 21 | 22 | } else { 23 | console.log('Aloha. My name is worker #' + process.pid); 24 | cluster.worker.destroy(); 25 | } -------------------------------------------------------------------------------- /Day04/Clustering/cluster_sample_2.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | var workers = []; 3 | var names = ['con do', 'vuki', 'lora', 'deymin', 'mayk', 'cordi', 'klaus', 'commander', 'jenkins', 'semuel', 'fire starter']; 4 | var colors = ['red', 'green', 'blue', 'gold', 'white', 'black', 'brown', 'yellow', 'gray', 'silver']; 5 | if (cluster.isMaster) { 6 | console.log('I am the process #' + process.pid); 7 | for (var i = 0; i < 3; i++) { 8 | var worker = cluster.fork(); 9 | workers.push(worker); 10 | worker.on('message', function (message) { 11 | console.log('\t\tChild says that:' + JSON.stringify(message)); 12 | }); 13 | workers.forEach(function (worker) { 14 | var index = Math.floor(Math.random() * names.length) + 1; 15 | worker.send({ name: names[index - 1] }); 16 | }, this); 17 | } 18 | 19 | } else { 20 | console.log('Aloha. I am the worker process #' + process.pid); 21 | process.on('message', function (message) { 22 | console.log('\The boss says that: ' + JSON.stringify(message)); 23 | }); 24 | var index = Math.floor(Math.random() * colors.length) + 1; 25 | process.send({ color: colors[index - 1] }); 26 | cluster.worker.destroy(); 27 | } -------------------------------------------------------------------------------- /Day04/Clustering/cluster_sample_3.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | var http = require('http'); 3 | var cpuCount = 2; 4 | var names = ['con do', 'vuki', 'lora', 'deymin', 'meyk', 'cordi', 'klaus', 'commander', 'jenkins', 'semuel', 'fire starter']; 5 | 6 | if (cluster.isMaster) { 7 | console.log('Master PID: ' + process.pid); 8 | for (var i = 0; i < cpuCount; i++) { 9 | cluster.fork(); 10 | } 11 | 12 | cluster.on('fork', function (worker) { 13 | console.log('\tfork (worker ' + worker.process.pid + ')'); 14 | }); 15 | 16 | cluster.on('online', function (worker) { 17 | console.log('\tonline (worker ' + worker.process.pid + ')'); 18 | }) 19 | 20 | cluster.on('listening', function (worker, address) { 21 | console.log('\tlistening (worker ' + worker.id + ') pid ' + worker.process.pid + ', ' + address.address + ':' + address.port + ')'); 22 | }); 23 | 24 | cluster.on('exit', function (worker) { 25 | console.log('\texit (worker ' + worker.process.pid + ')'); 26 | }); 27 | 28 | } else { 29 | console.log('Worker # has been' + process.pid + ' started.'); 30 | http.createServer(function (req, res) { 31 | res.writeHead(200); 32 | var index = Math.floor(Math.random() * names.length) + 1; 33 | res.end('My name is "' + names[index - 1] + '" (pid ' + cluster.worker.process.pid + ')\n'); 34 | }).listen(65001, "127.0.0.1"); 35 | } -------------------------------------------------------------------------------- /Day04/mocha_with_browser/index.html: -------------------------------------------------------------------------------- 1 | 2 |