text:
Q: How to write a Device Discovery Tool using Bash I have an embedded PC running Linux server and a simple web server which is used in agriculture industry, my customers buy these PCs and use them in their fields. ( they install it on a pole 6 or 7 meters above ground level and it is very hard to access)
sometimes they change the range of these PCs IP address from original one to their own desired IP Range.
for example I ship them with 192.168.10.10/24 but they might change it to something like 172.16.12.19/29 or 10.10.200.10/8 or ....
the problem is that after a while they forget the PC IP Address and we want to give them a tool to detect and show them the current IP Address.
I thought maybe using Broadcast IP address and sending a message over local network might help to solve this problem. but after some search I realized I have to know the range at least for example (172.16.12.X or 10.10.200.X) which is not possible for me because the farmers forgot the network range too.
Is there any tool like "NC" in Linux which can help me to write a bash script to find their IP ? I have network access to the PC but I cannot connect a Monitor to the PC so the only way is to find the IP using the local network.
I want something like this :
echo "What is your IP Address ? " | nc -w1 -u 4545

and I put something on the PC which answers to this message whenever they got the exact phrase What is your IP Address ? "
nc -l -u -p 4545

but for the nc I have to specify a network range which is not possible for me.
Edit:
if you have worked with Device Discovery tool (DDT) for IP Cameras you know that they will find the camera IP independent of the PC which has the DDT on it. I want something exactly like those program but with bash commands.

A: As posted, the problem looks too wide.
As I understand, you have two different problems:

*

*Generate a method to avoid the problem in future cases.

*Access to the servers that currently have the problem, to implement solution 1.

For problem #1,
instead of getting a way to know the new IP, you could have the servers recover the old IP to a fixed value.
You could set a crontab task that checks the current IP, and whenever it deviates from a set value, it changes the IP back to the target.
You will of course have time windows of "network-blindness", depending on the frequency set in crontab.
Alternatively, a crontab task could broadcast/send email/etc. the new IP.
The right mechanisms depend very much on what are you willing to operate, how are you accessing the servers.
All this seems a workaround.
If correctly configured, they should not "forget the PC IP address".
This is the point to fix, I guess.
If you could give more information on the current configuration, that will narrow the problem.
For problem #2,
if that is your target please mention it.
I have a "similar" problem.
A server that I am accessing remotely changes IP once in a while, since it is assigned by DHCP.
Whenever I have problems sshing to the server, I execute a small script that, by a combination of ping and ssh (within a loop of IPs), and checking on the response, can get the current IP.
Depending on many aspects of your network configuration this may work for you or not.

A: I guess the farmers are reconfiguring it because their local network address changes.  In which case, why not allow the server to get it's address over DHCP, you could make a note of the Mac address (which won't change) and then search the DHCP servers tables or even try a lookup on the DNS server to find the pc.  Unpluging the cable from the end at the switch and plugging it back in should initiate a DHCP configuration session.  Most DHCP servers allow you to assign an address based on a Mac address so you have some control over it at the dhcp server end.

A: With netcat you could do something like a cronjob on your "pole-mounted servers" that does something like this every X minutes:
#!/bin/bash

# replace eth0 with the name of your interface or get the IP via other means

ip="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ' ' -f 10)"
datum=$(date)
echo "This is my IP: "$ip | netcat -q 2 -b -u 255.255.255.255 12001

The User/Farmer then only has to listen like this:
echo | nc -ulp 12001

And after X minutes they should get something like this:
This is my IP: 192.168.1.121

This only works if the "Farmers PC" and your "pole-mounted servers" are in the same subnet, though.

Explanation:
The script will send a UDP broadcast on Port 12001 and exit nc, after the payload (our echo command) + 2 seconds. The IP doesn't have to be got via ifconfig obviously, but its quite easy to parse..
Sending it to 255.255.255.255 means broadcast to the whole subnet, regardless of size.
So we don't have to know which network we are on.
On the client side, we listen with nc until we get a payload. I found nc  terminates cleanly in combination with a line-break (via the echo).

A: If you use avahi on your embedded PC you won't have to re-invent/re-implement service-discovery
On embedded PC:s:
apt-get install avahi-daemon
systemctl enable avahi-daemon --now
un-comment #publish-workstation=yes in /etc/avahi/avahi-daemon.conf
systemctl reload avahi-daemon

On machine used to discover embedded PC:s
apt-get install avahi-utils
avahi-browse -atr #  will output names and ip:s of devices on network to terminal


text:
Q: C# Database MasterReset I'm not sure if this is possible and I can't find any answers anywhere else.
Is it possible to have a blank OleDb database stored in the Folders of a Project in C# and after a buttonClick replace the current database (that's being used) with the blank Database?
I'm not looking for a way to save the data from the original somewhere else, although I can understand how that is useful and good practice.
I'm primarily interested in whether this is possible, and how I would go about learning how to use it in my system.
Thanks for reading, and thanks in advance for any help or suggestions :)

A: I suggest instead of using a fixed database file the user has to "reset", allowing the user to create multiple database files that he can choose from. Most office applications have "create file"/"open file"-dialogs, so users are very familiar with them. You may want to implement an "open last file" or "recent files list"-feature for convenience.
First of all, this would allow the user to start fresh without having to throw away his old data. A user would also be much less reluctant to create something new than to "reset" something (as he should be), so that would also help in user experience terms.
Secondly, disconnecting a database or truncating the contents can work, but it is not as simple as it first sounds. If you're still connected to the database, the file will be locked and you can't remove it. The truncate approach can also cause problems, not only does your whole application have to be able to deal with a suddenly empty database, existing foreign key constraints will have to be considered too.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Show that the stabilizer is a prime subgroup We define a subgroup $H$ as being convex if $g\in H\implies h\in H$ for all $1\leq h\leq g$. A convex subgroup $P$ is prime if for any two convex subgroups $X,Y$: $X\cap Y \subseteq P$ implies that $X\subseteq P$ or $Y\subseteq P$.
Say that $G$ is a latttice ordered subgroup of $A(S)$, the automorphisms of a totally ordered set $S$. Let $G_\alpha$ be the stabilizer of some $\alpha \in S$, i.e. $\{g:\alpha g=\alpha\}$.
Glass' Partially Ordered Groups states that $G_\alpha$ is "obviously" a prime (convex) subgroup of $G$, but I don't understand why.
I don't even see why it needs to be convex - while I can't come up with a counter example, I can't see any reason why if $g$ stabilizes $\alpha$ and $h\leq g$ then $h$ must also stabilize $\alpha$.

A: If $1 \leq h \leq g$ then $x \leq h(x) \leq g(x)$ for all $x \in S$ by definition of the lattice order on $A(S)$. Taking $x=\alpha$ we get $\alpha \leq h(\alpha) \leq \alpha$, as was to be shown ($G_a$ is convex).
Now suppose $h \wedge k =1$ for $h,k \in G$. Then $\min(h(\alpha),k(\alpha))=1(\alpha)$, that is,either $h(\alpha)=\alpha$ or $k(\alpha)=\alpha$. Thus either $h$ or $k$ in $G_a$. Hence $G_a$ is prime by Glass's Lemma 3.3.3.ii on page 37. This completes the proof of the "clearly" claim on page 140 (next to a proof of Holland's theorem).
The lattice order of $A(S)$ is described on the first page of Holland (1963) and also as Example 1.3.19 in Glass's Partially Ordered Groups. The prime part might also be proven in that paper (check the "tower" stuff), but this is not my area.

*

*Holland, Charles.
"The lattice-ordered groups of automorphisms of an ordered set."
Michigan Math. J. 10 (1963) 399–408.
MR158009
DOI:10.1307/mmj/1028998976


text:
Q: How to use Microsoft Coyote in F# code - protected nested attribute type in parent type Is there a language difference between F# and C# here that is blocking the use of Microsoft Coyote from F# code?
Because the OnEventDoActionAttribute is defined in the inherited type Microsoft.Coyote.Actors.Actor with a protected access modifier, it looks like  it is still accessible in inherited actor types in C# but not so in F#.
Hello world sample converted to F#:
type SetupEvent(serverId : ActorId) =
    inherit Event()
    member this.ServerId = serverId

type PingEvent(callerId : ActorId) =
    inherit Event()
    member this.Caller = callerId

type PongEvent() =
    inherit Event()

// both attribute spec fail
//[<Microsoft.Coyote.Actors.Actor.OnEventDoAction(typeof<PingEvent>, "HandlePing")>] // Error: The type 'OnEventDoActionAttribute' is not accessible from this code location
[<OnEventDoAction(typeof<PingEvent>, "HandlePing")>] // Error: The type 'OnEventDoAction' is not defined
type Server() =
    inherit Actor()

    member this.HandlePing(e : Event) =
        let ping = e :?> PingEvent
        printfn "Server handling ping"
        printfn "Server sending pong back to caller"
        this.SendEvent(ping.Caller, new PongEvent());

// both attribute spec fail
//[<Microsoft.Coyote.Actors.Actor.OnEventDoAction(typeof<PongEvent>, "HandlePong")>] // Error: The type 'OnEventDoActionAttribute' is not accessible from this code location
[<OnEventDoAction(typeof<PongEvent>, "HandlePong")>] // Error: The type 'OnEventDoAction' is not defined
type Client() =

    inherit Actor()

    let mutable serverId : ActorId = null

    override this.OnInitializeAsync(initialEvent : Event) : System.Threading.Tasks.Task =
        printfn "%A initializing" this.Id
        serverId <- (initialEvent :?> SetupEvent).ServerId
        printfn "%A sending ping event to server" this.Id
        this.SendEvent(serverId, new PingEvent(this.Id))
        base.OnInitializeAsync(initialEvent)

    member this.HandlePong() =
        printfn "%A received pong event" this.Id

[<Test>]
let Execute (runtime : IActorRuntime) =
    let serverId = runtime.CreateActor(typeof<Server>)
    runtime.CreateActor(typeof<Client>, new SetupEvent(serverId)) |> ignore
    runtime.CreateActor(typeof<Client>, new SetupEvent(serverId)) |> ignore
    runtime.CreateActor(typeof<Client>, new SetupEvent(serverId)) |> ignore

let runtime = RuntimeFactory.Create()
Execute(runtime) |> ignore
Console.ReadLine() |> ignore

Not sure what to do in order to work around this issue.
LINQPad document URI to try out the code directly: http://share.linqpad.net/a9rif7.linq

A: Yes it was to reduce scope pollution, and to ensure you only get intellisense for these types when you are in a valid place to use them inside Visual Studio.  Cool idea to build an F# example though...

