How the apparmor works?

How to use apparmor to confine reading one file if there are two files?
I have used autodep, enforce, and complain

differential equations – For the same code, Why NDSolve sometimes works good and sometimes doesn’t?

My code is given below

T1(n_, m_) := NIntegrate((-Log(t)^(m - 1))*(LaguerreL(n, m, -Log(t)))^2, {t, 0, 1}); T1(0, 0)

T2(n_, m_) :=NIntegrate((-Log(t)^(m - 1))*(LaguerreL(n - 1, m, -Log(t)))^2, {t, 0, 1}); T2(0, 0)

T3(n_, m_) :=NIntegrate((-Log(t)^(m - 1))*LaguerreL(n, m, -Log(t))*LaguerreL(n - 1, m, -Log(t)), {t, 0,1}); T3(0, 0)

T4(n_, m_, B_, z_) := NIntegrate((-Log(t))^(2*m)*t*(LaguerreL(n, m, -Log(t)))^3*Exp(-B/(f0(z))^2*(-Log(t))^m*t*(LaguerreL(n, m, -Log(t)))^2)*((m + 2*n)*LaguerreL(n, m, -Log(t)) + Log(t)* LaguerreL(n, m, -Log(t)) - 2*(m + n)* LaguerreL(n - 1, m, -Log(t))), {t, 0, 1}); T4(0, 0, 0.7, z)

s(n_, m_, B_, W_, z_) := NDSolve({f0''(z) + 1/f0(z)*(f0'(z))^2 == Factorial(n)/(Factorial(n + m)*(2*n + m + 1))*1/(f0(z))^3*(Factorial(n + m)/ Factorial(n)*(-2*n - m + 1) + (2*n + m)^2*T1(n, m) + 4*(m + n)^2*T2(n, m) - 4*(m + n)*(m + 2*n) T3(n, m) + B*W^2*T4(n, m, B, z)), f0(0) == 1, f0'(0) == 0},f0, {z, 0, 20}); a(z_) = s(0, 0, 0.7, 4, z)

T1, T2, T3, T4 are the integrals to be used in the NDSolve s(n,m,B,W,z).

F0(n_, m_, B_, W_, z_) = Evaluate(f0(z) /. a(z))

F0 is the solution of NDsolve s(n,m,B,W,z) for the arguments given by a(z)

S(wp_, L_) := 1/2*Sqrt((Pi)/8)*wp/L^3*Exp(-1/(2*L^2) - 3/2); S(0.885*10^15, 0.4)

ki(wp_, L_, w_, k_, c_) := (S(wp, L)*w)/(k*(0.1)^2*c^2); ki(1.77*10^15, 0.4, 0.531*10^15, 1.18*10^7, 3*10^8)

S4(n_, m_, B_, W_, r_, b_, z_) := NIntegrate(t^((r^2*(F0(n, m, B, W, z))^2)/(b^2*(f(z))^2))*((r^2*(F0(n, m, B, W, z))^2)/(b^2*(f(z))^2))^m*(-Log(t))^ 2*m)*(LaguerreL(n,m, -((r^2*(F0(n, m, B, W, z))^2)/(b^2*(f(z))^2))*Log(t)))^2*LaguerreL(n, m, -Log(t))*Exp(-B/(F0(m, n, B, W, z))^2*(-Log(t))^m*t*(LaguerreL(n, m, -Log(t)))^2)*(2* (m + 2*n)*LaguerreL(n, m, -Log(t)) + 2*Log(t)*LaguerreL(n, m, -Log(t)) - 4*(m + n)*LaguerreL(n - 1, m, -Log(t))), {t, 0, 1}); S4(0, 0, 0.7, 4, 1.3*10^-6, 3*10^-6, z)

ss is another NDSolve that used the value of integral S4 and the solution of the first NDSolve.

