nodejs H5页面 Camila Waz 2022-11-27 00:24:03
nodejs H5页面 Camila Waz 2022-11-26 23:30:33
450访问人次
Camila Waz 2022-03-15 15:13:54
3
[root@localhost ~]# groupadd [选项] 组名
[root@localhost ~]# groupmod [选现] 组名
[root@localhost ~]# groupdel 组名
linux教程 H5页面 Camila Waz 2022-11-20 18:42:03
4

查看用户hlj的uid和gid

[hlj@localhost html]$ id hlj
uid=1002(hlj) gid=1004(hlj) 组=1004(hlj)

把hlj用户加入root组后,查看用户hlj的uid和gid

[root@localhost /]# usermod -G root  hlj
[hlj@localhost html]$ id hlj
uid=1002(hlj) gid=1004(hlj) 组=1004(hlj),0(root)
linux教程 H5页面 Camila Waz 2022-11-20 18:23:03
linux教程 H5页面 Camila Waz 2022-11-20 18:00:38
linux教程 H5页面 Camila Waz 2022-11-19 10:01:16
2
const dgram = require("dgram");
const client = dgram.createSocket('udp4');

client.send('客户端发起的信息!', 41234, 'localhost', (err) => {
    client.close();
});

https://nodejs.org/api/dgram.html#event-close

nodejs H5页面 Camila Waz 2022-11-15 20:16:44
linux教程 H5页面 Camila Waz 2022-11-13 21:14:01
1
const http = require('http');
const fs = require('fs');
http.createServer(function (req, res) {

    (async () => {
        const file = fs.readFileSync('log.txt');
        console.log(file.toString())
    })();

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.write('Node.js says hello!');
    res.end();
}).listen(8080);
nodejs H5页面 Camila Waz 2022-11-10 21:34:35
24
import { test, expect } from '@playwright/test';

test('test', async ({ page, context }) => {
  //在创建/导航页面之前开始跟踪
  const obj = {
    screenshots: true,
    snapshots: true,
    sources: true
  }
  await context.tracing.start(obj)

  await page.goto('http://good1230.com/');
  //遍历菜单
  const count = await page.locator('ul.width-135 > a.none-line').count();
  const rows = await page.locator('ul.width-135 > a.none-line');

  for (let i = 0; i < count; ++i) {
    await rows.nth(i).click()
    await expect(page).toHaveURL(page.url());
    console.log(page.url())
  }
  // 停止跟踪并将其导出到 zip 存档中。
  await context.tracing.stop({ path: "trace.zip" })
});
nodejs H5页面 Camila Waz 2022-11-06 13:48:22
94
nginx -s stop      快速关机
nginx -s quit      正常关机
nginx -s reload    更改配置,使用新配置启动新工作进程,正常关闭旧工作进程
nginx -s reopen    重新打开日志文件

运行任务列表命令行实用程序以查看nginx进程:
C:\nginx-1.23.2>tasklist /fi "imagename eq nginx.exe"
Image Name           PID Session Name     Session#    Mem Usage
=============== ======== ============== ========== ============
nginx.exe            652 Console                 0      2 780 K
nginx.exe           1332 Console                 0      3 112 K

https://nginx.org/en/docs/windows.html#known_issues

网站开发工具 H5页面 Camila Waz 2022-10-28 20:51:46
105

https://playwright.dev/docs/api/class-playwright

https://github.com/microsoft/playwright

const http = require('http');
http.createServer(function (req, res) {

  const { chromium, firefox, webkit } = require('playwright');
  (async () => {
    const browser = await chromium.launch();  // Or 'firefox' or 'webkit'.
    const page = await browser.newPage();
    await page.goto('http://www.good1230.com');
    await page.screenshot({ path: `screenshot.png` }); // 图片默认保存到同当前文件的目录下
    // other actions...
    await browser.close();
  })();

  res.writeHead(200, {'Content-Type': 'text/html'}); 
  res.write('Node.js says hello!');
  res.end();

}).listen(8080);
nodejs H5页面 Camila Waz 2022-10-27 22:38:31
123

