问:
How can I get the output which displying at spyder terminal to my Interface, which is also is in "data" variable?
The list which is generating via  is in "data" which I am printing, but I want that list or 'data' on my interface "label" with scrollbar. How can I do it?

I have tried all the ways that get(), relief, etc

```<code>import tkinter as tk
from tkinter import ttk
from tkinter import *
import pandas as pd

window = tk.Tk()

#menubar = Menu(window)

window.title('Automatic Extraction Of Examiners List')
width = 500
height = 500
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
         window.geometry("%dx%d" % (width, height))
         window.resizable(1000,1000)

    #file = Menu(window,menubar,tearoff=0)
    #menubar.add_cascade(label='File',menu=file)

    window.config(bg="white")
    #
    data = pd.read_csv("E:/ResumePDF/ResumeCSVv4.csv")
    #name = tk.StringVar()
    #nameEntered = ttk.Entry(window, width = 12, textvariable =name).grid(column= 4, row = 0)

    variable = tk.StringVar()
    variable.set("Choose your subject") # default value
    w = ttk.OptionMenu(window, variable,"Choose your subject", "Big Data", "Machine Learning").place(x=200,y=50)

    def click():
        if variable.get() == "Big Data":
           #lbl = ttk.Label(window).place(x= 200, y = 150)
           print("List For Big Data Examiners: \n")
           data.sort_values("BigData", ascending=False, inplace=True)
           print(data[['Name','Email']],"\n")
           #res = "This is a one"+ print(data1)
           #lbl.config(text=data1)
           lbl.data.get()
           #r = 0
           #for col in data:
                #c = 0
                #for row in col:
             # i've added some styling
                     #label = ttk.Label(window, width = 10, height = 2, text =
                     row, relief = ttk.RIDGE)
                     #label.grid(row = 50, column = 100)
                     #c += 1
                #r += 1

        elif variable.get() == "Machine Learning":
            print("List For Machine Learning Examiners: \n")
            data.sort_values("MachineLearning", ascending=False, inplace=True)
            print(data[['Name','Email']],"\n")

    button = ttk.Button(window, text = "SHOW", command=click).place(x = 150 , y = 100)
    button1 = ttk.Button(window, text = "EXIT", command=window.destroy).place(x=300,y=100)
    lbl = ttk.Label(window).place(x= 200, y = 150)

    window.mainloop()
</code>```

When code comes to this line "lbl.data.get()"

Exception in Tkinter callback
      lbl.data.get() AttributeError: 'NoneType' object has no attribute 'data'

答:
lbl is a tkinter Label, which does not have a data attribute. If you want your data in a scrollbar you can use the ListBox and Scrollbar widget instead of a single lable. You can easily add elements to it and also the user can select one of the entries.

Here is an example from this ref, how to use the scrollbar widget:

```<code>from tkinter import *

root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill = Y )

mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
   mylist.insert(END, "This is line number " + str(line))

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )

mainloop()
</code>```

Body:
The list which is generating via  is in "data" which I am printing, but I want that list or 'data' on my interface "label" with scrollbar. How can I do it?

I have tried all the ways that get(), relief, etc

import tkinter as tk
from tkinter import ttk
from tkinter import *
import pandas as pd

window = tk.Tk()

#menubar = Menu(window)

window.title('Automatic Extraction Of Examiners List')
width = 500
height = 500
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
         window.geometry("%dx%d" % (width, height))
         window.resizable(1000,1000)

    #file = Menu(window,menubar,tearoff=0)
    #menubar.add_cascade(label='File',menu=file)

    window.config(bg="white")
    #
    data = pd.read_csv("E:/ResumePDF/ResumeCSVv4.csv")
    #name = tk.StringVar()
    #nameEntered = ttk.Entry(window, width = 12, textvariable =name).grid(column= 4, row = 0)

    variable = tk.StringVar()
    variable.set("Choose your subject") # default value
    w = ttk.OptionMenu(window, variable,"Choose your subject", "Big Data", "Machine Learning").place(x=200,y=50)

    def click():
        if variable.get() == "Big Data":
           #lbl = ttk.Label(window).place(x= 200, y = 150)
           print("List For Big Data Examiners: \n")
           data.sort_values("BigData", ascending=False, inplace=True)
           print(data[['Name','Email']],"\n")
           #res = "This is a one"+ print(data1)
           #lbl.config(text=data1)
           lbl.data.get()
           #r = 0
           #for col in data:
                #c = 0
                #for row in col:
             # i've added some styling
                     #label = ttk.Label(window, width = 10, height = 2, text =
                     row, relief = ttk.RIDGE)
                     #label.grid(row = 50, column = 100)
                     #c += 1
                #r += 1

        elif variable.get() == "Machine Learning":
            print("List For Machine Learning Examiners: \n")
            data.sort_values("MachineLearning", ascending=False, inplace=True)
            print(data[['Name','Email']],"\n")

    button = ttk.Button(window, text = "SHOW", command=click).place(x = 150 , y = 100)
    button1 = ttk.Button(window, text = "EXIT", command=window.destroy).place(x=300,y=100)
    lbl = ttk.Label(window).place(x= 200, y = 150)

    window.mainloop()

When code comes to this line "lbl.data.get()"

Exception in Tkinter callback
      lbl.data.get() AttributeError: 'NoneType' object has no attribute 'data'

Body:
lbl is a tkinter Label, which does not have a data attribute. If you want your data in a scrollbar you can use the ListBox and Scrollbar widget instead of a single lable. You can easily add elements to it and also the user can select one of the entries.

Here is an example from this ref, how to use the scrollbar widget:

from tkinter import *

root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill = Y )

mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
   mylist.insert(END, "This is line number " + str(line))

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )

mainloop()


来源: stackexchange

问:
Pip - Fatal error in launcher: Unable to create process using '"'
I installed python 3.5.1 via ampps and it's working. However, when i try to use pip, i get the following message:

```<code>Fatal error in launcher: Unable to create process using '"'
</code>```

I already reinstalled ampps into a path which doesn't include any whitespaces. Note that the "python -m pip" workaround doesn't work for me too, since i get the following message everytime i use it:

```<code>C:\Users\MyUserName\Desktop\Ampps\python\python.exe: Error while finding spec for 'pip.__main__' (<class 'ImportError'>: No module named 'queue'); 'pip' is a package and cannot be directly executed
</code>```

How do i get pip to work properly? I hope, there is a way to use the pip command itself without the preceding python command.

EDIT: This is what happens, if i try to run python -c "import pip.__main__":

```<code>Traceback (most recent call last):
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\__init__.py", line 11, in <module>
    from logging.config import dictConfig as logging_dictConfig
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\config.py", line 30, in <module>
    import logging.handlers
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\handlers.py", line 28, in <module>
    import queue
ImportError: No module named 'queue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\__init__.py", line 13, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\utils\__init__.py", line 18, in <module>
    from pip.compat import console_to_str, stdlib_pkgs
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\__init__.py", line 13, in <module>
    from pip.compat.dictconfig import dictConfig as logging_dictConfig
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\dictconfig.py", line 22, in <module>
    import logging.handlers
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\handlers.py", line 28, in <module>
    import queue
ImportError: No module named 'queue'
</code>```

答:
All the above answers are of great technical help. Recently I also faced the same issue due to a blunder I did with my project.

I created venv inside my project root by issuing the command python -m venv . and then for some reason I didn't like the name of my project. So I changed it and boom.

pip started behaving erratically and I searched dozens of forums thinking some corrupt file had crept inside my python installation. I didn't find any solution there that could help me. Finally, I opened my activate.bat file to know how this script was changing my environment and there I saw the old project name mentioned. Eureka!

I reverted back to my old project name and everything became smooth. Without any reinstallation. Without any change request to office admin. Without any delay.

SOLUTION: If you have changed the name of your project after creating your venv, you might face this error. Reverting the new name into the old name will save your time and effort. Also please don't forget to upvote if this answer helped.

ContentLicense: CC BY-SA 3.0

Body:
I installed python 3.5.1 via ampps and it's working. However, when i try to use pip, i get the following message:

Fatal error in launcher: Unable to create process using '"'

I already reinstalled ampps into a path which doesn't include any whitespaces. Note that the "python -m pip" workaround doesn't work for me too, since i get the following message everytime i use it:

C:\Users\MyUserName\Desktop\Ampps\python\python.exe: Error while finding spec for 'pip.__main__' (<class 'ImportError'>: No module named 'queue'); 'pip' is a package and cannot be directly executed

How do i get pip to work properly? I hope, there is a way to use the pip command itself without the preceding python command.

EDIT: This is what happens, if i try to run python -c "import pip.__main__":

Traceback (most recent call last):
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\__init__.py", line 11, in <module>
    from logging.config import dictConfig as logging_dictConfig
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\config.py", line 30, in <module>
    import logging.handlers
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\handlers.py", line 28, in <module>
    import queue
ImportError: No module named 'queue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\__init__.py", line 13, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\utils\__init__.py", line 18, in <module>
    from pip.compat import console_to_str, stdlib_pkgs
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\__init__.py", line 13, in <module>
    from pip.compat.dictconfig import dictConfig as logging_dictConfig
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\site-packages\pip\compat\dictconfig.py", line 22, in <module>
    import logging.handlers
  File "C:\Users\MyUserName\Desktop\Ampps\python\lib\logging\handlers.py", line 28, in <module>
    import queue
ImportError: No module named 'queue'

ContentLicense: CC BY-SA 4.0


问:
async/await running on single thread
I have a console application where in some instances a user interface needs to be presented. This user interface needs to remain responsive as it will contain a loading gif, progress bar, cancel button etc. I have the following sample code:

```<code>class Program
{
    static void Main(string[] args)
    {
        DoWork().GetAwaiter().GetResult();
    }

    private static async Task DoWork()
    {
        TestForm form = new TestForm();
        form.Show();

        string s = await Task.Run(() =>
        {
            System.Threading.Thread.Sleep(5000);
            return "Plop";
        });

        if (s == "Plop")
        {
            form.Close();
        }
    }
}
</code>```