A: Unfortunately, they declared the attribute to be a protected sealed nested inside Actor. While F# cannot declare anything as protected, it can follow access restriction - usually people enforce access restriction for a reason.
The other way you could have done this is to have a top-level class which inherits from Actor and implement the clients as nested classes. But F# doesn't support nesting classes either.
I don't see any particular reason for it to be declared protected other than scope pollution.
Probably forking and changing the access modifier is the easiest option right now.


text:
Q: Seeing what looks like a "declared" keyword in python I'm taking an online Python course, and while I'm in over my head at the sign-in prompt, I'm still having at it.
An example is given in the online text (for a palindrome program) where it gives as an example:
def toChars(s):
    s = s.lower()
    ans = ' '
    for c in s:
        if c in 'abcdefghijklmnopqrstuvwxyz':
            ans = ans + c
    return ans

what is giving me fits is how the 'c' gets understood by Python. From what I can gather, the 'c' is treated as a keyword, understood as a keyword for 'char,' but where does Python get that?  There's no explanation that I've found anywhere, wondering if anyone can set me straight on this.

A: c is not a keyword, it's a variable name.
In Python, strings are iterable. When you iterate over a string, it yields its characters one by one.
Thus the following:
for c in s:

simply iterates over the characters of s and assigns each character in turn to c.

A: All for c in s: does is takes one character in s, assigns it to the variable c, then executes the for loop body. Then, it assigns the next character in s to c and s on.
For example, let s = "LARRY123". First, s = s.lower() will assign "larry123" to s. Within the for loop, c is first set to 'l'. Then if c in "abcdefghijklmnopqrstuvwxyz": checks whether c is a letter and if it is, then it appends it to ans. In the next iteration, c is equal to 'a'. Then 'r'. And so on. When c is 1, 2 or 3, it will not be appended to ans because it is not an alphabet.
In the end, ans will be larry. Hope that helps.


text:
Q: Removing Leading 0 from a number causes value to change I do not understand what is happening here, based on Convert string into integer in bash script - "Leading Zero" number error, I am able to convert the string into integer. I can even do addition. However, when I compare the numbers it gives me the wrong comparison. Refer to example below
Here's an example
array=(02 08 10 11 23 52)

