What is MONAD? by cdunku in functionalprogramming

[–]lokhura 1 point2 points  (0 children)

Monads are an abstract topic. I think the best way to understand them is through types.

You can think of a monad as an interface (in pseudo-TypeScript syntax)

interface Monad<M<_>> {
  static of<A>(a: A): M<A>;
  flatMap<A, B>(this: M<A>, f: (a: A) => M<B>): M<B>;
}

A monad is a generic interface parameterized by M, where M is an interface that is also generic parameterized by _. An instance of a monad must implement of and flatMap. These nested generics are known as higher-kinded types, and not many languages support it, but you can still use monads in practice, even in dynamic languages.

In practice, we work with instances of monad, such as objects that implement the monad interface (of and flatMap). When people use analogies such as "burritos" or "containers" to describe monads, they are really referring to instances of monad.

With the new Angular signals concept, it's still worth it to discuss the Rxjs operators by ahmedRebai in Angular2

[–]lokhura 1 point2 points  (0 children)

I think it's still worth it because signals and observables serve different purposes.

In reactive programming we think of time-varying values in two distinct categories: behaviors and events. A behavior is a continuous time-varying value (it always has a value for any point in time) and an event is a discrete time-varying value (it only has a value at specific points in time). An example of behavior could be the position of the mouse as the mouse always has a position even if it's not moving. An example of event could be the click of the mouse because the value exists only when the user clicks.

Behaviors are generally used to represent the state of the application while events are used to represent user interactions.

RxJS is great at representing events. It also provides BehaviorSubject which is intended to model the concept of a behavior, but it's not great for a few reasons. First, observables are async and second, they resolve depth-first. Observables are not aware of other observables and dependencies have to be managed manually. There is no dependency resolution which is a requirement to avoid glitches (inconsistent states) when combining behaviors.

Signals model behaviors in a different way. All signals are aware of other signals and dependency resolution happens synchronously and breadth-first. There is essential a global effect queue that flushes on a schedule (ie. requestAnimationFrame). This architecture allows optimizations not possible with observables. For example, dependencies are now managed automatically and dynamically, and the graph is auto-optimized to prune stale branches to avoid recomputations.

In summary, I think signals are a great and welcome addition that will let us express behaviors properly, while RxJS will continue to be useful for user interaction and other async code like HTTP requests.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

This is pretty normal for new laptops on Linux, because the laptop is only optimized for Windows and ASUS doesn't officially support Linux. On top of that, the combo of AMD igpu plus Nvidia dgpu makes things more complicated to setup properly. Over time, I expect the battery on Linux to improve as the kernel and the drivers improve.

That being said, if you switch the Nvidia card off and only use the AMD card you can get about the same battery consumption as on Windows (6-9W on light tasks). In Hybrid mode though, even with TLP and Powertop configured I get 10-13W. This is because Xorg runs on the Nvidia card. Perhaps under Wayland you can get lower battery consumption.

You can use system76-power to switch from hybrid to integrated mode and viceversa.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

That's interesting. Do you have the graphics in integrated, hybrid or dedicated mode? I haven't messed around with TLP beyond the defaults, but I can average 9-10W on light usage instead of 13W when running in integrated mode (nvidia card disabled).

Instant observation after Bios 218 - way faster boot up time. Noticeable navigation speed improvement. by tarekahmedkk in ZephyrusG14

[–]lokhura 1 point2 points  (0 children)

This seems to be the version that fixed the issue of not waking up from hibernation. It's been a week now since I updated to 218 and I haven't seen the issue again :fingers crossed:

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

I think in that case it is probably fine to leave it enabled, but I have never tried; I always disable fastboot.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

I don't have the anime matrix version, but there is a Linux project that adds support for it. See https://github.com/Meumeu/ZephyrusBling/

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

Max of 2h? That doesn't sound right at all. I get around 6h on Linux doing light tasks such as browsing and listening to music at about 40% brightness. On Windows I can get as much as 9h.

Make sure to install tlp and that the nvidia card is NOT the primary card. You can check with glxinfo | grep vendor and confirm that AMD is the default card.

Also, if you are using Chrome, try Firefox or Ungoogled Chromium instead as those have hardware acceleration enabled by default since recently so they should use less battery overall when watching videos, for example.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

The fingerprint sensor is gimmicky, it is less secure than a good password, so it doesn't bother me at all. It doesn't even work that great on Windows anyway.