https://zh.javascript.info/fetch

async test() {
  let response = await fetch('good4/test/1.jpg');

  let blob = await response.blob(); // 下载为 Blob 对象
  const progressBar_max = document.getElementById("progressBar_max");

  progressBar_max.innerHTML = `${(blob.size / 1024 / 1024).toFixed(3)}MB`;

  // 为其创建一个 <img>
  let img = document.createElement('img');
  img.style = 'width:100px';
  document.body.append(img);

  // 显示它
  img.src = URL.createObjectURL(blob);
},
JavaScript H5页面 Camila Waz 2022-10-03 12:12:10
2

https://zinoui.com/blog/ajax-request-progress-bar

download() {
    var progressBar = document.getElementById("progress");
    var progressBar_value = document.getElementById("progressBar_value");
    var progressBar_max = document.getElementById("progressBar_max");

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "/good4/1.jpg?" + Math.floor(Math.random() * 99999), true);
    xhr.responseType = "text";
    xhr.onprogress = function (e) {
        console.log(e)
        if (e.lengthComputable) {
        progressBar.max = e.total;
        progressBar.value = e.loaded;
        progressBar_value.innerHTML = `${(e.loaded / 1024 / 1024).toFixed(3)}MB`;
        progressBar_max.innerHTML = `${(e.total / 1024 / 1024).toFixed(3)}MB`;
        }
    };
    xhr.onloadstart = function (e) {
        progressBar.value = 0;
    };
    xhr.onloadend = function (e) {
        progressBar.value = e.loaded;
    };
    xhr.send(null);
}
JavaScript H5页面 Camila Waz 2022-10-02 11:10:49
8
let num = 0
const imageObj = new Image();
const timer = setInterval(() => {
    document.getElementById('time').innerHTML = num++
    imageObj.onload = () => {
      document.getElementById('img').src = imageObj.src
      console.log(num)
      clearInterval(timer);
    }
},1000)

imageObj.src = 'http://good1230.com/templates/test_img/1.jpg';
JavaScript H5页面 Camila Waz 2022-10-01 11:53:21
16
const text = `日志异常内容:${err}`
const blob = new Blob([text], {type: 'text/plain'});
let formData = new FormData();
  formData.append("file", blob, `${new Date().getTime()}.txt`);

uploadException(formData).then(res => {

})
JavaScript H5页面 Camila Waz 2022-09-29 23:33:05
4
this.$once('hook:beforeDestroy', () => {
   clearInterval(timer);
})
vue H5页面 Camila Waz 2022-09-12 08:01:18
JavaScript H5页面 Camila Waz 2022-09-05 12:12:53
3
function reverse_a_number(n)
{
  n = n + "";
  return n.split("").reverse().join("");
}
console.log(reverse_a_number(32243));
JavaScript H5页面 Camila Waz 2022-09-05 11:58:53
7
function coinFlip() {
 return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
}
JavaScript H5页面 Camila Waz 2022-09-05 11:53:49
3
window.navigator.userAgent
JavaScript H5页面 Camila Waz 2022-09-05 11:45:55
3
 function sleep(milliseconds) {
    return new Promise(resolve => setTimeout(resolve, milliseconds));
 }
 async function fun() {
    document.write('Hello World');
    for (let i = 1; i <=10 ; i++) {        
       await sleep(2000);
       document.write( i + " " + "Welcome to the javaTpoint.com" + " " + "</br>");
    }
 }
 fun();
JavaScript H5页面 Camila Waz 2022-09-05 08:47:20
11
function downloadCSV(csv, filename) {  
    var csvFile;  
    var downloadLink;  
     
    //define the file type to text/csv  
    csvFile = new Blob([csv], {type: 'text/csv'});  
    downloadLink = document.createElement("a");  
    downloadLink.download = filename;  
    downloadLink.href = window.URL.createObjectURL(csvFile);  
    downloadLink.style.display = "none";  
  
    document.body.appendChild(downloadLink);  
    downloadLink.click();  
}
JavaScript H5页面 Camila Waz 2022-09-05 08:27:19
3
var hiddenElement = document.createElement('a');  
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);  
hiddenElement.target = '_blank';  