for i in 0 1 2 3 4 5
    do
        if [[ ${array[i]#0} > 15 ]]
        then
            echo "${array[i]#0} is greater than 15"
        else
            echo "${array[i]#0} is less than 15"
        fi
done

Output
2 is greater than 15
8 is greater than 15
10 is less than 15
11 is less than 15
23 is greater than 15
52 is greater than 15

A: Either change [[ ]] to (( )) to use > or change the operator to -gt to do integer comparisons inside of [[ ]]
First:
#!/bin/bash

array=(02 08 10 11 23 52)

for i in 0 1 2 3 4 5
do
    if (( ${array[i]#0} > 15 ))
    then
        echo "${array[i]#0} is greater than 15"
    else
        echo "${array[i]#0} is less than 15"
    fi
done

Second:
#!/bin/bash

array=(02 08 10 11 23 52)

for i in 0 1 2 3 4 5
do
    if [[ ${array[i]#0} -gt 15 ]]
    then
        echo "${array[i]#0} is greater than 15"
    else
        echo "${array[i]#0} is less than 15"
    fi
done

If you use < > == inside of [ ] or [[ ]] is a string comparison operator. The string "02" is in fact less than the string "15":
% [[ 02 > 15 ]]; echo $?
1                        # '1' means false and '0' means true

BUT you are stripping the leading "0" with #0:
% s="02"
% echo ${s#0}
2

So now you are comparing the STRING "2" to the STRING "15":
% [[ 2 > 15 ]]; echo $?
0
% [[ ${s#0} > 15 ]]; echo $?
0

Which give the surprising result you are seeing...
See this answer for an expanded set of examples.


text:
Q: How to retriew data of Employee model in users registration form in Django I am creating an ERP app using Django. I have the Employee model which holds the master data of the employee. Employees must register themselves before using the app. I have created a page where the employee enters his employee number and if an employee exists in the database he/she can register himself/herself to the app.
In my registration form, I want to retrieve the information of the employee form employee model whose Employee Number is checked. how to do that? how can I pass the information of the employee to the registration form? please help

A: for example if you want to retrive the username request.user.username

A: From what you have written i am able to get a little bit about your problem. I think you have problem after the employee check number is verified and you want to know that how can employee can enter his/her own data to the database. You can do a simple thing by creating a new model employee details and in that model you can enter the employee details and from that you can use foreign key to connect the two models.


text:
Q: Why can't I override the default argument? Consider the following code:
import pickle

def open_file(fname, fname1 = None):
    # returns a new OPEN file
    if fname1:
        while fname == fname1:
            f_name = input("File already open, filename: ")
    f = None
    while not f:
        try:
            f = open(fname, "rb")
        except IOError:
            fname = input("File not found, filename: ")
    print(fname, "open")
    return f

def get_2cubes():
    a_name = input("\nWhat is the name of the first cube's file? ")
    a_file = open_file(a_name)
    #a_cube = pickle.load(a_file)
    a_file.close()

    b_name = input("\nWhat is the name of the second cube's file? ")
    b_file = open_file(b_name, a_name)
    #b_cube = pickle.load(b_file)
    b_file.close()
    #return a_cube, b_cube

get_2cubes()

The code is meant to open a second file only if it's not the first file.
The first file's name is represented by fname1 in open_file(). If the name of the second file (b_name in this case) matches that of the first file the user will be prompted to enter a new name.
I supplied a default argument of None for the fname1 parameter because the function will sometimes be used only for opening one file and not for also comparing it to another file. However, I can't seem to override the default argument.
The a_name variable from the 7th line of get_2cubes is not being recognized by the if fname1: condition in open_file, and as a result I can open the same file twice. How would I correct this?

A: I think you need to use raw_input. Otherwise the text entered will treated as a variable name, and therefore will equal to None. (Unless you're on Python 3)


text:
Q: Express Route.post issue I use Express for my back-end application. But I have the problem Why there is not any problem on signup route, but when server starts it crashes with following error.

The place it identifies as source of error is signin route. But, what is the difference between signin and signup here. I can't figure out.

A: Check if your AuthenticationController.signin is defined. Try doing console.log(AuthenticationController.signin) and see if it is defined. I guess most probably typo issue. May be it's AuthenticationController.signIn notice capital I.


text:
Q: join table.A with table.B, table.B having multiple rows with respect to one id from table.A e.g
select id,product from products;

id product
1  iPhone 6
2  Dell Inspiron

pid is foreign key referencing to product id in products
select * from product_image;

id pid image
1  1   he7gu8h9d54w.jpg
2  2   jgeywfyu3r34.jpg
3  1   drtsw54e452r.jpg
4  2   weyr63tr236r.jpg

after joining, i am getting this..
id product       img_id pid image
1  iPhone 6      1      1   he7gu8h9d54w.jpg
1  iPhone 6      3      1   drtsw54e452r.jpg
2  Dell Inspiron 2      2   jgeywfyu3r34.jpg
2  Dell Inspiron 4      1   drtsw54e452r.jpg

I'm getting multiple rows from product_image with respect to one id in product table
I want to get one row from product_image with respect to a product_id...plz help..
i want this...
id product       img_id pid image
1  iPhone 6      1      1   he7gu8h9d54w.jpg
2  Dell Inspiron 4      1   drtsw54e452r.jpg

A: For each product, you can use NOT EXISTS to make sure no image with lower id exists:
select p.id, p.product, pi.id, pi.pid, pi.image
from products as p
  join product_image as pi on p.id = pi.pid
where not exists (select * from product_image as pi2
                  where pi2.pid = pi.pid
                    and pi2.id < pi.id)

Alternatively, have a sub-query that returns each pid's minimum id, join one more time with that sub-query:
select p.id, p.product, pi.id, pi.pid, pi.image
from products as p
  join product_image as pi on p.id = pi.pid
  join (select pid, min(id) as id from product_image group by pid) pi2
      on pi.id = pi2.id and pi.pid = pi2.pid

May execute faster on MySQL.

A: You can subselect the min(id) form product_image for restrict the selection
select a.id, a.product, b.id, b.pid, b.image
from products as a, product_image as b
where a.id = b.pid
and b.id in (select min(id) from product_image group by pid)

A: What you are looking is an equivalent of SELECT DISTiNCT ON but there is none in MySQL. please see this topic: Converting SELECT DISTINCT ON queries from Postgresql to MySQL
If you don't care which row will be returned, this will work:
SQL Fiddle
MySQL 5.6 Schema Setup:
CREATE TABLE prod
    (`id` int, `product` varchar(12))
;

INSERT INTO prod
    (`id`, `product`)
VALUES
    (1, 'iPhone6'),
    (2, 'DellInspiron')
;

CREATE TABLE img
    (`id` int, `pid` int, `image` varchar(16))
;

INSERT INTO img
    (`id`, `pid`, `image`)
VALUES
    (1, 1, 'he7gu8h9d54w.jpg'),
    (2, 2, 'jgeywfyu3r34.jpg'),
    (3, 1, 'drtsw54e452r.jpg'),
    (4, 2, 'weyr63tr236r.jpg')
;

Query 1:
select
  id, pid, image
from img
group by pid

Results:
| id | pid |            image |
|----|-----|------------------|
|  1 |   1 | he7gu8h9d54w.jpg |
|  2 |   2 | jgeywfyu3r34.jpg |

Query 2:
select
  prod.id as prod_id, prod.product as prod_product
  , img.id as img_id, img.pid as img_pid, img.image as img_image
from prod
join img on img.pid = prod.id
group by img.pid

Results:
| id |      product | id | pid |            image |
|----|--------------|----|-----|------------------|
|  1 |      iPhone6 |  1 |   1 | he7gu8h9d54w.jpg |
|  2 | DellInspiron |  2 |   2 | jgeywfyu3r34.jpg |


text:
Q: When to use resolv.conf? I understand resolv.conf file is used by Linux to resolve DNS lookup but I cant figure if I need to edit this file in my case.
My Scenario:
I am not hosting the DNS on my vps machine. I have purchase Godaddy Premium DNS Service to set my A Records, mx etc.. My vps is only used to host 1 website where Nginx handles all incoming requests.
My Questions:
1) In my case where I am using Godaddy DNS service, do I still need to add the Nameserver resolution in resolv.conf file? Or does resolv.conf only applies if I am hosting my own DNS on my machine using BIND or something else?
2) The current resolv.conf file looks like this. In the ip address, does it mean I have to enter the Godaddy Nameserver's ip address here?
nameserver 123.00.00.123   <-- Is this Godaddy NS Ip address?

3) Which services uses this resolv.conf? I mean does Nginx, Postfix or ssh refer to the configuration in this file at all?
I've set everything else up and only now I came across resolv.conf by accident and I dont know if my set-up is incomplete without this info. Can someone help me understand this please?

A: Every system needs to configure it's resolver, regardless if it's a DNS server or not. This is used by the core library of the OS which will be used whenever any service needs to resolve a name - they just use  library function for it which uses this configuration (there might be exceptions when programs do this on their own, but this are rare special cases).
What this config file does is essentially to tell the system: OK, if you need to find out how to contact a machine where you know the name, ask the server listed here to get the IP address.

The current resolv.conf file looks like this. In the ip address, does it mean I have to enter the Godaddy Nameserver's ip address here?

Even if your own domain is hosted by GoDaddy, that doesn't mean at all that you have to use their DNS server. Instead, use the DNS server that your VPS provider tells you to use. DNS is a distributed database for a reason. In most cases, your own domain will quite unimportant for your server, but if it is, your providers DNS will either find out the name for you (if it's recursive) or tell your system "I don't know anything about that, ask this DNS server instead".
Read http://en.wikipedia.org/wiki/Domain_Name_System to understand how DNS works to begin with. That will make the role of the local resolver clearer as well.


text:
Q: Custom Linux Desktop Environment on Electron Is it possible to create Desktop Environment like KDE or GNOME using Electron framework? How this can be achieved?

A: For sure you won't be able to run KDE or Gnome from a Javascript environnement.
But, some Javascript desktop projects exists (like the one you can see on FreeboxOS).
Take a look to OS.js for example : https://demo.os-js.org/
Best regards and good luck in integration.


text:
Q: How to simultaneously play different videos on different monitors in a multi-monitor setup? I am new here and this is my first post. I am a college student and am doing a project that requires playing 5 different videos on 5 different monitors, simultaneously. It's like driving a car, while you look at the central monitor, and also you can glance over you left an right using other monitors. We already have the monitors set up.
The OS is Fedora release 13 (Goddard). Using xinerama.
I have some experience with C and matlab, I can do some python and bash scripting too (unfortunately not much, but I can learn if I need to~).
I have searched through a lot of different sites, but didn't get what exactly I want. I think to solve my problem, I need to be able to distinguish between my different monitors, and specify a certain video to play on a certain monitor. Or, I can move my cursor (by programming of course) to a certain monitor and launch the corresponding video, because I experimented and found out that an application is always launched on the monitor where the mouse is currently at.
Could anyone provide some hint on just how to go about doing that? Any help would be appreciated!!
Thanks!

A: Take a look at video whale project which uses gstreamer and xinerama for video wall implementation. Making a video-wall using Gstreamer and Xinerama


text:
Q: Bootstrap ScrollSpy Hello guys I'm using bootstrap scroll spy. when I click on the link it takes me to that specific portion but the problem that I am facing   is that when I'm scrolling up or down the options is not becoming active. I don't know why am I facing this problem. Please help. Here is my code. I

Section 1

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

          ↑ Back to top ↓ Next section

Section 2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

          ↑ Back to top ↓ Next section

Section 1

Section 2

A: I have solved your problem. Here is the solution:
<!DOCTYPE html>

  <title>Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

Section 1

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

            ↑ Back to top ↓ Next section

Section 2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

            ↑ Back to top ↓ Next section

Section 1

Section 2

You should add .nav class to your ul element inside the nav, .active class to one of the list items as default, set data-spy="scroll" data-target="#myScrollspy" data-offset="20" attributes to the body tag instead of #buyer_guide div, and could you please be sure the add all the JS and CSS files below:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">


text:
Q: How to set the height of UITextField in the UIAlertController? I know that to set the height of regular textfield programatically by using this code
textField.frame.size.height = 60

But if I implement this code to textfield inside my UIAlertController, it doesn't work. I also try to change the keyboard to ASCII capable, but it doesn't change the keyboard after I run the app. it seems I miss something
Here is the code of my alert controller
let alertController = UIAlertController(title: "Write Comment", message: "Tell us why you are not satisfied", preferredStyle: .alert)

alertController.addAction(UIAlertAction(title: "Send", style: .default, handler: { alert -> Void in
    let textField = alertController.textFields![0] as UITextField
    textField.frame.size.height = 60
    textField.keyboardType = .asciiCapable

    let commentDefect = textField.text ?? ""
    self.sendComment(defectID: defectID, comment: commentDefect)

}))

alertController.view.tintColor = UIColor(red: 0/255, green: 129/255, blue: 58/255, alpha: 1)
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alertController.addTextField(configurationHandler: {(textField : UITextField!) -> Void in
    textField.placeholder = ""
})

self.present(alertController, animated: true, completion: nil)

and here is the result :

It seems the height is still around 17. What went wrong here?

A: you have add below code:-
alertController.addTextField(configurationHandler: {(textField : UITextField!) -> Void in
        textField.placeholder = ""
        let heightConstraint = NSLayoutConstraint(item: textField, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 120)
        textField.addConstraint(heightConstraint)
})

Hope it help you.
It's duplicate

A: let alertController = UIAlertController(title: "Write Comment", message: "Tell us why you are not satisfied", preferredStyle: .alert)
        alertController.addTextField { (textField:UITextField) in

            let heightConstraint = NSLayoutConstraint(item: textField, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: yourHeightValue)
            textField.placeholder = ""
            textField.addConstraint(heightConstraint)
            textField.keyboardType = .asciiCapable
        }
        alertController.addAction(UIAlertAction(title: "Send", style: .default, handler: { (alert) in

            let commentDefect = alertController.textFields?.first?.text ?? ""
            self.sendComment(defectID: defectID, comment: commentDefect)
        }))
        alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
        alertController.view.tintColor = UIColor(red: 0.0/255.0, green: 129.9/255.0, blue: 58.0/255.0, alpha: 1.0)
        self.present(alertController, animated: true, completion: nil)


text:
Q: renderer2 selectRootElement() did not match any elements I am creating a little webpage which needs to use dynamically created element inside the div. I want to render buttons in .ts file but  I am getting

ERROR Error: The selector "myDIV" did not match any elements

Here's the example adding simple text in .ts file:
  renderButtons(){
    const element = this.renderer.selectRootElement('myDIV');
    const text = this.renderer.createText('something');
    this.renderer.appendChild(element, text);
  }

.html file:

Regards

A: You do it in wrong way, define your dynamic elements INSIDE html template e.g.

    <button *ngIf="showButton==true">myButton</button>
    <ng-container *ngIf="showText==true">{{ myText }}</ng-container>

where myText, showButton and showText are fields of component defined inside .ts file. The <ng-container> put content (text) without creating html element (like div/span)
If you want to use many elements - define one element as separate component and use it in parent component html template as follows
<myElement *ngFor="let item in elementsDataArray" [data]="item"></myElement>

where elementsDataArray is array defined in parent .ts file, which contains objects (items) with data used in you myElement component and bind to its parameter data.


text:
Q: Button won't redirect to given html page in location.href I can't redirect to the next page. Please help me. I have a project due tomorrow. I've been trying for more than five hours. Please help me. I'm begging you guys. I don't know what I'm doing wrong. I'm very new to Javascript.
Please tell me what I'm doing wrong

document.getElementById("one").onclick = function() {
  location.href = "lessons.html"
};
<!DOCTYPE html>

  <title> MaxFluency Tutorials Page</title>
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="tutorial.css">

  </script>

 Tutorials

      <button class=les id=one type="button">
 Lesson 1:
 Nature of Communication </button>
      <button class=les id="2nd">
Lesson 2:
</button>
      <button class="les" id="3rd">
Lesson 3:
</button>

    <button class="loc"> Home</button>
      <button class="loc"> Highscores </button>
      <button class="loc"> Support us!</button>

A: Your HTML is quite malformed, with some opening tags not closed anywhere, closing tags that do not have any matching tag, etc... This needs some tidying.
Also, if this Javascript code is in an external file, make sure it is wrapped in an onload event (making sure that all HTML elements actually loaded before calling document.getElementById). Finally, note the semicolon placement. You should place the semicolon after the statement, not after the function's ending }!
Side note: Why re-inventing the wheel when you can simply use an anchor tag () for redirecting?

onload = function() {
  document.getElementById("one").onclick = function () {
    console.log("clicked!");
    location.href = "lessons.html";
  }
}
<!DOCTYPE html>

        <title> MaxFluency Tutorials Page</title>
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="tutorial.css">

 Tutorials

        <button class=les id=one type="button" >
 Lesson 1:
 Nature of Communication </button>
         <button class=les id="2nd">
Lesson 2:
</button>
         <button class="les" id="3rd">
Lesson 3:
</button>

         <button class="loc"> Home</button>
           <button class="loc"> Highscores </button>
               <button class="loc"> Support us!</button>

A: 1) there is a lonely closing script tag in the head section.
2) your closing header and div tags before .lessons are in reverse order
3) Here is a fiddle that seems to be working. Button goes to a 404 just because the lessons.html doesn't exist here.
I also added a slash for a relative path. I assume you are probably working from a single root directory given that it is a tutorial but I could be wrong there.
location.href = "/lessons.html";

https://jsfiddle.net/y7txje5c/1/


text:
Q: Strikethrough overlay on specific cells of a heatmap in ggplot2 I would like to generate a heatmap with specific cells having an overlaid strikethrough, or some other simple pattern on the cell. I would like to achieve the same results as in this question (ggplot2 geom_tile diagonal line overlay) however I am not able to reproduce this solution, as I am very much struggling to follow the solution's code after geom_segment().
Here's some example data for a data frame:
GN  a   b
willy   -1.58215    -2.53036
wee 0.611129    0.485053
waffy   1.580719    0.857198

and the code for the heatmap:
library(tidyr)
library(ggplot2)
legend_title <- "log(z/w)"
pivot_longer(df, 2:3) %>%
    ggplot(aes(name, GN, fill=value)) +
    geom_tile(color = 'black') +
    scale_x_discrete(expand = c(0, 0)) +
    scale_y_discrete(expand = c(0, 0)) +
    coord_equal() +
    theme(axis.title.x = element_blank(),
          axis.title.y = element_blank(),
          axis.ticks.x = element_blank(),
          axis.text.x = element_blank(),
          axis.text.y = element_text(color = 'black', face = 'bold')) +
    scale_fill_gradient2(legend_title, low = "blue", mid = "white", high = "red")

This should produce the following heatmap:

I would like to be able to specify, for example, the left cell of row waffy and the right cell of wee to be stricken through. It would be even better if there are design options for this, for example having three colored diagonal strikethroughs.
Many thanks for any help.

A: Starting with the original plot, p.
library(tidyverse)

df <- tibble(
  GN = c("willy", "wee", "waffy"),
  a = c(-1.58215, 0.611129, 1.580719),
  b = c(-2.53036, 0.485053, 0.857198)
)

p <-
  ggplot(pivot_longer(df, 2:3), aes(name, GN, fill=value)) +
  geom_tile(color = 'black') +
  scale_x_discrete(expand = c(0, 0)) +
  scale_y_discrete(expand = c(0, 0)) +
  coord_equal() +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.ticks.x = element_blank(),
        axis.text.x = element_blank(),
        axis.text.y = element_text(color = 'black', face = 'bold')) +
  scale_fill_gradient2("log(z/w)", low = "blue", mid = "white", high = "red")

add_strikes takes a plot and adds strikes to the specified cells.
add_strikes <- function(p, cell, color, n_lines, thickness) {
  strike_df <- tibble(cell, color, n_lines, thickness)

  data <-
    ggplot_build(p)$data[[1]] %>%
    rownames_to_column("cell") %>%
    inner_join(uncount(strike_df, n_lines)) %>%
    group_by(cell) %>%
    mutate(
      x = pmax(xmin - (xmax - xmin) + row_number() * 2 * (xmax - xmin) / (n() + 1), xmin),
      y = pmax(ymax - row_number() * 2 * (ymax - ymin) / (n() + 1), ymin),
      xend = pmin(xmin + row_number() * 2 * (xmax - xmin) / (n() + 1), xmax),
      yend = pmin(ymax + (ymax - ymin) - row_number() * 2 * (ymax - ymin) / (n() + 1), ymax)
    )
  p + geom_segment(
    data = data,
    aes(x, y, xend = xend, yend = yend, color = I(color), size = I(thickness)),
    inherit.aes = FALSE,
    show.legend = FALSE
  )
}

Specify how you want the strikes to look.
add_strikes(
  p,
  cell = c("4", "5"),
  color = c("black", "#ebb734"),
  n_lines = c(3, 6),
  thickness = c(0.8, 0.2)
)


text:
Q: Can I use ServerManager from Microsoft.Web.Administration without admin user as an application pool identity I want to read some settings of the application pool using the ServerManager object from the Microsoft.Web.Administration.dll. The problem is that it works only if the identity of the application pool is a windows user with administrator privileges. Otherwise I am getting UnauthorizedAccessException - Filename: redirection.config; Error: Cannot read configuration file due to insufficient permissions.
Is there any workaround about this issue.
My code is the following:
        ServerManager manager = new ServerManager();
        string currentSiteName = System.Web.Hosting.HostingEnvironment.SiteName;
        Site currentSite = manager.Sites[currentSiteName];
        string appVirtaulPath = HttpRuntime.AppDomainAppVirtualPath;

        string appPoolName = string.Empty;
        foreach (Application app in currentSite.Applications)
        {
            string appPath = app.Path;
            if (appPath == appVirtaulPath)
            {
                appPoolName = app.ApplicationPoolName;
            }
        }

        ApplicationPool currentAppPool = manager.ApplicationPools[appPoolName];

Thanks!

A: No, there is no workaround to read the configuration file without causing a big security concern. What are you trying to accomplish?
If reading configuration settings, you can use an API in the same DLL that will give you read-only configuration access for that site settings, such as reading web.config or values in applicationHost.config for that site only, and not encrypted ones (such as passwords). The API is called WebConfigurationManager and has a static method called GetSection, such as WebConfigurationManager.GetSection("system.webServer/defaultDocument")
See: https://msdn.microsoft.com/en-us/library/microsoft.web.administration.webconfigurationmanager.getsection.aspx
However, several settings (namely all the ones used to start the process w3wp.exe) are not possible to be read through that API.
Short story: Unfortunately for security reasons many of those settings are not possible to be read from a worker process. There are some things you can read using server variables such as Request.ServerVariables["APP_POOL_ID"]), or Request.ServerVariables["APP_POOL_CONFIG"]). Of course bitness you could calculate the size of a pointer (4 or 8), or use environment variables (like PROCESSOR_ARCHITECTURE)
Longer story: In IIS for security reasons we take the applicationHost.config file and we split it into smaller application pool.config files (by default located at C:\inetpub\temp\appPools) which are isolated for security reasons so that even if untrusted code were to run in the process (w3wp.exe) to try to steal/read the settings of other sites it would be physically impossible. You can open the file and see which settings are there and you can read those. You'll notice the appPools section is missing entirely since that is only used by WAS to start w3wp.exe.


text:
Q: Facebook Authentication working on Emulator, But not on physical device Hey everyone just recently developed my first android app that logs into facebook and tries to status update Without the dialog box, using the graph API.
The code below is the authorization code (which was on the fbook dev site itself) and it worked fine for me all along, until recently. Now my app logins in fine on my emulator but when I export the APK file and put it on my phone it gives me 'authentication error". Can someone explain this? It just doesn't show me the login page anymore, After I created a new keystore and hashkey AND updated that hashkey on my dev app page on facebook as usual.
I think it's due to the keyhash etc, but I dont understand that well enough to figure out what's wrong. What I do is, I click export, application, then I create a new keystore (the first time, otherwise I use existing keystore), then I find my hashkey using "keytool exportcert" etc as show on the fbook dev site. Then I enter that hashkey into the app on my facebook account. But sometimes even though the keystore password is correct it says "keystore format" is different, even though I used it before the same app! Then I have to create a new keystore, and exportcert again and all of that is a pain! There must be an easier way?
Can someone possibly explain how the hashkey for Facebook apps work as well?
Thanks in advance!
My Authentication Code :
public void login()
{

    facebook.authorize(this,new String[] { "email", "read_stream", "publish_stream"}, new DialogListener(){
        int fbcheck=0;
        @Override
        public void onComplete(Bundle values) {
            fbcheck=1;
        facebookauthcheck(fbcheck);
        }

        @Override
        public void onFacebookError(FacebookError error) {
            fbcheck=0;
            facebookauthcheck(fbcheck);
        }

        @Override
        public void onError(DialogError e) {
        fbcheck=0;
        facebookauthcheck(fbcheck);
        }

        @Override
        public void onCancel() {
            fbcheck=2;
            facebookauthcheck(fbcheck);
            }

    });
}

public void facebookauthcheck(int fbcheck)
{
    if (fbcheck == 0)   {
        Toast.makeText(this, "Authentication Error", Toast.LENGTH_LONG).show();
    }
    else if (fbcheck==1)
    {
        Toast.makeText(this, "Authenticated", Toast.LENGTH_LONG).show();
    }
    else
        Toast.makeText(this, "Authentication Cancelled", Toast.LENGTH_LONG).show();
}

A: Yeah I had this issue,
It worked fine on the emulator, worked fine on my dev phone, but failed on the test users phone.
It's to do with the Facebook app and SSO.
Have a read of this : http://sean.lyn.ch/2011/07/android-the-facebook-sdk-sso-and-you/
It has 3 solutions.
I couldn't get SSO to work so I went for option two, (opt out of SSO!) This is done by:
  facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, this);

If you want to fix it and get SSO to work:

Correctly generate your hash key for the debug apk certificate. (detailed in the link above).

Ref:
Corresponding SO Question

A: I am using facebook login with fragments (please replace 'activity') with 'this':
 private void loginToFacebook()
    {
        mPrefs = activity.getPreferences(Context.MODE_PRIVATE);
        facebook = new Facebook(APP_ID);
        accessToken = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);

        if (accessToken != null)
        {
            facebook.setAccessToken(accessToken);
        }

        if (expires != 0)
        {
            facebook.setAccessExpires(expires);
        }

        if (!facebook.isSessionValid())
        {
            facebook.authorize(activity, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new DialogListener() {

                public void onFacebookError(FacebookError arg0) {
                    // TODO Auto-generated method stub

                }

                public void onError(DialogError arg0) {
                    // TODO Auto-generated method stub

                }

                public void onComplete(Bundle arg0) {
                      SharedPreferences.Editor editor = mPrefs.edit();
                        editor.putString("access_token", facebook.getAccessToken());
                        editor.putLong("access_expires", facebook.getAccessExpires());
                        editor.commit();
                        uploadPhoto(facebook, bitmap, null); // calling another method to upload an image to FB after logging in..
                }

                public void onCancel() {
                    // TODO Auto-generated method stub

                }
            });

        }
    }


text:
Q: AngularJs - Disable input on table dependent upon top row selection I am trying to make a tables input elements disabled from below the top (master) row if the "Active" or "Engaged" boolean is set to true on the top row. I do not want them to loose their data below the top row when they set it true, only to disable it. If the user sets the "Active" && "Engaged" to false on the top row then I want them to be able to edit the data below the top row again. Is there an easy way to do this with AngularJs?
Here is an example: https://jsfiddle.net/7kg6kuzm/2/

{{test}}

            People
            Active
            Engaged
            Town

{{month}}

            <input type="text" ng-model="info.people"/>
            <input type="checkbox" ng-model="info.active"/>
            <input type="checkbox" ng-model="info.engaged"/>
            <input type="text" ng-model="info.form" />

possible json object value (in this case since the "all" or top row has one of the booleans set to true the rest of the rows would be disabled):
var months = {
  "all": {"people":25,"active":true,"engaged":false,"form":"test0"},
  "jan": {"people":63,"active":false,"engaged":true,"form":"test2"},
  "feb": {"people":46,"active":true,"engaged":false,"form":"test3"},
  "mar": {"people":65,"active":false,"engaged":false,"form":"test4"},
  "apr": {"people":66,"active":true,"engaged":true,"form":"test5"},
  "may": {"people":67,"active":false,"engaged":true,"form":"test6"}
}

A: I figured it out, putting for future reference or if anybody else needs to know how to do this:
https://jsfiddle.net/7kg6kuzm/3/
I ended up putting a check on each input line and also checking the value of the first line:
<input ng-disabled="(months['all'].active || months['all'].engaged) && this.month!=='all'" type="text" ng-model="info.people"/>


text:
Q: UIImagePickerController cancel button not working when compressing video My app provides a video upload function. But after selecting the video, UIImagePickerController will perform video compression. At this time, clicking the Cancel button will not interrupt the compression process. Is there a way to solve this problem? Reference Image: https://i.stack.imgur.com/mBSAv.png
system is iOS 12.1
 let vc = UIImagePickerController()
 vc.sourceType = .photoLibrary
 vc.mediaTypes = [kUTTypeMovie as String]
 vc.delegate = self
 navigationController?.present(vc, animated: true, completion: nil)
//when compressing video left button is not responding

A: You can't interrupt the systems UIImagePickerController video compression.
What you can do if you need this functionality is initialize the UIImagePickerController with passthrough preset like this:
if (@available(iOS 11.0, *))
    picker.videoExportPreset = AVAssetExportPresetPassthrough;

Then you can fully manage compression with something like SDAVAssetExportSession (that is a more feature-complete version of systems AVAssetExportSession) and a modal view with a progress indicator and a cancel button that call cancelExport of your exportSession instance.


text:
Q: How do i get my program to register the second error in my try/catch program I am new to C++. I have a try/catch program but, whenever I try to test the second catch block to see if it catches its related throw statement, the program prints the message from the first catch block. This is the code:
I have tried to change the specific error (something like std::invalid_argument) to something more general like std::exception but that wasn't specific enough for my error message. This is for a class and the code must account for user input that isn't a number, or isn't a number 1-4.
//c++

/*For context, choice is an integer from
User input that is supposed to be a number 1-4.*/

void search() {
    int choice;
    std::cout << "Search by:\n1:Title\n2:Year\n3:Actor\n4:Rating\n";

    try {
        std::cin >> choice;
        if(!isdigit(choice)) {
            throw std::invalid_argument("Please type a number. \n");
        }
        if(choice >= 5 || choice <= 1) {
            throw out_of_range("Please input a number between 1 and 4");
        }
    }
    catch(std::out_of_range const& e){
        std::cout << e.what();
        cin.clear();
    }
    catch(std::invalid_argument const& e) {
        std::cout << e.what();
    }

Sorry if it"s not the best, I am still learning.
The issue is that the out_of_range catch statement does not print its error message when it is thrown. I only get the invalid_argument throw/catch response.

A: This line
if(!isdigit(choice)) {

doesn't do what you think it does. It returns whether a character code such as 'x' (120 in ASCII) or '4' (52 in ASCII) is a digit or not. (i.e. it returns true for all character codes between '0' and '9').  But choice does not represent a character code, it represents the number that the user typed in integer form.
If I'm not mistaken, choice will be 0 if what's typed isn't a valid integer. In which case, you can keep your code simply as:
    try {
        std::cin >> choice;
        if(choice >= 5 || choice <= 1) {
            throw out_of_range("Please input a number between 1 and 4");
        }
    }
    catch(std::out_of_range const& e){
        std::cout << e.what();
        cin.clear();
    }


text:
Q: Pygame window freeze during large calculations in main loop I have a game where you play against an AI. The main pygame loop looks something like this:
def main():
    running = True
    while running:

        # Some code here.....

        if move_made == True:
            move = ai_make_move(gamestate)

The problem here is that ai_make_move() takes around 10-15 seconds to calculate. During this time the pygame window freezes since the main loop is not updating until ai_make_move() is ready. Is there a way to make calculations in the background and keep the main pygame loop running somehow? So that I can e.g. move the window around during calculation time.

A: import pygame
from pygame.locals import *
import threading
#your constants and more there
finished=True
def ai_make_move(args):
    global finished
    # do some stuff there
    finished=True
def main():
    global finished
    running=True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:
                running=False
        #do some stuff here
        if move_made and finished:
            thread=threading.Thread(target=lambda: ai_make_move(gamestate))
            thread.start()
            finished=False
        #also there
        pygame.display.update()

if __name__ == '__main__':
    main()

it allows you to do pygame code in paralel as the ai_make_move function works
I can't promise it works but only that you should change somehow your code( if it does not work ) . I mean the base is here but maybe you should change something in your code to make what you want
hope i helped you!


text:
Q: Unable to See Button(s) in an inflated View I had created AlertDialog by inflating the following XML:
    LayoutInflater li = LayoutInflater.from(this);
    View dialogView = li.inflate(R.layout.activity_list_logs, null);
    ListView list = (ListView) dialogView.findViewById(R.id.listDates);

The full code for showing alertDialog is:
private void showLogs(final List<Absentees> abs) {
    LayoutInflater li = LayoutInflater.from(this);
    View dialogView = li.inflate(R.layout.activity_list_logs, null);
    ListView list = (ListView) dialogView.findViewById(R.id.listDates);
    list.setAdapter(new CustomAdapterTagAbsentees(this,abs));
    list.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapter, View view,int position, long id) {
                Absentees a =(Absentees)adapter.getItemAtPosition(position);
                try
                {
                    showLogDetails(a);
                }
                catch(Exception e)
                {
                    show_popup(e+"");
                }
            }

        });
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setView(dialogView);
    alertDialogBuilder.setTitle("Attendance Details:");
    alertDialogBuilder.setMessage("Day : ");
    alertDialogBuilder
        .setCancelable(true)
        .setPositiveButton("Dismiss",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {
                dialog.cancel();
            }
        });
  AlertDialog alertDialog = alertDialogBuilder.create();
  alertDialog.show();
}