ss(n_, m_, B_, W_, r_, b_, k0_, k_, wp_, w_, L_, c_, z_) := NDSolve({f''(z) + 1/f(z)*(f'(z))^2 == (Factorial(n)/(Factorial(n + m)*(2*n + m + 1))*1/(f(z))^3*(r^4*k0^2)/(b^4*k^2))*(Factorial(n + m)/Factorial(n)*(-2*n - m + 1) + T1(n, m)*(2*n + m)^2 + 4*T2(n, m)*(m + n)^2 -4*T3(n, m)*(m + n)*(m + 2*n) + (B*W^2)/2*1/((0.1^2)*3)*Exp(-2*ki(wp, w, L, k, c)*z*k0*r^2)*S4(n, m, B, W, r, b, z)) + ((2*(S(w, L))^2*w^2*Exp(-2*ki(wp, w, L, k, c)*z*k0*r^2))/((0.1)^4*c^4*3^2))*(r^4*k0^2)/k^2*(f(z)), f(0) == 1, f'(0) == 0},f{z, 0, 3.0}); aa(z_) = ss(0, 0, 0.7, 4, 1.3*10^(-6), 3*10^(-6), 0.59*10^7,1.18*10^7, 0.885*10^15, 0.531*10^15, 0.4, 3*(10^8), z) // Quiet

Plot(Evaluate(f(z) /. aa(z)), {z, 0, 3})

For the same code sometimes I get the final plot and sometimes getting errors. I tried it many times. Why it happens.

How do I design a screen which works for multiple cross devices

nowadays there are too many devices with different height and different aspect ratio, should I make the design for a smaller device and top of that I add a percentage respectively? or there is any other way to look at?

functions – TautologyQ like feature that also works for inequalities

If a=b and b=c, then a=c.

So in mathematica,

TautologyQ((a == b) && (b == c) (Implies) a == c, {a, b, c})

yields ‘True’.

If a<b and b<c, then a<c. (if a,b,c are elements of an ordered set)

But

TautologyQ((a < b) && (b < c) (Implies) a < c, {a, b, c})

does yield ‘True’.

Instead it yields an error message ‘…is not Boolean valued…’

Because < is not a boolean expression.

Is there a built-in feature in mathematica similar to TautologyQ, which yields true for the latter code ?

My question can be restated as following :
‘extend TautologyQ to include inequality symbol’

If it is possible, I want to go further and further. (first include some basic calcuation symbol like +,-,*,/,mod, then function defining and composition, …)

safari – AppleScript: “Repeat” Loop Only Works With Variable

Very curious as to why this works (the context is an open and activated/frontmost Safari window displaying the “Customize Toolbar” sheet):

tell application "System Events"
    tell process "Safari"
        set entireContents to entire contents of sheet 1 of front window
        repeat with x in entireContents
            if class of x is image and description of x contains "My Extension" then
                set targetExtIconPos to position of image 1 of x
            else if class of x is image and description of x is "default set of toolbar items" then
                set defaultToolbarPos to position of x
            end if
        end repeat
    end tell
end tel

but changing repeat with x in entireContents to repeat with x in entire contents of sheet 1 of front window throws an error (and does so even if parenthesis are utilized as in repeat with x in (entire contents of sheet 1 of front window))?

The error I get is: execution error: System Events got an error: Can’t make item 1 of entire contents of sheet 1 of window 1 of process "Safari" into type specifier. (-1700)

This caused alot of headache before I randomly found it would work if I just assigned it to a var first…

Also is there a way to achieve what I am attempting here without using a loop at all? I feel like there is a way, but the syntax is just awfully hard and complex to figure out and nail down.

20.04 – System hangs (sometimes mouse works)

I run 20.04.2 LTS.

I experience some hangs lately. Sometimes I can move the mouse and sometimes I can’t.

I tried to REISUB last time, but it didn’t work.

apport.log from 31st january is empty, apport.log1 from 30th january contains the following:

ERROR: apport (pid 53032) Sat Jan 30 14:30:22 2021: called for pid
53010, signal 11, core limit 0, dump mode 1 ERROR: apport (pid 53032)
Sat Jan 30 14:30:22 2021: executable: /usr/bin/eog (command line “eog
/run/user/1002/gvfs/smb-share:server=myserver,share=myshare/signal-2021-01-28-015034_001.jpeg”)
ERROR: apport (pid 53032) Sat Jan 30 14:30:22 2021: debug: session
gdbus call: (true,)

ERROR: apport (pid 53032) Sat Jan 30 14:30:38 2021: wrote report
/var/crash/_usr_bin_eog.1002.crash

/var/crash is empty

Where can I dig further?

big sur – Bigsur: Bluetooth mouse works after running “bluetoothd”

Why do I need to run %bluetoothd to get my Bluetooth mouse to be detected?
If I don’t do this the bluetooth connection in the taskbar just flashes blue when I move the mouse.

What I don’t understand is why my Bluetooth speaker works but my mouse doesn’t until I run this command?

Finally, how can I make this fix permanent?

edit:
Include a log:

% bluetoothd       
objc[2167]: Class PipeInfo is implemented in both /System/Library/PrivateFrameworks/WPDaemon.framework/Versions/A/WPDaemon and /usr/sbin/bluetoothd. One of the two will be used. Which one is undefined.
[bluetoothd][netPrefChanged] ###### Sharing Dictionary doesn't exist
2021-02-25 09:30:53.287 bluetoothd[2167:19352] Error: [AppleBluetoothHIDDeviceGen2][_setEventService:]Couldn't copy BD_ADDR
2021-02-25 09:30:53.287 bluetoothd[2167:19352] Error: [AppleBluetoothHIDDeviceGen2][_setEventService:]Couldn't copy BD_ADDR
2021-02-25 09:30:53.292 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.294 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.460 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.462 bluetoothd[2167:19352] SystemPowerNotifier: IORegisterForSystemPower for port 38147
2021-02-25 09:30:53.487 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.488 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.501 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.502 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.503 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.505 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:53.507 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:55.595 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:55.814 bluetoothd[2167:19352] newlyConnectedHIDDevice
2021-02-25 09:30:55.829 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:55.833 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:55.846 bluetoothd[2167:19352] [setSystemPreference] syncs returns false
2021-02-25 09:30:55.849 bluetoothd[2167:19352] [setSystemPreference] syncs returns false

public key infrastructure – How roaming works with ssh private keys?

This occurred to me when looking at the security model wireguard is using. Instead of relying on users credentials and Radius authenticating central server each user has a private key used to authenticate VPN. This is modeled after SSH PKI.

But how does it work when users switch computers. In big organisation it is common for employees to move around a lot and login to different machines. Is the idea for them to only have access VPN, SSH from their own desks? Or are the keys stored on some local network file share?

mathematical optimization – FindMaximum works on desktop but not on laptop

I have a simple code to find maximum as follows.

myfunc = {-1 + 2/(1 + d), 1/2 (-1 + 1/d), 1 - d, 1 + 1/(-2 + d), 
   1 - d, 1 - d, -1 + 1/d, -1 + 1/d, 1/(1 + d), 1/(2 d), 1/d, 1/d, d/(
   1 - d)};
FindMaximum({##, 0 <= d <= 1}, d) & /@ myfunc

It works well on my desktop and the result is:

{{1., {d -> 0.}}, {(Infinity), {d -> 0.}}, {1., {d -> 
    0.}}, {0.5, {d -> 0.}}, {1., {d -> 0.}}, {1., {d -> 
    0.}}, {(Infinity), {d -> 0.}}, {(Infinity), {d -> 
    0.}}, {1., {d -> 0.}}, {(Infinity), {d -> 
    0.}}, {(Infinity), {d -> 0.}}, {(Infinity), {d -> 
    0.}}, {(Infinity), {d -> 1.}}}

However, I got error with $Failed when I ran it on my laptop.

{{1., {d -> 3.54538*10^-8}}, {-$Failed, {d -> 0.}}, {1., {d -> 
    0.}}, {0.5, {d -> 0.}}, {1., {d -> 0.}}, {1., {d -> 
    0.}}, {-$Failed, {d -> 0.}}, {-$Failed, {d -> 0.}}, {1., {d -> 
    0.}}, {(Infinity), {d -> Indeterminate}}, {(Infinity), {d -> 
    0.}}, {(Infinity), {d -> 0.}}, {(Infinity), {d -> 
    Indeterminate}}}

Why does this happen? How can I solve this?

networking – When connecting from one subnet to another through a WireGuard VPN, why TCP requires NAT on both sides but ICMP works without NAT?

I encountered this issue today with the following setup:

[Cloud Server] --> [Cloud Gateway Server] <- WireGuard -> [Home Router] <-- [Home Device]
  • I have source NAT on my router. My home devices can SSH into my cloud server.
  • I have no NAT on my cloud gateway server. The routing table on the gateway is correct, and iptables is set to forward packets.

I noticed that, from cloud servers behind the gateway, I can ping my home devices, but no SSH connection can be established. After I set up source NAT on the cloud gateway, for packets forwarded from the cloud subnet, everything works fine.

My question is, why is NAT required on the cloud gateway? Does that have anything to do with the fact that packets from home devices are NATed? Or is there some fundamental limitation on the fact that cloud subnet, home subnet, and WireGuard subnet share different IP ranges?

I did some simulation of how the packets are processed and I cannot find out the issue. I have to admit that my understanding of networking is mostly from Wikipedia and Googling around. I am looking for some theoretical explanation, if possible. Thanks in advance!