问:
MongoDB get results where date is equal to max date
Assume I have the following document:

```<code>[
  {
    "callId": "17dac51e-125e-499e-9064-f20bd3b1a9d8",
    "caller": {
      "firstName": "Test",
      "lastName": "Testing",
      "phoneNumber": "1231231234"
    },
    "routeHistory": [
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-01T06:00:00.000Z",
        "status": "routed"
      },
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-03T06:00:00.000Z",
        "status": "ended"
      }
    ]
  }
]
</code>```

I want to get results where routeHistory.routeDate is equal to the $max routeDate value in routeHistory. I would expect my results to look like the following:

```<code>[
  {
    "callId": "17dac51e-125e-499e-9064-f20bd3b1a9d8",
    "caller": {
      "firstName": "Test",
      "lastName": "Testing",
      "phoneNumber": "1231231234"
    },
    "routeHistory": [
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-03T06:00:00.000Z",
        "status": "ended"
      }
    ]
  }
]
</code>```

Is there a clean way to do this in a single aggregate, so that additional $match criteria can be applied?

答:
You can use $let to define temporary variable being $max date and the use $filter along with $arrayElemAt to get first matching element:

```<code>db.collection.aggregate([
    {
        $addFields: {
            routeHistory: {
                $let: {
                    vars: {
                        maxDate: { $max: "$routeHistory.routeDate" }
                    },
                    in: {
                        $arrayElemAt: [
                            { $filter: { input: "$routeHistory", cond: { $eq: [ "$$maxDate", "$$this.routeDate" ] } } },
                            0
                        ]
                    }
                }
            }
        }
    }
])
</code>```

Mongo Playground

EDIT:

version without $let:

```<code>db.collection.aggregate([
    {
        $addFields: {
            maxDate: {
                $max: "$routeHistory.routeDate"
            }
        }
    },
    {
        $addFields: {
            routeHistory: {
                $arrayElemAt: [
                    {
                        $filter: { input: "$routeHistory", cond: { $eq: [ "$$maxDate", "$$this.routeDate" ] } }
                    },
                    0
                    ]
                }
            }
        }
    }
])
</code>```

Body:
Assume I have the following document:

[
  {
    "callId": "17dac51e-125e-499e-9064-f20bd3b1a9d8",
    "caller": {
      "firstName": "Test",
      "lastName": "Testing",
      "phoneNumber": "1231231234"
    },
    "routeHistory": [
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-01T06:00:00.000Z",
        "status": "routed"
      },
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-03T06:00:00.000Z",
        "status": "ended"
      }
    ]
  }
]

I want to get results where routeHistory.routeDate is equal to the $max routeDate value in routeHistory. I would expect my results to look like the following:

[
  {
    "callId": "17dac51e-125e-499e-9064-f20bd3b1a9d8",
    "caller": {
      "firstName": "Test",
      "lastName": "Testing",
      "phoneNumber": "1231231234"
    },
    "routeHistory": [
      {
        "assignedUserId": "cfa0ffe9-c77d-4eec-87d7-4430f7772e81",
        "routeDate": "2020-01-03T06:00:00.000Z",
        "status": "ended"
      }
    ]
  }
]

Is there a clean way to do this in a single aggregate, so that additional $match criteria can be applied?

Body:
You can use $let to define temporary variable being $max date and the use $filter along with $arrayElemAt to get first matching element:

db.collection.aggregate([
    {
        $addFields: {
            routeHistory: {
                $let: {
                    vars: {
                        maxDate: { $max: "$routeHistory.routeDate" }
                    },
                    in: {
                        $arrayElemAt: [
                            { $filter: { input: "$routeHistory", cond: { $eq: [ "$$maxDate", "$$this.routeDate" ] } } },
                            0
                        ]
                    }
                }
            }
        }
    }
])

Mongo Playground

EDIT:

version without $let:

db.collection.aggregate([
    {
        $addFields: {
            maxDate: {
                $max: "$routeHistory.routeDate"
            }
        }
    },
    {
        $addFields: {
            routeHistory: {
                $arrayElemAt: [
                    {
                        $filter: { input: "$routeHistory", cond: { $eq: [ "$$maxDate", "$$this.routeDate" ] } }
                    },
                    0
                    ]
                }
            }
        }
    }
])


来源: stackexchange

问:
Whats a good approach/pattern to solve this scheduling problem
I have an object

```<code>public class Task
{
    public TimeSpan Length { get; set; }
    public IList<Task> Dependencies { get; set; }

    public DateTime? StartDate { get; set; }
}
</code>```

which has dependencies on other instances. For example:

(read "<-" as "depends on")

B <- A

C <- A

D <- B,C

and

Q <- P

R <- Q

Given a list of Tasks* and an EndDate, I need to set the StartDate on each task such that they will all be completed by the EndDate. Tasks may run in parallel where possible, so....

A has to be completed before B and C (which can be done at the same time), and D can only be run after B and C are both complete.

R must run after Q, after P, but these can be run in parelell to A B C and D.

* the list will be complete, all dependencies will be present in the list

Thanks for any advice
Andrew

答:
```<code>    public class Task
    {
        public long Length;
        public List<Task> Dependencies = new List<Task>();
        public DateTime StartDate;
        public DateTime EndDate;

        public void CompleteBaseSchedule()
        {
            DateTime startDate = DateTime.MinValue;
            foreach (Task task in Dependencies)
            {
             startDate = (startDate < task.EndDate) ? task.EndDate : startDate;
                task.CompleteBaseSchedule();

            }
            this.StartDate = startDate;
            this.Length = this.EndDate.Ticks - this.StartDate.Ticks;
        }
</code>```

somewhere in the main:

```<code>            Task task1 = new Task();
            task1.EndDate = new DateTime(2009, 3, 3);
            Task task2 = new Task();
            task1.EndDate = new DateTime(2009, 3, 5);
            Task task3 = new Task();
            task1.EndDate = new DateTime(2009, 3, 2);
            Task task4 = new Task();
            task1.EndDate = new DateTime(2009, 3, 6);
            task4.Dependencies.AddRange(new Task[]{ task1, task2, task3 });

            task4.CompleteBaseSchedule();
            Console.WriteLine(task4.StartDate);
            Console.ReadLine();
</code>```

OwnerDisplayName: Andrew Bullock

ContentLicense: CC BY-SA 2.5

Body:
I have an object

public class Task
{
    public TimeSpan Length { get; set; }
    public IList<Task> Dependencies { get; set; }

    public DateTime? StartDate { get; set; }
}

which has dependencies on other instances. For example:

(read "<-" as "depends on")

B <- A

C <- A

D <- B,C

and

Q <- P

R <- Q

Given a list of Tasks* and an EndDate, I need to set the StartDate on each task such that they will all be completed by the EndDate. Tasks may run in parallel where possible, so....

A has to be completed before B and C (which can be done at the same time), and D can only be run after B and C are both complete.

R must run after Q, after P, but these can be run in parelell to A B C and D.

* the list will be complete, all dependencies will be present in the list

Thanks for any advice
Andrew

LastEditorDisplayName: Andrew Bullock

Body:
    public class Task
    {
        public long Length;
        public List<Task> Dependencies = new List<Task>();
        public DateTime StartDate;
        public DateTime EndDate;

        public void CompleteBaseSchedule()
        {
            DateTime startDate = DateTime.MinValue;
            foreach (Task task in Dependencies)
            {
             startDate = (startDate < task.EndDate) ? task.EndDate : startDate;
                task.CompleteBaseSchedule();

            }
            this.StartDate = startDate;
            this.Length = this.EndDate.Ticks - this.StartDate.Ticks;
        }

somewhere in the main:

            Task task1 = new Task();
            task1.EndDate = new DateTime(2009, 3, 3);
            Task task2 = new Task();
            task1.EndDate = new DateTime(2009, 3, 5);
            Task task3 = new Task();
            task1.EndDate = new DateTime(2009, 3, 2);
            Task task4 = new Task();
            task1.EndDate = new DateTime(2009, 3, 6);
            task4.Dependencies.AddRange(new Task[]{ task1, task2, task3 });

            task4.CompleteBaseSchedule();
            Console.WriteLine(task4.StartDate);
            Console.ReadLine();

OwnerDisplayName: coldice


问:
Masked svg element not showing whole svg item
In this example I am trying to scroll a masked container item using transform: translate and  animation: infinite.

Problem is that only a small partition of the masked container item is scrolling. How would I get it scrolling as it does in the imgur link below?

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  text-align: center;
  margin: 20px;
}

#code-main {
  animation: code 3s infinite;
}