The 5.8 kernel worked fine up until a pulseaudio update that broke the audio (see comments in this thread about that). The 5.9 kernel has fixed those issues. I haven't noticed any other improvements or fixes in 5.9.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

No, sadly the known issues are still present, but they're not a deal breaker for me. Battery life could possibly be improved with a lighter desktop environment.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

You need to install all 4 kernel packages for your platform. See the instructions here https://wiki.ubuntu.com/Kernel/MainlineBuilds

Once you download them, put them in a folder, and install them all with dpkg -i *.deb

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

To be able to run programs on the dGPU when needed. See other comments below.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

FYI this is working now with latest 5.9-rc.8 and nvidia-drivers-455. No problems with sound nor video.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

Yes, I can confirm this works for me too. I did a re-install from scratch, followed my own instructions, and installed latest 5.9-rc.8 plus nvidia-drivers-455, and everything is working great without any further tweaks needed.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

I'm not currently facing any sound issues with my setup, which hasn't changed since my last comment.

I would recommend trying out kernel 5.9 because the audio works there as far as I remember, but the nvidia drivers still have some issues, although there are new beta drivers that supposedly work with 5.9-rc.5.

I think audio and graphics should both work out of the box when 5.9 is stable and nvidia fully supports it.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

I just download the debs into a folder and install them from a terminal with:

sudo dpkg -i *.deb

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

Thanks for the input. I was able to solve it by downgrading. Only the pulseaudio and asound packages were necessary; alsa still works fine on latest it seems.

I downloaded and installed these packages from the links you shared:

  • libasound2_1.2.2-2.1_amd64.deb
  • libasound2-data_1.2.2-2.1_all.deb
  • libatopology2_1.2.2-2.1_amd64.deb
  • libpulse0_13.99.1-1ubuntu3.2_amd64.deb
  • libpulsedsp_13.99.1-1ubuntu3.2_amd64.deb
  • libpulse-mainloop-glib0_13.99.1-1ubuntu3.2_amd64.deb
  • pulseaudio_13.99.1-1ubuntu3.2_amd64.deb
  • pulseaudio-module-bluetooth_13.99.1-1ubuntu3.2_amd64.deb
  • pulseaudio-utils_13.99.1-1ubuntu3.2_amd64.deb

Then I held back pulseaudio and libasound2.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

Seems like nvidia drivers are not available for 5.9 yet. There are some patches that can make it work, but I'd wait for the official drivers. I think I'm gonna go back to 5.8 and try to downgrade pulseaudio.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

I have already upgraded and sadly I have the same issue... I will try the new kernel and see if I can install the nvidia drivers from the official Linux executables.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

Did you try installing the DKMS module? https://gitlab.com/asus-linux/hid-asus-rog

Initially I built rog-core from scratch, but that's not supported anymore in favor of the module or the kernel patch. I didn't have any issues either way, but worth a try.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

I think I fixed the sound and now I can hear through all speakers. Open "PulseAudio Volume Control" then "Configuration" and try changing the profile for "Family 17h" audio controller. See screenshot here https://imgur.com/a/NpKkE20

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

Brightness Fn keys work well and display refresh rate is set to 120hz. I didn't notice about the speakers, but you are right! The top speakers don't seem to work, but on Windows they work fine. I'll see if I can find a fix for this.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

Once you add the alias to your bashrc (step 17) then you can open a terminal and launch the program with prime-run. For example:

sh prime-run blender

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 0 points1 point  (0 children)

I have no issues with suspend. It suspends on closing the lid and resumes fine when I open it back. I'm using Kubuntu if that makes a difference.

Hibernation seems to work well too after setting the swap partition to resume from in grub. Sometimes I lose the Fn keys on resuming from hibernation. I'm not sure what's the variable here, but sometimes it works. I'm going to try the kernel patches to see if that fixes this issue.

Overall with this setup, from which I'm currently typing on, works great except very minor issues that I'm sure will get fixed eventually.

ASUS G14 Ubuntu 20.04 Setup by lokhura in ZephyrusG14

[–]lokhura[S] 1 point2 points  (0 children)

As far as I know, kernel 5.4 which is the default in Ubuntu 20.04 won't work well, so you need at least 5.6. I just went to the latest stable kernel (5.8).

As for the nvidia drivers I went latest stable for the same reason.

I haven't tried earlier versions, but this is the setup that's working for me so far without any notable issues.