I would expect from the code above for the TestForm to be displayed for approximately 5 seconds before being closed due to the value of the string being "Plop", however all that happens is the Task is run and the if statement is never reached. Furthermore the UI of the TestForm does not remain responsive. What is wrong with this code?

答:
Its a classic deadlock.When your code hit await ,control goes back to main thread which is a blocking wait for DoWork GetResult(); When Task.Run thread is finished controls tries to go back to main thread but its waiting for DoWork to be finished. That is the reason last If statement never executes.

But apart from deadlock ,there is also one more issue in your code which will make your UI freeze.Its the form.Show() method.If you remove everything related to async-await and only use form ,it will still freeze.The problem is Show method expects a windows message loop which will be provided if you create a Windows.Forms application but here you are launching form from console application which doesnt have a message loop. One solution would be to use form.ShowDialog which will create its own message loop. Another solution is to use System.Windows.Forms.Application.Run method which provides a win messages loop to the form created through thread pool thread. I can give you one possible solution here but its up to you how you structure your code as the root cause is identified.

```<code>static void Main(string[] args)
    {
        TestForm form = new TestForm();
        form.Load += Form_Load;

        Application.Run(form);

    }

    private static async void Form_Load(object sender, EventArgs e)
    {
        var form = sender as Form;
        string s = await Task.Run(() =>
        {
            System.Threading.Thread.Sleep(5000);
            return "Plop";
        });

        if (s == "Plop")
        {
            form?.Close();
        }
    }
</code>```

Title: async/await running on single thread

Body:
I have a console application where in some instances a user interface needs to be presented. This user interface needs to remain responsive as it will contain a loading gif, progress bar, cancel button etc. I have the following sample code:

class Program
{
    static void Main(string[] args)
    {
        DoWork().GetAwaiter().GetResult();
    }

    private static async Task DoWork()
    {
        TestForm form = new TestForm();
        form.Show();

        string s = await Task.Run(() =>
        {
            System.Threading.Thread.Sleep(5000);
            return "Plop";
        });

        if (s == "Plop")
        {
            form.Close();
        }
    }
}

I would expect from the code above for the TestForm to be displayed for approximately 5 seconds before being closed due to the value of the string being "Plop", however all that happens is the Task is run and the if statement is never reached. Furthermore the UI of the TestForm does not remain responsive. What is wrong with this code?

Body:
Its a classic deadlock.When your code hit await ,control goes back to main thread which is a blocking wait for DoWork GetResult(); When Task.Run thread is finished controls tries to go back to main thread but its waiting for DoWork to be finished. That is the reason last If statement never executes.

But apart from deadlock ,there is also one more issue in your code which will make your UI freeze.Its the form.Show() method.If you remove everything related to async-await and only use form ,it will still freeze.The problem is Show method expects a windows message loop which will be provided if you create a Windows.Forms application but here you are launching form from console application which doesnt have a message loop. One solution would be to use form.ShowDialog which will create its own message loop. Another solution is to use System.Windows.Forms.Application.Run method which provides a win messages loop to the form created through thread pool thread. I can give you one possible solution here but its up to you how you structure your code as the root cause is identified.

static void Main(string[] args)
    {
        TestForm form = new TestForm();
        form.Load += Form_Load;

        Application.Run(form);

    }

    private static async void Form_Load(object sender, EventArgs e)
    {
        var form = sender as Form;
        string s = await Task.Run(() =>
        {
            System.Threading.Thread.Sleep(5000);
            return "Plop";
        });

        if (s == "Plop")
        {
            form?.Close();
        }
    }


问:
Consolidate array of numbers without exceeding a predefined maximum value per element
I'm trying to combine numbers in an array by adding them so that the max value can only by 30.

For example, this is my array:

```<code>array(10,30,10,10,15);
</code>```

After combining the numbers in the array to items with a max value 30, the result should be:

```<code>array(30,30,15);
</code>```

How to achieve this?

答:
```<code>$total = array_sum(array(10,30,10,10,15)); //assign sum totals from orignal array
$maxValue = 30; //assign max value allowed in array
$numberOfWholeOccurancesOfMaxValue = floor($total/$maxValue);
$remainder = $total%$maxValue;

//build array
$i=0;
while ( $i < $numberOfWholeOccurancesOfMaxValue ){
    $array[] = $maxValue;
    $i++;
}

$array[] = $remainder;

print_r($array);
</code>```

Body:
I'm trying to combine numbers in an array by adding them so that the max value can only by 30.

For example, this is my array:

array(10,30,10,10,15);

After combining the numbers in the array to items with a max value 30, the result should be:

array(30,30,15);

How to achieve this?


问:
How can i fix the dropdown menu when i scroll down on phone it goes away
On Windows small screen it works but on phone it goes away, I tried so many things but I can't find something to fix, or way to go around.

https://meedia-testomgeving.nu/index.html

I have followed a guides. and some youtube video's but it didnt work. About navigation menu. I don't know what kind of code I used it some time ago.

HTML

```<code><!doctype html>
<html>
<header>
<nav id="cssmenu">
<div class="logo"><img src="Meedia Producten PC & Hardware/Background/Home Page&Favicon&Footer/Meedia LOGO.png"></div>
<div id="head-mobile"></div>
<div class="button-nav"></div>
<ul>
<li class="active"><a href="index.html">HOME</a></li>
<li><a href="Over ons.html">OVER ONS</a>
   <ul>
       <li><a href="Voor Ouders.html" target="">Voor Ouders</a></li>
         <ul>
         </ul>
      </li>
             <li><a href="Voor Hulpverleners.html" target="">Voor Hulpverleners</a></li>
         <ul>
         </ul>
       </li>
   </ul>
</li>
<li><a href="Meedoen met meedia.html">MEEDOEN MET MEEDIA</a>
   <ul>
       <li><a href="ICT & Multimedia.html" target="">ICT & Multimedia</a></li>
         <ul>
         </ul>
      </li>
           <li><a href="Fashion & Lifestyle.html" target="">Fashion & Lifestyle</a></li>
         <ul>
         </ul>
      </li>

             <li><a href="Onderwijs Ondersteuning.html" target="">Onderwijs Ondersteuning</a></li>
         <ul>
         </ul>
       </li>
   </ul>
</li>
<li><a href="Producten.html">PRODUCTEN</a>
   <ul>
      <li><a href="PC & Hardware.html" target="">PC & Hardware</a>
         <ul>
            <li><a href="Meedia Market PC.html" target="_blank">PC</a></li>
            <li><a href="Meedia Market Laptop.html" target="_blank">Laptop</a></li>
            <li><a href="Meedia Market Monitoren.html" target="_blank">Monitoren</a></li>
            <li><a href="Meedia Market Randapparatuur.html" target="_blank">Randapparatuur</a></li>
            <li><a href="Meedia Market Hardware.html" target="_blank">Hardware</a></li>
            <li><a href="Meedia Market Onderdelen.html" target="_blank">Onderdelen</a></li>
            <li><a href="Meedia Market Netwerk.html" target="_blank">Netwerk</a></li>
            <li><a href="Meedia Market Printers.html" target="_blank">Printers</a></li>
         </ul>
      </li>
      <li><a href="Market Fashion & Lifestyle.html">Fashion & LifeStyle</a>
         <ul>
            <li><a href="Meedia Market Kasten.html" target="_blank">Kasten</a></li>
            <li><a href="Meedia Market Lampen.html" target="_blank">Lampen</a></li>
            <li><a href="Meedia Market Manden.html" target="_blank">Manden</a></li>
            <li><a href="Meedia Market Stoelen.html" target="_blank">Stoelen</a></li>
            <li><a href="Meedia Market Iets aan de wand.html" target="_blank">iets aan de Wand</a></li>
            <li><a href="Meedia Market sign borden.html" target="_blank">Sign Borden</a></li>
            <li><a href="Meedia Market Boekjes.html" target="_blank">Boekjes</a></li>
            <li><a href="Meedia Market Kleding.html" target="_blank">Kleding</a></li>
         </ul>
       </li>
   </ul>
</li>
<li><a href="Nieuws.html" target="">NIEUWS</a></li>
<li><a href="Foto's.html" target="">FOTO'S</a></li>
<li><a href="Contact.html">CONTACT</a>

  <ul>
       <li><a href="Contactformulier.html" target="">Contactformulier</a></li>
         <ul>
         </ul>
      </li>
         <ul>
         </ul>
      </li>
</ul>
</nav>

</header>
</code>```

CSS

