์ธํ”„๋Ÿฐ 11

[์ธํ”„๋Ÿฐ] ์•„์ดํฐ ์•ฑ ๊ฐœ๋ฐœ(3)

์˜ค๋Š˜์€ ํด๋ž˜์Šค์™€ ๊ตฌ์กฐ์ฒด ๊ทธ๋ฆฌ๊ณ  ์—ด๊ฑฐํ˜• ! ๐Ÿ‰ class ๐Ÿ‰ class Circle { // class๋ช…์€ ๋Œ€๋ฌธ์ž๋กœ ์‹œ์ž‘ var radius = 3.123 // class ์†์„ฑ let pi = 3.1415926535 func area() -> Double { // ๋ฉ”์†Œ๋“œ return (radius * radius * pi) } } let circle = Circle() // ์ธ์Šคํ„ด์Šค(๊ฐ์ฒด, ์˜ค๋ธŒ์ ํŠธ) ์ƒ์„ฑ let circle = Circle.init() // ์œ„์™€ ๊ฐ™์Œ circle.area() ํ”„๋กœํผํ‹ฐ๊ฐ€ ์ดˆ๊ธฐํ™”๋ผ์žˆ์ง€ ์•Š์œผ๋ฉด ์—๋Ÿฌ class ์ƒ์† class Apple { // super class: ๊ณตํ†ต var appleColor = "red" } class AppleAndBanana : Apple { //..

[์ธํ”„๋Ÿฐ] ์•„์ดํฐ ์•ฑ ๊ฐœ๋ฐœ(2)

์˜ค๋Š˜์€ swift์˜ ๊ธฐ๋ณธ ๋ฌธ๋ฒ•๋ถ€ํ„ฐ ํ•จ์ˆ˜๊นŒ์ง€ ! ๐Ÿ˜ธ ๐Ÿ‰ ๊ธฐ๋ณธ ๋ฌธ๋ฒ• ๐Ÿ‰ ๋ณ€์ˆ˜ ์ƒ์ˆ˜ var r = 3.123// ๋ณ€ํ•˜๋Š” ๊ฐ’ let p = 3.1415926535 // ๋ณ€ํ•˜์ง€ ์•Š๋Š” ๊ฐ’ var message : String = "ํ•˜์ด" // Bool, Int, String, Float, Double ... cmd + click → ๋ณ€์ˆ˜๋ช… ํ•œ๋ฒˆ์— ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ ๋ฐ์ดํ„ฐ์˜ ์ž๋ฃŒํ˜•์„ ๋ณด๊ณ  ํƒ€์ž… ์ถ”๋ก  → ๋ฐ์ดํ„ฐ๊ฐ€ ์—†์œผ๋ฉด ์ž๋ฃŒํ˜• ๋ช…์‹œ ํ•„์š” ํ•œ๋ฒˆ ์ž๋ฃŒํ˜•์ด ์ •ํ•ด์ง€๋ฉด ๋ณ€๊ฒฝ ๋ถˆ๊ฐ€๋Šฅ Intํ˜•์€ ํ”Œ๋žซํผ์— ๋”ฐ๋ผ ๋ฒ”์œ„๊ฐ€ ๋‹ฌ๋ผ์ง Int8, 16, 32, 64๋กœ ๋‹ค์–‘ํ•œ๋ฐ ์‚ฌ์šฉ๊ฐ€๋Šฅ ๋ฒ”์œ„๊ฐ€ ๋„˜์–ด๊ฐ€๊ฒŒ ๋˜๋ฉด ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ๋ฐœ์ƒ Int๋กœ ์„ ์–ธํ•˜๊ฒŒ ๋˜๋ฉด ์ž์‹ ์˜ cpu์— ๋งž๊ฒŒ ์ž๋™์ ์œผ๋กœ ์„ค์ •๋จ ํ•จ์ˆ˜ // ํ•จ์ˆ˜ ์„ ์–ธ func circleArea(r: Double..

[์ธํ”„๋Ÿฐ] ์•„์ดํฐ ์•ฑ ๊ฐœ๋ฐœ(1)

๋”๋ณด๊ธฐ ๐Ÿ˜‡ ์˜ค๋Š˜๋ถ€ํ„ฐ ios ๊ฐœ๋ฐœ ๊ณต๋ถ€ ์‹œ์ž‘ ๐Ÿ˜‡ ์šฐ์„  xcode๋ฅผ ์„ค์น˜ํ•ด์ฃผ์—ˆ๋‹ค! (์ง„์งœ... ๋จธ๋ƒ..? ๋‹ค๋ฅธ ์•ฑ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์ƒ๊ฐํ–ˆ๋Š”๋ฐ ์ง„์งœ ์˜ค๋ž˜ ๊ฑธ๋ ธ๋‹ค.. ๊ทผ๋ฐ ๋‹ค๋ฅธ ๋ถ„๋“ค์€ ๋‚ด ์ƒ์ƒ์„ ์ดˆ์›”ํ•  ์ •๋„๋กœ ์˜ค๋ž˜ ๊ฑธ๋ ค์„œ ํฌ๋กฌ์—์„œ ์„ค์น˜๋ฐ›๊ธฐ๋„ ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค) ๐Ÿ‰ xcode ์‚ฌ์šฉ๋ฒ• ๐Ÿ‰ ๋นˆ ํŒŒ์ผ ์ƒ์„ฑ xcode → file → playground → ๋นˆ ํŒŒ์ผ ์ƒ์„ฑ์„ ํ•ด์ค€๋‹ค ๊ฐ•์˜๋ฅผ ๋”ฐ๋ผ variable์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ์—ˆ๋‹ค ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ xcode ๊ตฌ์„ฑ์š”์†Œ: ์†Œ์Šค ํŽธ์ง‘๊ธฐ (.swift) + ํ™”๋ฉด ๋””์ž์ธ์ด ๊ฐ€๋Šฅํ•œ ์Šคํ† ๋ฆฌ๋ณด๋“œ (Main, Launchscreen) main: ์•ฑ ๋ฉ”์ธ ํ™”๋ฉด launch screen: ์•ฑ ์‹œ์ž‘ ์ „ ๋กœ๋“œ ํ™”๋ฉด entry point: ์‹œ์ž‘ํ™”๋ฉด ์„ ํƒ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ label: ํ…์ŠคํŠธ๋ฅผ ์ถ”๊ฐ€..

[์ƒํ™œ์ฝ”๋”ฉ] NodeJs ํ™œ์šฉํ•˜๊ธฐ(2)

Session : cookie๋ฅผ ์กฐ๊ธˆ ๋” ๊ฐœ์„ ํ•œ ๋ฐฉ๋ฒ• ์ฟ ํ‚ค์™€ ์„œ๋ฒ„์˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์ž˜ ์กฐํ•ฉํ•ด ์„ธ์…˜์„ ๋งŒ๋“ ๋‹ค cookie๋Š” id๋‚˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋‹ค๋ฃจ๊ธฐ์—๋Š” ์œ„ํ—˜ํ•˜๋‹ค → ๋ณด์•ˆ ๋ฌธ์ œ ์„ธ์…˜์€ ์„œ๋ฒ„๊ฐ€ ์ฟ ํ‚ค ๋ฐฉ์‹์œผ๋กœ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š”๋ฐ ์ด๋•Œ ์ฟ ํ‚ค์™€ ๋‹ค๋ฅด๊ฒŒ ์‚ฌ์šฉ์ž์˜ ์‹๋ณ„์ž id ๊ฐ’๋งŒ์„ ์ €์žฅํ•œ๋‹ค → ์‹ค์ œ ๋ฐ์ดํ„ฐ๋Š” ์„œ๋ฒ„์˜ database์— ์ €์žฅ๋˜์–ด ์žˆ๋‹ค ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ํด๋ผ์ด์–ธํŠธ๊ฐ€ id๋ฅผ ๊ฐ–๊ณ  ์„œ๋ฒ„์— ์ ‘์†ํ•  ๋•Œ ์„œ๋ฒ„๊ฐ€ ํ•ด๋‹น id ๊ฐ’์— ํ•ด๋‹นํ•˜๋Š” data๋ฅผ ์ฝ์–ด์™€ ์‚ฌ์šฉํ•œ๋‹ค ↓↓ ์‹ค์ œ๋กœ ์„ธ์…˜์˜ set-cookie์—๋Š” connect.sid์˜ ๊ฐ’๋งŒ ์žˆ๊ณ  ์ฟ ํ‚ค์˜ set-cookie์—๋Š” count์˜ ์ •๋ณด๊ฐ€ ๋‹ด๊ฒจ์žˆ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค ๋‹ค์‹œ ๋งํ•˜๋ฉด session์€ ํด๋ผ์ด์–ธํŠธ์— ์‚ฌ์šฉ์ž์˜ id ๊ฐ’๋งŒ ์ €์žฅํ•˜๊ณ , cookie๋Š” ํด๋ผ์ด..

[์ƒํ™œ์ฝ”๋”ฉ] NodeJs ํ™œ์šฉํ•˜๊ธฐ(1)

HTTP : ๋ธŒ๋ผ์šฐ์ €์™€ ์„œ๋ฒ„๊ฐ€ ์†Œํ†ต(request, response message)ํ•˜๋Š” ํ†ต์‹  ๋ฐฉ๋ฒ• - stateless Cookie : ์„œ๋ฒ„์—์„œ ์ „์˜ ๊ธฐ๋ก์„ ์ €์žฅ → session → ์ธ์ฆ์œผ๋กœ ํ™•์žฅ๋  ์ˆ˜ ์žˆ์Œ ์ด์ œ Nodejs๋ฅผ ์ด์šฉํ•ด์„œ count์˜ ์ˆ˜๋ฅผ ๋Š˜๋ ค๊ฐ€๋ฉด์„œ response ํ—ค๋”๋ฅผ ํ†ตํ•ด ๋ธŒ๋ผ์šฐ์ €์—์„œ ์„ธํŒ…ํ•˜๋ผ๊ณ  ๋ช…๋ นํ•œ๋‹ค ๊ทธ๋ฆฌ๊ณ  ๋ธŒ๋ผ์šฐ์ €๋Š” ์„œ๋ฒ„์˜ ๋ช…๋ น์— ๋”ฐ๋ผ ๋‹ค์Œ์— ๋ฐฉ๋ฌธํ–ˆ์„ ๋•Œ count๋ฅผ 2๋กœ ๋ฐ”๊พผ๋‹ค !! ์ฟ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์–ด๋–ค ๊ฒŒ ํ•„์š”ํ•œ์ง€ ์•Œ์•„๋ณด๋ฉด !! https://expressjs.com/en/4x/api.html#req.cookies Express 4.x - API Reference Express 4.x API express() Creates an Express application. T..

[์ƒํ™œ์ฝ”๋”ฉ] Nodejs๋กœ Database ๋‹ค๋ฃจ๊ธฐ(3)

์ด๋ฒˆ ์ˆ˜์—…์—์„œ๋Š” ์ €๋ฒˆ ์ˆ˜์—…๊นŒ์ง€ ์งฐ๋˜ ์ฝ”๋“œ์—์„œ fs๋ฅผ ์ด์šฉํ–ˆ๋˜ ๋ถ€๋ถ„์„ database๋ฅผ ์ด์šฉํ•˜๋„๋ก ๋ฐ”๊ฟ€ ๊ฒƒ์ด๋‹ค! ๊ทธ์ „์— app_file.js์˜ ๋ณต์‚ฌ๋ณธ app_mysql.js๋ฅผ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ ์ €๋ฒˆ๊นŒ์ง€ ์งฐ๋˜ ์ฝ”๋“œ์™€ ๋‹ฌ๋ผ์„œใ…œใ…œ(multer ๋ถ€๋ถ„๋งŒ) ๋”ฐ๋กœ ์ถ”๊ฐ€ํ•ด์คฌ๋‹ค ๋”๋ณด๊ธฐ ์ถ”๊ฐ€ํ•œ multer ๋ถ€๋ถ„ let multer = require('multer'); let _storage =multer.diskStorage({ description: function (req, file, cb){ cb(null, 'uploads/') }, filename: function (req, file, cb){ cb(null, file.originalname); } }) let upload = multer({_storage: _storag..

[์ƒํ™œ์ฝ”๋”ฉ] Nodejs๋กœ Database ๋‹ค๋ฃจ๊ธฐ(2)

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ MySQL ์ œ์–ดํ•˜๊ธฐ : Node-MySQL ๋จผ์ € node-mysql ์„ค์น˜! https://github.com/mysqljs/mysql mysqljs/mysql A pure node.js JavaScript Client implementing the MySQL protocol. - mysqljs/mysql github.com ๊นƒํ—™์— ๋ฐฉ๋ฌธ์„ ํ•˜๋ฉด 'MySQL ํ”„๋กœํ† ์ฝœ์„ ๊ตฌํ˜„ํ•˜๋Š” ์ˆœ์ˆ˜ํ•œ node.js JavaScript ํด๋ผ์ด์–ธํŠธ.' ๋ผ๋Š” ๋œป์ด๋ผ๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ๋‹ค let mysql = require('mysql'); // node-mysql(๊ฐ์ฒด)์„ mysql(๋ณ€์ˆ˜)์— ๋‹ด๊ธฐ let connection = mysql.createConnection({ // node-mysql(๊ฐ์ฒด)์˜ ํ•จ์ˆ˜ ํ˜ธ์ถœ, ..

[์ƒํ™œ์ฝ”๋”ฉ] Nodejs๋กœ Database ๋‹ค๋ฃจ๊ธฐ(1)

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค database๋Š” ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ๊ด€๊ณ„ํ˜• database(Oracle, Mysql, Sql server)์™€ ๊ทธ ์™ธ์˜ ๋‹ค์–‘ํ•œ NoSQL๋กœ ๋‚˜๋‰œ๋‹ค. MySQL ์„ค์น˜ ๋ฐ ์‚ฌ์šฉ https://bitnami.com/stack/wamp WAMP Bitnami WAMP Stack provides a complete, fully-integrated and ready to run WAMP development environment. In addition to PHP, MySQL and Apache, it includes FastCGI, OpenSSL, phpMyAdmin, ModSecurity, SQLite, ImageMagick, xDebug, Xcache, OpenLDAP, ModSecurity, bitn..

[์ƒํ™œ์ฝ”๋”ฉ] Node.js ๋ฅผ ์ด์šฉํ•ด ์›น์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋งŒ๋“ค๊ธฐ(4)

๊ธ€ ๋ชฉ๋ก ๋งŒ๋“ค๊ธฐ ์ €์žฅ๋œ data๋ฅผ ์ฝ์–ด์˜ค๋Š” ๋ฒ• *GET์— ๋Œ€ํ•œ ๋ผ์šฐํŠธ app.get('/topic', function(req, res){ // get ๋ฐฉ์‹์œผ๋กœ /topic ๋ผ์šฐํŠธ fs.readdir('data', function(err, files){ if(err){ res.status(500).send('Internal Server Error'); } res.render('view', {topics: files}); }) }) ํ…œํ”Œ๋ฆฟ์—”์ง„์„ ์ด์šฉํ•œ๋‹ค app.set('views', './views_file'); app.set('view engine', 'pug'); ์ „ ์ˆ˜์—…์—์„œ ์ž‘์„ฑํ–ˆ๋˜ ์ด ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด์•ผ ํ•จ readdir์„ ์ด์šฉํ•ด์„œ data๋ฅผ ์ฝ์–ด์˜จ๋‹ค ๊ทธ๋•Œ callback ํ•จ์ˆ˜๋Š” err์™€ file ๋ชฉ๋ก(f..

[์ƒํ™œ์ฝ”๋”ฉ] Node.js ๋ฅผ ์ด์šฉํ•ด ์›น์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋งŒ๋“ค๊ธฐ(2)

๋™๊ธฐํ™” ๋น„๋™๊ธฐํ™” let fs = require('fs'); // Sync console.log('1'); let data = fs.readFileSync('data.txt',{encoding:'utf8'}); console.log(data); //Async console.log('2'); fs.readFile('data.txt', {encoding:'utf8'}, function(err, data){ console.log('3'); console.log(data); }); console.log('4'); Express express๋ฅผ ์„ค์น˜ํ•œ ํ›„! let express = require('express'); let app = express(); app.get('/', function(req, res){ r..