@keyframes code {
  from {
    transform: translate(0px, 0px);
  }
  to {
    transform: translate(0px, 150px);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <title>Document</title>
</head>

<body>
  <svg width="712" height="670" viewBox="0 0 712 670" fill="none" xmlns="http://www.w3.org/2000/svg">
        <g id="undraw_feeling_proud_qne1 1">
        <g clip-path="url(#clip0)">
        <g id="guy">
        <path id="Vector" d="M516.326 380.047V565.042L547.27 615.472L549.625 619.308H671.722L674.189 380.047H516.326Z" fill="#E6E6E6"/>
        <path id="Vector_2" opacity="0.1" d="M516.326 380.047V565.042L547.27 615.472L549.169 380.047H516.326Z" fill="black"/>
        <path id="Vector_3" d="M221.566 375.113V560.109L190.622 610.539L188.267 614.374H66.17L63.703 375.113H221.566Z" fill="#E6E6E6"/>
        <path id="Vector_4" opacity="0.1" d="M221.566 375.113V560.109L190.622 610.539L188.723 375.113H221.566Z" fill="black"/>
        <path id="Vector_5" d="M711.188 371.414V382.513H47.67V366.48L109.335 334.414H656.923L711.188 371.414Z" fill="#E6E6E6"/>
        <path id="Vector_6" opacity="0.1" d="M711.188 371.414V382.513H47.67V366.48L711.188 371.414Z" fill="black"/>
        <path id="Vector_7" d="M142.635 426.912H113.035L100.702 418.279H156.201L142.635 426.912Z" fill="#3F3D56"/>
        <path id="Vector_8" d="M142.635 462.678H113.035L100.702 454.045H156.201L142.635 462.678Z" fill="#3F3D56"/>
        <path id="Vector_9" d="M142.635 513.244H113.035L100.702 504.61H156.201L142.635 513.244Z" fill="#3F3D56"/>
        <path id="Vector_10" d="M142.635 563.809H113.035L100.702 555.176H156.201L142.635 563.809Z" fill="#3F3D56"/>
        <path id="Vector_11" d="M595.257 431.845H624.857L637.19 423.212H581.691L595.257 431.845Z" fill="#3F3D56"/>
        <path id="Vector_12" d="M595.257 467.611H624.857L637.19 458.978H581.691L595.257 467.611Z" fill="#3F3D56"/>
        <path id="Vector_13" d="M595.257 518.177H624.857L637.19 509.544H581.691L595.257 518.177Z" fill="#3F3D56"/>
        <path id="Vector_14" d="M595.257 568.742H624.857L637.19 560.109H581.691L595.257 568.742Z" fill="#3F3D56"/>
        <path id="Vector_15" d="M490.821 127.605C491.695 127.605 492.403 126.897 492.403 126.023C492.403 125.149 491.695 124.44 490.821 124.44C489.947 124.44 489.239 125.149 489.239 126.023C489.239 126.897 489.947 127.605 490.821 127.605Z" fill="#F2F2F2"/>
        <path id="Vector_16" d="M490.821 300.387C494.142 300.387 496.834 297.695 496.834 294.374C496.834 291.053 494.142 288.362 490.821 288.362C487.5 288.362 484.809 291.053 484.809 294.374C484.809 297.695 487.5 300.387 490.821 300.387Z" fill="#F2F2F2"/>
        <path id="Vector_17" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981L315.632 346.589H477.971L481.452 357.981Z" fill="#3F3D56"/>
        <path id="Vector_18" d="M546.97 354.883C546.659 356.208 545.489 357.607 542.843 358.93C533.35 363.677 514.046 357.664 514.046 357.664C514.046 357.664 499.173 355.133 499.173 348.487C499.59 348.201 500.026 347.942 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="#3F3D56"/>
        <path id="Vector_19" opacity="0.1" d="M546.97 354.883C535.35 359.335 524.992 359.667 514.363 352.284C510.343 349.313 505.476 347.71 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="black"/>
        <path id="Vector_20" d="M532.4 352.284C534.672 352.284 536.514 351.718 536.514 351.019C536.514 350.32 534.672 349.753 532.4 349.753C530.128 349.753 528.286 350.32 528.286 351.019C528.286 351.718 530.128 352.284 532.4 352.284Z" fill="#F2F2F2"/>
        <path id="Vector_21" opacity="0.1" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981H481.452Z" fill="black"/>
        <path id="Vector_22" d="M94.6615 0.0286924C92.9336 -0.113172 91.2035 0.273333 89.7002 1.13699C88.2242 2.14779 87.2939 3.91861 86.3443 5.56646C82.7136 11.9421 77.7985 17.4942 71.9101 21.8711C67.6211 25.0131 62.1684 28.9308 62.9022 34.7238C63.2893 36.6369 63.996 38.4711 64.9927 40.1493C68.9493 48.1363 79.7463 54.3086 78.6843 63.4224C82.6153 56.8415 77.3573 53.5874 81.2883 47.0065C83.1604 43.8725 86.4124 40.3348 89.2388 42.303C90.1852 42.962 90.8066 44.1439 91.792 44.7222C94.1432 46.1019 96.6446 43.4642 98.7259 41.5958C105.903 35.1532 116.109 36.841 125.04 38.8484C129.256 39.7961 133.887 41.0394 136.379 45.0691C139.656 50.3673 133.266 56.0894 131.651 62.0796C131.52 62.59 131.513 63.1248 131.633 63.6381C131.753 64.1514 131.996 64.6281 132.34 65.0273C132.684 65.4266 133.12 65.7365 133.61 65.9305C134.1 66.1246 134.63 66.1971 135.154 66.1417C137.834 65.8774 141.009 65.6607 141.167 64.4848C144.539 64.6048 148.67 64.223 150.114 60.7123C150.556 59.3233 150.789 57.8765 150.807 56.4191C151.337 50.5219 153.84 45.1419 155.498 39.5292C157.156 33.9164 157.877 27.3387 155.079 22.3624C154.08 20.7067 152.845 19.2057 151.413 17.9068C135.534 2.54006 114.657 0.00588238 94.6615 0.0286924Z" fill="#2F2E41"/>
        <path id="Vector_23" d="M82.1377 74.9337C82.1377 74.9337 85.5911 103.712 72.9286 106.014C60.2661 108.317 84.4399 147.455 84.4399 147.455L141.997 154.362L128.183 108.317C128.183 108.317 118.974 104.863 124.73 81.8406C130.485 58.8178 82.1377 74.9337 82.1377 74.9337Z" fill="#FFB8B8"/>
        <path id="Vector_24" d="M47.028 569.347L51.633 632.66H75.806L68.9 569.347H47.028Z" fill="#FFB8B8"/>
        <path id="Vector_25" d="M224.303 449.629L227.756 502.581L254.233 491.07L243.872 447.327L224.303 449.629Z" fill="#FFB8B8"/>
        <path id="Vector_26" d="M29.761 327.608C29.761 327.608 30.9121 394.374 37.819 416.246C44.7259 438.117 43.5747 439.268 42.4236 442.722C41.2724 446.175 40.1213 443.873 40.1213 449.629C40.1213 455.384 37.819 546.324 40.1213 554.382C42.4235 562.44 33.2145 576.254 40.1213 577.405C47.0281 578.556 79.2599 577.405 80.411 570.498C81.5622 563.591 71.202 561.289 75.8065 556.684C80.4111 552.08 87.3179 457.687 87.3179 457.687L103.434 392.072L133.363 357.538H196.676L216.245 433.513C216.245 433.513 208.187 455.384 213.943 455.384C219.699 455.384 254.233 462.291 254.233 436.966C254.233 411.641 242.721 336.817 240.419 334.515C238.117 332.213 241.57 324.155 238.117 320.701C234.663 317.248 194.374 293.074 179.409 288.47C164.444 283.865 143.451 278.385 143.451 278.385L29.761 327.608Z" fill="#2F2E41"/>
        <path id="Vector_27" d="M254.233 481.86C254.233 481.86 236.966 476.105 228.908 493.372C220.85 510.639 224.303 515.243 224.303 515.243C224.303 515.243 250.779 524.452 255.384 519.848C257.387 517.845 263.748 517.149 270.296 517.002C280.269 516.778 282.923 502.668 273.504 499.383C273.223 499.285 272.939 499.2 272.651 499.127C263.442 496.825 254.233 481.86 254.233 481.86Z" fill="#2F2E41"/>
        <path id="Vector_28" d="M108.038 93.9275C127.111 93.9275 142.572 78.4661 142.572 59.3934C142.572 40.3208 127.111 24.8593 108.038 24.8593C88.9656 24.8593 73.5042 40.3208 73.5042 59.3934C73.5042 78.4661 88.9656 93.9275 108.038 93.9275Z" fill="#FFB8B8"/>
        <path id="Vector_29" d="M63.144 120.404C63.144 120.404 119.55 131.915 133.363 113.497C147.177 95.0786 152.933 165.298 152.933 165.298L159.839 238.971L149.479 279.26C149.479 279.26 95.3758 323.004 78.1087 326.457C60.8417 329.91 34.3655 332.213 34.3655 332.213C34.3655 332.213 42.4236 204.437 42.4236 202.134C42.4236 199.832 63.144 120.404 63.144 120.404Z" fill="#6C63FF"/>
        <path id="Vector_30" d="M80.2983 98.8144C80.2983 98.8144 67.7485 91.6252 64.2951 98.532C60.8417 105.439 28.6099 122.706 25.1565 122.706C21.7031 122.706 32.0633 218.25 27.4587 229.762C22.8542 241.273 0.982611 325.306 13.6451 332.213C26.3076 339.119 17.0985 325.306 29.761 342.573C42.4235 359.84 104.585 359.84 108.038 352.933C111.492 346.026 80.411 294.225 86.1667 245.877C91.9224 197.53 101.131 130.764 93.0735 121.555C85.0156 112.346 80.2983 98.8144 80.2983 98.8144Z" fill="#2F2E41"/>
        <path id="Vector_31" d="M121.852 106.59L123.455 101.072C123.455 101.072 171.351 116.95 173.653 127.31C175.955 137.671 174.804 210.192 166.746 215.948C158.688 221.704 147.177 230.913 155.235 244.726C163.293 258.54 172.502 273.505 179.409 274.656C186.316 275.807 198.978 283.865 195.525 291.923C192.071 299.981 150.63 285.016 150.63 285.016C150.63 285.016 123.003 264.296 124.154 232.064C125.305 199.832 121.852 106.59 121.852 106.59Z" fill="#2F2E41"/>
        <path id="Vector_32" d="M162.142 242.424L134.514 294.225C134.514 294.225 94.2246 335.666 117.247 340.271C140.27 344.875 152.933 302.283 152.933 302.283L182.862 259.691L162.142 242.424Z" fill="#FFB8B8"/>
        <path id="Vector_33" d="M96.3438 9.06446C94.9518 8.96132 93.5575 9.23175 92.3051 9.8478C91.1726 10.6749 90.2393 11.7445 89.5733 12.9785C86.5029 17.5971 82.5005 21.5224 77.8232 24.5025C74.3318 26.7233 69.893 29.4922 70.4904 33.5867C70.8146 34.9595 71.3917 36.2599 72.1922 37.4214C75.4241 43.1236 76.7108 49.7234 75.8574 56.2221L85.4575 42.2681C86.9814 40.053 89.6287 37.5526 91.9296 38.9437C92.6999 39.4095 93.2058 40.2449 94.0079 40.6535C95.9219 41.6287 97.9581 39.7644 99.6524 38.4439C105.495 33.8903 113.803 35.0832 121.073 36.502C124.505 37.1718 128.275 38.0506 130.304 40.8987C133.676 45.6319 130.155 52.4709 132.123 57.9388C132.674 57.5531 133.141 57.0608 133.498 56.491C133.855 55.9211 134.095 55.2855 134.201 54.6216C136.946 54.7064 140.309 54.4366 141.485 51.9552C141.842 50.9828 142.033 49.9568 142.049 48.9208C142.48 44.7527 144.518 40.9502 145.867 36.9831C147.217 33.0161 147.804 28.367 145.526 24.8497C144.693 23.658 143.687 22.5967 142.542 21.7006C129.616 10.8395 112.621 9.04834 96.3438 9.06446Z" fill="#2F2E41"/>
        <path id="Vector_34" d="M162.142 122.706L172.867 125.553C172.867 125.553 197.827 189.472 192.071 233.215C186.316 276.958 182.862 267.749 182.862 267.749C182.862 267.749 173.653 247.029 152.933 251.633L162.142 122.706Z" fill="#2F2E41"/>
        <path id="Vector_35" d="M48.6229 624.292C45.847 628.064 46.4035 633.456 43.9446 637.443C41.8132 640.898 37.7962 642.71 35.1302 645.771C34.2795 646.788 33.5212 647.879 32.8641 649.031C30.391 653.174 28.3808 658.483 30.8165 662.648C32.7758 665.998 36.8943 667.307 40.6715 668.2C45.4455 669.328 50.4058 670.23 55.235 669.368C60.0642 668.506 64.7838 665.549 66.5057 660.956C66.8441 659.801 67.2464 658.666 67.7108 657.555C70.3282 652.402 78.5383 652.347 81.217 647.225C83.0917 643.641 81.3684 639.309 79.6459 635.649L74.3848 624.472C72.6389 620.763 65.5611 622.896 61.8714 622.007C57.0591 620.848 52.0848 619.571 48.6229 624.292Z" fill="#2F2E41"/>
        <path id="Vector_36" d="M10.1917 265.447L58.5394 340.271C58.5394 340.271 88.4689 378.258 97.678 360.991C106.887 343.724 65.4462 314.946 65.4462 314.946L34.3655 257.389L10.1917 265.447Z" fill="#FFB8B8"/>
        <path id="Vector_37" d="M34.3655 125.008L25.1564 122.706C25.1564 122.706 6.73827 128.462 2.13372 152.635C-2.47081 176.809 0.982583 273.505 6.73826 274.656C12.4939 275.807 35.1655 257.819 38.7945 261.633C42.4235 265.447 30.9121 245.877 34.3655 235.517C37.8189 225.157 34.3655 125.008 34.3655 125.008Z" fill="#2F2E41"/>
        <path id="Vector_38" d="M615.414 120.485H366.228C364.991 120.485 363.765 120.728 362.622 121.202C361.478 121.675 360.439 122.37 359.564 123.245C358.689 124.12 357.995 125.159 357.522 126.302C357.048 127.446 356.804 128.671 356.805 129.909V297.766C356.804 299.004 357.048 300.23 357.522 301.373C357.995 302.516 358.689 303.555 359.564 304.43C360.439 305.306 361.478 306 362.622 306.473C363.765 306.947 364.991 307.19 366.228 307.19H460.821L457.277 329.817C457.277 329.817 437.025 340.576 451.265 340.892C465.505 341.209 532.593 340.892 532.593 340.892C532.593 340.892 545.567 340.892 524.998 329.5L521.664 307.19H615.414C616.651 307.19 617.877 306.947 619.02 306.473C620.164 306 621.203 305.306 622.078 304.43C622.953 303.555 623.647 302.516 624.121 301.373C624.594 300.23 624.838 299.004 624.838 297.766V129.909C624.838 128.671 624.594 127.446 624.121 126.302C623.647 125.159 622.953 124.12 622.078 123.245C621.203 122.37 620.164 121.675 619.02 121.202C617.877 120.728 616.651 120.485 615.414 120.485Z" fill="#3F3D56"/>
        </g>
        <path id="Vector_39" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="366" y="130" width="250" height="140">
        <path id="Vector_40" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        </mask>
        <g mask="url(#mask0)">
        <g id="code-main" filter="url(#filter0_d)">
        <g id="code-main_2">
        <g id="Group 15">
        <path id="Rectangle 59" d="M424.752 164.345H395V171.444H424.752V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 60" d="M527.784 164.345H517.315V171.444H527.784V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 61" d="M548.721 164.345H538.252V171.444H548.721V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 62" d="M506.296 164.345H435.221V171.444H506.296V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 63" d="M547.619 134.308H517.866V141.408H547.619V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 64" d="M587.839 134.308H558.087V141.408H587.839V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 66" d="M405.468 134.308H395V141.408H405.468V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 67" d="M426.405 134.308H415.937V141.408H426.405V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 68" d="M507.949 134.308H436.874V141.408H507.949V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 69" d="M485.91 149.6H456.158V156.699H485.91V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 70" d="M445.689 149.6H415.937V156.699H445.689V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 71" d="M405.468 149.6H395V156.699H405.468V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 73" d="M587.839 149.6H577.371V156.699H587.839V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 74" d="M566.902 149.6H495.827V156.699H566.902V149.6Z" fill="#6C63FF"/>
        </g>
        </g>
        </g>
        </g>
        </g>
        </g>
        <defs>
        <filter id="filter0_d" x="391" y="-181" width="200.839" height="360.444" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
        <feFlood flood-opacity="0" result="BackgroundImageFix"/>
        <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
        <feOffset dy="4"/>
        <feGaussianBlur stdDeviation="2"/>
        <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
        <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
        <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
        </filter>
        <clipPath id="clip0">
        <rect width="711.188" height="669.683" fill="white"/>
        </clipPath>
        </defs>
        </svg>

</body>

</html></code>```

Codepen: https://codepen.io/DevKris/pen/KKpVxVa

Desired outcome: https://imgur.com/a/lG7vgem

ContentLicense: CC BY-SA 4.0

Body:
In this example I am trying to scroll a masked container item using transform: translate and  animation: infinite.

Problem is that only a small partition of the masked container item is scrolling. How would I get it scrolling as it does in the imgur link below?

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  text-align: center;
  margin: 20px;
}

#code-main {
  animation: code 3s infinite;
}

@keyframes code {
  from {
    transform: translate(0px, 0px);
  }
  to {
    transform: translate(0px, 150px);
  }
}

<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <title>Document</title>

  <svg width="712" height="670" viewBox="0 0 712 670" fill="none" xmlns="http://www.w3.org/2000/svg">
        <g id="undraw_feeling_proud_qne1 1">
        <g clip-path="url(#clip0)">
        <g id="guy">
        <path id="Vector" d="M516.326 380.047V565.042L547.27 615.472L549.625 619.308H671.722L674.189 380.047H516.326Z" fill="#E6E6E6"/>
        <path id="Vector_2" opacity="0.1" d="M516.326 380.047V565.042L547.27 615.472L549.169 380.047H516.326Z" fill="black"/>
        <path id="Vector_3" d="M221.566 375.113V560.109L190.622 610.539L188.267 614.374H66.17L63.703 375.113H221.566Z" fill="#E6E6E6"/>
        <path id="Vector_4" opacity="0.1" d="M221.566 375.113V560.109L190.622 610.539L188.723 375.113H221.566Z" fill="black"/>
        <path id="Vector_5" d="M711.188 371.414V382.513H47.67V366.48L109.335 334.414H656.923L711.188 371.414Z" fill="#E6E6E6"/>
        <path id="Vector_6" opacity="0.1" d="M711.188 371.414V382.513H47.67V366.48L711.188 371.414Z" fill="black"/>
        <path id="Vector_7" d="M142.635 426.912H113.035L100.702 418.279H156.201L142.635 426.912Z" fill="#3F3D56"/>
        <path id="Vector_8" d="M142.635 462.678H113.035L100.702 454.045H156.201L142.635 462.678Z" fill="#3F3D56"/>
        <path id="Vector_9" d="M142.635 513.244H113.035L100.702 504.61H156.201L142.635 513.244Z" fill="#3F3D56"/>
        <path id="Vector_10" d="M142.635 563.809H113.035L100.702 555.176H156.201L142.635 563.809Z" fill="#3F3D56"/>
        <path id="Vector_11" d="M595.257 431.845H624.857L637.19 423.212H581.691L595.257 431.845Z" fill="#3F3D56"/>
        <path id="Vector_12" d="M595.257 467.611H624.857L637.19 458.978H581.691L595.257 467.611Z" fill="#3F3D56"/>
        <path id="Vector_13" d="M595.257 518.177H624.857L637.19 509.544H581.691L595.257 518.177Z" fill="#3F3D56"/>
        <path id="Vector_14" d="M595.257 568.742H624.857L637.19 560.109H581.691L595.257 568.742Z" fill="#3F3D56"/>
        <path id="Vector_15" d="M490.821 127.605C491.695 127.605 492.403 126.897 492.403 126.023C492.403 125.149 491.695 124.44 490.821 124.44C489.947 124.44 489.239 125.149 489.239 126.023C489.239 126.897 489.947 127.605 490.821 127.605Z" fill="#F2F2F2"/>
        <path id="Vector_16" d="M490.821 300.387C494.142 300.387 496.834 297.695 496.834 294.374C496.834 291.053 494.142 288.362 490.821 288.362C487.5 288.362 484.809 291.053 484.809 294.374C484.809 297.695 487.5 300.387 490.821 300.387Z" fill="#F2F2F2"/>
        <path id="Vector_17" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981L315.632 346.589H477.971L481.452 357.981Z" fill="#3F3D56"/>
        <path id="Vector_18" d="M546.97 354.883C546.659 356.208 545.489 357.607 542.843 358.93C533.35 363.677 514.046 357.664 514.046 357.664C514.046 357.664 499.173 355.133 499.173 348.487C499.59 348.201 500.026 347.942 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="#3F3D56"/>
        <path id="Vector_19" opacity="0.1" d="M546.97 354.883C535.35 359.335 524.992 359.667 514.363 352.284C510.343 349.313 505.476 347.71 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="black"/>
        <path id="Vector_20" d="M532.4 352.284C534.672 352.284 536.514 351.718 536.514 351.019C536.514 350.32 534.672 349.753 532.4 349.753C530.128 349.753 528.286 350.32 528.286 351.019C528.286 351.718 530.128 352.284 532.4 352.284Z" fill="#F2F2F2"/>
        <path id="Vector_21" opacity="0.1" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981H481.452Z" fill="black"/>
        <path id="Vector_22" d="M94.6615 0.0286924C92.9336 -0.113172 91.2035 0.273333 89.7002 1.13699C88.2242 2.14779 87.2939 3.91861 86.3443 5.56646C82.7136 11.9421 77.7985 17.4942 71.9101 21.8711C67.6211 25.0131 62.1684 28.9308 62.9022 34.7238C63.2893 36.6369 63.996 38.4711 64.9927 40.1493C68.9493 48.1363 79.7463 54.3086 78.6843 63.4224C82.6153 56.8415 77.3573 53.5874 81.2883 47.0065C83.1604 43.8725 86.4124 40.3348 89.2388 42.303C90.1852 42.962 90.8066 44.1439 91.792 44.7222C94.1432 46.1019 96.6446 43.4642 98.7259 41.5958C105.903 35.1532 116.109 36.841 125.04 38.8484C129.256 39.7961 133.887 41.0394 136.379 45.0691C139.656 50.3673 133.266 56.0894 131.651 62.0796C131.52 62.59 131.513 63.1248 131.633 63.6381C131.753 64.1514 131.996 64.6281 132.34 65.0273C132.684 65.4266 133.12 65.7365 133.61 65.9305C134.1 66.1246 134.63 66.1971 135.154 66.1417C137.834 65.8774 141.009 65.6607 141.167 64.4848C144.539 64.6048 148.67 64.223 150.114 60.7123C150.556 59.3233 150.789 57.8765 150.807 56.4191C151.337 50.5219 153.84 45.1419 155.498 39.5292C157.156 33.9164 157.877 27.3387 155.079 22.3624C154.08 20.7067 152.845 19.2057 151.413 17.9068C135.534 2.54006 114.657 0.00588238 94.6615 0.0286924Z" fill="#2F2E41"/>
        <path id="Vector_23" d="M82.1377 74.9337C82.1377 74.9337 85.5911 103.712 72.9286 106.014C60.2661 108.317 84.4399 147.455 84.4399 147.455L141.997 154.362L128.183 108.317C128.183 108.317 118.974 104.863 124.73 81.8406C130.485 58.8178 82.1377 74.9337 82.1377 74.9337Z" fill="#FFB8B8"/>
        <path id="Vector_24" d="M47.028 569.347L51.633 632.66H75.806L68.9 569.347H47.028Z" fill="#FFB8B8"/>
        <path id="Vector_25" d="M224.303 449.629L227.756 502.581L254.233 491.07L243.872 447.327L224.303 449.629Z" fill="#FFB8B8"/>
        <path id="Vector_26" d="M29.761 327.608C29.761 327.608 30.9121 394.374 37.819 416.246C44.7259 438.117 43.5747 439.268 42.4236 442.722C41.2724 446.175 40.1213 443.873 40.1213 449.629C40.1213 455.384 37.819 546.324 40.1213 554.382C42.4235 562.44 33.2145 576.254 40.1213 577.405C47.0281 578.556 79.2599 577.405 80.411 570.498C81.5622 563.591 71.202 561.289 75.8065 556.684C80.4111 552.08 87.3179 457.687 87.3179 457.687L103.434 392.072L133.363 357.538H196.676L216.245 433.513C216.245 433.513 208.187 455.384 213.943 455.384C219.699 455.384 254.233 462.291 254.233 436.966C254.233 411.641 242.721 336.817 240.419 334.515C238.117 332.213 241.57 324.155 238.117 320.701C234.663 317.248 194.374 293.074 179.409 288.47C164.444 283.865 143.451 278.385 143.451 278.385L29.761 327.608Z" fill="#2F2E41"/>
        <path id="Vector_27" d="M254.233 481.86C254.233 481.86 236.966 476.105 228.908 493.372C220.85 510.639 224.303 515.243 224.303 515.243C224.303 515.243 250.779 524.452 255.384 519.848C257.387 517.845 263.748 517.149 270.296 517.002C280.269 516.778 282.923 502.668 273.504 499.383C273.223 499.285 272.939 499.2 272.651 499.127C263.442 496.825 254.233 481.86 254.233 481.86Z" fill="#2F2E41"/>
        <path id="Vector_28" d="M108.038 93.9275C127.111 93.9275 142.572 78.4661 142.572 59.3934C142.572 40.3208 127.111 24.8593 108.038 24.8593C88.9656 24.8593 73.5042 40.3208 73.5042 59.3934C73.5042 78.4661 88.9656 93.9275 108.038 93.9275Z" fill="#FFB8B8"/>
        <path id="Vector_29" d="M63.144 120.404C63.144 120.404 119.55 131.915 133.363 113.497C147.177 95.0786 152.933 165.298 152.933 165.298L159.839 238.971L149.479 279.26C149.479 279.26 95.3758 323.004 78.1087 326.457C60.8417 329.91 34.3655 332.213 34.3655 332.213C34.3655 332.213 42.4236 204.437 42.4236 202.134C42.4236 199.832 63.144 120.404 63.144 120.404Z" fill="#6C63FF"/>
        <path id="Vector_30" d="M80.2983 98.8144C80.2983 98.8144 67.7485 91.6252 64.2951 98.532C60.8417 105.439 28.6099 122.706 25.1565 122.706C21.7031 122.706 32.0633 218.25 27.4587 229.762C22.8542 241.273 0.982611 325.306 13.6451 332.213C26.3076 339.119 17.0985 325.306 29.761 342.573C42.4235 359.84 104.585 359.84 108.038 352.933C111.492 346.026 80.411 294.225 86.1667 245.877C91.9224 197.53 101.131 130.764 93.0735 121.555C85.0156 112.346 80.2983 98.8144 80.2983 98.8144Z" fill="#2F2E41"/>
        <path id="Vector_31" d="M121.852 106.59L123.455 101.072C123.455 101.072 171.351 116.95 173.653 127.31C175.955 137.671 174.804 210.192 166.746 215.948C158.688 221.704 147.177 230.913 155.235 244.726C163.293 258.54 172.502 273.505 179.409 274.656C186.316 275.807 198.978 283.865 195.525 291.923C192.071 299.981 150.63 285.016 150.63 285.016C150.63 285.016 123.003 264.296 124.154 232.064C125.305 199.832 121.852 106.59 121.852 106.59Z" fill="#2F2E41"/>
        <path id="Vector_32" d="M162.142 242.424L134.514 294.225C134.514 294.225 94.2246 335.666 117.247 340.271C140.27 344.875 152.933 302.283 152.933 302.283L182.862 259.691L162.142 242.424Z" fill="#FFB8B8"/>
        <path id="Vector_33" d="M96.3438 9.06446C94.9518 8.96132 93.5575 9.23175 92.3051 9.8478C91.1726 10.6749 90.2393 11.7445 89.5733 12.9785C86.5029 17.5971 82.5005 21.5224 77.8232 24.5025C74.3318 26.7233 69.893 29.4922 70.4904 33.5867C70.8146 34.9595 71.3917 36.2599 72.1922 37.4214C75.4241 43.1236 76.7108 49.7234 75.8574 56.2221L85.4575 42.2681C86.9814 40.053 89.6287 37.5526 91.9296 38.9437C92.6999 39.4095 93.2058 40.2449 94.0079 40.6535C95.9219 41.6287 97.9581 39.7644 99.6524 38.4439C105.495 33.8903 113.803 35.0832 121.073 36.502C124.505 37.1718 128.275 38.0506 130.304 40.8987C133.676 45.6319 130.155 52.4709 132.123 57.9388C132.674 57.5531 133.141 57.0608 133.498 56.491C133.855 55.9211 134.095 55.2855 134.201 54.6216C136.946 54.7064 140.309 54.4366 141.485 51.9552C141.842 50.9828 142.033 49.9568 142.049 48.9208C142.48 44.7527 144.518 40.9502 145.867 36.9831C147.217 33.0161 147.804 28.367 145.526 24.8497C144.693 23.658 143.687 22.5967 142.542 21.7006C129.616 10.8395 112.621 9.04834 96.3438 9.06446Z" fill="#2F2E41"/>
        <path id="Vector_34" d="M162.142 122.706L172.867 125.553C172.867 125.553 197.827 189.472 192.071 233.215C186.316 276.958 182.862 267.749 182.862 267.749C182.862 267.749 173.653 247.029 152.933 251.633L162.142 122.706Z" fill="#2F2E41"/>
        <path id="Vector_35" d="M48.6229 624.292C45.847 628.064 46.4035 633.456 43.9446 637.443C41.8132 640.898 37.7962 642.71 35.1302 645.771C34.2795 646.788 33.5212 647.879 32.8641 649.031C30.391 653.174 28.3808 658.483 30.8165 662.648C32.7758 665.998 36.8943 667.307 40.6715 668.2C45.4455 669.328 50.4058 670.23 55.235 669.368C60.0642 668.506 64.7838 665.549 66.5057 660.956C66.8441 659.801 67.2464 658.666 67.7108 657.555C70.3282 652.402 78.5383 652.347 81.217 647.225C83.0917 643.641 81.3684 639.309 79.6459 635.649L74.3848 624.472C72.6389 620.763 65.5611 622.896 61.8714 622.007C57.0591 620.848 52.0848 619.571 48.6229 624.292Z" fill="#2F2E41"/>
        <path id="Vector_36" d="M10.1917 265.447L58.5394 340.271C58.5394 340.271 88.4689 378.258 97.678 360.991C106.887 343.724 65.4462 314.946 65.4462 314.946L34.3655 257.389L10.1917 265.447Z" fill="#FFB8B8"/>
        <path id="Vector_37" d="M34.3655 125.008L25.1564 122.706C25.1564 122.706 6.73827 128.462 2.13372 152.635C-2.47081 176.809 0.982583 273.505 6.73826 274.656C12.4939 275.807 35.1655 257.819 38.7945 261.633C42.4235 265.447 30.9121 245.877 34.3655 235.517C37.8189 225.157 34.3655 125.008 34.3655 125.008Z" fill="#2F2E41"/>
        <path id="Vector_38" d="M615.414 120.485H366.228C364.991 120.485 363.765 120.728 362.622 121.202C361.478 121.675 360.439 122.37 359.564 123.245C358.689 124.12 357.995 125.159 357.522 126.302C357.048 127.446 356.804 128.671 356.805 129.909V297.766C356.804 299.004 357.048 300.23 357.522 301.373C357.995 302.516 358.689 303.555 359.564 304.43C360.439 305.306 361.478 306 362.622 306.473C363.765 306.947 364.991 307.19 366.228 307.19H460.821L457.277 329.817C457.277 329.817 437.025 340.576 451.265 340.892C465.505 341.209 532.593 340.892 532.593 340.892C532.593 340.892 545.567 340.892 524.998 329.5L521.664 307.19H615.414C616.651 307.19 617.877 306.947 619.02 306.473C620.164 306 621.203 305.306 622.078 304.43C622.953 303.555 623.647 302.516 624.121 301.373C624.594 300.23 624.838 299.004 624.838 297.766V129.909C624.838 128.671 624.594 127.446 624.121 126.302C623.647 125.159 622.953 124.12 622.078 123.245C621.203 122.37 620.164 121.675 619.02 121.202C617.877 120.728 616.651 120.485 615.414 120.485Z" fill="#3F3D56"/>
        </g>
        <path id="Vector_39" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="366" y="130" width="250" height="140">
        <path id="Vector_40" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        </mask>
        <g mask="url(#mask0)">
        <g id="code-main" filter="url(#filter0_d)">
        <g id="code-main_2">
        <g id="Group 15">
        <path id="Rectangle 59" d="M424.752 164.345H395V171.444H424.752V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 60" d="M527.784 164.345H517.315V171.444H527.784V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 61" d="M548.721 164.345H538.252V171.444H548.721V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 62" d="M506.296 164.345H435.221V171.444H506.296V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle 63" d="M547.619 134.308H517.866V141.408H547.619V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 64" d="M587.839 134.308H558.087V141.408H587.839V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 66" d="M405.468 134.308H395V141.408H405.468V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 67" d="M426.405 134.308H415.937V141.408H426.405V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 68" d="M507.949 134.308H436.874V141.408H507.949V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle 69" d="M485.91 149.6H456.158V156.699H485.91V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 70" d="M445.689 149.6H415.937V156.699H445.689V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 71" d="M405.468 149.6H395V156.699H405.468V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 73" d="M587.839 149.6H577.371V156.699H587.839V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle 74" d="M566.902 149.6H495.827V156.699H566.902V149.6Z" fill="#6C63FF"/>
        </g>
        </g>
        </g>
        </g>
        </g>
        </g>
        <defs>
        <filter id="filter0_d" x="391" y="-181" width="200.839" height="360.444" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
        <feFlood flood-opacity="0" result="BackgroundImageFix"/>
        <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
        <feOffset dy="4"/>
        <feGaussianBlur stdDeviation="2"/>
        <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
        <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
        <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
        </filter>
        <clipPath id="clip0">
        <rect width="711.188" height="669.683" fill="white"/>
        </clipPath>
        </defs>
        </svg>

Codepen: https://codepen.io/DevKris/pen/KKpVxVa

Desired outcome: https://imgur.com/a/lG7vgem

Body:
You need to reuse the #Group15 several times:
Also I would use ids with no sapces: i.e. id="Group15" instead of id="Group 15"

I hope this is what you are asking.

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    text-align:center;
    margin: 20px;
}

#code-main {
    animation: code 3s infinite;
}

@keyframes code {
    from {
        transform: translate(0px, 0px);
    }
    to {
        transform: translate(0px, 150px);
    }
}

<svg width="712" height="670" viewBox="0 0 712 670" fill="none" xmlns="http://www.w3.org/2000/svg">
        <g id="undraw_feeling_proud_qne1 1">
        <g clip-path="url(#clip0)">
        <g id="guy">

        <path id="Vector_38" d="M615.414 120.485H366.228C364.991 120.485 363.765 120.728 362.622 121.202C361.478 121.675 360.439 122.37 359.564 123.245C358.689 124.12 357.995 125.159 357.522 126.302C357.048 127.446 356.804 128.671 356.805 129.909V297.766C356.804 299.004 357.048 300.23 357.522 301.373C357.995 302.516 358.689 303.555 359.564 304.43C360.439 305.306 361.478 306 362.622 306.473C363.765 306.947 364.991 307.19 366.228 307.19H460.821L457.277 329.817C457.277 329.817 437.025 340.576 451.265 340.892C465.505 341.209 532.593 340.892 532.593 340.892C532.593 340.892 545.567 340.892 524.998 329.5L521.664 307.19H615.414C616.651 307.19 617.877 306.947 619.02 306.473C620.164 306 621.203 305.306 622.078 304.43C622.953 303.555 623.647 302.516 624.121 301.373C624.594 300.23 624.838 299.004 624.838 297.766V129.909C624.838 128.671 624.594 127.446 624.121 126.302C623.647 125.159 622.953 124.12 622.078 123.245C621.203 122.37 620.164 121.675 619.02 121.202C617.877 120.728 616.651 120.485 615.414 120.485Z" fill="#3F3D56"/>
        </g>
        <path id="Vector_39" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        <mask id="mask0">
        <path id="Vector_40" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/>
        </mask>
        <g mask="url(#mask0)" >
        <g id="code-main" filter="url(#filter0_d)">
        <g id="code-main_2">
        <g id="Group15">
        <path id="Rectangle59" d="M424.752 164.345H395V171.444H424.752V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle60" d="M527.784 164.345H517.315V171.444H527.784V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle61" d="M548.721 164.345H538.252V171.444H548.721V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle62" d="M506.296 164.345H435.221V171.444H506.296V164.345Z" fill="#6C63FF"/>
        <path id="Rectangle63" d="M547.619 134.308H517.866V141.408H547.619V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle64" d="M587.839 134.308H558.087V141.408H587.839V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle66" d="M405.468 134.308H395V141.408H405.468V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle67" d="M426.405 134.308H415.937V141.408H426.405V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle68" d="M507.949 134.308H436.874V141.408H507.949V134.308Z" fill="#6C63FF"/>
        <path id="Rectangle69" d="M485.91 149.6H456.158V156.699H485.91V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle70" d="M445.689 149.6H415.937V156.699H445.689V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle71" d="M405.468 149.6H395V156.699H405.468V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle73" d="M587.839 149.6H577.371V156.699H587.839V149.6Z" fill="#6C63FF"/>
        <path id="Rectangle74" d="M566.902 149.6H495.827V156.699H566.902V149.6Z" fill="#6C63FF"/>
        </g>
        <use xlink:href="#Group15" y="-45" />
        <use xlink:href="#Group15" y="-90" />
        <use xlink:href="#Group15" y="-135" />
        <use xlink:href="#Group15" y="-180" />
        </g>
        </g>
        </g>
        </g>
        </g>
        <defs>
        <filter id="filter0_d" x="391" y="-181" width="200.839" height="360.444" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
        <feFlood flood-opacity="0" result="BackgroundImageFix"/>
        <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
        <feOffset dy="4"/>
        <feGaussianBlur stdDeviation="2"/>
        <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
        <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
        <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
        </filter>
        <clipPath id="clip0">
        <rect width="711.188" height="669.683" fill="white"/>
        </clipPath>
        </defs>
        </svg>


问:
QR scan plugin for Flutter (or Dart)
I'm trying to find a QR scanner plugin that is stable and does not use any Firebase configuration.
I've looked into the following, but some of them are old, no longer supported or depend on Firebase and other dependencies.

https://github.com/apptreesoftware/flutter_barcode_reader is no longer maintained.

https://github.com/rushio-consulting/flutter_camera_ml_vision requires Firebase integration.

https://github.com/juliuscanute/qr_code_scanner not sure if this is stable. No commit for 6 months now. But fits the bill.

Are there other QR scan libraries in Dart, that I can plug in to Flutter's Camera plugin myself?

答:
Im usind qrScan for my project and I didn't face any problem yet. I'ts also really easy to work with:</p>

```<code>import 'package:qrscan/qrscan.dart' as scanner;

  Future _scan() async {
   String barcode = await scanner.scan();
   if (barcode == null) {
    print('nothing return.');
   } else {
    this._outputController.text = barcode;
   _displayDialog();
   }
  }
</code>```

Title: QR scan plugin for Flutter (or Dart)

Body:
Im usind qrScan for my project and I didn't face any problem yet. I'ts also really easy to work with:

import 'package:qrscan/qrscan.dart' as scanner;

  Future _scan() async {
   String barcode = await scanner.scan();
   if (barcode == null) {
    print('nothing return.');
   } else {
    this._outputController.text = barcode;
   _displayDialog();
   }
  }


问:
SwiftUI, How to dismiss current presenting View when API call returns successfully
I am using SwiftUI and I am trying to achieve a simple logical action but unable to understand SwiftUI action hierarchy.

I have one API call something like this,

```<code>final class TaskData: ObservableObject {

    @Published var updatedFields = false
    @Published var updateMsg = ""

    func updateFields()
    {
        //Some API Call
        .whenSuccess { (response) in
            DispatchQueue.main.async {
                self.updatedFields = true
                self.updateMsg = "Successfully updated fields"
                //Send Request to dismiss current View ???
            }
        }
    }
}
</code>```

Now, I have a View something like this, and on a request I want to dismiss this View, but I am unable to find any method for that,

```<code>struct TaskView: View {

@Environment(\.presentationMode) var currentView: Binding<PresentationMode>
@EnvironmentObject var taskData: TaskData

var body : some View {

    //Some Views here ////

    //Need Some code here to dismiss currentView?????

    .navigationBarItems(trailing: Button(action: {

    }, label: {
        Text("Done")
    }).onTapGesture {
        self.taskData.updateFields() // Method Call to Update fields
    })
}
</code>```

if someone can explain this thing in a little detail as I am newbie to SwiftUI, I have seen a lot tutorial but unable to understand this structure of swift.

答:
It is not shown how TaskView is presented, but having presentationMode in give code snapshot let's assume that it is valid, so the approach might be as follows

```<code>@Environment(\.presentationMode) var presentationMode //better to name it same,
                                                      //type is extracted from Environment
@EnvironmentObject var taskData: TaskData

var body : some View {

    //Some Views here ////
    SomeView()
        .onReceive(taskData.$updatedFields) { success in
           if success {
              self.presentationMode.wrappedValue.dismiss() // dismiss self
           }
        }
    ...
</code>```

Body:
I am using SwiftUI and I am trying to achieve a simple logical action but unable to understand SwiftUI action hierarchy.

I have one API call something like this,

final class TaskData: ObservableObject {

    @Published var updatedFields = false
    @Published var updateMsg = ""

    func updateFields()
    {
        //Some API Call
        .whenSuccess { (response) in
            DispatchQueue.main.async {
                self.updatedFields = true
                self.updateMsg = "Successfully updated fields"
                //Send Request to dismiss current View ???
            }
        }
    }
}

Now, I have a View something like this, and on a request I want to dismiss this View, but I am unable to find any method for that,

struct TaskView: View {

@Environment(\.presentationMode) var currentView: Binding<PresentationMode>
@EnvironmentObject var taskData: TaskData

var body : some View {

    //Some Views here ////

    //Need Some code here to dismiss currentView?????

    .navigationBarItems(trailing: Button(action: {

    }, label: {
        Text("Done")
    }).onTapGesture {
        self.taskData.updateFields() // Method Call to Update fields
    })
}

if someone can explain this thing in a little detail as I am newbie to SwiftUI, I have seen a lot tutorial but unable to understand this structure of swift.

Body:
It is not shown how TaskView is presented, but having presentationMode in give code snapshot let's assume that it is valid, so the approach might be as follows

@Environment(\.presentationMode) var presentationMode //better to name it same,
                                                      //type is extracted from Environment
@EnvironmentObject var taskData: TaskData

var body : some View {

    //Some Views here ////
    SomeView()
        .onReceive(taskData.$updatedFields) { success in
           if success {
              self.presentationMode.wrappedValue.dismiss() // dismiss self
           }
        }
    ...


问:
Can I use gcloud in Git Bash on Windows?
So, I've installed Git, Git Bash, Python2.7, and I've just installed the Google Cloud SDK per the official guide.  Using Windows 10.

In cmd.exe, or the "Google Cloud SDK Shell",  gcloud works fine.

Within Git Bash, however (the terminal that I prefer to use), gcloud returns the following output (screenshot).

echo $PATH in Git Bash does include the path to the Google SDK (highlighted here).

Am I missing something?  Is there anything in $PATH that is possibly conflicting with gcloud, or did I misconfigure the path somehow?

I appreciate any insight.

UPDATE. Here is the output of env|grep PATH.  I'm not sure what it tells me. Any other executable in the PATH is working (vagrant, conda, python, etc), but gcloud is not.

答: Another option - copying the gsutil and bq files from Linux version to /google-cloud-sdk/bin on Windows.

ContentLicense: CC BY-SA 3.0


问:
Not found in annotated query error with @Query
I am using spring data with REST. I have a table country and an Entity corresponding to it called Country.java

I have annotated my method in CountryRepositopry as

```<code>public interface CountryRepository extends Repository<Country, Short> {

    @RestResource(path = "bycode3")
        @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
        Country findCountryByCodeAlpha3(@Param("code") String countryCode);
 }
</code>```

I am getting following exception while starting tomcat-

```<code>Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract com.persistence.entity.common.Country com.persistence.repository.CountryRepository.findCountryByCodeAlpha3(java.lang.String) but parameter 'code' not found in annotated query 'select c from Country c where c.codeAlpha3=?1 and c.active=1'!
</code>```

答:
If you are using @Param annotation, you should use same as ur entity class parameter and also use it same in "(@Param("code") String countryCode)" also:

```<code>public interface CountryRepository extends Repository<Country, Short> {

    @RestResource(path = "bycode3")
        @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
        Country findCountryByCodeAlpha3(@Param("code") String countryCode);
 }
</code>```

According to this, it should be changed like this:

```<code>@RestResource(path = "bycode3")
    @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
    Country findCountryByCodeAlpha3(@Param("codeAlpha3") String countryCode);
</code>```

Body:
I am using spring data with REST. I have a table country and an Entity corresponding to it called Country.java

I have annotated my method in CountryRepositopry as

public interface CountryRepository extends Repository<Country, Short> {

    @RestResource(path = "bycode3")
        @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
        Country findCountryByCodeAlpha3(@Param("code") String countryCode);
 }

I am getting following exception while starting tomcat-

Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract com.persistence.entity.common.Country com.persistence.repository.CountryRepository.findCountryByCodeAlpha3(java.lang.String) but parameter 'code' not found in annotated query 'select c from Country c where c.codeAlpha3=?1 and c.active=1'!

Body:
If you are using @Param annotation, you should use same as ur entity class parameter and also use it same in "(@Param("code") String countryCode)" also:

public interface CountryRepository extends Repository<Country, Short> {

    @RestResource(path = "bycode3")
        @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
        Country findCountryByCodeAlpha3(@Param("code") String countryCode);
 }

According to this, it should be changed like this:

@RestResource(path = "bycode3")
    @Query("select c from Country c where c.codeAlpha3=?1 and c.active=1")
    Country findCountryByCodeAlpha3(@Param("codeAlpha3") String countryCode);


问:
RegExp vs IRegExp2: class name confusion
Example:

```<code>Dim oRegEx As IRegExp2
Set oRegEx = New regexp
</code>```

Alternative:

```<code>Dim oRegEx As regexp
Set oRegEx = New regexp
</code>```

Both produce the same result, that is an object named "oRegEx" of type "RegExp/IRegExp2" as shown in the Type column of the Locals window.

The object browser for the library VBScript_RegExp_55 only shows the class "RegExp".

So, my questions are:

1) what is "IRegExp2"?

2) Should I prefer "IRegExp2" or "regexp" in the Dim line?

3) What are the different meanings of the first and the second name in the Type column of the Locals window?

答:
If you open up the library via oleview, this is the IDL definition:

```<code>[
  uuid(3F4DACA4-160D-11D2-A8E9-00104B365C9F)
]
coclass RegExp {
    [default] interface IRegExp2;
};
</code>```

The way VB6/VBA works; they exposes coclass as the first-class object, which is why you see RegExp in the object browser. However, you are not prevented from using the interfaces, which is why VBA/VB6 allows you to do Dim foo As IRegExp2 and thus substitute the implementation with some other implementation (in theory, at least). Because the RegExp is the only implementation of the IRegExp2 interface there is no practical difference. Had you created a class that implements IRegExp2, then it would make sense to declare variables as IRegExp2 so that you have the freedom of using either the VBScript's implementation or your custom implementation.

Note that there is also a IRegExp. However, IRegExp2 does not derive from it. Nonetheless, they are quite similar and you can assign it even though it's not explicitly stated so in the IDL:

```<code>Public Sub test()
    Dim i1 As IRegExp
    Dim i2 As IRegExp2
    Dim o As RegExp

    Set o = New VBScript_RegExp_55.RegExp
    Set i2 = o
    Set i1 = o
End Sub
</code>```

The reason why this works is so that you can have your old code that was originally written against the original RegExp 1.0 library continue to work using the RegExp 5.5 library without actually changing your code.

It is important to note that even though VBA/VB6 shows you coclasses, in fact you are always working with the COM interfaces under the hood. We can pretend that they are "class" because of the coclass having a default interface.

Body:
Example:

Dim oRegEx As IRegExp2
Set oRegEx = New regexp

Alternative:

Dim oRegEx As regexp
Set oRegEx = New regexp

Both produce the same result, that is an object named "oRegEx" of type "RegExp/IRegExp2" as shown in the Type column of the Locals window.

The object browser for the library VBScript_RegExp_55 only shows the class "RegExp".

So, my questions are:

1) what is "IRegExp2"?

2) Should I prefer "IRegExp2" or "regexp" in the Dim line?

3) What are the different meanings of the first and the second name in the Type column of the Locals window?

Body:
If you open up the library via oleview, this is the IDL definition:

[
  uuid(3F4DACA4-160D-11D2-A8E9-00104B365C9F)
]
coclass RegExp {
    [default] interface IRegExp2;
};

The way VB6/VBA works; they exposes coclass as the first-class object, which is why you see RegExp in the object browser. However, you are not prevented from using the interfaces, which is why VBA/VB6 allows you to do Dim foo As IRegExp2 and thus substitute the implementation with some other implementation (in theory, at least). Because the RegExp is the only implementation of the IRegExp2 interface there is no practical difference. Had you created a class that implements IRegExp2, then it would make sense to declare variables as IRegExp2 so that you have the freedom of using either the VBScript's implementation or your custom implementation.

Note that there is also a IRegExp. However, IRegExp2 does not derive from it. Nonetheless, they are quite similar and you can assign it even though it's not explicitly stated so in the IDL:

Public Sub test()
    Dim i1 As IRegExp
    Dim i2 As IRegExp2
    Dim o As RegExp

    Set o = New VBScript_RegExp_55.RegExp
    Set i2 = o
    Set i1 = o
End Sub

The reason why this works is so that you can have your old code that was originally written against the original RegExp 1.0 library continue to work using the RegExp 5.5 library without actually changing your code.

It is important to note that even though VBA/VB6 shows you coclasses, in fact you are always working with the COM interfaces under the hood. We can pretend that they are "class" because of the coclass having a default interface.


问:
I can't import pygame inside pycharm
I can't import pygame inside pycharm.

I've been using Linux Mint 19, Anaconda 3, Pycharm 2019.3.1.

I've created a conda environment and install pygame: conda install pygame -c cogsci

Then I ran (my_env) tiago@tiago-XPS-8700:~$ python3 mycode.py. And I got the following error:

teste.py:3: RuntimeWarning: use mixer: libSDL_mixer-1.2.so.0: cannot
  open shared object file: No such file or directory (ImportError:
  libSDL_mixer-1.2.so.0: cannot open shared object file: No such file or
  directory)   pygame.mixer.music.load('bat.mp3') Traceback (most recent
  call last):   File "teste.py", line 3, in
      pygame.mixer.music.load('bat.mp3')   File "/home/tiago/anaconda3/envs/pycharm/lib/python3.5/site-packages/pygame/init.py",
  line 105, in getattr
      raise NotImplementedError(MissingPygameModule) NotImplementedError: mixer module not available (ImportError:
  libSDL_mixer-1.2.so.0: cannot open shared object file: No such file or
  directory)

After reading some blog at internet I installed sudo apt install libsdl-mixer1.2.

After that if I run (my_env) tiago@tiago-XPS-8700:~$ python3 mycode.py at Linux terminal at my conda environment, my code run successfully.

But If I try to run the same code inside Pycharm I get the following error:

/home/tiago/anaconda3/envs/pycharm/bin/python
  /home/tiago/Documentos/PYTHON/cursoemvideo/exercicios/ex_021.py
  Traceback (most recent call last):   File
  "/home/tiago/Documentos/PYTHON/cursoemvideo/exercicios/ex_021.py",
  line 3, in
      import pygame   File "/home/tiago/anaconda3/envs/pycharm/lib/python3.5/site-packages/pygame/init.py",
  line 133, in
      from pygame.base import * ImportError: libSDL-1.2.so.0: cannot open shared object file: No such file or directory

Process finished with exit code 1

What am I missing?

答: In conda environment  they have pre installed packages and libraries which u can easily use by importing them but in pycharm u additionally need to intall that package so that u can use it in pycharm </p>

Title: I can't import pygame inside pycharm


问:
xdmp:email and AWS SES
I'm trying to use AWS SES to send email from MarkLogic using the 'xdmp:email' command, but I keep getting an "address not verified" error.  I have tried supplying verified email addresses in every conceivable email field (reply-to, sender, from, etc) but I have not found a way around this particular error using simply xdmp:email. It is worth noting that if I enter an unverified email address into the "sender" field, for example, both unverified email addresses will appear in the error message.  This tells me 1) I have entered the reply-to, sender, etc addresses correctly in xdmp:email and 2) AWS is noting those addresses and, if verified, letting it go through.  The problem is this email address I really don't have control over.  The error is:

```<code>Error sending mail: : 554 Message rejected: Email address is not verified.
The following identities failed the check in region US-EAST-1: daemon@ip-10-62-92-128.ec2.internal
</code>```

I am entering the credentials in the options.  All-in-all, I am fairly confident that everything else is correctly done.  For example, until I entered credentials I received an authorization error.  Until I validated the actual TO addresses, I received errors that those addresses were not properly validated.  I've been able to resolve those errors.  The bulk of this email code is in full operation outside of AWS so I'm not overly worried there is some basic problem with the code.

FWIW, we have requested a "paid" SES account and therefore we are no longer working in a "sandbox."  We have deleted and recreated the SMTP IAM User. Googling suggests that upgrading should have sufficiently addressed this problem, with the User issue as second idea, so I'm frankly unclear if this is an AWS issue too. Regardless of those AWS-specific questions, it seems to me that I should be able to send an email from MarkLogic relatively easily via the SES sandbox, versus having to immediately upgrade to a paid account.

Is there something I am missing?  I would very much like to be missing something simple.  Is there some way not to have ML attach this dummy email address to the message?  Is there a way to validate this dummy email address in such a way that it is scalable should the service expand?  Is the common solution to verify the domain, which, for me, will not be a simple matter?  Should I be looking at setting up a localhost SMTP relay using postfix or something (and, of course, who knows if that will actually get around this issue)?  How are others using MarkLogic and SES together in AWS?

答:
This error occurs when either the FROM or SENDER email headers are not validated.
Authentication is first step but doesnt bypass the from/sender checks.
First verify in some other tool that SES is configured correctly for the same email address.  You may need to try using a smtp relay or some similar low level tool to debug this.
The settings for xdmp:email include a "from" but not a "sender"  (often called 'Envelope From') -- BOTH these need to be validated SES email addreses.

A workaround is to configure a local smtp proxy using something like postfix can be configured to work with SES correctly and has the benefits of good smtp spool processing for handling retries/errors and intermittent load issues that are beyond the xdmp:email abilities.

Title: xdmp:email and AWS SES

Body:
I'm trying to use AWS SES to send email from MarkLogic using the 'xdmp:email' command, but I keep getting an "address not verified" error.  I have tried supplying verified email addresses in every conceivable email field (reply-to, sender, from, etc) but I have not found a way around this particular error using simply xdmp:email. It is worth noting that if I enter an unverified email address into the "sender" field, for example, both unverified email addresses will appear in the error message.  This tells me 1) I have entered the reply-to, sender, etc addresses correctly in xdmp:email and 2) AWS is noting those addresses and, if verified, letting it go through.  The problem is this email address I really don't have control over.  The error is:

Error sending mail: : 554 Message rejected: Email address is not verified.
The following identities failed the check in region US-EAST-1: daemon@ip-10-62-92-128.ec2.internal

I am entering the credentials in the options.  All-in-all, I am fairly confident that everything else is correctly done.  For example, until I entered credentials I received an authorization error.  Until I validated the actual TO addresses, I received errors that those addresses were not properly validated.  I've been able to resolve those errors.  The bulk of this email code is in full operation outside of AWS so I'm not overly worried there is some basic problem with the code.

FWIW, we have requested a "paid" SES account and therefore we are no longer working in a "sandbox."  We have deleted and recreated the SMTP IAM User. Googling suggests that upgrading should have sufficiently addressed this problem, with the User issue as second idea, so I'm frankly unclear if this is an AWS issue too. Regardless of those AWS-specific questions, it seems to me that I should be able to send an email from MarkLogic relatively easily via the SES sandbox, versus having to immediately upgrade to a paid account.

Is there something I am missing?  I would very much like to be missing something simple.  Is there some way not to have ML attach this dummy email address to the message?  Is there a way to validate this dummy email address in such a way that it is scalable should the service expand?  Is the common solution to verify the domain, which, for me, will not be a simple matter?  Should I be looking at setting up a localhost SMTP relay using postfix or something (and, of course, who knows if that will actually get around this issue)?  How are others using MarkLogic and SES together in AWS?


问:
css transition height to hide content in container
I have a div absolute positioned located on the bottom side of the screen. I want to hide its content with an animation (not only setting display none) when a sibling div is clicked by transitioning max-height to 0.

The problem is that the content has at the same time child tags which keep height setted, causing to overflow the current body height.

What is the best solution to solve it?

I have reproduced the behaviour: https://codepen.io/javheroli/pen/QWbyZEr?editors=0110

```<code>.hide-container{
  opacity: 1;
  max-height: 4em;
  transition: opacity .8s, max-height .5s;
}
.hide {
  opacity: 0;
  max-height: 0;
  transition: opacity .3s, max-height .5s;
}
</code>```

答:
I think the easiest way would be to transition only the height property and add an overflow: hidden definition.

That way when you reduce the height the content just gets hidden. If you also want to animate the content you could animate the opacity of the child elements. It would be easier to check if you'd provided your HTML structure.

Body:
I have a div absolute positioned located on the bottom side of the screen. I want to hide its content with an animation (not only setting display none) when a sibling div is clicked by transitioning max-height to 0.

The problem is that the content has at the same time child tags which keep height setted, causing to overflow the current body height.

What is the best solution to solve it?

I have reproduced the behaviour: https://codepen.io/javheroli/pen/QWbyZEr?editors=0110

.hide-container{
  opacity: 1;
  max-height: 4em;
  transition: opacity .8s, max-height .5s;
}
.hide {
  opacity: 0;
  max-height: 0;
  transition: opacity .3s, max-height .5s;
}


问:
Google Chrome + FireFox not loading custom fonts (access-control-allow-origin)
I believe it was yesterday when my website's custom fonts ceased to function. Now, the fonts are only shown on Safari, while Chrome and Firefox throw access control allow origin errors to their respective consoles.
Chrome Error:

Access to font at 'https://blockheaddevdevdev--grify.repl.co/styles/font/wide.ttf' from origin 'https://blockheaddevdevdev.grify.repl.co' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Firefox Error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://blockheaddevdevdev--grify.repl.co/styles/font/wide.ttf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).[Learn More]

Here is the font I am using
Here is the CSS that applies the fonts to the page
Here is the page that should run these custom fonts

答: I replaced the my url http://127.0.0.1/sitename/ into http://localhost/sitename/ and it worked</p>


问:
How modify regex to exclude some text?
I have regex as '@(?:@msU'. I need modify this expression to exclude , ), exclude ()

How can I modify my regex?

Title: How modify regex to exclude some text?

Body:
I totally agree with the comment of @JayBlanchard mentionning the fact that it would be far safer using a PHP DOM parser. You can then easily remove them if they don't have the no-defer attribute.

But well... if you really want to do it with a regular expression, I would first try to look for all the <script> tags and capture the attributes in a capturing group with something a bit like this:

First try to find script tags: <\s*script(?<attributes>[^>]*)>.*?<\s*\/\s*script\s*>

Test here: https://regex101.com/r/dVEMqA/3/

The idea is to do the job in 2 passes. This could be done by using PHP's preg_replace_callback() function that lets you then execute some PHP for each match and there you'll be able to parse the attributes a bit safely and see if you've got a no-defer attribute and decide to keep it instead of pushing it into your array of scripts to move to the bottom of your page.

You could also use preg_match_all() and loop over the results to decide what to do. But I would personnaly go for the DOM parser solution first and then for the preg_replace_callback() solution with a callback function that can access an array to store the items that have been removed. This can be done with the help of anonymous (closure) functions and the use ($scripts_to_move_down) functionnality. See here: https://www.php.net/manual/en/functions.anonymous.php

This would become something like this:

$script_tags_to_move = [];

// Find all script tags and store and then remove them if they don't have the
// no-defer attribute.
$html = preg_replace_callback(
    '/<\s*script(?<attributes>[^>]*)>.*?<\s*\/\s*script\s*>/si',
    function ($matches) use (&$script_tags_to_move) {
        // If the attributes contains no-defer (search is not very safe -> to improve).
        if (preg_match('/(^|\s)no-defer(\s|$)/i', $matches['attributes'])) {
            // Keep the script tag in the HTML.
            return $matches[0];
        } else {
            // Store the script tag.
            $script_tags_to_move[] = $matches[0];
            // And remove it from the HTML.
            return '';
        }
    },
    $html
);

// Inject the script tags at the end, before the closing body tag.
$html = preg_replace(
    '~<\s*/\s*body\s*>~is',
    implode("\n", $script_tags_to_move) . '</body>',
    $html
);

Try it out here: http://sandbox.onlinephpfunctions.com/code/21a938482e883a1d470e61f312764c112c73bb85


问:
Android Espresso: How check "drawableStart" of EditText?
I have my xml layout:

```<code><EditText
            android:id="@+id/passwordEditText"
            android:layout_width="0dp"
            android:layout_height="45dp"
            android:layout_marginBottom="20dp"
            android:drawableStart="@drawable/ic_sign_in_password"
            android:drawablePadding="15dp"
            android:hint="@string/password"
android:textSize="15sp"/>
</code>```

I want to write Espresso test check that EditText has
android:drawableStart="@drawable/ic_sign_in_password".

How I can do this?

答:
Based on this article I made a small change to be able to check any compoundDrawables inside a TextView

fun withDrawable(
    @DrawableRes id: Int,
    @ColorRes tint: Int? = null,
    tintMode: PorterDuff.Mode = PorterDuff.Mode.SRC_IN,
    drawablePosition: TextDrawablePosition = TextDrawablePosition.Left
) = object :
    TypeSafeMatcher<View>() {
    override fun describeTo(description: Description) {
        description.appendText("View with drawable same as drawable with id $id")
        tint?.let { description.appendText(", tint color id: $tint, mode: $tintMode") }
    }

    override fun matchesSafely(view: View): Boolean {
        val context = view.context
        val tintColor = tint?.toColor(context)
        val expectedBitmap = context.getDrawable(id)?.tinted(tintColor, tintMode)?.toBitmap()

        return when (view) {
            is TextView -> view.compoundDrawables[drawablePosition.ordinal].toBitmap().sameAs(expectedBitmap)
            is ImageView -> view.drawable.toBitmap().sameAs(expectedBitmap)
            else -> false
        }
    }
}

enum class TextDrawablePosition {
    Left, Top, Right, Bottom
}

private fun Int.toColor(context: Context) = ContextCompat.getColor(context, this)

private fun Drawable.tinted(@ColorInt tintColor: Int? = null, tintMode: PorterDuff.Mode = SRC_IN) =
    apply {
        setTintList(tintColor?.toColorStateList())
        setTintMode(tintMode)
    }

private fun Int.toColorStateList() = ColorStateList.valueOf(this)
```

Body:
I have my xml layout:

<EditText
            android:id="@+id/passwordEditText"
            android:layout_width="0dp"
            android:layout_height="45dp"
            android:layout_marginBottom="20dp"
            android:drawableStart="@drawable/ic_sign_in_password"
            android:drawablePadding="15dp"
            android:hint="@string/password"
android:textSize="15sp"/>

I want to write Espresso test check that EditText has
android:drawableStart="@drawable/ic_sign_in_password".

How I can do this?


问:
Django - Inline form for OneToOne field in admin site
Hi This question has been asked many times but unfortunately I could not find an answer for it that would actually work. Below are my models:

```<code>class Person(models.Model):
    name = models.CharField(max_length=100)
    ...

class Address(models.Model):
    person = models.OneToOneField(Person)
    ...
</code>```

Then in the admin I have:

```<code>class AddressInline(admin.StackedInline):
    model = Address

class PersonAdmin(admin.ModelAdmin):
    inlines = (AddressInline)

admin.site.register(Person, PersonAdmin)
</code>```

and then i get this infamous error:

```<code><class 'address.models.Address'> has no ForeignKey to <class 'person.models.Person'>
</code>```

I have tried:

django-reverse-admin. Unfortunately did not work with Django 1.6 and I am not saavy enough to make it work with 1.6

Several suggection in stackover flow on using proxy models and abstract base class and those did not work either.

I would really appreciate if someone could help me to find a workaround for it.

答:
For those who looking solution for Django 2.0:
you can just use this library: https://pypi.org/project/django-reverse-admin/

It worked well for me.

Body:
Hi This question has been asked many times but unfortunately I could not find an answer for it that would actually work. Below are my models:

class Person(models.Model):
    name = models.CharField(max_length=100)
    ...

class Address(models.Model):
    person = models.OneToOneField(Person)
    ...

Then in the admin I have:

class AddressInline(admin.StackedInline):
    model = Address

class PersonAdmin(admin.ModelAdmin):
    inlines = (AddressInline)

admin.site.register(Person, PersonAdmin)

and then i get this infamous error:

<class 'address.models.Address'> has no ForeignKey to <class 'person.models.Person'>

I have tried:

django-reverse-admin. Unfortunately did not work with Django 1.6 and I am not saavy enough to make it work with 1.6

Several suggection in stackover flow on using proxy models and abstract base class and those did not work either.

I would really appreciate if someone could help me to find a workaround for it.


问:
ASP.NET Core SaveChangesAsync does not save everything
PROBLEM:

If I put SaveChangesAsync outside of the loop, it changes only the last data which was put with _context.Add(attdef);

Why is that so?

First I thought it's because I have autoIncrement, but when I disabled it, It still did not work.

Using  SaveChanges instead of SaveChangesAsync does not fix problem aswell.

But updating data works well.

GameController.cs

```<code>for (int i = 0; i < editViewModel.TowerAttack.Count; i++)
{
    tower = _context.Tower.First(m => m.TowerId == editViewModel.TowerId[i]);
    tower.Attack -= editViewModel.TowerAttack[i];
    _context.Update(tower);
    attdef.Id = 0; // AutoIncrement
    attdef.Amount = attackSum;
    _context.Add(attdef);
}

await _context.SaveChangesAsync();
</code>```

答:
I think you have declared attdef variable somewhere above and in the loop you're updating the same reference and adding it to the context. Due to this, you have single item adding in the context. The better way is to do it something like this</p>

```<code>var attdefs = new List<Attdef>();
for (int i = 0; i < editViewModel.TowerAttack.Count; i++)
            {
                tower = _context.Tower.First(m => m.TowerId == editViewModel.TowerId[i]);
                tower.Attack -= editViewModel.TowerAttack[i];
                _context.Update(tower);
                attdefs.Add(new AttacDef { id = 0, Amount = attackSum }) ;
            }
              _context.AddRange(attdefs); // don't remember exaxct syntaxt but this should be faster way
              await _context.SaveChangesAsync();
</code>```

Body:
PROBLEM:

If I put SaveChangesAsync outside of the loop, it changes only the last data which was put with _context.Add(attdef);

Why is that so?

First I thought it's because I have autoIncrement, but when I disabled it, It still did not work.

Using  SaveChanges instead of SaveChangesAsync does not fix problem aswell.

But updating data works well.

GameController.cs

for (int i = 0; i < editViewModel.TowerAttack.Count; i++)
{
    tower = _context.Tower.First(m => m.TowerId == editViewModel.TowerId[i]);
    tower.Attack -= editViewModel.TowerAttack[i];
    _context.Update(tower);
    attdef.Id = 0; // AutoIncrement
    attdef.Amount = attackSum;
    _context.Add(attdef);
}

await _context.SaveChangesAsync();

Body:
I think you have declared attdef variable somewhere above and in the loop you're updating the same reference and adding it to the context. Due to this, you have single item adding in the context. The better way is to do it something like this

var attdefs = new List<Attdef>();
for (int i = 0; i < editViewModel.TowerAttack.Count; i++)
            {
                tower = _context.Tower.First(m => m.TowerId == editViewModel.TowerId[i]);
                tower.Attack -= editViewModel.TowerAttack[i];
                _context.Update(tower);
                attdefs.Add(new AttacDef { id = 0, Amount = attackSum }) ;
            }
              _context.AddRange(attdefs); // don't remember exaxct syntaxt but this should be faster way
              await _context.SaveChangesAsync();


问:
Azure move app service to a different app service plan
I have the following setup:

Resource group 1

App service plan 1

App Service 1 (app service plan 1)

Resource group 2

App service plan 2

App Service 2 (app service plan 2)

App Service 3 (app service plan 1)

I would like to move App Service 3 which is into Resource group 2 but uses app service plan 1, to app service plan 2.

Is this possible? I have tried to use the feature "Change App service plan" available on the new portal but when I click on it a blade appear saying that "No App Service plan found".

I suspect that the blade looks for app service plan available on the original resource group and does not permit neither to create a new one.

Please see the attached picture for details.

Thanks

答:
Are App service plan 1 and App service plan 2 in the same region?

You can have resources in multiple regions in the same resource group, but App Services and App Service plan must be in the same region.

My best guess is:

App service plan 1, App Service 1, and App Service 3 are in Region X.

App service plan 2 and App Service 2 are in Region Y.

You might have to recreate App Service 1a in App Service Plan 2. :(


问:
Azure function HTTP Request 404 when published to Azure through Docker and Visual Studio
I'm attempting to learn some more about Azure Functions 2.0 and Docker containers to publish to my Azure instance. I followed to tutorial below with the only difference being that I published with docker to a container registry in azure using visual studio 2019.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio

This all worked correctly and I was able to start my container and visit the site. However, in the example you can visit /api/function1 and get a response. This works on my localhost but on the live site it returns a 404. It seems that /api/function1 is not reachable after being published.

The app itself returns this when visiting the IP itself so I know it is working. Do I need to do something else in Azure to expose my APIs?

My container log only shows this.

```<code>Hosting environment: Production
Content root path: C:\
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
</code>```

I grabbed my dockerfile from here

https://github.com/Azure/azure-functions-docker/blob/master/host/2.0/nanoserver-1809/Dockerfile

```<code># escape=`

# Installer image
FROM mcr.microsoft.com/windows/servercore:1809 AS installer-env

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Retrieve .NET Core SDK
ENV DOTNET_SDK_VERSION 2.2.402

RUN Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$Env:DOTNET_SDK_VERSION/dotnet-sdk-$Env:DOTNET_SDK_VERSION-win-x64.zip; `
    $dotnet_sha512 = '0fa3bf476b560c8fc70749df37a41580f5b97334b7a1f19d66e32096d055043f4d7ad2828f994306e0a24c62a3030358bcc4579d2d8d439d90f36fecfb2666f6'; `
    if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $dotnet_sha512) { `
        Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
        exit 1; `
    }; `
    `
    Expand-Archive dotnet.zip -DestinationPath dotnet; `
    Remove-Item -Force dotnet.zip

ENV ASPNETCORE_URLS=http://+:80 `
    DOTNET_RUNNING_IN_CONTAINER=true `
    DOTNET_USE_POLLING_FILE_WATCHER=true `
    NUGET_XMLDOC_MODE=skip `
    PublishWithAspNetCoreTargetManifest=false `
    HOST_COMMIT=69f124faed40d20d9d8e5b8d51f305d249b21512 `
    BUILD_NUMBER=12858

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
    Invoke-WebRequest -OutFile host.zip https://github.com/Azure/azure-functions-host/archive/$Env:HOST_COMMIT.zip; `
    Expand-Archive host.zip .; `
    cd azure-functions-host-$Env:HOST_COMMIT; `
    /dotnet/dotnet publish /p:BuildNumber=$Env:BUILD_NUMBER /p:CommitHash=$Env:HOST_COMMIT src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj --output C:\runtime

# Runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.7-nanoserver-1809

COPY --from=installer-env ["C:\\runtime", "C:\\runtime"]

ENV AzureWebJobsScriptRoot=C:\approot `
    WEBSITE_HOSTNAME=localhost:80

CMD ["dotnet", "C:\\runtime\\Microsoft.Azure.WebJobs.Script.WebHost.dll"]
</code>```

Here's my function1 code for my azure function

```<code>public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string productid = req.Query["productid"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            productid = productid ?? data?.product;

            Product newProduct = new Product()
            {
                ProductNumber = 0,
                ProductName = "Unknown",
                ProductCost = 0
            };
            if (Convert.ToInt32(productid) ==1)
            {
                newProduct = new Product()
                {
                    ProductCost = 100,
                    ProductName = "Lime Tree",
                    ProductNumber = 1
                };
            }
            else if(Convert.ToInt32(productid) == 2)
            {
                newProduct = new Product()
                {
                    ProductCost = 500,
                    ProductName = "Lemon Tree",
                    ProductNumber = 2
                };
            }
            return productid != null
                ? (ActionResult)new JsonResult(newProduct)
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
        }
</code>```

Here's a photo of my container running with my image.

I'm new to this so any advice would be helpful for sure!

Thanks!

答:
@silent's answer was correct - Linux containers are the way to go for Azure Functions. My environment wasn't set up correctly for Linux containers but once I got a correct environment this worked out of the box.

Here's my latest DockerFile for another project that uses Linux Containers

See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

```<code>FROM mcr.microsoft.com/azure-functions/dotnet:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["FunctionTestAppLinux/FunctionTestAppLinux.csproj", "FunctionTestAppLinux/"]
RUN dotnet restore "FunctionTestAppLinux/FunctionTestAppLinux.csproj"
COPY . .
WORKDIR "/src/FunctionTestAppLinux"
RUN dotnet build "FunctionTestAppLinux.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "FunctionTestAppLinux.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app
</code>```

Body:
I'm attempting to learn some more about Azure Functions 2.0 and Docker containers to publish to my Azure instance. I followed to tutorial below with the only difference being that I published with docker to a container registry in azure using visual studio 2019.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio

This all worked correctly and I was able to start my container and visit the site. However, in the example you can visit /api/function1 and get a response. This works on my localhost but on the live site it returns a 404. It seems that /api/function1 is not reachable after being published.

The app itself returns this when visiting the IP itself so I know it is working. Do I need to do something else in Azure to expose my APIs?

My container log only shows this.

Hosting environment: Production
Content root path: C:\
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

I grabbed my dockerfile from here

https://github.com/Azure/azure-functions-docker/blob/master/host/2.0/nanoserver-1809/Dockerfile

# escape=`

# Installer image
FROM mcr.microsoft.com/windows/servercore:1809 AS installer-env

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Retrieve .NET Core SDK
ENV DOTNET_SDK_VERSION 2.2.402

RUN Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$Env:DOTNET_SDK_VERSION/dotnet-sdk-$Env:DOTNET_SDK_VERSION-win-x64.zip; `
    $dotnet_sha512 = '0fa3bf476b560c8fc70749df37a41580f5b97334b7a1f19d66e32096d055043f4d7ad2828f994306e0a24c62a3030358bcc4579d2d8d439d90f36fecfb2666f6'; `
    if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $dotnet_sha512) { `
        Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
        exit 1; `
    }; `
    `
    Expand-Archive dotnet.zip -DestinationPath dotnet; `
    Remove-Item -Force dotnet.zip

ENV ASPNETCORE_URLS=http://+:80 `
    DOTNET_RUNNING_IN_CONTAINER=true `
    DOTNET_USE_POLLING_FILE_WATCHER=true `
    NUGET_XMLDOC_MODE=skip `
    PublishWithAspNetCoreTargetManifest=false `
    HOST_COMMIT=69f124faed40d20d9d8e5b8d51f305d249b21512 `
    BUILD_NUMBER=12858

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
    Invoke-WebRequest -OutFile host.zip https://github.com/Azure/azure-functions-host/archive/$Env:HOST_COMMIT.zip; `
    Expand-Archive host.zip .; `
    cd azure-functions-host-$Env:HOST_COMMIT; `
    /dotnet/dotnet publish /p:BuildNumber=$Env:BUILD_NUMBER /p:CommitHash=$Env:HOST_COMMIT src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj --output C:\runtime

# Runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.7-nanoserver-1809

COPY --from=installer-env ["C:\\runtime", "C:\\runtime"]

ENV AzureWebJobsScriptRoot=C:\approot `
    WEBSITE_HOSTNAME=localhost:80

CMD ["dotnet", "C:\\runtime\\Microsoft.Azure.WebJobs.Script.WebHost.dll"]

Here's my function1 code for my azure function

public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string productid = req.Query["productid"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            productid = productid ?? data?.product;

            Product newProduct = new Product()
            {
                ProductNumber = 0,
                ProductName = "Unknown",
                ProductCost = 0
            };
            if (Convert.ToInt32(productid) ==1)
            {
                newProduct = new Product()
                {
                    ProductCost = 100,
                    ProductName = "Lime Tree",
                    ProductNumber = 1
                };
            }
            else if(Convert.ToInt32(productid) == 2)
            {
                newProduct = new Product()
                {
                    ProductCost = 500,
                    ProductName = "Lemon Tree",
                    ProductNumber = 2
                };
            }
            return productid != null
                ? (ActionResult)new JsonResult(newProduct)
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
        }

Here's a photo of my container running with my image.

I'm new to this so any advice would be helpful for sure!

Thanks!

Body:
@silent's answer was correct - Linux containers are the way to go for Azure Functions. My environment wasn't set up correctly for Linux containers but once I got a correct environment this worked out of the box.

Here's my latest DockerFile for another project that uses Linux Containers

See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/azure-functions/dotnet:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["FunctionTestAppLinux/FunctionTestAppLinux.csproj", "FunctionTestAppLinux/"]
RUN dotnet restore "FunctionTestAppLinux/FunctionTestAppLinux.csproj"
COPY . .
WORKDIR "/src/FunctionTestAppLinux"
RUN dotnet build "FunctionTestAppLinux.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "FunctionTestAppLinux.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app


问:
Admin panel and MVC
I'm studying MVC a little but i don't understand where the "admin control panel" fits in the MVC structure. I'm working with PHP. Maybe anyone can give me some ideas?</p>

答:
An Admin control panel is just another interface to your models. You just use the same models as you use for your app and you create methods/actions in your controller that are only accessible by admin users (which in their turn might use some specific admin-only methods in the associated model).

An example with a blog would be that you have a model called Post which contains your blogposts. In your PostsController you've got three methods: view(), add() and delete(). Regular users only have access to the view() method and it's associated view, whereas admin users can also use the other two methods and their associated views.

How you setup these access rights depends on the MVC framework you're using, but one solution is to use an Access Control List or ACL.

Title: Admin panel and MVC


答: This can be fixed by adding overflow: hidden; to your .hide-container .hide element.

Title: css transition height to hide content in container


问:
How to make jitterplot on matplolib python
Here is my code (adapted from here):

```<code>df_1 = pd.DataFrame({'Cells' : np.arange(0,100), 'Delta_7' : np.random.rand(100,), 'Delta_10' : np.random.rand(100,), 'Delta_14' : np.random.rand(100,)}, columns = ['Cells','Delta_7', 'Delta_10', 'Delta_14'])

#figure
fig, ax1 = plt.subplots()
fig.set_size_inches(13, 10)

#c sequence
c = df_1['Delta_7']

#plot

plt.scatter(np.full((len(df_1), 1), 1), df_1['Delta_7'] , s = 50, c=c, cmap = 'viridis')
plt.scatter(np.full((len(df_1), 1), 2), df_1['Delta_10'] , s = 50, c=c, cmap = 'viridis')
plt.scatter(np.full((len(df_1), 1), 3), df_1['Delta_14'] , s = 50, c=c, cmap = 'viridis')
cbar = plt.colorbar()
</code>```

I would like to make a beautiful jitterplot (like on R or seaborn) with matplotlib. The thing is that I would like to give each cell a color based on its 'Delta_7' value. And this color would be kept when plotting 'Delta_10' and 'Delta_14', that I didn't manage to do with seaborn.
Please, could you let me know if you have any clue (python package, coding tricks …)?

Kindly,

答:
The positions of the dots can be obtained from the list returned by scatter. These positions can be jittered, for example only in the x-direction. Possibly the range of the x-axis needs to be extended a bit to show every displaced dot.

Here is some code to start experimenting:

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

def jitter_dots(dots):
    offsets = dots.get_offsets()
    jittered_offsets = offsets
    # only jitter in the x-direction
    jittered_offsets[:, 0] += np.random.uniform(-0.3, 0.3, offsets.shape[0])
    dots.set_offsets(jittered_offsets)

df_1 = pd.DataFrame({'Cells': np.arange(0, 100),
                     'Delta_7': np.random.rand(100),
                     'Delta_10': np.random.rand(100),
                     'Delta_14': np.random.rand(100)})
fig, ax1 = plt.subplots()

columns = df_1.columns[1:]
c = df_1['Delta_7']
for i, column in enumerate(columns):
    dots = plt.scatter(np.full((len(df_1), 1), i), df_1[column], s=50, c=c, cmap='plasma')
    jitter_dots(dots)
plt.xticks(range(len(columns)), columns)
xmin, xmax = plt.xlim()
plt.xlim(xmin - 0.3, xmax + 0.3)  # make some room to show the jittered dots
cbar = plt.colorbar()
plt.show()
```

Body:
Here is my code (adapted from here):

df_1 = pd.DataFrame({'Cells' : np.arange(0,100), 'Delta_7' : np.random.rand(100,), 'Delta_10' : np.random.rand(100,), 'Delta_14' : np.random.rand(100,)}, columns = ['Cells','Delta_7', 'Delta_10', 'Delta_14'])

#figure
fig, ax1 = plt.subplots()
fig.set_size_inches(13, 10)

#c sequence
c = df_1['Delta_7']

#plot

plt.scatter(np.full((len(df_1), 1), 1), df_1['Delta_7'] , s = 50, c=c, cmap = 'viridis')
plt.scatter(np.full((len(df_1), 1), 2), df_1['Delta_10'] , s = 50, c=c, cmap = 'viridis')
plt.scatter(np.full((len(df_1), 1), 3), df_1['Delta_14'] , s = 50, c=c, cmap = 'viridis')
cbar = plt.colorbar()

I would like to make a beautiful jitterplot (like on R or seaborn) with matplotlib. The thing is that I would like to give each cell a color based on its 'Delta_7' value. And this color would be kept when plotting 'Delta_10' and 'Delta_14', that I didn't manage to do with seaborn.
Please, could you let me know if you have any clue (python package, coding tricks …)?

Kindly,