The Layout Used :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
>
<ListView
    android:id="@+id/listDates"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:textSize="20sp"
    />
</LinearLayout>

About My Problem:
if the List is small enough to fit the screen I can see "Dismiss" button(The positiveButton).

Else if the List is too large, I can't see the "Dismiss" Button

Kindly Help me!!, I tried to add a Button to Bottom of the  within the layout itself, Its showing correctly, But i wonder why this default way of showing a positiveButton is not displaying at all

A: Use a RelativeLayout instead of a Linear.  Put the buttons to layout_alignParentBottom="true".  Put the listview to layout_above="id of button".  This will force the buttons to the bottom of the screen and reserve space for them before the listview is drawn.  Otherwise the listview is greedy and will suck up all the space needed.

A: Here is the final Solution for my problem, Thanks for @blackbelt for the suggestion
 private void showLogs(final List<Absentees> abs) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    final ListAdapter adapter = new CustomAdapterTagAbsentees(this,abs);
    alertDialogBuilder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            showLogs(abs);
            Absentees a =(Absentees) adapter.getItem(item);
            showLogDetails(a);
        }
    });

    alertDialogBuilder.setTitle("Attendance Details:");
    //alertDialogBuilder.setMessage("Day : XXXX");
    alertDialogBuilder
        .setCancelable(false)
        .setPositiveButton("Dismiss",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {
                dialog.cancel();
            }
        });
  AlertDialog alertDialog = alertDialogBuilder.create();
  alertDialog.show();
}