//provide the name for the CSV file to be downloaded  
hiddenElement.download = 'Famous Personalities.csv';  
hiddenElement.click(); 
JavaScript H5页面 Camila Waz 2022-09-05 08:26:25
35
const heart_box = document.getElementById('heart')
// 创建标签
let element = document.createElement('div')
    element.id = `heart_${keyName}`
    element.style.cssText = styles.container
    heart_box.appendChild(element)

// 移除标签
setTimeout(function(){
  const heart_element = document.getElementById(`heart_${keyName}`)
  heart_box.removeChild(heart_element)
  const heart_style = document.getElementById(`heart_id_${keyName}`)
  document.head.removeChild(heart_style)
}, 3000)
JavaScript H5页面 Camila Waz 2022-09-02 19:01:05
88
pdf H5页面 Camila Waz 2022-03-15 15:13:54
80
  function animate(options) {
    var start = performance.now();
    requestAnimationFrame(function animate(time) {
      // timeFraction от 0 до 1
      var timeFraction = (time - start) / options.duration;
      if (timeFraction > 1) timeFraction = 1;

      // текущее состояние анимации
      var progress = options.timing(timeFraction)
      
      options.draw(progress);

      if (timeFraction < 1) {
        requestAnimationFrame(animate);
      }
    });
  }
JavaScript H5页面 Camila Waz 2022-03-07 13:41:42
109
  • readAsArrayBuffer(blob)– 以二进制格式读取数据ArrayBuffer。
  • readAsText(blob, [encoding])– 以给定编码的文本字符串形式读取数据(utf-8默认情况下)。
  • readAsDataURL(blob)– 读取二进制数据并将其编码为 base64 数据 url。
  • abort()– 取消操作。
  • 更多方法:https://javascript.info/file
JavaScript H5页面 Camila Waz 2022-03-07 10:46:42
39
<form id="formElem">
  <input type="text" name="name" value="John">
  <input type="text" name="surname" value="Smith">
  <input type="submit">
</form>

<script>
  formElem.onsubmit = async (e) => {
    e.preventDefault();

    let response = await fetch('/article/formdata/post/user', {
      method: 'POST',
      body: new FormData(formElem)
    });

    let result = await response.json();

    alert(result.message);
  };
</script>
JavaScript H5页面 Camila Waz 2022-03-07 09:56:00
22
console.log('%c Hi everyone!', 'color: #1c87c9; font-size: 18px');
console.log('%c Style 1! %c Style 2!',
  'color: #1c87c9; background: #ccc; font-size: 20px;', 
  'color: #8ebf42; background: # 666; font - size: 20 px;'
);
JavaScript H5页面 Camila Waz 2022-03-04 14:05:34
3
let number = 4579
let hexStr = number.toString(16)
console.log(hexStr)  // 11e3

let hexStr2 = '11e3'
let number2 = parseInt(hexStr2, 16)
console.log(number2)  // 4579
JavaScript H5页面 Camila Waz 2022-03-04 13:46:49
8
let str = "Hello People"
let encodedString = btoa(str)
console.log(encodedString) // "SGVsbG8gUGVvcGxl"

let dec = atob(encodedString)
console.log(dec) // "Hello People"
JavaScript H5页面 Camila Waz 2022-03-04 13:37:21
14
canvas.toBlob(function(blob) {
  // blob ready, download it
  let link = document.createElement('a');
  link.download = 'example';

  link.href = URL.createObjectURL(blob);
  link.click();

  // delete the internal blob reference, to let the browser clear memory from it
  URL.revokeObjectURL(link.href);
}, 'image/jpg');
JavaScript H5页面 Camila Waz 2022-03-04 11:09:33
28
<a download="hello.txt" href='#' id="link">Download</a>

<script>
   let blob = new Blob(["Hello, world!"], {type: 'text/plain'}); 
   link.href = URL.createObjectURL(blob);
</script>
JavaScript H5页面 Camila Waz 2022-03-04 10:29:11