```<code>*{margin:0;padding:0;text-decoration:none}
body{background:url(Images/.jpg)}
header{position:relative;width:100%;background:#333;}
.logo{position:relative;z-index:123;padding:10px;font:18px verdana;color:#31a3dd;float:left;width:19%}
.logo a{color:#31a3dd;}
nav{position:relative;width:1010px;margin:0 auto;}
#cssmenu,#cssmenu ul,#cssmenu ul li,#cssmenu ul li a,#cssmenu #head-mobile{border:0;list-style:none;line-height:1;display:block;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
#cssmenu:after,#cssmenu > ul:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}
#cssmenu #head-mobile{display:none}
#cssmenu{font-family:sans-serif;background:#333}
#cssmenu > ul > li{float:left}
#cssmenu > ul > li > a{padding:17px;font-size:12px;letter-spacing:1px;text-decoration:none;color:#FFFFFF;font-weight:700;}
#cssmenu > ul > li:hover > a,#cssmenu ul li.active a{color:#fff}
#cssmenu > ul > li:hover,#cssmenu ul li.active:hover,#cssmenu ul li.active,#cssmenu ul li.has-sub.active:hover{background:#31a3dd!important;-webkit-transition:background .3s ease;-ms-transition:background .3s ease;transition:background .3s ease;}
#cssmenu > ul > li.has-sub > a{padding-right:30px}
#cssmenu > ul > li.has-sub > a:after{position:absolute;top:22px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu > ul > li.has-sub > a:before{position:absolute;top:19px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu > ul > li.has-sub:hover > a:before{top:23px;height:0}
#cssmenu ul ul{position:absolute;left:-9999px}
#cssmenu ul ul li{height:0;-webkit-transition:all .25s ease;-ms-transition:all .25s ease;background:#333;transition:all .25s ease}
#cssmenu ul ul li:hover{}
#cssmenu li:hover > ul{left:auto}
#cssmenu li:hover > ul > li{height:35px}
#cssmenu ul ul ul{margin-left:100%;top:0}
#cssmenu ul ul li a{border-bottom:1px solid rgba(150,150,150,0.15);padding:11px 15px;width:170px;font-size:12px;text-decoration:none;color:#FFFFFF;font-weight:400;}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a{border-bottom:0}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover{color:#fff}
#cssmenu ul ul li.has-sub > a:after{position:absolute;top:16px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu ul ul li.has-sub > a:before{position:absolute;top:13px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu ul ul > li.has-sub:hover > a:before{top:17px;height:0}
#cssmenu ul ul li.has-sub:hover,#cssmenu ul li.has-sub ul li.has-sub ul li:hover{background:#363636;}
#cssmenu ul ul ul li.active a{border-left:1px solid #333}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active> a{border-top:1px solid #333}

@media screen and (max-width:1000px){
.logo{position:absolute;top:0;left: 0;width:100%;height:46px;text-align:center;padding:10px 0 0 0 ;float:none}
.logo2{display:none}
nav{width:100%;}
#cssmenu{width:100%}
#cssmenu ul{width:100%;display:none}
#cssmenu ul li{width:100%;border-top:1px solid #444}
#cssmenu ul li:hover{background:#363636;}
#cssmenu ul ul li,#cssmenu li:hover > ul > li{height:auto}
#cssmenu ul li a,#cssmenu ul ul li a{width:100%;border-bottom:0}
#cssmenu > ul > li{float:none}
#cssmenu ul ul li a{padding-left:25px}
#cssmenu ul ul li{background:#333!important;}
#cssmenu ul ul li:hover{background:#363636!important}
#cssmenu ul ul ul li a{padding-left:35px}
#cssmenu ul ul li a{color:#FFFFFF;background:none}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a{color:#fff}
#cssmenu ul ul,#cssmenu ul ul ul{position:relative;left:0;width:100%;margin:0;text-align:left}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before{display:none}
#cssmenu #head-mobile{display:block;padding:23px;color:#FFFFFF;font-size:12px;font-weight:700}
.button-nav{width:55px;height:46px;position:absolute;right:0;top:0;cursor:pointer;z-index: 12399994;}
.button-nav:after{position:absolute;top:22px;right:20px;display:block;height:4px;width:20px;border-top:2px solid #FFFFFF;border-bottom:2px solid #FFFFFF;content:''}
.button-nav:before{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;position:absolute;top:16px;right:20px;display:block;height:2px;width:20px;background:#FFFFFF;content:''}
.button-nav.menu-opened:after{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;top:23px;border:0;height:2px;width:19px;background:#fff;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}
.button-nav.menu-opened:before{top:23px;background:#fff;width:19px;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}
#cssmenu .submenu-button-nav{position:absolute;z-index:99;right:0;top:0;display:block;border-left:1px solid #444;height:46px;width:46px;cursor:pointer}
#cssmenu .submenu-button-nav.submenu-opened{background:#262626}
#cssmenu ul ul .submenu-button-nav{height:34px;width:34px}
#cssmenu .submenu-button-nav:after{position:absolute;top:22px;right:19px;width:8px;height:2px;display:block;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:after{top:15px;right:13px}
#cssmenu .submenu-button-nav.submenu-opened:after{background:#fff}
#cssmenu .submenu-button-nav:before{position:absolute;top:19px;right:22px;display:block;width:2px;height:8px;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:before{top:12px;right:16px}
#cssmenu .submenu-button-nav.submenu-opened:before{display:none}
#cssmenu ul ul ul li.active a{border-left:none}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active > a{border-top:none}
}

#cssmenu{
z-index: 1000;
position:relative;
}

#cssmnu {
  opacity: 1.1;
}
</code>```

JQuery

```<code>(function($) {
$.fn.menumaker = function(options) {
 var cssmenu = $(this), settings = $.extend({
   format: "dropdown",
   sticky: false
 }, options);
 return this.each(function() {
   $(this).find(".button-nav").on('click', function(){
     $(this).toggleClass('menu-opened');
     var mainmenu = $(this).next('ul');
     if (mainmenu.hasClass('open')) {
       mainmenu.slideToggle().removeClass('open');
     }
     else {
       mainmenu.slideToggle().addClass('open');
       if (settings.format === "dropdown") {
         mainmenu.find('ul').show();
       }
     }
   });
   cssmenu.find('li ul').parent().addClass('has-sub');
multiTg = function() {
     cssmenu.find(".has-sub").prepend('<span class="submenu-button-nav"></span>');
     cssmenu.find('.submenu-button-nav').on('click', function() {
       $(this).toggleClass('submenu-opened');
       if ($(this).siblings('ul').hasClass('open')) {
         $(this).siblings('ul').removeClass('open').slideToggle();
       }
       else {
         $(this).siblings('ul').addClass('open').slideToggle();
       }
     });
   };
   if (settings.format === 'multitoggle') multiTg();
   else cssmenu.addClass('dropdown');
   if (settings.sticky === true) cssmenu.css('position', 'fixed');
resizeFix = function() {
  var mediasize = 1000;
     if ($( window ).width() > mediasize) {
       cssmenu.find('ul').show();
     }
     if ($(window).width() <= mediasize) {
       cssmenu.find('ul').hide().removeClass('open');
     }
   };
   resizeFix();
   return $(window).on('resize', resizeFix);
 });
  };
})(jQuery);

(function($){
$(document).ready(function(){
$("#cssmenu").menumaker({
   format: "multitoggle"
});
});
})(jQuery);

</code>```

Thanks already

答:
I've changed it like this but stil it didn't work

CSS

```<code>*{margin:0;padding:0;text-decoration:none}
body{background:url(Images/.jpg)}
header{position:relative;width:100%;background:#333;}
.logo{position:relative;z-index:123;padding:10px;font:18px verdana;color:#31a3dd;float:left;width:19%}
.logo a{color:#31a3dd;}
nav{position:relative;width:1010px;margin:0 auto;}
#cssmenu,#cssmenu ul,#cssmenu ul li,#cssmenu ul li a,#cssmenu #head-mobile{border:0;list-style:none;line-height:1;display:block;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
#cssmenu:after,#cssmenu > ul:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}
#cssmenu #head-mobile{display:none}
#cssmenu{font-family:sans-serif;background:#333}
#cssmenu > ul > li{float:left}
#cssmenu > ul > li > a{padding:17px;font-size:12px;letter-spacing:1px;text-decoration:none;color:#FFFFFF;font-weight:700;}
#cssmenu > ul > li:hover > a,#cssmenu ul li.active a{color:#fff}
#cssmenu > ul > li:hover,#cssmenu ul li.active:hover,#cssmenu ul li.active,#cssmenu ul li.has-sub.active:hover{background:#31a3dd!important;-webkit-transition:background .3s ease;-ms-transition:background .3s ease;transition:background .3s ease;}
#cssmenu > ul > li.has-sub > a{padding-right:30px}
#cssmenu > ul > li.has-sub > a:after{position:absolute;top:22px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu > ul > li.has-sub > a:before{position:absolute;top:19px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu > ul > li.has-sub:hover > a:before{top:23px;height:0}
#cssmenu ul ul{position:absolute;left:-9999px}
#cssmenu ul ul li{height:0;-webkit-transition:all .25s ease;-ms-transition:all .25s ease;background:#333;transition:all .25s ease}
#cssmenu ul ul li:hover{}
#cssmenu li:hover > ul{left:auto}
#cssmenu li:hover > ul > li{height:35px}
#cssmenu ul ul ul{margin-left:100%;top:0}
#cssmenu ul ul li a{border-bottom:1px solid rgba(150,150,150,0.15);padding:11px 15px;width:170px;font-size:12px;text-decoration:none;color:#FFFFFF;font-weight:400;}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a{border-bottom:0}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover{color:#fff}
#cssmenu ul ul li.has-sub > a:after{position:absolute;top:16px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu ul ul li.has-sub > a:before{position:absolute;top:13px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu ul ul > li.has-sub:hover > a:before{top:17px;height:0}
#cssmenu ul ul li.has-sub:hover,#cssmenu ul li.has-sub ul li.has-sub ul li:hover{background:#363636;}
#cssmenu ul ul ul li.active a{border-left:1px solid #333}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active> a{border-top:1px solid #333}

@media screen and (max-width:1000px){
.logo{position:absolute;top:0;left: 0;width:100%;height:46px;text-align:center;padding:10px 0 0 0 ;float:none}
.logo2{display:none}
nav{width:100%;}
#cssmenu{width:100%}
#cssmenu ul{width:100%;display:none}
#cssmenu ul li{width:100%;border-top:1px solid #444}
#cssmenu ul li:hover{background:#363636;}
#cssmenu ul ul li,#cssmenu li:hover > ul > li{height:auto}
#cssmenu ul li a,#cssmenu ul ul li a{width:100%;border-bottom:0}
#cssmenu > ul > li{float:none}
#cssmenu ul ul li a{padding-left:25px}
#cssmenu ul ul li{background:#333!important;}
#cssmenu ul ul li:hover{background:#363636!important}
#cssmenu ul ul ul li a{padding-left:35px}
#cssmenu ul ul li a{color:#FFFFFF;background:none}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a{color:#fff}
#cssmenu ul ul,#cssmenu ul ul ul{position:relative;left:0;width:100%;margin:0;text-align:left}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before{display:none}
#cssmenu #head-mobile{display:block;padding:23px;color:#FFFFFF;font-size:12px;font-weight:700}
.button-nav{width:55px;height:46px;position:absolute;right:0;top:0;cursor:pointer;z-index: 12399994;}
.button-nav:after{position:absolute;top:22px;right:20px;display:block;height:4px;width:20px;border-top:2px solid #FFFFFF;border-bottom:2px solid #FFFFFF;content:''}
.button-nav:before{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;position:absolute;top:16px;right:20px;display:block;height:2px;width:20px;background:#FFFFFF;content:''}
.button-nav.menu-opened:after{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;top:23px;border:0;height:2px;width:19px;background:#fff;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}
.button-nav.menu-opened:before{top:23px;background:#fff;width:19px;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}
#cssmenu .submenu-button-nav{position:absolute;z-index:99;right:0;top:0;display:block;border-left:1px solid #444;height:46px;width:46px;cursor:pointer}
#cssmenu .submenu-button-nav.submenu-opened{background:#262626}
#cssmenu ul ul .submenu-button-nav{height:34px;width:34px}
#cssmenu .submenu-button-nav:after{position:absolute;top:22px;right:19px;width:8px;height:2px;display:block;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:after{top:15px;right:13px}
#cssmenu .submenu-button-nav.submenu-opened:after{background:#fff}
#cssmenu .submenu-button-nav:before{position:absolute;top:19px;right:22px;display:block;width:2px;height:8px;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:before{top:12px;right:16px}
#cssmenu .submenu-button-nav.submenu-opened:before{display:none}
#cssmenu ul ul ul li.active a{border-left:none}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active > a{border-top:none}
}

@media screen and (max-width:600px){
#cssmenu {
        z-index: 1000;
        position: fixed;
    }

#cssmenu{
z-index: 1000;
position:relative;
}

#cssmnu {
    opacity: 1.1;}
}

</code>```

