-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,622 changed files
with
438,007 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//fileSystem 内置模块 | ||
const fs = require('fs'); | ||
const AipImageClassifyClient = require("baidu-aip-sdk").imageClassify; | ||
// console.log('hello node'); | ||
const image = fs.readFileSync("car.jpg").toString("base64");//base64图片格式 | ||
// console.log(image); | ||
var client = new AipImageClassifyClient('17712371','an4WjGIUmTRK86Mv9WXgbHZO','nMpplCZiuS0AqoQNqFaLfNfjsKCcsFl2'); | ||
client | ||
.carDetect(image) | ||
.then(function(result){ | ||
console.log(result); | ||
}) | ||
|
||
|
||
//回调函数 | ||
// 文件在哪?磁盘里 | ||
// js 在哪运行? 内存 I/O操作 | ||
// fs.readFile('./text.txt',function(err,data){ | ||
// if (err) { | ||
// return console.error(err); | ||
// } | ||
// console.log(data.toString()); //直接输出data,会出现buff流 | ||
// }) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const fs = require('fs'); | ||
// const AipImageClassifyClient = require("baidu-aip-sdk").imageClassify; | ||
const image = fs.readFileSync("./chepai.jpg").toString("base64"); | ||
const AipOcrClient = require('baidu-aip-sdk').ocr; | ||
var client = new AipOcrClient('17712415','kx2YOmPEeZmrEvaFvUvVR2Rq','bC7dtpWDBGTEWHvXTZRkliHVnR9sivHE'); | ||
|
||
const options = {}; | ||
options["multi_detect"] = "true"; | ||
|
||
client | ||
.licensePlate(image,options) | ||
.then(function(result){ | ||
console.log(result); | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "car", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"baidu-aip-sdk": "^2.4.4" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- 用算法学语法,用AI学node (服务器端) | ||
- npm (node的包管理器) | ||
JS前端开发变成后端开发 | ||
npm init -y | ||
- npm install baidu-aip-sdk npm包之一 | ||
不用写,使用第三方服务就可以了 | ||
- js 开发后端 | ||
node .js 直接运行 js 的后端运行方式 | ||
前端是在浏览器,后端是在命令行中 | ||
/car 服务器 require('fs') | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello node |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- AI社会 | ||
人人都AI? SDK 来自百度大脑 | ||
大数据+算法喂出来的 | ||
人工智能 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// let [ , ,baz] = [1,2,3]; //属于匹配模式,只要两边模式相同,会相应的去赋值 | ||
// console.log(baz); //3 | ||
|
||
// let [a,...b] = [1,2,3,4,5,6]; // ...表示剩下的所有值 | ||
// console.log(b); //[2, 3, 4, 5, 6 ] | ||
|
||
// let [foo] = 1; //1 is not iterable(遍历器) | ||
// 有三类数据结构具备Itearable接口:数组,某些类似数组的的对象,map,set结构 | ||
|
||
// let[a,b,c] = new Set(['a','b','c']); //set结构 | ||
// console.log(a); //a | ||
|
||
// let[a = 1] = [undefined] //赋默认值是,es6使用严格相等运算符,undefined默认值会生效 | ||
// let[b = 1] = [null] // null不会生效 null不严格等于undefined | ||
// let[c = 1] = [] //我认为undefined相当于空白 | ||
// console.log(a); //1 | ||
// console.log(b); //null | ||
// console.log(c); //1 | ||
|
||
// let[x = y,y = 1] = [] //ReferenceError(引用错误) x引用y时,y还没有赋值 | ||
// console.log(x); | ||
|
||
// let {a,b} = {b:'a',a:'b'} //数组的元素是按次序排列的,变量的取值由它的位置决定 | ||
// let{c} = {b:'a',a:'b'} //对象的属性没有次序,变量必须与属性同名,才能取到正确的值。 | ||
// console.log(a); //a | ||
// console.log(c); //undefined | ||
|
||
// let{foo:baz} = {foo:'aaa'} // 真正被赋值的是后者baz而不是前者foo | ||
// console.log(baz); //aaa | ||
// console.log(foo); //ReferenceError | ||
|
||
// let x = 1, | ||
// y = 2; | ||
// [x, y] = [y, x]; | ||
// console.log("x=" + x +",y=" + y); //可以直接进行值互换 | ||
|
||
// function fun() { //返回多个值时可以返回一个数组或者一个对象 | ||
// return { | ||
// a:1, | ||
// b:2 | ||
// }; | ||
// } | ||
// var {x,y}= fun(); //这里显示未定义 ***不是很清楚*** | ||
// console.log(x,y); | ||
// let {c,d} = {c:1,d:2}; //有值 | ||
// console.log(c,d); | ||
|
||
// let jsonData = { //可以快速提取json数据 | ||
// id: 42, | ||
// status: "OK", | ||
// data: [867, 5309] | ||
// }; | ||
|
||
// let { id, status, data: number } = jsonData; | ||
// console.log(id, status, number); | ||
|
||
const map = new Map(); //Map结构 用for of循环遍历 | ||
map.set(1,3,5); | ||
map.set(2,4); | ||
|
||
for (let a of map){ | ||
console.log(a); | ||
} | ||
|
||
for (let [,a] of map){ | ||
console.log(a); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// console.log("\u{20BB7}"); //unicode表示法 | ||
|
||
// let name = 'lin',time = 'today'; //模板字符串,可以在${}里镶嵌变量 | ||
// console.log(`hello ${name},how are you ${time}`); | ||
|
||
// let greeting = `\`Yo\` World!`; //如果在模板字符串中使用反引号,需要用反斜杆转义 | ||
// console.log(greeting); | ||
|
||
// let func = (num) => `hello ${num}!`; //引用字符串模板本身,可以写成函数。 | ||
// console.log(func('lin')); | ||
|
||
// let a = 5; | ||
// let b = 10; | ||
// function tag(s, v1, v2) { | ||
// console.log(s[0]); | ||
// console.log(s[1]); | ||
// console.log(s[2]); | ||
// console.log(v1); | ||
// console.log(v2); | ||
|
||
// return "OK"; | ||
// } | ||
// //模板字符里有变量,会将模板字符串先处理成多个参数,在调用函数。 | ||
// tag`Hello ${ a + b }world${ a * b }`; | ||
// // 上面的表达式相当于下面的表达式,然后调用了上面的tag函数。 | ||
// // tag(['Hello ', 'world ', ''], 15, 50); | ||
|
||
// let s = "hello world!"; | ||
|
||
// console.log(s.includes('hello')); //返回布尔值,表示是否找到了参数字符串。 | ||
// console.log(s.startsWith('h')); //返回布尔值,表示参数字符串是否在原字符串的头部。 | ||
// console.log(s.endsWith('!')); //返回布尔值,表示参数字符串是否在原字符串的尾部。 | ||
|
||
// 'x'.repeat(2); //返回一个新的字符串,表示讲原字符串重复n次(n>=0) | ||
// 'x'.repeat(3.2); //会向上进行取整,这里会取3 | ||
|
||
// console.log('x'.repeat(2)); //xx | ||
// console.log('x'.repeat(3.2)); //xxx | ||
|
||
// const s = " abc " | ||
// console.log(s.trim()); //消除字符串里的空格 | ||
// console.log(s.trimStart()); //只修改字符串头部的空格 | ||
// console.log(s.trimEnd()); //只修改字符串尾部的空格 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function foo() { | ||
function bar(a) { | ||
i = 3; //这里的赋值表达式覆盖了for循环里的i,会导致无限循环 | ||
var i = 3; //去除只要这么改 | ||
console.log(a + i); | ||
} | ||
for (var i = 0; i<10; i++){ | ||
bar(i * 2); | ||
} | ||
} | ||
foo(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const express = require('express'); //引用express | ||
const db = require('./db/db.js'); //连接数据库 | ||
const models = require('./models/data.js'); //导入数据 | ||
const bodyParser = require('body-parser'); | ||
const data = require('./routes/index.js'); | ||
|
||
const app = express(); //实例化express | ||
|
||
app.use(bodyParser.json()) //post请求 | ||
app.use(bodyParser.urlencoded({extended:true}))//编码扩展 | ||
|
||
app.use('/data',data); | ||
app.listen(3000, () => { | ||
console.log('app listening in port 3000') | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const mongoose = require('mongoose'); | ||
mongoose.connect('mongodb://localhost/data'); | ||
|
||
const db = mongoose.connection; | ||
|
||
db.once('open',() => { | ||
console.log('数据库连接成功!') | ||
}) | ||
|
||
db.on('error',console.error.bind(console, 'connection error:')); | ||
|
||
module.exports = db; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const mongoose = require('mongoose') | ||
const Schema = mongoose.Schema; | ||
|
||
var dataSchema = new Schema({ | ||
name: String, | ||
age: Number, | ||
sex: String, | ||
address: String | ||
}); | ||
|
||
const data = module.exports = mongoose.model('data',dataSchema); |
Oops, something went wrong.