I have to comment/remove
 alertDialogBuilder.setMessage("Day : XXXX ");

for succesfull implementation, Dont know why!!


text:
Q: Orbit equations for a vector field Suppose I am given a vector field $X$ over a two-dimensional Euclidean Space.
Suppose that the equation $\{f=0\}$ (which defines a curve in the plane) is the equation of a orbit of the vector fields $X$.
What does this means in terms of $X(f)$ I am guessing that the set $\{f=0\}$ must be $X$-invariant, therefore $f$ satisfies $X(f)=p\cdot f$, $p$ being a constant. is this right?
EDIT: I should also add that $f$ is an irreductible polynomial! We can also consider that $X$ is a polynomial field of the form $X=px\partial_x+qy\partial_y$ where $p$ and $q$ are positive integer which are relatively primes.

A: If orbit belongs to some curve $f(x, y) = \rm{const}$, then  at least you could obtain by differentiantion  that $(\nabla f, X) = 0$ along this curve. It's easy to show that by chain rule: suppose that $(x(t), y(t))$ is a trajectory that belongs to curve $f(x, y)= \rm const$, then $f(x(t), y(t)) = \rm{const}$ and $\frac{\partial f}{\partial x} \cdot x'_t + \frac{\partial f}{\partial y} \cdot y'_t = 0$ which can be rewritten as $(\nabla f, X)$.


text:
Q: PHP file_get_contents source code location I would like to have a look at the source code of file_get_contents.
I've been googling for hours now but cannot find it or it's location in php download.
I downloaded php-5.4.15.
Does anyone know where I could find this?

A: You can view (and more importantly, search) the PHP source online here.
The source for the current version of file_get_contents in the 5.4 branch is here. As an added bonus, all names in the source are also linked to searches from which you can easily get to their definitions in turn.


text:
Q: Copy Files from a Folder With in a Folder Hello Guys i would like your help in the following. I have a folder that contains some msi files that i am installing with powershell. the code is as follows.
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2010_Runtimes_x86.msi") -ArgumentList '/qb' -Wait

i use the same command to install the rest of the msi files. I have a different folder thats called Project that lives inside the original folder. I would like to copy all the files that are inside project folder to a different directory.
Copy-Item -Path $(Join-Path -Path $PSScriptRoot -ChildPath "Project") -Destination "C:\Program Files (x86)\Hewlett Packard Enterprise\Records Manager" -Recurse

The code for copying files does not work :(
My entire code is:
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2010_Runtimes_x86.msi") -ArgumentList '/qb' -Wait
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2013_Runtimes_x86.msi") -ArgumentList '/qb' -Wait
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "HPE_RM_x86.msi") -ArgumentList '/qb' -Wait

Remove-Item 'C:\Users\Public\Desktop\HPE RM Queue Processor.lnk'
Remove-Item 'C:\Users\Public\Desktop\HPE RM Desktop.lnk'

Copy-Item -Path $(Join-Path -Path $PSScriptRoot -ChildPath "Project") -Destination "C:\Program Files (x86)\Hewlett Packard Enterprise\Records Manager" -Recurse


text:
Q: How to replace all newline characters except the ones after " using php regex Please help me with a regular expression to replace the newline characters with dot (.) in the following dummy lines.
First line where i want to replace the newline character
Second line where i want to replace the newline character
I want to skip this line as i have quote at the end "
Third line I want to replace new line character
Expected
First line where i want to replace the newline character.Second line where i want to replace the newline character.I want to skip this line as it has quote at the end "Third line I want to replace new line character

A: You can use this regex:
$repl = preg_replace('/(?<!")(\R|\z)/', '.', $input);

RegEx Demo

*

*\R matches any Unicode newline sequence.

*\z assert position at the very end of the string.

