![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端
文章平均质量分 88
唯识相链
技术交流,vx:1131052403
展开
-
s081[2]-unix内存分配方式-malloc实现
内存分配 前序课程 操作系统接口:https://dreamerjonson.com/2020/01/04/6-s081-1/ 系统编程(Systems programming) wiki参考 与应用程序编程相比,系统编程的主要区别在于,应用程序编程旨在产生直接向用户提供服务的软件。 系统编程主要为其他应用程序提供服务,直接操作操作系统。它的目标是实现对可用资源的有效利用。 例如: unix...原创 2020-01-16 15:30:35 · 292 阅读 · 0 评论 -
MAC环境配置
注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。 Tmux 快捷键 & 速查表 在 Tmux 中,按下 Tmux 前缀 ctrl+b,然后: 会话 窗口 (标签页) 调整窗口排序 窗格(分割窗口) 同步窗格 这么做可以切换到想要的窗口,输入 Tmux 前缀和一个冒号呼出命令提示行,然...原创 2020-01-09 20:05:40 · 687 阅读 · 0 评论 -
node[8]-json
原始文件 json.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //字符串 var personString = '{"name":"Andrew","age":25}'; console.log( typeof personString);//string...原创 2018-11-14 22:37:22 · 81 阅读 · 0 评论 -
node[9]-保存节点
原始文件 app.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 const yargs = require('yargs'); const nodes = require('./nodes.js') console.log('Start app.'); console.log(pr...原创 2018-11-14 22:38:17 · 134 阅读 · 0 评论 -
node[10]-封装代码
对于之前的代码进行封装 原始文件app.js 对于返回节点进行判断,如果新增了节点,就打印新增节点。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 //打印字符串 const yargs = require('yargs'); const nodes =...原创 2018-11-14 22:39:09 · 125 阅读 · 0 评论 -
node[16]-heroku-deploy
2018-11-16 nodejs nodejs 前端 2 评论 字数统计: 337(字) 阅读时长: 1(分) 源文件 views/partials/footer.hbs: 1 2 3 <Header> <footer>{{pageTitle}}</footer> <Header> ...原创 2018-11-19 22:42:44 · 178 阅读 · 0 评论 -
node[17]-mongodb
2018-11-16 nodejs nodejs 前端 3 评论 字数统计: 102(字) 阅读时长: 1(分) 下载mongodb https://www.mongodb.com mongod 解压,进入bin目录 1 2 //-dbpath代表数据放置在哪里 ./mongod -dbpath /Users/jackson/Download...原创 2018-11-19 22:43:35 · 109 阅读 · 0 评论 -
node[18]-mongodb-node增删查改
2018-11-16 nodejs nodejs 前端 3 评论 字数统计: 804(字) 阅读时长: 4(分) 1 > npm install --save mongodb 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...原创 2018-11-19 22:44:30 · 186 阅读 · 0 评论 -
node[19]-mongoose操作mongoDB数据库
node[19]-mongoose 2018-11-18 nodejs nodejs 前端 3 评论 字数统计: 205(字) 阅读时长: 1(分) mongoose 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 var mongoose...原创 2018-11-19 22:52:37 · 132 阅读 · 0 评论 -
node[20]-postman
安装postman 网址:https://www.getpostman.com 网址访问,保存数据 postman.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ...原创 2018-11-26 22:50:47 · 159 阅读 · 0 评论 -
node[21]-express+mondoDB应用部署到heroku
node[21]-express+mondoDB应用部署到heroku 2018-11-18 nodejs nodejs 前端 17 评论 字数统计: 394(字) 阅读时长: 2(分) express+mongoDB部署到heroku 注意process.env.PORT 与 process.env.MONGODB_URI 源代码postman.js: 1 2 3 4...原创 2018-11-26 22:52:43 · 213 阅读 · 0 评论 -
node[7]-yargs
yargs用于方便的处理命令行参数。导入yargs包,在项目路径下: 1 > npm install --save yargs 原始文件 app.js: 1 2 3 4 5 6 7 8 const yargs = require('yargs'); console.log('Start app.');...原创 2018-11-14 22:36:39 · 171 阅读 · 0 评论 -
node[6]-用户输入
原始文件 app.js: 1 2 3 console.log('Start app.'); console.log(process.argv); 获取用户输入 打开控制台,在当前目录下输入: 1 > nodemon app.js add 输出字符串 默认第一个为node系统路径 第二...原创 2018-11-14 22:35:38 · 1013 阅读 · 0 评论 -
node[5]-nodemon
nodemon nodemon帮助我们,当我们修改文件时,node程序自动从新执行。 安装 1 > npm install -g nodemon 原始文件 app.js: 1 2 3 4 5 6 7 8 9 10 console.log('Start app.'); const _ = req...原创 2018-11-14 22:34:48 · 600 阅读 · 0 评论 -
深度理解nodejs[3]—疯狂事件代码
疯狂的代码。 下面这段疯狂的代码,你能知道它输出什么结果吗? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 const https = require('https'); const start = Date.now(); const fs =...原创 2018-11-13 19:40:33 · 102 阅读 · 0 评论 -
node[11]-yargs高级
yargs高级用法,用于输出帮助信息,缩写提示等。 app.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 ...原创 2018-11-15 23:49:40 · 337 阅读 · 0 评论 -
node[12]-异步
如下异步代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 console.log('start...'); setTimeout(()=>{ console.log('first callback'); },2000) setTimeout(()=>{ console.log('second callback'); }...原创 2018-11-15 23:53:17 · 97 阅读 · 0 评论 -
node[13]-回调
自定义回调函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //自定义函数,包含回调函数 var getUser=(id,callback)=>{ var user = { id:id, name:'jonson' } setTimeout(()=>{ callback(user); ...原创 2018-11-15 23:54:09 · 142 阅读 · 0 评论 -
node[14]-promise
Promise promise是nodejs的对象,用于处理异步的同步操作。 new Promsie新建一个promise对象,两个参数(resolve,reject)是两个函数。 当调用resolve意味着操作成功。 当调用reject意味着操作失败。 resolve和reject都只会执行一次。 then 函数会在promise执行完毕之后调用。 第一个参数回调函数会在resolve成功...原创 2018-11-15 23:54:44 · 190 阅读 · 0 评论 -
node[15]-express
最简单的服务器 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 const express = require('express'); var app = express(); //返回html格式 app.get('/',(req,res)=>{ res.send('<h...原创 2018-11-15 23:55:19 · 116 阅读 · 0 评论 -
深度理解nodejs[1]-node底层机制
nodejs作为javascript在后端运行的环境,源码由js与C完成。本质上,nodejs是借助于谷歌V8引擎来运行javascript代码。使用了C的libuv库来处理网络,访问文件系统等操作。 nodejs的作用 1、提供一种接口,仅仅书写javascript的代码,就可以让他们正确执行,不用书写C++代码。 2、丰富的api。http、fs、path、crypto …module...原创 2018-11-12 21:14:50 · 1068 阅读 · 0 评论 -
深度理解nodejs[4]-cluster多线程node
下面的express程序可以看出nodejs单线程的缺陷,当访问主页面localhost:3000时,doWork(5000)方法会暂停5秒钟。 由于长时间的等待时间会使得node陷入到停顿的状态。当其他的请求来的时候,也只能够等待。例如当访问后立即访问localhost:3000/fast,只能够等待一段时间。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...原创 2018-11-14 22:30:10 · 1413 阅读 · 1 评论 -
node[2]-Helloworld
nodejs helloworld 新建文件app.js: 1 2 //打印字符串 console.log('Start app.'); 打开控制台,在当前目录下输入: 1 > node app.js 输出字符串Start app. nodejs 复杂helloworld ...原创 2018-11-14 22:31:43 · 92 阅读 · 0 评论 -
node[3]-require
require 导入其他文件 require可以执行其他文件的内容。 新建文件: nodes.js: 1 console.log('start nodes.js'); app.js: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 //打印字符串 console.log...原创 2018-11-14 22:32:53 · 97 阅读 · 0 评论 -
node[4]-第三方包
导入第三方包 nodejs 有丰富的第三方模块导入,例如要导入lodash包,在项目路径下: 1 > npm install --save lodash app.js: 1 2 3 4 5 6 7 8 9 10 console.log('Start app.'); const _ = requir...原创 2018-11-14 22:33:47 · 141 阅读 · 0 评论 -
深度理解nodejs[2]-事件循环
进程与线程 我们在电脑中会运行多个程序,每一个程序中都会有多个线程。 例如我们运行比特币客户端的时候,我们某一个线程要处理网络、某一个线程要处理挖矿、某一个线程要处理用户输入… 线程的调度使用了操作系统级别的调度器来明确了哪一个线程应该被执行。线程也有优先级之分,例如监听鼠标滑动的优先级就会很高,因为其不能等待太长的时间。 为了在给定的时间内更快更多的处理线程: 1、我们可以通过增加CPU的核...原创 2018-11-13 19:39:15 · 211 阅读 · 0 评论