But thanks for trying am very grateful!

Body:
On Windows small screen it works but on phone it goes away, I tried so many things but I can't find something to fix, or way to go around.

https://meedia-testomgeving.nu/index.html

I have followed a guides. and some youtube video's but it didnt work. About navigation menu. I don't know what kind of code I used it some time ago.

HTML

<!doctype html>

HOME

OVER ONS

Voor Ouders

Voor Hulpverleners

MEEDOEN MET MEEDIA

ICT & Multimedia

Fashion & Lifestyle

Onderwijs Ondersteuning

PRODUCTEN

PC & Hardware

PC

Laptop

Monitoren

Randapparatuur

Hardware

Onderdelen

Netwerk

Printers

Fashion & LifeStyle

Kasten

Lampen

Manden

Stoelen

iets aan de Wand

Sign Borden

Boekjes

Kleding

NIEUWS

FOTO'S

CONTACT

Contactformulier

CSS

*{margin:0;padding:0;text-decoration:none}
body{background:url(Images/.jpg)}
header{position:relative;width:100%;background:#333;}
.logo{position:relative;z-index:123;padding:10px;font:18px verdana;color:#31a3dd;float:left;width:19%}
.logo a{color:#31a3dd;}
nav{position:relative;width:1010px;margin:0 auto;}
#cssmenu,#cssmenu ul,#cssmenu ul li,#cssmenu ul li a,#cssmenu #head-mobile{border:0;list-style:none;line-height:1;display:block;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
#cssmenu:after,#cssmenu > ul:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}
#cssmenu #head-mobile{display:none}
#cssmenu{font-family:sans-serif;background:#333}
#cssmenu > ul > li{float:left}
#cssmenu > ul > li > a{padding:17px;font-size:12px;letter-spacing:1px;text-decoration:none;color:#FFFFFF;font-weight:700;}
#cssmenu > ul > li:hover > a,#cssmenu ul li.active a{color:#fff}
#cssmenu > ul > li:hover,#cssmenu ul li.active:hover,#cssmenu ul li.active,#cssmenu ul li.has-sub.active:hover{background:#31a3dd!important;-webkit-transition:background .3s ease;-ms-transition:background .3s ease;transition:background .3s ease;}
#cssmenu > ul > li.has-sub > a{padding-right:30px}
#cssmenu > ul > li.has-sub > a:after{position:absolute;top:22px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu > ul > li.has-sub > a:before{position:absolute;top:19px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu > ul > li.has-sub:hover > a:before{top:23px;height:0}
#cssmenu ul ul{position:absolute;left:-9999px}
#cssmenu ul ul li{height:0;-webkit-transition:all .25s ease;-ms-transition:all .25s ease;background:#333;transition:all .25s ease}
#cssmenu ul ul li:hover{}
#cssmenu li:hover > ul{left:auto}
#cssmenu li:hover > ul > li{height:35px}
#cssmenu ul ul ul{margin-left:100%;top:0}
#cssmenu ul ul li a{border-bottom:1px solid rgba(150,150,150,0.15);padding:11px 15px;width:170px;font-size:12px;text-decoration:none;color:#FFFFFF;font-weight:400;}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a{border-bottom:0}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover{color:#fff}
#cssmenu ul ul li.has-sub > a:after{position:absolute;top:16px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu ul ul li.has-sub > a:before{position:absolute;top:13px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu ul ul > li.has-sub:hover > a:before{top:17px;height:0}
#cssmenu ul ul li.has-sub:hover,#cssmenu ul li.has-sub ul li.has-sub ul li:hover{background:#363636;}
#cssmenu ul ul ul li.active a{border-left:1px solid #333}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active> a{border-top:1px solid #333}

@media screen and (max-width:1000px){
.logo{position:absolute;top:0;left: 0;width:100%;height:46px;text-align:center;padding:10px 0 0 0 ;float:none}
.logo2{display:none}
nav{width:100%;}
#cssmenu{width:100%}
#cssmenu ul{width:100%;display:none}
#cssmenu ul li{width:100%;border-top:1px solid #444}
#cssmenu ul li:hover{background:#363636;}
#cssmenu ul ul li,#cssmenu li:hover > ul > li{height:auto}
#cssmenu ul li a,#cssmenu ul ul li a{width:100%;border-bottom:0}
#cssmenu > ul > li{float:none}
#cssmenu ul ul li a{padding-left:25px}
#cssmenu ul ul li{background:#333!important;}
#cssmenu ul ul li:hover{background:#363636!important}
#cssmenu ul ul ul li a{padding-left:35px}
#cssmenu ul ul li a{color:#FFFFFF;background:none}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a{color:#fff}
#cssmenu ul ul,#cssmenu ul ul ul{position:relative;left:0;width:100%;margin:0;text-align:left}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before{display:none}
#cssmenu #head-mobile{display:block;padding:23px;color:#FFFFFF;font-size:12px;font-weight:700}
.button-nav{width:55px;height:46px;position:absolute;right:0;top:0;cursor:pointer;z-index: 12399994;}
.button-nav:after{position:absolute;top:22px;right:20px;display:block;height:4px;width:20px;border-top:2px solid #FFFFFF;border-bottom:2px solid #FFFFFF;content:''}
.button-nav:before{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;position:absolute;top:16px;right:20px;display:block;height:2px;width:20px;background:#FFFFFF;content:''}
.button-nav.menu-opened:after{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;top:23px;border:0;height:2px;width:19px;background:#fff;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}
.button-nav.menu-opened:before{top:23px;background:#fff;width:19px;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}
#cssmenu .submenu-button-nav{position:absolute;z-index:99;right:0;top:0;display:block;border-left:1px solid #444;height:46px;width:46px;cursor:pointer}
#cssmenu .submenu-button-nav.submenu-opened{background:#262626}
#cssmenu ul ul .submenu-button-nav{height:34px;width:34px}
#cssmenu .submenu-button-nav:after{position:absolute;top:22px;right:19px;width:8px;height:2px;display:block;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:after{top:15px;right:13px}
#cssmenu .submenu-button-nav.submenu-opened:after{background:#fff}
#cssmenu .submenu-button-nav:before{position:absolute;top:19px;right:22px;display:block;width:2px;height:8px;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:before{top:12px;right:16px}
#cssmenu .submenu-button-nav.submenu-opened:before{display:none}
#cssmenu ul ul ul li.active a{border-left:none}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active > a{border-top:none}
}

#cssmenu{
z-index: 1000;
position:relative;
}

#cssmnu {
  opacity: 1.1;
}

JQuery

(function($) {
$.fn.menumaker = function(options) {
 var cssmenu = $(this), settings = $.extend({
   format: "dropdown",
   sticky: false
 }, options);
 return this.each(function() {
   $(this).find(".button-nav").on('click', function(){
     $(this).toggleClass('menu-opened');
     var mainmenu = $(this).next('ul');
     if (mainmenu.hasClass('open')) {
       mainmenu.slideToggle().removeClass('open');
     }
     else {
       mainmenu.slideToggle().addClass('open');
       if (settings.format === "dropdown") {
         mainmenu.find('ul').show();
       }
     }
   });
   cssmenu.find('li ul').parent().addClass('has-sub');
multiTg = function() {
     cssmenu.find(".has-sub").prepend('');
     cssmenu.find('.submenu-button-nav').on('click', function() {
       $(this).toggleClass('submenu-opened');
       if ($(this).siblings('ul').hasClass('open')) {
         $(this).siblings('ul').removeClass('open').slideToggle();
       }
       else {
         $(this).siblings('ul').addClass('open').slideToggle();
       }
     });
   };
   if (settings.format === 'multitoggle') multiTg();
   else cssmenu.addClass('dropdown');
   if (settings.sticky === true) cssmenu.css('position', 'fixed');
resizeFix = function() {
  var mediasize = 1000;
     if ($( window ).width() > mediasize) {
       cssmenu.find('ul').show();
     }
     if ($(window).width() <= mediasize) {
       cssmenu.find('ul').hide().removeClass('open');
     }
   };
   resizeFix();
   return $(window).on('resize', resizeFix);
 });
  };
})(jQuery);

(function($){
$(document).ready(function(){
$("#cssmenu").menumaker({
   format: "multitoggle"
});
});
})(jQuery);

Thanks already

Body:
I've changed it like this but stil it didn't work

CSS

*{margin:0;padding:0;text-decoration:none}
body{background:url(Images/.jpg)}
header{position:relative;width:100%;background:#333;}
.logo{position:relative;z-index:123;padding:10px;font:18px verdana;color:#31a3dd;float:left;width:19%}
.logo a{color:#31a3dd;}
nav{position:relative;width:1010px;margin:0 auto;}
#cssmenu,#cssmenu ul,#cssmenu ul li,#cssmenu ul li a,#cssmenu #head-mobile{border:0;list-style:none;line-height:1;display:block;position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
#cssmenu:after,#cssmenu > ul:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}
#cssmenu #head-mobile{display:none}
#cssmenu{font-family:sans-serif;background:#333}
#cssmenu > ul > li{float:left}
#cssmenu > ul > li > a{padding:17px;font-size:12px;letter-spacing:1px;text-decoration:none;color:#FFFFFF;font-weight:700;}
#cssmenu > ul > li:hover > a,#cssmenu ul li.active a{color:#fff}
#cssmenu > ul > li:hover,#cssmenu ul li.active:hover,#cssmenu ul li.active,#cssmenu ul li.has-sub.active:hover{background:#31a3dd!important;-webkit-transition:background .3s ease;-ms-transition:background .3s ease;transition:background .3s ease;}
#cssmenu > ul > li.has-sub > a{padding-right:30px}
#cssmenu > ul > li.has-sub > a:after{position:absolute;top:22px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu > ul > li.has-sub > a:before{position:absolute;top:19px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu > ul > li.has-sub:hover > a:before{top:23px;height:0}
#cssmenu ul ul{position:absolute;left:-9999px}
#cssmenu ul ul li{height:0;-webkit-transition:all .25s ease;-ms-transition:all .25s ease;background:#333;transition:all .25s ease}
#cssmenu ul ul li:hover{}
#cssmenu li:hover > ul{left:auto}
#cssmenu li:hover > ul > li{height:35px}
#cssmenu ul ul ul{margin-left:100%;top:0}
#cssmenu ul ul li a{border-bottom:1px solid rgba(150,150,150,0.15);padding:11px 15px;width:170px;font-size:12px;text-decoration:none;color:#FFFFFF;font-weight:400;}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a{border-bottom:0}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover{color:#fff}
#cssmenu ul ul li.has-sub > a:after{position:absolute;top:16px;right:11px;width:8px;height:2px;display:block;background:#ffffff;content:''}
#cssmenu ul ul li.has-sub > a:before{position:absolute;top:13px;right:14px;display:block;width:2px;height:8px;background:#ffffff;content:'';-webkit-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}
#cssmenu ul ul > li.has-sub:hover > a:before{top:17px;height:0}
#cssmenu ul ul li.has-sub:hover,#cssmenu ul li.has-sub ul li.has-sub ul li:hover{background:#363636;}
#cssmenu ul ul ul li.active a{border-left:1px solid #333}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active> a{border-top:1px solid #333}

@media screen and (max-width:1000px){
.logo{position:absolute;top:0;left: 0;width:100%;height:46px;text-align:center;padding:10px 0 0 0 ;float:none}
.logo2{display:none}
nav{width:100%;}
#cssmenu{width:100%}
#cssmenu ul{width:100%;display:none}
#cssmenu ul li{width:100%;border-top:1px solid #444}
#cssmenu ul li:hover{background:#363636;}
#cssmenu ul ul li,#cssmenu li:hover > ul > li{height:auto}
#cssmenu ul li a,#cssmenu ul ul li a{width:100%;border-bottom:0}
#cssmenu > ul > li{float:none}
#cssmenu ul ul li a{padding-left:25px}
#cssmenu ul ul li{background:#333!important;}
#cssmenu ul ul li:hover{background:#363636!important}
#cssmenu ul ul ul li a{padding-left:35px}
#cssmenu ul ul li a{color:#FFFFFF;background:none}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a{color:#fff}
#cssmenu ul ul,#cssmenu ul ul ul{position:relative;left:0;width:100%;margin:0;text-align:left}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before{display:none}
#cssmenu #head-mobile{display:block;padding:23px;color:#FFFFFF;font-size:12px;font-weight:700}
.button-nav{width:55px;height:46px;position:absolute;right:0;top:0;cursor:pointer;z-index: 12399994;}
.button-nav:after{position:absolute;top:22px;right:20px;display:block;height:4px;width:20px;border-top:2px solid #FFFFFF;border-bottom:2px solid #FFFFFF;content:''}
.button-nav:before{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;position:absolute;top:16px;right:20px;display:block;height:2px;width:20px;background:#FFFFFF;content:''}
.button-nav.menu-opened:after{-webkit-transition:all .3s ease;-ms-transition:all .3s ease;transition:all .3s ease;top:23px;border:0;height:2px;width:19px;background:#fff;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}
.button-nav.menu-opened:before{top:23px;background:#fff;width:19px;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}
#cssmenu .submenu-button-nav{position:absolute;z-index:99;right:0;top:0;display:block;border-left:1px solid #444;height:46px;width:46px;cursor:pointer}
#cssmenu .submenu-button-nav.submenu-opened{background:#262626}
#cssmenu ul ul .submenu-button-nav{height:34px;width:34px}
#cssmenu .submenu-button-nav:after{position:absolute;top:22px;right:19px;width:8px;height:2px;display:block;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:after{top:15px;right:13px}
#cssmenu .submenu-button-nav.submenu-opened:after{background:#fff}
#cssmenu .submenu-button-nav:before{position:absolute;top:19px;right:22px;display:block;width:2px;height:8px;background:#FFFFFF;content:''}
#cssmenu ul ul .submenu-button-nav:before{top:12px;right:16px}
#cssmenu .submenu-button-nav.submenu-opened:before{display:none}
#cssmenu ul ul ul li.active a{border-left:none}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active > a{border-top:none}
}

@media screen and (max-width:600px){
#cssmenu {
        z-index: 1000;
        position: fixed;
    }

#cssmenu{
z-index: 1000;
position:relative;
}

#cssmnu {
    opacity: 1.1;}
}

But thanks for trying am very grateful!


问:
Dropdown selectedIndexChange Event is calling Radiobutton selectedIndexChange event.Both controls are inside repeater
Inside my repeater control I have a radiobutton list, a dropdown list and a textbox.
 On selectedIndexChange event of the radiobutton, I am binding dropdown list as my dropdown values should be different for each radiobutton option.

Until this, my functionality is working perfectly. Now I want to autopopulate the textbox value based which will be selected text of dropdown but SelectedIndexChangeEvent of dropdown is calling Radiobutton's selectedIndexChange Event.

Any help on this ?

I have Autopostback set to true of dropdown.
Dropdown selectedIndexChange event is calling radiobutton selectedindexchange Event.

Code

////////////Code Behind File //////////////

答:
```<code>Html Part of the code:

<form id="form1" runat="server">
        <div>
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table border="1">
                        <tr>
                            <th>Name</th>
                            <th>Country</th>
                            <th>City</th>
                            <th>Comments</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Label ID="lblName" Text='<%# Eval("Name") %>' runat="server" />
                        </td>
                        <td>
                            <asp:RadioButtonList ID="rblCountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rblCountry_SelectedIndexChanged">
                                <asp:ListItem Text="United States" Value="US"></asp:ListItem>
                                <asp:ListItem Text="United Kingdom" Value="UK"></asp:ListItem>
                                <asp:ListItem Text="Australia" Value="Aus"></asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
    </form>

   code behind part:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            PopulateList();
        }
    }

    private void PopulateList()
    {
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[1] { new DataColumn("Name", typeof(string))});
        dt.Rows.Add("John Hammond");
        dt.Rows.Add("Mudassar Khan");
        dt.Rows.Add("Suzanne Mathews");
        dt.Rows.Add("Robert Schidner");
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }

    protected void rblCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        RepeaterItem item = (sender as RadioButtonList).NamingContainer as RepeaterItem;
        string countryName = (item.FindControl("rblCountry") as RadioButtonList).Text;
        DropDownList ddlCity = item.FindControl("ddlCity") as DropDownList;
        TextBox txtCity = item.FindControl("txtCity") as TextBox;
        ListItem li;
        if (ddlCity != null)
        {
            ddlCity.Items.Clear();
            switch (countryName)
            {
                case "US":
                    li = new ListItem() { Text = "Chicago", Value = "Chicago" };
                    ddlCity.Items.Add(li);
                    li = new ListItem() { Text = "Washington", Value = "Washington" };
                    ddlCity.Items.Add(li);
                    break;
                case "UK":
                    li = new ListItem() { Text = "Manchester", Value = "Manchester" };
                    ddlCity.Items.Add(li);
                    li = new ListItem() { Text = "London", Value = "London" };
                    ddlCity.Items.Add(li);
                    li = new ListItem() { Text = "Scotland", Value = "Scotland" };
                    ddlCity.Items.Add(li);
                    break;
                case "Aus":
                    li = new ListItem() { Text = "Sydney", Value = "Sydney" };
                    ddlCity.Items.Add(li);
                    li = new ListItem() { Text = "Melbourne", Value = "Melbourne" };
                    ddlCity.Items.Add(li);
                    break;
            }
            if (ddlCity != null && ddlCity.SelectedItem != null)
                txtCity.Text = ddlCity.SelectedItem.Text;
        }
    }

    protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        RepeaterItem item = (sender as DropDownList).NamingContainer as RepeaterItem;
        DropDownList ddlCity = item.FindControl("ddlCity") as DropDownList;
        TextBox txtCity = item.FindControl("txtCity") as TextBox;
        txtCity.Text = ddlCity.SelectedItem.Text;
    }
</code>```


问:
Handling back button in Android Navigation Component
I'd like to know how properly handle system back button action using Navigation Controller. In my app I have two fragments (for ex. fragment1 and fragment2) and I have an action in fragment1 with destination to fragment2. Everything works well except one thing - when user presses system back button in fragment2 I want to show a dialog (using DialogFragment for example) to confirm exit. What is the best way to implement this behavior? If I use app:defaultNavHost="true" in my host fragment then it automatically goes back ignoring my rules. And, additionally, what is this component for?

Should I use "pop to" may be?

答:
The recommended approach is to add an OnBackPressedCallback to the activity's OnBackPressedDispatcher.

```<code>requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
    // handle back event
}
</code>```

Body:
The recommended approach is to add an OnBackPressedCallback to the activity's OnBackPressedDispatcher.

requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
    // handle back event
}


问:
Add a new property to an object property
I need to write new properties for the comment property without erasing it.
This is my object now:

```<code>product:
{
  name: 'name',
  briefPDescription: 'text',
  details:
   {
     about: 'text',
     description: 'text',
     comment:
     {
         "text": 'text'
     },
     subDescription: 'text'
}
</code>```

What you need to write:

```<code>author:
{
    name: 'name',
    position: 'text',
    photo: '../avatar.png'
}
</code>```

How should it be:

```<code>product:
{
  name: 'name',
  briefPDescription: 'text',
  details:
  {
     about: 'text',
     description: 'text',
     comment:
     {
         text: ''text',
         name: 'name',
         position: 'text',
         photo: '../avatar.png'
     },
     subDescription: 'text'
}
</code>```

I did this:

```<code>product.comment = author;
</code>```

But it deleted the text property.
How can I write new properties to the comment property without erasing it?

答:
here is a simple tricky function got from typescript compiler;

```<code>    var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
</code>```

Call:

```<code>product = __assign({}, product, { comment: author });
</code>```

Body:
I need to write new properties for the comment property without erasing it.
This is my object now:

product:
{
  name: 'name',
  briefPDescription: 'text',
  details:
   {
     about: 'text',
     description: 'text',
     comment:
     {
         "text": 'text'
     },
     subDescription: 'text'
}

What you need to write:

author:
{
    name: 'name',
    position: 'text',
    photo: '../avatar.png'
}

How should it be:

product:
{
  name: 'name',
  briefPDescription: 'text',
  details:
  {
     about: 'text',
     description: 'text',
     comment:
     {
         text: ''text',
         name: 'name',
         position: 'text',
         photo: '../avatar.png'
     },
     subDescription: 'text'
}

I did this:

product.comment = author;

But it deleted the text property.
How can I write new properties to the comment property without erasing it?

Body:
here is a simple tricky function got from typescript compiler;

    var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};

Call:

product = __assign({}, product, { comment: author });


问:
How to DEFLATE with a command line tool to extract a git object?
I'm looking for a command line wrapper for the DEFLATE algorithm.

I have a file (git blob) that is compressed using DEFLATE, and I want to uncompress it. The gzip command does not seem to have an option to directly use the DEFLATE algorithm, rather than the gzip format.

Ideally I'm looking for a standard Unix/Linux tool that can do this.

edit: This is the output I get when trying to use gzip for my problem:

```<code>$ cat .git/objects/c0/fb67ab3fda7909000da003f4b2ce50a53f43e7 | gunzip

gzip: stdin: not in gzip format
</code>```

答:
To add to the collection, here are perl one-liners for deflate/inflate/raw deflate/raw inflate.

Deflate

perl -MIO::Compress::Deflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Compress::Deflate::deflate(\$in, \$out); print $out;'
```
<p><strong>Inflate</strong></p>
<pre class="lang-bash prettyprint-override"><code>perl -MIO::Uncompress::Inflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Uncompress::Inflate::inflate(\$in, \$out); print $out;'
</code>```

Raw deflate

perl -MIO::Compress::RawDeflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Compress::RawDeflate::rawdeflate(\$in, \$out); print $out;'
```
<p><strong>Raw inflate</strong></p>
<pre class="lang-bash prettyprint-override"><code>perl -MIO::Uncompress::RawInflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Uncompress::RawInflate::rawinflate(\$in, \$out); print $out;'
</code>```

Body:
I'm looking for a command line wrapper for the DEFLATE algorithm.

I have a file (git blob) that is compressed using DEFLATE, and I want to uncompress it. The gzip command does not seem to have an option to directly use the DEFLATE algorithm, rather than the gzip format.

Ideally I'm looking for a standard Unix/Linux tool that can do this.

edit: This is the output I get when trying to use gzip for my problem:

$ cat .git/objects/c0/fb67ab3fda7909000da003f4b2ce50a53f43e7 | gunzip

gzip: stdin: not in gzip format

Body:
To add to the collection, here are perl one-liners for deflate/inflate/raw deflate/raw inflate.

Deflate

perl -MIO::Compress::Deflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Compress::Deflate::deflate(\$in, \$out); print $out;'

Inflate

perl -MIO::Uncompress::Inflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Uncompress::Inflate::inflate(\$in, \$out); print $out;'

Raw deflate

perl -MIO::Compress::RawDeflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Compress::RawDeflate::rawdeflate(\$in, \$out); print $out;'

Raw inflate

perl -MIO::Uncompress::RawInflate -e 'undef $/; my ($in, $out) = (<>, undef); IO::Uncompress::RawInflate::rawinflate(\$in, \$out); print $out;'


问:
VBA: How to Automatically Include Cell Borders Without Error (Runtime 1004) Line Style
So this a question about the same big project my others are.

I am now just tidying up some formatting and essentially want a sub (that I can call from another) which will automatically add the borders I need around the new data being posted to the sheet.

I recorded the macro of adding the borders (and changed the range to one that is variable - RowToPasteTo) and all was working well.

I tried to call it from another piece of code and it went haywire, now giving me an error of:

Run-Time error '1004':

Unable to set the LineStyle Property of the Borders class

As the error mentions, it seems to be an error with the .LineStyle but I am using the same style as what their recorder gave me.

How can I get this working again so that is completes all borders?

EDIT: Forgot to add the code - sorry!

```<code>Sub Borders()

Dim RowToPasteTo As Long

With Sheets(4)

 RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
 Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Select
  With Selection.Borders
    .LineStyle = xlContinuous
    .ThemeColor = 3
    .TintAndShade = -9.99786370433668E-02
    .Weight = xlThin
    End With
End With

End Sub
</code>```

EDIT 2: This piece of code is to insert the borders when each new row of data is moved to this sheet (grid marks are off, as the borders are only to be shown on the lines with data.

I have tried all amendments so far suggested and am still receiving errors when running the above code alone.

I have now also created a blank sheet (and adjusted the sheets number accordingly) and I receive a different error there.

The (minimised) code that will later call this piece if as follows:

```<code>Sub ToTank()
Dim RowToPasteTo As Long
        RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1

        Sheets(4).Unprotect
        .Range("A" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Locked = False
Call Borders()

End Sub
</code>```

答:
As said above, .Borders require at least 1 argument to work. One way to achieve what you are trying to do is:

Sub Borders()

Dim RowToPasteTo As Long

With Sheets(4)

    RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1

    For X = 1 To 4
        With .Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Borders(X)
            .LineStyle = xlContinuous
            .ColorIndex = 3
            .Weight = xlThin
        End With
    Next X
End With

End Sub
```

<p><strong>Correction</strong> as per @Damian's comment, though the above is perfectly usable as well:</p>

<pre class="lang-vb prettyprint-override"><code>Sub Borders()

Dim RowToPasteTo As Long

With Sheets("Sheet1")

    RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
    With .Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Borders
        .LineStyle = xlContinuous
        .ColorIndex = 3
        .Weight = xlThin
    End With
End With

End Sub
</code>```

See Borders for more details.

Body:
So this a question about the same big project my others are.

I am now just tidying up some formatting and essentially want a sub (that I can call from another) which will automatically add the borders I need around the new data being posted to the sheet.

I recorded the macro of adding the borders (and changed the range to one that is variable - RowToPasteTo) and all was working well.

I tried to call it from another piece of code and it went haywire, now giving me an error of:

Run-Time error '1004':

Unable to set the LineStyle Property of the Borders class

As the error mentions, it seems to be an error with the .LineStyle but I am using the same style as what their recorder gave me.

How can I get this working again so that is completes all borders?

EDIT: Forgot to add the code - sorry!

Sub Borders()

Dim RowToPasteTo As Long

With Sheets(4)

 RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
 Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Select
  With Selection.Borders
    .LineStyle = xlContinuous
    .ThemeColor = 3
    .TintAndShade = -9.99786370433668E-02
    .Weight = xlThin
    End With
End With

End Sub

EDIT 2: This piece of code is to insert the borders when each new row of data is moved to this sheet (grid marks are off, as the borders are only to be shown on the lines with data.

I have tried all amendments so far suggested and am still receiving errors when running the above code alone.

I have now also created a blank sheet (and adjusted the sheets number accordingly) and I receive a different error there.

The (minimised) code that will later call this piece if as follows:

Sub ToTank()
Dim RowToPasteTo As Long
        RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1

        Sheets(4).Unprotect
        .Range("A" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Locked = False
Call Borders()

End Sub

Body:
As said above, .Borders require at least 1 argument to work. One way to achieve what you are trying to do is:

Sub Borders()

Dim RowToPasteTo As Long

With Sheets(4)

    RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1

    For X = 1 To 4
        With .Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Borders(X)
            .LineStyle = xlContinuous
            .ColorIndex = 3
            .Weight = xlThin
        End With
    Next X
End With

End Sub

Correction as per @Damian's comment, though the above is perfectly usable as well:

Sub Borders()

Dim RowToPasteTo As Long

With Sheets("Sheet1")

    RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
    With .Range("B" & RowToPasteTo & ":" & "Z" & RowToPasteTo).Borders
        .LineStyle = xlContinuous
        .ColorIndex = 3
        .Weight = xlThin
    End With
End With

End Sub

See Borders for more details.


问:
Get-ADGroup where there are more than 500 members (including nested)
I'm trying to run a PowerShell query to bring back groups with more than 500 members in it.

I've tried to run a measure statement & count -gt 500

Get-ADGroup  -Filter {name -like "Distribution*"} -Properties * |
    measure |
    where count -gt 100 |
    select name
```

I'd like this to bring back just group names that have > 500 members in it.

答:
This won't be especially quick but you can run this to get an output of each group and a count of how many members there are. The where statement at the end will only output those with more than or equal to 500 members.</p>

```<code>Get-ADGroup -Filter * | select Name, @{n="Count";e={(Get-ADGroupMember $_.samaccountname -Recursive).count}} | ? Count -ge 500
</code>```

Body:
I'm trying to run a PowerShell query to bring back groups with more than 500 members in it.

I've tried to run a measure statement & count -gt 500

Get-ADGroup  -Filter {name -like "Distribution*"} -Properties * |
    measure |
    where count -gt 100 |
    select name

I'd like this to bring back just group names that have > 500 members in it.

Body:
This won't be especially quick but you can run this to get an output of each group and a count of how many members there are. The where statement at the end will only output those with more than or equal to 500 members.

Get-ADGroup -Filter * | select Name, @{n="Count";e={(Get-ADGroupMember $_.samaccountname -Recursive).count}} | ? Count -ge 500


问:
Select only the first row when merging data frames with multiple matches
I have two data frames, "data" and "scores", and want to merge them on the "id" column:

```<code>data = data.frame(id = c(1,2,3,4,5),
                  state = c("KS","MN","AL","FL","CA"))
scores = data.frame(id = c(1,1,1,2,2,3,3,3),
                    score = c(66,75,78,86,85,76,75,90))
merge(data, scores, by = "id")
semi_join(data, scores, by = "id")
</code>```

In the "scores" data, there are "id" with multiple observations, where each match gets a row following the join. See ?merge:

If there is more than one match, all possible matches contribute one row each.

However, I want keep only the row corresponding to the first match from the scores table.

A semi join would have been nice, but I'm not able to select the score from the right table.

Any suggestions?

答:
In base you can use match to Select only the first row when merging data frames with multiple matches.

```<code>#Return also those which found no match
(tt <- cbind(data, score=scores[match(data$id, scores$id),"score"]))
#  id state score
#1  1    KS    66
#2  2    MN    86
#3  3    AL    76
#4  4    FL    NA
#5  5    CA    NA

#Return only those which found a match
tt[!is.na(tt$score),]
#  id state score
#1  1    KS    66
#2  2    MN    86
#3  3    AL    76
</code>```

Body:
I have two data frames, "data" and "scores", and want to merge them on the "id" column:

data = data.frame(id = c(1,2,3,4,5),
                  state = c("KS","MN","AL","FL","CA"))
scores = data.frame(id = c(1,1,1,2,2,3,3,3),
                    score = c(66,75,78,86,85,76,75,90))
merge(data, scores, by = "id")
semi_join(data, scores, by = "id")

In the "scores" data, there are "id" with multiple observations, where each match gets a row following the join. See ?merge:

If there is more than one match, all possible matches contribute one row each.

However, I want keep only the row corresponding to the first match from the scores table.

A semi join would have been nice, but I'm not able to select the score from the right table.

Any suggestions?

Body:
In base you can use match to Select only the first row when merging data frames with multiple matches.

#Return also those which found no match
(tt <- cbind(data, score=scores[match(data$id, scores$id),"score"]))
#  id state score
#1  1    KS    66
#2  2    MN    86
#3  3    AL    76
#4  4    FL    NA
#5  5    CA    NA

#Return only those which found a match
tt[!is.na(tt$score),]
#  id state score
#1  1    KS    66
#2  2    MN    86
#3  3    AL    76


问:
Getting newly inserted id as empty string when I add SET NAMES to my insert statement
I have following program which insert emoji and any text to my MySql AWS Database. I was unable to add Emojis in my MySql database, but then i fixed this problem by changing collation and adding this-> SET NAMES utf8mb4; query before my previous insert query but now i am unable to get last inserted id from it. what should i do in order to insert emoji as well as to get last inserted id from it.

Here is my code.

```<code>public static JSONObject emoji(String comment) {
        JSONObject json = new JSONObject();
        Connection con = null;
        PreparedStatement stmt = null;
        String newInsertId = "";
        try {
            BasicDataSource bds = DBConnection.getInstance().getBds();
            con = bds.getConnection();
            String query = "SET NAMES utf8mb4; insert into emojis set message = '" + comment + "';";
            stmt = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            if (stmt.executeUpdate() > 0) {
                json.put("success", 1);
            }
            ResultSet rs = stmt.getGeneratedKeys();
            if (rs.next()) {
                newInsertId = rs.getString(1); //giving empty values cause of that SET NAMES utf8mb4; query
            }
            System.out.println(newInsertId); //empty
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
        try {
            DbUtils.close(con);
            DbUtils.close(stmt);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
        return json;
    }
</code>```

答:
```<code>static int create() throws SQLException {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        // 2.建立连接
        conn = JdbcUtils.getConnection();
        // conn = JdbcUtilsSing.getInstance().getConnection();
        // 3.创建语句
        String sql = "insert into user(name,birthday, money) values ('name2 gk', '1987-01-01', 400) ";
        ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);//参数2最好写上，虽然Mysql不写也能获取但是不代表别的数据库可以做到
        ps.executeUpdate();

        rs = ps.getGeneratedKeys();
        int id = 0;
        if (rs.next())
            id = rs.getInt(1);
        return id;
    } finally {
        JdbcUtils.free(rs, ps, conn);
    }
}
</code>```

<p>——————————————————————————————————————————————————————</p>

```<code>Focus on this 'Statement.RETURN_GENERATED_KEYS'
</code>```

Body:
I have following program which insert emoji and any text to my MySql AWS Database. I was unable to add Emojis in my MySql database, but then i fixed this problem by changing collation and adding this-> SET NAMES utf8mb4; query before my previous insert query but now i am unable to get last inserted id from it. what should i do in order to insert emoji as well as to get last inserted id from it.

Here is my code.

public static JSONObject emoji(String comment) {
        JSONObject json = new JSONObject();
        Connection con = null;
        PreparedStatement stmt = null;
        String newInsertId = "";
        try {
            BasicDataSource bds = DBConnection.getInstance().getBds();
            con = bds.getConnection();
            String query = "SET NAMES utf8mb4; insert into emojis set message = '" + comment + "';";
            stmt = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            if (stmt.executeUpdate() > 0) {
                json.put("success", 1);
            }
            ResultSet rs = stmt.getGeneratedKeys();
            if (rs.next()) {
                newInsertId = rs.getString(1); //giving empty values cause of that SET NAMES utf8mb4; query
            }
            System.out.println(newInsertId); //empty
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
        try {
            DbUtils.close(con);
            DbUtils.close(stmt);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
        return json;
    }

Body:
static int create() throws SQLException {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        // 2.建立连接
        conn = JdbcUtils.getConnection();
        // conn = JdbcUtilsSing.getInstance().getConnection();
        // 3.创建语句
        String sql = "insert into user(name,birthday, money) values ('name2 gk', '1987-01-01', 400) ";
        ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);//参数2最好写上，虽然Mysql不写也能获取但是不代表别的数据库可以做到
        ps.executeUpdate();

        rs = ps.getGeneratedKeys();
        int id = 0;
        if (rs.next())
            id = rs.getInt(1);
        return id;
    } finally {
        JdbcUtils.free(rs, ps, conn);
    }
}

——————————————————————————————————————————————————————

Focus on this 'Statement.RETURN_GENERATED_KEYS'


问:
Android Google Sign In Failed com.google.android.gms.common.api.ApiException: 12500
So I'm trying to use Google Sign In Authentication using Firebase as provide by this link :
https://firebase.google.com/docs/auth/android/google-signin?hl=en

I followed every single step including putting my SHA-1 Fingerprint into the firebase project. I'm currently on debug mode so I only have one SHA-1 Fingerprint.

Here's my code:

```<code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.client_id))
            .requestEmail()
            .build();

    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

    mAuth = FirebaseAuth.getInstance();

    LinearLayout gLog = (LinearLayout) findViewById(R.id.googleLogin);
    gLog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            signIn();
        }
    });

}

private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w("Error", "Google sign in failed", e);
            // ...
        }
    }
}

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d("Akun", "firebaseAuthWithGoogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d("MsgFirebase", "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        Intent i = new Intent(login_activity.this, main_activity.class);
                        i.putExtra("nama", user.getDisplayName());
                        i.putExtra("email", user.getEmail());
                        startActivity(i);
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w("MsgFirebase", "signInWithCredential:failure", task.getException());
                    }

                    // ...
                }
            });
}
</code>```

And here's the error that I got :

```<code>com.google.android.gms.common.api.ApiException: 12500:
    at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
    at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
    at com.mfs.rumah_duka.login_activity.onActivityResult(login_activity.java:112)
    at android.app.Activity.dispatchActivityResult(Activity.java:6562)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3752)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3799)
    at android.app.ActivityThread.access$1500(ActivityThread.java:154)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5555)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:118)