*(?<!") is negative lookbehind to make sure line end is not preceded with "


text:
Q: proFTPD not working due to socket bind error I am trying to set up an FTP server on one of my devices that runs DietPi and I selected proFTPD as a server.
I have installed the software and followed some set-up information I found here. But then I noticed that the service was not running. After trying to find it in via ps aux | grep proftpd I did not succeed.
After issuing: systemclt status proftpd.service I got the following:
● proftpd.service - LSB: Starts ProFTPD daemon
   Loaded: loaded (/etc/init.d/proftpd; generated)
   Active: failed (Result: exit-code) since Tue 2021-04-13 22:58:49 BST; 9s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 26998 ExecStart=/etc/init.d/proftpd start (code=exited, status=1/FAILURE)

Apr 13 22:58:48 DietPi systemd[1]: Starting LSB: Starts ProFTPD daemon...
Apr 13 22:58:49 DietPi proftpd[26998]: Starting ftp server: proftpd2021-04-13 22:58:49,163 DietPi proftpd[2700
5]: mod_ctrls/0.9.5: error: unable to bind to local socket: Address already in use
Apr 13 22:58:49 DietPi proftpd[26998]: 2021-04-13 22:58:49,242 DietPi proftpd[27005]: error: unable to stat()
/var/log/proftpd: No such file or directory
Apr 13 22:58:49 DietPi proftpd[26998]: 2021-04-13 22:58:49,244 DietPi proftpd[27005]: mod_ctrls/0.9.5: unable
to open ControlsLog '/var/log/proftpd/controls.log': No such file or directory
Apr 13 22:58:49 DietPi proftpd[26998]: 2021-04-13 22:58:49,246 DietPi proftpd[27005]: fatal: ControlsLog: unab
le to open '/var/log/proftpd/controls.log': No such file or directory on line 68 of '/etc/proftpd/proftpd.conf'
Apr 13 22:58:49 DietPi proftpd[26998]:  failed!
Apr 13 22:58:49 DietPi systemd[1]: proftpd.service: Control process exited, code=exited, s
tatus=1/FAILURE
Apr 13 22:58:49 DietPi systemd[1]: proftpd.service: Failed with result 'exit-code'.
Apr 13 22:58:49 DietPi systemd[1]: Failed to start LSB: Starts ProFTPD daemon.

So I dug a little bit here and turns out that no other process runs or binds on port 21. So, what could be the issue of the service failing here?
Furthermore, by issuing sudo lsof -i tcp:21 I do not get any response.
Also, via nmap I get the following:
PORT   STATE SERVICE
22/tcp open  ssh
53/tcp open  domain
80/tcp open  http

No 21/tcp port here.
Debug via proftpd -nd10 on the cl:
roftpd -nd10
2021-04-14 08:13:45,498 DietPi proftpd[951]: using PCRE 8.39 2016-06-14
2021-04-14 08:13:45,508 DietPi proftpd[951]: using TCP receive buffer size of 131072 bytes
2021-04-14 08:13:45,510 DietPi proftpd[951]: using TCP send buffer size of 16384 bytes
2021-04-14 08:13:45,513 DietPi proftpd[951]: testing Unix domain socket using S_ISFIFO
2021-04-14 08:13:45,517 DietPi proftpd[951]: testing Unix domain socket using S_ISSOCK
2021-04-14 08:13:45,519 DietPi proftpd[951]: using S_ISSOCK macro for Unix domain socket detection
2021-04-14 08:13:45,528 DietPi proftpd[951]: mod_ctrls/0.9.5: error: unable to bind to local socket: Address already in use
2021-04-14 08:13:45,532 DietPi proftpd[951]: using 'UTF-8' as local charset for UTF-8 conversion
2021-04-14 08:13:45,535 DietPi proftpd[951]: ROOT PRIVS at mod_core.c:376
2021-04-14 08:13:45,537 DietPi proftpd[951]: RELINQUISH PRIVS at mod_core.c:378
2021-04-14 08:13:45,541 DietPi proftpd[951]: ROOT PRIVS at mod_core.c:385
2021-04-14 08:13:45,544 DietPi proftpd[951]: ROOT PRIVS at parser.c:1187
2021-04-14 08:13:45,549 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_ctrls_admin.c'
2021-04-14 08:13:45,554 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_ctrls_admin' (from '/usr/lib/proftpd/mod_ctrls_admin.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,558 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_tls.c'
2021-04-14 08:13:45,562 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_tls' (from '/usr/lib/proftpd/mod_tls.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,565 DietPi proftpd[951]: mod_tls/2.7: using OpenSSL 1.1.1d  10 Sep 2019
2021-04-14 08:13:45,587 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_radius.c'
2021-04-14 08:13:45,591 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_radius' (from '/usr/lib/proftpd/mod_radius.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,594 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_quotatab.c'
2021-04-14 08:13:45,599 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_quotatab' (from '/usr/lib/proftpd/mod_quotatab.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,602 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_quotatab_file.c'
2021-04-14 08:13:45,607 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_quotatab_file' (from '/usr/lib/proftpd/mod_quotatab_file.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,609 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_quotatab_radius.c'
2021-04-14 08:13:45,612 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_quotatab_radius' (from '/usr/lib/proftpd/mod_quotatab_radius.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,617 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_wrap.c'
2021-04-14 08:13:45,625 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_wrap' (from '/usr/lib/proftpd/mod_wrap.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,628 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_rewrite.c'
2021-04-14 08:13:45,633 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_rewrite' (from '/usr/lib/proftpd/mod_rewrite.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,636 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_load.c'
2021-04-14 08:13:45,639 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_load' (from '/usr/lib/proftpd/mod_load.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,643 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_ban.c'
2021-04-14 08:13:45,648 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_ban' (from '/usr/lib/proftpd/mod_ban.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,651 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_wrap2.c'
2021-04-14 08:13:45,656 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_wrap2' (from '/usr/lib/proftpd/mod_wrap2.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,660 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_wrap2_file.c'
2021-04-14 08:13:45,664 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_wrap2_file' (from '/usr/lib/proftpd/mod_wrap2_file.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,668 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_dynmasq.c'
2021-04-14 08:13:45,673 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_dynmasq' (from '/usr/lib/proftpd/mod_dynmasq.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,675 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_exec.c'
2021-04-14 08:13:45,681 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_exec' (from '/usr/lib/proftpd/mod_exec.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,683 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_shaper.c'
2021-04-14 08:13:45,688 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_shaper' (from '/usr/lib/proftpd/mod_shaper.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,692 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_ratio.c'
2021-04-14 08:13:45,696 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_ratio' (from '/usr/lib/proftpd/mod_ratio.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,699 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_site_misc.c'
2021-04-14 08:13:45,704 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_site_misc' (from '/usr/lib/proftpd/mod_site_misc.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,706 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_sftp.c'
2021-04-14 08:13:45,722 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_sftp' (from '/usr/lib/proftpd/mod_sftp.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,725 DietPi proftpd[951]: mod_sftp/1.0.0: using OpenSSL 1.1.1d  10 Sep 2019
2021-04-14 08:13:45,737 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_sftp_pam.c'
2021-04-14 08:13:45,741 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_sftp_pam' (from '/usr/lib/proftpd/mod_sftp_pam.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,744 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_facl.c'
2021-04-14 08:13:45,749 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_facl' (from '/usr/lib/proftpd/mod_facl.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,752 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_unique_id.c'
2021-04-14 08:13:45,757 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_unique_id' (from '/usr/lib/proftpd/mod_unique_id.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,762 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_copy.c'
2021-04-14 08:13:45,768 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_copy' (from '/usr/lib/proftpd/mod_copy.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,773 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_deflate.c'
2021-04-14 08:13:45,787 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_deflate' (from '/usr/lib/proftpd/mod_deflate.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,789 DietPi proftpd[951]: mod_deflate/0.5.7: using zlib 1.2.11
2021-04-14 08:13:45,792 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_ifversion.c'
2021-04-14 08:13:45,798 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_ifversion' (from '/usr/lib/proftpd/mod_ifversion.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,800 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_memcache.c'
2021-04-14 08:13:45,805 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_memcache' (from '/usr/lib/proftpd/mod_memcache.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,809 DietPi proftpd[951]: mod_memcache/0.1: using libmemcached-1.0.18
2021-04-14 08:13:45,812 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_tls_memcache.c'
2021-04-14 08:13:45,815 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_tls_memcache' (from '/usr/lib/proftpd/mod_tls_memcache.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,815 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_readme.c'
2021-04-14 08:13:45,823 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_readme' (from '/usr/lib/proftpd/mod_readme.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,825 DietPi proftpd[951]: mod_dso/0.5: loading 'mod_ifsession.c'
2021-04-14 08:13:45,831 DietPi proftpd[951]: mod_dso/0.5: loaded module 'mod_ifsession' (from '/usr/lib/proftpd/mod_ifsession.so', last modified on Tue Mar 10 23:03:08 2020)
2021-04-14 08:13:45,835 DietPi proftpd[951]: RELINQUISH PRIVS at parser.c:1190
2021-04-14 08:13:45,838 DietPi proftpd[951]: RELINQUISH PRIVS at mod_core.c:388
2021-04-14 08:13:45,844 DietPi proftpd[951]: DenyFilter: compiling regex '\*.*/'
2021-04-14 08:13:45,857 DietPi proftpd[951]: retrieved UID 1000 for user 'dietpi'
2021-04-14 08:13:45,862 DietPi proftpd[951]: retrieved GID 1000 for group 'dietpi'
2021-04-14 08:13:45,866 DietPi proftpd[951]: <IfModule>: using 'mod_quotatab.c' section at line 53
2021-04-14 08:13:45,868 DietPi proftpd[951]: <IfModule>: using 'mod_ratio.c' section at line 57
2021-04-14 08:13:45,871 DietPi proftpd[951]: <IfModule>: using 'mod_delay.c' section at line 61
2021-04-14 08:13:45,873 DietPi proftpd[951]: <IfModule>: using 'mod_ctrls.c' section at line 65
2021-04-14 08:13:45,874 DietPi proftpd[951]: ROOT PRIVS at mod_ctrls.c:114
2021-04-14 08:13:45,877 DietPi proftpd[951]: RELINQUISH PRIVS at mod_ctrls.c:117
2021-04-14 08:13:45,878 DietPi proftpd[951]: <IfModule>: using 'mod_ctrls_admin.c' section at line 73
2021-04-14 08:13:45,879 DietPi proftpd[951]: ROOT PRIVS at mod_core.c:376
2021-04-14 08:13:45,879 DietPi proftpd[951]: RELINQUISH PRIVS at mod_core.c:378
2021-04-14 08:13:45,879 DietPi proftpd[951]: ROOT PRIVS at mod_core.c:385
2021-04-14 08:13:45,879 DietPi proftpd[951]: processing configuration directory '/etc/proftpd/conf.d/'
2021-04-14 08:13:45,880 DietPi proftpd[951]: RELINQUISH PRIVS at mod_core.c:388
2021-04-14 08:13:45,907 DietPi proftpd[951]: UseReverseDNS off, returning IP address instead of DNS name
2021-04-14 08:13:45,907 DietPi proftpd[951] 127.0.0.1:
2021-04-14 08:13:45,907 DietPi proftpd[951] 127.0.0.1: Config for DietPi FTP:
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: IdentLookups
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: DeferWelcome
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: MultilineRFC2228
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: DefaultServer
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: ShowSymlinks
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: AllowRetrieveRestart
2021-04-14 08:13:45,908 DietPi proftpd[951] 127.0.0.1: AllowStoreRestart
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: TimeoutNoTransfer
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: TimeoutStalled
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: TimeoutIdle
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: DisplayLogin
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: DisplayChdir
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: ListOptions
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: DenyFilter
2021-04-14 08:13:45,909 DietPi proftpd[951] 127.0.0.1: DefaultRoot
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: RootLogin
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: UserID
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: UserName
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: GroupID
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: GroupName
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: Umask
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: DirUmask
2021-04-14 08:13:45,910 DietPi proftpd[951] 127.0.0.1: AllowOverwrite
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: TransferLog
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: SystemLog
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: WtmpLog
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: QuotaEngine
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: Ratios
2021-04-14 08:13:45,911 DietPi proftpd[951] 127.0.0.1: DelayEngine
2021-04-14 08:13:45,912 DietPi proftpd[951] 127.0.0.1: mod_facl/0.6: registered 'facl' FS
2021-04-14 08:13:45,921 DietPi proftpd[951] 127.0.0.1: mod_tls/2.7: generating initial TLS session ticket key
2021-04-14 08:13:45,924 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at mod_tls.c:4815
2021-04-14 08:13:45,927 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at mod_tls.c:4818
2021-04-14 08:13:45,930 DietPi proftpd[951] 127.0.0.1: mod_tls/2.7: scheduling new TLS session ticket key every 3600 secs
2021-04-14 08:13:45,935 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: binding to text domain 'proftpd' using locale path '/usr/share/locale'
2021-04-14 08:13:45,936 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: using locale files in '/usr/share/locale'
2021-04-14 08:13:45,939 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'ko_KR': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,943 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'bg_BG': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,945 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'ja_JP': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,948 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'en_US': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,951 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'fr_FR': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,954 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'es_ES': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,958 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'zh_TW': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,960 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'zh_CN': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,964 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'it_IT': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,968 DietPi proftpd[951] 127.0.0.1: mod_lang/1.1: skipping possible language 'ru_RU': not supported by setlocale(3); see `locale -a'
2021-04-14 08:13:45,971 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at mod_log.c:2151
2021-04-14 08:13:45,974 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at mod_log.c:2154
2021-04-14 08:13:45,976 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at mod_rlimit.c:555
2021-04-14 08:13:45,978 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at mod_rlimit.c:558
2021-04-14 08:13:45,980 DietPi proftpd[951] 127.0.0.1: set core resource limits for daemon
2021-04-14 08:13:45,981 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at mod_auth_unix.c:1338
2021-04-14 08:13:45,986 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at mod_auth_unix.c:1341
2021-04-14 08:13:45,989 DietPi proftpd[951] 127.0.0.1: retrieved group ID: 1000
2021-04-14 08:13:45,991 DietPi proftpd[951] 127.0.0.1: setting group ID: 1000
2021-04-14 08:13:45,993 DietPi proftpd[951] 127.0.0.1: SETUP PRIVS at main.c:2594
2021-04-14 08:13:45,994 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at main.c:1862
2021-04-14 08:13:45,995 DietPi proftpd[951] 127.0.0.1: deleting existing scoreboard '/run/proftpd.scoreboard'
2021-04-14 08:13:45,996 DietPi proftpd[951] 127.0.0.1: opening scoreboard '/run/proftpd.scoreboard'
2021-04-14 08:13:45,998 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at main.c:1889
2021-04-14 08:13:46,002 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at mod_ctrls_admin.c:1632
2021-04-14 08:13:46,002 DietPi proftpd[951] 127.0.0.1: opening scoreboard '/run/proftpd.scoreboard'
2021-04-14 08:13:46,005 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at mod_ctrls_admin.c:1634
2021-04-14 08:13:46,007 DietPi proftpd[951] 127.0.0.1: ROOT PRIVS at inet.c:409
2021-04-14 08:13:46,008 DietPi proftpd[951] 127.0.0.1: RELINQUISH PRIVS at inet.c:459
2021-04-14 08:13:46,009 DietPi proftpd[951] 127.0.0.1: Failed binding to ::, port 21: Address already in use
2021-04-14 08:13:46,011 DietPi proftpd[951] 127.0.0.1: Check the ServerType directive to ensure you are configured correctly
2021-04-14 08:13:46,011 DietPi proftpd[951] 127.0.0.1: Check to see if inetd/xinetd, or another proftpd instance, is already using ::, port 21
2021-04-14 08:13:46,011 DietPi proftpd[951] 127.0.0.1: Unable to start proftpd; check logs for more details

Debug via strace proftpd | grep -E "SOCKET|sock"
getpeername(0, 0xbe8a6c1c, [16])        = -1 ENOTSOCK (Socket operation on non-socket)
socket(AF_UNIX, SOCK_DGRAM, 0)          = 3
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
getsockopt(4, SOL_SOCKET, SO_RCVBUF, [131072], [4]) = 0
getsockopt(4, SOL_SOCKET, SO_SNDBUF, [16384], [4]) = 0
socket(AF_UNIX, SOCK_STREAM, 0)         = 4
bind(4, {sa_family=AF_UNIX, sun_path="/run/test.sock"}, 110) = 0
unlink("/run/test.sock")                = 0
socket(AF_UNIX, SOCK_STREAM, 0)         = 4
bind(4, {sa_family=AF_UNIX, sun_path="/run/proftpd.sock"}, 110) = -1 EADDRINUSE (Address already in use)
write(2, "2021-04-14 11:08:40,739 DietPiHo"..., 1292021-04-14 11:08:40,739 DietPi proftpd[2682]: mod_ctrls/0.9.5: error: unable to bind to local socket: Address already in use
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 6
connect(6, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 6
connect(6, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 4
getsockname(4, {sa_family=AF_NETLINK, nl_pid=2682, nl_groups=00000000}, [12]) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 4
getsockname(4, {sa_family=AF_INET, sin_port=htons(44402), sin_addr=inet_addr("127.0.0.1")}, [28->16]) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(40796), sin_addr=inet_addr("127.0.0.1")}, [28->16]) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 4

A: The strace output indicates that the error is caused by the attempt to create /run/proftpd.sock, which apparently already exists.
Try fuser /run/proftpd.sock to see if any process is holding onto it; it will report the PID numbers of any such processes. Then use ps -fp <PID number here> to get more information about the process(es) in question.
If it's systemd, you might need to do something like systemctl stop proftpd.socket; systemctl disable proftpd.socket to get rid of it. (In this case, DietPi's default ProFTPD configuration might have been tailored to use systemd's socket activation mechanism - essentially a mechanism that can replace the classic inetd/xinetd in running the FTP daemon on-demand only. As you seem to want to run ProFTPD as a classic stand-alone service, you would need to disable systemd's socket for it.)
If it's some other process, you might want to kill it and figure out how to prevent it from getting started again.
But if fuser lists no processes at all, it might be that the /run/proftpd.sock is simply a left-over from an earlier test run that did not start correctly; in that case, run rm /run/proftpd.sock and try systemctl start proftpd.service again.


text:
Q: Typescript code within jQuery callback function I want to put the typescript code inside the jQuery callback function. This is an Angular 6 component ts file. I'm using Material DataTable as HTML template. When I click a button, I want to first let the row fadeout, then update the mongoDB, and then repaginate my datatable.
Right now in this sequence, the fadeOut does not work properly because the update function is not inside the callback function of jQuery (I guess).
Could someone please shed some light?
Thx

onSetOK(user: USER, i: number) {
  const index = this.dataSource.data.indexOf(user);
  console.log(index);

  //here begins the jQuery code to let the row fadeout
  $().ready(function() {
    const $row = $('#row' + i);
    $row.fadeOut(1000, function(e) {

      $row.remove();
      // put the below typescript code here
    });
  });

  //typescript code, update mongoDB
  this.service.updateUserOK(user).subscribe(res => {

    this.dataSource.data.splice(index, 1);
    this.dataSource.sort = this.sort;

    this.dataSource.paginator = this.paginator;

  });

}
...

<ng-container matColumnDef='Actions'>
  <mat-header-cell *matHeaderCellDef mat-sort-header> Actions </mat-header-cell>
  <mat-cell *matCellDef='let u, let i = index' (click)='$event.stopPropagation()'>
    <button mat-raised-button (click)='onSetOK(u, i)'>
      <i class='fas fa-check fa-2x'></i>
    </button>
  </mat-cell>
</ng-container>

<mat-row *matRowDef='let row; columns: getDisplayedColumns(); let i = index;' attr.id='row{{i}}'></mat-row>

A: You are missusing the ready function. Quote from the jQuery API Docs:

Description: Specify a function to execute when the DOM is fully loaded.

Because your DOM is at this point fully loaded, the callback will never be called. Just execute your fade effect like this:
onSetOK(user: USER, i: number) {
  const index = this.dataSource.data.indexOf(user);
  console.log(index);

  //here begins the jQuery code to let the row fadeout
  const $row = $('#row' + i);
  $row.fadeOut(1000, (e) => {

    $row.remove();
    // put the below typescript code here

    //typescript code, update mongoDB
    this.service.updateUserOK(user).subscribe(res => {
      this.dataSource.data.splice(index, 1);
      this.dataSource.sort = this.sort;
      this.dataSource.paginator = this.paginator;
    });
  });
}


text:
Q: Adding two character arrays into one another I'm working on a program that is basically suppose to list IceCreams with their Ingredients, name, price and discount, to the point in the code given I'm trying to take 2 different Ice Cream names and if say the user entered Caramel Apple Delight and chocolate I need it to give me "Caramel Apple Delight + chocolate", and since I'm new to how operators works and this needs to be done with an operator I've been stuck for hours on this, I've run into a similar problem and I don't know how I can do this, I've considered to concat the strings but it doesn't make any sense when it comes to the printing part.
IceCream &operator +(const IceCream &i){
        IceCream temp;
        temp.name = strncpy(this->name) + strncat(i.name);
        if(*this>temp){
            delete [] temp.name;
            temp.name=new char [strlen(this->name)+1];
            strncpy(temp.name,this->name,strlen(this->name)+1);

        }
        return temp;
    }

This is the rest of the code and I am aware I have some issues with it but this is what I need help to solve since I'm having trouble understanding how all the operators work.
class IceCream{
    private:
    char *name;
    char ingr[100];
    float price;
    int discount;

    public:
    IceCream(){name=new char [0];}
    IceCream(char *name=" ", char* ingr=" ", float price=0.0, int discount=0){
        this->name=new char[strlen(name)+1];
        strcpy(this->name, name);
        strcpy(this->ingr,ingr);
        this->price=price;
        this->discount=discount;
    }

    IceCream(const IceCream &i){
        this->name=new char[strlen(i.name)+1];
        strcpy(this->name,i.name);
        strcpy(this->ingr,i.ingr);
        this->price=i.price;
        this->discount=i.discount;
    }

    ~IceCream(){delete [] this->name;}

    friend ostream& operator<<(ostream& out, IceCream &i){
        if(i.discount>0){
            out<<i.name<<": "<<i.ingr<<" "<<i.ingr" "<<"("i.discount")"<<endl;
        }
        else{
            out<<i.name<<": "<<i.ingr<<" "<<i.price" "<<endl;
        }
        return out;
    }

    IceCream &operator ++(int){
        discount+=5;
        return *this;
    }

    IceCream &operator +(const IceCream &i){
        IceCream temp;
        temp.name = strncpy(this->name) + strncat(i.name);
        if(*this>temp){
            delete [] temp.name;
            temp.ime=new char [strlen(this->name)+1];
            strncpy(temp.name,this->name,strlen(this->name)+1);

        }
        return temp;
    }

A: You can change your design and make a better solution for this problem:
// DecoratorPattern.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

class IiceCream
{
public:
    virtual void Make() = 0;
    virtual ~IiceCream() { }

};

class SimpleIceCream: public IiceCream
{
public:
    virtual void Make()
    {
        std::cout<<"\n milk + sugar +  Ice cream Powder";
    }

};

class IceCreamDecorator: public IiceCream
{

public:
    IceCreamDecorator(IiceCream& decorator):m_Decorator(decorator)
    {

    }

    virtual void Make()
    {
        m_Decorator.Make();
    }
    private:
    IiceCream& m_Decorator;
};

class WithFruits : public IceCreamDecorator
{

public:
     WithFruits(IiceCream& decorator):IceCreamDecorator(decorator)
     {

     }
     virtual void Make()
     {
         IceCreamDecorator::Make();
         std::cout<<" + Fruits";
     }

};

class WithNuts : public IceCreamDecorator
{

public:
    WithNuts(IiceCream& decorator):IceCreamDecorator(decorator)
    {

    }

    virtual void Make()
    {
        IceCreamDecorator::Make();
        std::cout<<" + Nuts";
    }

};

class WithWafers : public IceCreamDecorator
{

public:
    WithWafers(IiceCream& decorator):IceCreamDecorator(decorator)
    {

    }

    virtual void Make()
    {
        IceCreamDecorator::Make();
        std::cout<<" + Wafers";
    }

};

int _tmain(int argc, _TCHAR* argv[])
{
    IiceCream* pIceCreamSimple = new SimpleIceCream();
    pIceCreamSimple->Make();

    IiceCream* pIceCreamFruits = new WithFruits(*pIceCreamSimple);
    pIceCreamFruits->Make();

    IiceCream* pIceCreamNuts   = new WithNuts(*pIceCreamFruits);
    pIceCreamNuts->Make();

    IiceCream* pIceCreamWafers = new WithWafers(*pIceCreamNuts);
    pIceCreamWafers->Make();

    delete pIceCreamSimple;
    delete pIceCreamFruits;
    delete pIceCreamNuts;
    delete pIceCreamWafers;

    return 0;
}

This solution use decorator design pattern.

A: You can't use + to concatenate char arrays. You need to allocate space for the new string with new, then copy and concatenate into that.
IceCream &operator +(const IceCream &i){
    IceCream temp;
    delete[] temp.name; // Free the string allocated by the default constructor
    temp.name = new char[strlen(this->name) + strlen(i.name) + 1];
    strcpy(temp.name, this->name);
    strcat(temp.name, i.name);
    return temp;
}


text:
Q: A collection/Data Structure which prevents deletion and allows insertion and read only functionality I want your help for creating a data structure/ Collection which supports read and insert functionality and prevents deletion/removal of records.
One way i could think of is , to create a customized collection ( like myHashMap ) and override all the delete/remove methods and thus prevent removal/deletion of records? But this approach will not work if the Object is having removal method as Final.
Please suggest any better way ..!!!!

A: You can create your own arraylist by overriding the methods like remove() with unsupported operation exception. If you want you can also declare arraylist like this.
ArrayList<String> myList = new ArrayList<String>() {

    @Override
    public boolean remove(String str) {
      //If you want, you can throw Unsupported operation exception also.
      return false;
    }
  };

There may be some other good approaches, you can check answers from others also.

A: You can create your Map wrapper and provide only the methods you want to :
class MyHashMap<K, V>  {

    Map<K, V> map;

    public MyHashMap(Map<K, V> map) {
        this.map = map;
    }

    public V put(K key, V value) {
        return map.put(key, value);
    }

    public V get(K key) {
        return map.get(key);
    }

    // other methods you want
}

example:
MyHashMap<String, String> myMap = new MyHashMap<>(new HashMap<>());


text:
Q: Как восстановить удалённые файлы в отдельном каталоге логического раздела? Допустим в папке dir у меня лежали два файла file1.msk и file2.msk, которые были удалены командой rm. Существует ли способ восстановить только их (или все файлы в папке), но не весь логический раздел? И если да, то какой?

A:
Существует ли способ восстановить

Это зависит от файловой системы. Насколько я помню, для ext2 были какие-то утилитки, для ext3 - уже нет. Чем сложнее устроена ФС, тем меньше шансов восстановить хоть что-то. Почитайте вот это:
http://rus-linux.net/MyLDP/file-sys/vosstanovlenie-failov-v-Linux.html
может быть - поможет!


text:
Q: How does PHP handle simultaneous hits with same variable names on 1 file I have a php file where I have API code going on. This file is making use of the twitter api, in the file I'm passing user keys via sessions for processing and sending of tweet.
I'm wondering, what would happen when multiple requests are coming to this file at the same second?
If 5 requests from different geographical locations are coming to the file..each with different variable values...but all will be taking the same variable names...does php create 5 instances of that file to perform the tweets?
Please see my code to see what's going on: http://pastebin.com/ic6pYLgi
What would happen when multiple people are sending requests to that file?
<?php
session_start();
//pass session variables into  standard variable
$ck = $_SESSION['consumer_key'];
$cs = $_SESSION['consumer_secret'];
$at = $_SESSION['access_token'];
$ats = $_SESSION['access_token_secret'];
$hashtag = $_SESSION['hashtag'];
$tweet = $_POST['tweet'];

//TODO unset session at end of script
//TODO limit tweet length

if (!empty($ck && $cs && $at && $ats && $tweet)){
  $ck = $_POST['consumer_key'] = $ck; //get session value into POST then pass back to variable
  $cs = $_POST['consumer_secret'] = $cs;
  $at = $_POST['access_token'] = $at;
  $ats = $_POST['access_token_secret'] = $ats;
  $_POST['tweet'];
  $hashtag = $_POST['hashtag'] = $hashtag;
}

require "autoload.php";

use Abraham\TwitterOAuth\TwitterOAuth;

define('CONSUMER_KEY', $ck); // add app consumer key between single quotes
define('CONSUMER_SECRET', $cs); // add app consumer secret key between single quotes
$access_token = $at;
$access_token_secret = $ats;

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);

if (!empty($ck && $cs && $at && $ats && $tweet && $hashtag)) {

  $hashtag = '#' . $hashtag;
  $connection->post('statuses/update',array('status' => $tweet . ' ' . $hashtag));
  $t = $connection;
  echo '
';
  //print_r($t);
  echo '
';
  echo "Your message has been sent to Twitter with a hashtag.";
}

//TODO Add error handling to send to special inbox

//Tweet without hashtags

if (!empty($ck && $cs && $at && $ats && $tweet) && empty($hashtag)) {
  $connection->post('statuses/update',array('status' => $tweet));
  //$t = $connection;
  //echo '
';
  //print_r($t);
  //echo '
';
  //echo "Your message has been sent to Twitter without a hashtag.";
}

session_destroy(); //this will hopefully help with load on this file
?>

A: Any variables in a php request are independent of any simultaneous requests, so some other request being processed will in no way be making edits to your variables.
The $_SESSION var will contain a copy of the shared session scope.  The copy is made once at the time session_start() is called, and even if there are other simultaneous pages being processed, they will not make any difference to the contents of your $_SESSION
You may not have simultaneous processing going on though.  It is my understanding that PHP cannot process more simultaneous pages than there are processors on the server.  If you have a single processor server, there is no simultaneous processing of pages, a page request that comes in while another one is processing waits in line.


text:
Q: Why does toString() work in two different ways? I've regularly used toString() for two different ways, but only recently I realized I don't understand the mechanics of what is going on.
For example I use this function to return the type of an object:
var getType = function (obj) {
    return Object.prototype.toString.call(obj).slice(8, -1);
};

getType([1,2,3]) // returns "Array"

But if I do
[1,2,3].toString()

I will get
"1,2,3"

I thought that call simply calls the function with a given this which is equal to [1,2,3].
Similarly I thought that doing [1,2,3].toString() calls toString with [1,2,3] as the this value as well.
In both cases there are no parameters and the this value is the same so what is different?

A: That's because
Array.prototype.toString !== Object.prototype.toString

For example:
Array.prototype.toString.call([1,2,3]);  // "1,2,3"
Object.prototype.toString.call([1,2,3]); // "[object Array]"


text:
Q: Redirect to the original page after authorization on SEDE After authorization, https://data.stackexchange.com redirects to the main page.
Could you redirect to the original page (from which I've tried to log in)?


text:
Q: matplotlib secondary_xaxis() function doesn't work I was looking for ways to make a plot with two x-axis and I was very happy to found the secondary_xaxis() function on https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/secondary_axis.html. I read the description and had a look at the code and then I decided to simply download the whole thing (as a Jupyter notebook) and try it out.
However, even though I didn't make any changes to the code, it didn't work. I simply got the following error directly for the first plot:
AttributeError: 'AxesSubplot' object has no attribute 'secondary_xaxis'

I really don't understand why and how this error comes up as I just downloaded the code from the website. I also tried to copy and paste it from the website, but of course the result didn't change as the code is the same.