小编Lig*_*iga的帖子

Who is responsible for the Presentation and Session layers in OSI?

I am learning about the 7 layers of OSI. But I am currently stuck trying to understand these bottom two layers. Specifically - who performs the actions in these layers? They are called software layers but does the browser itself do all of these and how? Or the browser passes it on to a different program? How does it work?

So for example, I type in my browser google.com then the browser will establish a connection and send GET / …

networking router tcp http osi

5
推荐指数
1
解决办法
1176
查看次数

如何确保我的 docker 镜像/容器在 100 年后仍然可以工作?

我已经创建了我的 Docker compose 和 Dockerfile,但正如您所看到的,我正在从 Docker Hub 下载 PHP,并且还在下载和安装 PHP 扩展。但是,如果 20 年后这些镜像/包将不再托管在 Docker hub 上呢?如果我想仍然能够运行我的容器怎么办?

我能以某种方式及时冻结我的容器吗?我可以将它们全部捆绑在一起,这样如果我从现在起 100 年后回到它并运行我的图像,它仍然可以工作吗?我不想让它出去从互联网上下载任何东西。我想现在下载所有内容,并在将来运行它。

Docker 撰写文件

version: '3'
services:

  php:
    build:
      context: ./php
      dockerfile: Dockerfile
    image: digitalocean.com/php
    container_name: php
Run Code Online (Sandbox Code Playgroud)

还有我的 PHP Dockerfile

RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
Run Code Online (Sandbox Code Playgroud)

containers docker dockerfile docker-compose

5
推荐指数
1
解决办法
60
查看次数

为什么我们需要用于状态管理的 mutations、setter 和 getter?

我刚刚在 Vue.js 中学习状态管理,我不太明白为什么它需要如此复杂和混淆所有这些不同的方法(突变、getter、setter)。直接改数据不是更简单吗?看起来是不是更干净了?

像这样使用纯代码有什么问题?我在这里缺少什么?除了我必须在每个组件中定义store: window.store。这样做对我来说是否安全,或者我是否非常有必要使用 Vuex?

// global app data
window.store = {
    appName: 'Hello World!'
}