</code>```

I tried to check if the resultCode from the SigningIntent is success. It turns our it's not Activity.RESULT_OK.
I got the error right after I choose an account on the Sign In window.

Solutions that I've tried :

Changed web client ID in the Firebase Google Sign In setting to the
one from my Oath credential in my Cloud Console

Updated my gms service library to the latest version (According to Google Sign In error 12500)

Create an OAuth for Android in my Cloud Console

None of those gave me a solution. I tried to read the documentation as to what error code 12500 means but it seems there's no specific cause. It says that try to use another email and it's still the same.

Does anybody has any solution to this?

答: When your app authenticates with a backend server or accesses Google APIs from your backend server, then you must pass the OAuth 2.0 client ID that was created for your server to the requestIdToken method when you construct the GoogleSignInOptions object, for accessing the user's basic profile information. Also, don't forget to submit the support email in the OAuth consent screen found in the Credentials page in the API Console.</p>

Body:
So I'm trying to use Google Sign In Authentication using Firebase as provide by this link :
https://firebase.google.com/docs/auth/android/google-signin?hl=en

I followed every single step including putting my SHA-1 Fingerprint into the firebase project. I'm currently on debug mode so I only have one SHA-1 Fingerprint.

Here's my code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.client_id))
            .requestEmail()
            .build();

    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

    mAuth = FirebaseAuth.getInstance();

    LinearLayout gLog = (LinearLayout) findViewById(R.id.googleLogin);
    gLog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            signIn();
        }
    });

}

private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w("Error", "Google sign in failed", e);
            // ...
        }
    }
}

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d("Akun", "firebaseAuthWithGoogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d("MsgFirebase", "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        Intent i = new Intent(login_activity.this, main_activity.class);
                        i.putExtra("nama", user.getDisplayName());
                        i.putExtra("email", user.getEmail());
                        startActivity(i);
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w("MsgFirebase", "signInWithCredential:failure", task.getException());
                    }

                    // ...
                }
            });
}

And here's the error that I got :

com.google.android.gms.common.api.ApiException: 12500:
    at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
    at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
    at com.mfs.rumah_duka.login_activity.onActivityResult(login_activity.java:112)
    at android.app.Activity.dispatchActivityResult(Activity.java:6562)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3752)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3799)
    at android.app.ActivityThread.access$1500(ActivityThread.java:154)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5555)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:118)

I tried to check if the resultCode from the SigningIntent is success. It turns our it's not Activity.RESULT_OK.
I got the error right after I choose an account on the Sign In window.

Solutions that I've tried :

Changed web client ID in the Firebase Google Sign In setting to the
one from my Oath credential in my Cloud Console

Updated my gms service library to the latest version (According to Google Sign In error 12500)

Create an OAuth for Android in my Cloud Console

None of those gave me a solution. I tried to read the documentation as to what error code 12500 means but it seems there's no specific cause. It says that try to use another email and it's still the same.

Does anybody has any solution to this?


问:
AttributeError: 'bytes' object has no attribute 'status'
I was following ex52 LPTHW and tired nosetests on all the tests in test folder, got the following error:

```<code>Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/bijing/projects/gothonweb/tests/app_tests.py", line 17, in test_game
    assert_response(resp.data)
  File "/Users/bijing/projects/gothonweb/tests/tools.py", line 5, in assert_response
    assert status in resp.status,"Excepted response %r not in %r" %(status,resp.status)
AttributeError: 'bytes' object has no attribute 'status'
</code>```

app.py

```<code>
urls=(
    '/game','GameEngine',
    '/','Index',
)

app=web.application(urls,globals())

#title hack so that debug mode works with sessions
if web.config.get('_session')is None:
    store=web.session.DiskStore('sessions')
    session=web.session.Session(app,store,initializer={'room':None})
    web.config._session=session
else:
    session=web.config_session

render=web.template.render('templates/',base="layout")

class Index(object):
    def GET(self):
        #this is used to "setup" the session with starting values
        session.room=map.START
        web.seeother("/game")

class GameEngine(object):
    def GET(self):
        if session.room:
            return render.show_room(room=session.room)
        else:
            #Why is there here?do you need it?
            return render.you_died()
    def POST(self):
        form=web.input(action=None)
        #there is a bug here,can you fix it?
        if session.room and form.action:
            session.room=session.room.go(form.action)
        else:
            session.room=None

if __name__=="__main__":
    app.run()
</code>```

tools.py

```<code>import re

def assert_response(resp,contains=None,matches=None,headers=None,status="200"):
    assert status in resp.status,"Excepted response %r not in %r" %(status,resp.status)
    if status=="200":
        assert resp.data,"Response data is empty."
    if contains:
        assert contains in resp.data,"Response dose not contain %r"%contains
    if matches:
        reg=re.compile(matches)
        assert reg.matches(resp.data),"Response does not match %r"%matches
    if headers:
        assert_equal(resp.headers,headers)