export default {
    template: `
        <div @click="changeAppName">Hellow {{ store.AppName }}</div>
    `,

    data()
    {
        return {
            store: window.store
        }
    }

    methods: {
        changeAppName() {
            store.appName = 'Reactive app name!'
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

javascript state-management vue.js vuex

4
推荐指数
1
解决办法
548
查看次数

如何根据标签更改 Chart.js 点的颜色

我有一个折线 Chart.js 图表,其中标签是星期几。我想根据日期(周一至周日)更改点背景。我可以根据数据值更改背景颜色,但这不是我需要的。相反,我想给每一天(标签)一个不同的色点。

在此处输入图片说明

例如,这就是我可以根据数据值(不是我需要的)更改点的方法

chartData: {
    labels: ['Monday', 'Tuesday', 'Wednesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],

    datasets: [{
        data: [57, 569, 12, 78, 569, 0, 5],
        fill: true,
        pointRadius: 4,
        pointBackgroundColor: function(context) {
            var index = context.dataIndex
            var value = context.dataset.data[index]
            return value > 100 ? 'green' : 'red'
        }
    }]
},
Run Code Online (Sandbox Code Playgroud)

但是当我尝试将其应用于标签时,出现错误:

类型错误:无法读取 pointBackgroundColor 处未定义的属性“0”

chartData: {
    labels: ['Monday', 'Tuesday', 'Wednesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],

    datasets: [{
        data: [57, 569, 12, 78, 569, 0, 5],
        fill: true,
        pointRadius: 4, …
Run Code Online (Sandbox Code Playgroud)

javascript charts linechart chart.js

4
推荐指数
1
解决办法
4642
查看次数

将数组与标题组合 - 获取空数组

我试图创建一个新的数组,其中键将是第一个数组的标题,值将是所有其他数组,但我得到一个空数组作为结果.

这是我的初始数组

$reader = \Asan\PHPExcel\Excel::load('test.xls', function(\Asan\PHPExcel\Reader\Xls $reader){});

foreach ($reader as $row)
{
    print_r($row);
}


Array
(
    [0] => Phone
    [1] => Sum
    [2] => Name
    [3] => Something else
)
Array
(
    [0] => +1 555123456
    [1] => 50.00
    [2] => Johnny Doe
    [3] => 100.50
)
Array
(
    [0] => 911
    [1] => 20.12
    [2] => Eli the Computer Guy
    [3] => 99.99
)
Run Code Online (Sandbox Code Playgroud)

我试着像这样创建新的数组

$row = 1; // header row
foreach ($reader as $row)
{
    if ($row == …
Run Code Online (Sandbox Code Playgroud)

php arrays

3
推荐指数
1
解决办法
95
查看次数

Laravel望远镜无法进行全新安装(路径错误)

我正在使用XAMPP,并在C:\ xampp \ htdocs \ larascopy中使用composer create-project --prefer-dist laravel / laravel larascopy安装了一个新的Laravel 5.8

我可以通过以下网址访问它: http:// localhost / larascopy / public /

然后使用《指南》中的以下命令安装Telescope:

composer require laravel/telescope
php artisan telescope:install
php artisan migrate
Run Code Online (Sandbox Code Playgroud)

然后我可以像这样打开望远镜 http:// localhost / larascopy / public / telescope

但是所有链接都是错误的!他们指向: http:// localhost / telescope / ...

所以我在控制台中收到所有这些错误。

POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/schedule?tag=&before=&take=50&family_hash= 404 (Not Found)
app.js?id=8776cf12ba6d7c72f145:1 Uncaught (in promise) Error: Request failed with status code 404
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉望远镜正确的路径?

php laravel

2
推荐指数
2
解决办法
597
查看次数

在Laravel中未从原始查询获得任何结果

我有一个原始查询,当我在phpMyAdmin中运行此查询时,它返回3个结果,但是当我尝试使用Laravel查询生成器时,我得到一个空数组。

我的查询

SELECT id, reply_text, sending_time
FROM sms_sender_inbox_replies
WHERE phone_number
IN ('+1234567819',  '+19873216154',  '+15984989898')
AND id IN (
    SELECT MAX( id ) 
    FROM sms_sender_inbox_replies
    GROUP BY phone_number
)
Run Code Online (Sandbox Code Playgroud)

结果:

+----+-----------------+---------------------+
| id |   reply_text    |    sending_time     |
+----+-----------------+---------------------+
| 87 | This is a test  | 2019-07-30 08:25:26 |
| 54 | And another one | 2019-07-29 06:35:11 |
| 12 | Last test       | 2019-06-16 09:44:26 |
+----+-----------------+---------------------+
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用Laravel进行此查询时,我得到了一个空数组[]

dump($phone_numbers);

// 0 => "+1234567819"
// 1 => "+19873216154"
// …
Run Code Online (Sandbox Code Playgroud)

php mysql sql laravel eloquent

2
推荐指数
1
解决办法
109
查看次数

Vue.js - 如何获取和设置组件输入字段的值?

我刚刚开始学习 Vue.js,但遇到了一个问题,我不知道如何访问和更改组件内的文本字段值。

假设我想访问或更改组件内第一个输入字段的值

我的组件

Vue.component('simple-input',
{
    template: `
        <input type="text" value="Some value...">
    `,
});
Run Code Online (Sandbox Code Playgroud)

超文本标记语言

<div id="root">
  <simple-input></simple-input>
  <simple-input></simple-input>
  <simple-input></simple-input>

  <div @click="alertSimpleInput1">Show first input value</div>
  <div @click="changeInput1('new value')">Change input value</div>

  <div @click="alertSimpleInput2">Show second input value</div>
</div>
Run Code Online (Sandbox Code Playgroud)

main.js

new Vue({
    el: '#root',
});
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

1
推荐指数
1
解决办法
3万
查看次数

如何检查浏览器是否处于全屏模式?

我知道新的全屏 API,但我找不到任何方法来检查浏览器此时是否处于全屏模式。我对 Chrome 特别感兴趣。有可能吗?

我正在寻找这样的东西

window.addEventListener('load', function() {
    if (FULLSCREEN) {
        console.log('We are in full screen mode!')
    } else {
        console.log('Normal mode')
    }
})
Run Code Online (Sandbox Code Playgroud)

javascript browser google-chrome fullscreen

1
推荐指数
1
解决办法
3239
查看次数