</code>```

app_test.py

```<code>from bin.app import app
from tests.tools import assert_response

def test_index():
    #check that we get a 303 on the /URL
    #this is because web.seeother()will always send the browser this http code
    resp=app.request("/")
    assert_response(resp,status="303")
def test_game():
    #checkt that we get a 200 on /game
    resp=app.request("/game")
    assert_response(resp,status='200')

    #check that we have response data on a form submit
    resp=app.request ("/game",method="POST")
    assert_response(resp.data)
</code>```

答:
```<code>assert_response(resp.data)
</code>```

You're passing in bytes data here, where assert_response expects a response object. Pass in resp itself, like you do in all the other cases too.

Body:
I was following ex52 LPTHW and tired nosetests on all the tests in test folder, got the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/bijing/projects/gothonweb/tests/app_tests.py", line 17, in test_game
    assert_response(resp.data)
  File "/Users/bijing/projects/gothonweb/tests/tools.py", line 5, in assert_response
    assert status in resp.status,"Excepted response %r not in %r" %(status,resp.status)
AttributeError: 'bytes' object has no attribute 'status'

app.py

urls=(
    '/game','GameEngine',
    '/','Index',
)

app=web.application(urls,globals())

#title hack so that debug mode works with sessions
if web.config.get('_session')is None:
    store=web.session.DiskStore('sessions')
    session=web.session.Session(app,store,initializer={'room':None})
    web.config._session=session
else:
    session=web.config_session

render=web.template.render('templates/',base="layout")

class Index(object):
    def GET(self):
        #this is used to "setup" the session with starting values
        session.room=map.START
        web.seeother("/game")

class GameEngine(object):
    def GET(self):
        if session.room:
            return render.show_room(room=session.room)
        else:
            #Why is there here?do you need it?
            return render.you_died()
    def POST(self):
        form=web.input(action=None)
        #there is a bug here,can you fix it?
        if session.room and form.action:
            session.room=session.room.go(form.action)
        else:
            session.room=None

if __name__=="__main__":
    app.run()

tools.py

import re

def assert_response(resp,contains=None,matches=None,headers=None,status="200"):
    assert status in resp.status,"Excepted response %r not in %r" %(status,resp.status)
    if status=="200":
        assert resp.data,"Response data is empty."
    if contains:
        assert contains in resp.data,"Response dose not contain %r"%contains
    if matches:
        reg=re.compile(matches)
        assert reg.matches(resp.data),"Response does not match %r"%matches
    if headers:
        assert_equal(resp.headers,headers)

app_test.py

from bin.app import app
from tests.tools import assert_response

def test_index():
    #check that we get a 303 on the /URL
    #this is because web.seeother()will always send the browser this http code
    resp=app.request("/")
    assert_response(resp,status="303")
def test_game():
    #checkt that we get a 200 on /game
    resp=app.request("/game")
    assert_response(resp,status='200')

    #check that we have response data on a form submit
    resp=app.request ("/game",method="POST")
    assert_response(resp.data)

Body:
assert_response(resp.data)

You're passing in bytes data here, where assert_response expects a response object. Pass in resp itself, like you do in all the other cases too.


问:
Blank bar at the bottom of a page
I've been working on a few sites, and for some reason, a blank bar keeps showing up at the bottom. I've tried inspecting the elements, and I get nothing that makes any sense. html and body elements are set for margin: 0 and padding: 0.

Any ideas on how to remove the blank bar at the bottom?

Thank you!

答:
Probably way off here and I'm not sure but one of the plugins you are using is placing a smiley at the bottom of the page. I think it is popular posts that does this.

Have your tried disabling the plugins one by one to see if this goes?

OwnerDisplayName: Brandon Martinez

Title: Blank bar at the bottom of a page

OwnerDisplayName: Hedley Phillips


问:
Issue with STM32F769 PWM output when updated according to condition
I am using STM32F769 Disc board with Mbed online compiler. My task is to change the PWM frequency and duty ratio according to input.

I've created a simple algorithm according to my need, the program is working well but whenever the controller updates the PWM frequency, there is strange behavior(overlapped maybe, difficult to explain verbally for me), the frequency is changed instantly and the output is incorrect at that moment. For other controllers (like arduino) this never happens, the controller updates value after the time period of PWM is over. But not in this case.
What can be wrong?

I thought to add a small delay before value is updated but that will not work, as every time a different delay would be needed. I have attached the code and screenshots.

#include "mbed.h"

AnalogIn analog_value(A0);

PwmOut pulse(D11);

int main() {

  double meas_v = 0;
  double out_freq, out_duty, s_time;
  while (1) {

    meas_v = analog_value.read() * 3300;
    if (meas_v < 1) {
      out_freq = 50000;
      out_duty = 40;
    } else if (meas_v >= 1000) {
      out_freq = 100000;
      out_duty = 80;
    } else {
      out_freq = 50000 + (meas_v * 50);
      out_duty = 40 + (meas_v * 0.04);
    }

    pulse.period(1.0 / out_freq);
    pulse = out_duty / 100;
    s_time = 0.0001;
    wait(s_time);
  }
}
```

The output should be updated after the current period is completed, not instantly.

Error I am getting

答: The underlying HAL code probably resets the current count value of the timer when you set the new period. You'll have to read the current timer cnt value and wait for it to reach 0. You can set a new period when the timer cnt value reaches 0.

Body:
I am using STM32F769 Disc board with Mbed online compiler. My task is to change the PWM frequency and duty ratio according to input.

I've created a simple algorithm according to my need, the program is working well but whenever the controller updates the PWM frequency, there is strange behavior(overlapped maybe, difficult to explain verbally for me), the frequency is changed instantly and the output is incorrect at that moment. For other controllers (like arduino) this never happens, the controller updates value after the time period of PWM is over. But not in this case.
What can be wrong?

I thought to add a small delay before value is updated but that will not work, as every time a different delay would be needed. I have attached the code and screenshots.

#include "mbed.h"

AnalogIn analog_value(A0);

PwmOut pulse(D11);

int main() {

  double meas_v = 0;
  double out_freq, out_duty, s_time;
  while (1) {

    meas_v = analog_value.read() * 3300;
    if (meas_v < 1) {
      out_freq = 50000;
      out_duty = 40;
    } else if (meas_v >= 1000) {
      out_freq = 100000;
      out_duty = 80;
    } else {
      out_freq = 50000 + (meas_v * 50);
      out_duty = 40 + (meas_v * 0.04);
    }

    pulse.period(1.0 / out_freq);
    pulse = out_duty / 100;
    s_time = 0.0001;
    wait(s_time);
  }
}

The output should be updated after the current period is completed, not instantly.

Error I am getting