atmos | Breathe easier with terraform | Infrastructure Automation library

 by   simplygenius Ruby Version: Current License: Non-SPDX

kandi X-RAY | atmos Summary

atmos is a Ruby library typically used in Devops, Infrastructure Automation, Terraform applications. atmos has no bugs and it has low support. However atmos has 2 vulnerabilities and it has a Non-SPDX License. You can download it from GitHub.
Atmos(phere) - Breathe easier with terraform. Atmos provides a layer of organization on top of terraform for creating cloud system architectures with Amazon Web Services. It handles the plumbing so you can focus on your application. The core atmos runtime is free and open-source, with a business friendly license (Apache). It provides some basic recipes to help get you going with a service oriented architecture implemented with AWS Elastic Container Services.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        atmos has a low active ecosystem.
                        summary
                        It has 89 star(s) with 6 fork(s). There are 6 watchers for this library.
                        summary
                        It had no major release in the last 6 months.
                        summary
                        There are 1 open issues and 4 have been closed. On average issues are closed in 48 days. There are no pull requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of atmos is current.
                        atmos Support
                          Best in #Infrastructure Automation
                            Average in #Infrastructure Automation
                            atmos Support
                              Best in #Infrastructure Automation
                                Average in #Infrastructure Automation

                                  kandi-Quality Quality

                                    summary
                                    atmos has 0 bugs and 0 code smells.
                                    atmos Quality
                                      Best in #Infrastructure Automation
                                        Average in #Infrastructure Automation
                                        atmos Quality
                                          Best in #Infrastructure Automation
                                            Average in #Infrastructure Automation

                                              kandi-Security Security

                                                summary
                                                atmos has 2 vulnerability issues reported (0 critical, 1 high, 1 medium, 0 low).
                                                summary
                                                atmos code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                atmos Security
                                                  Best in #Infrastructure Automation
                                                    Average in #Infrastructure Automation
                                                    atmos Security
                                                      Best in #Infrastructure Automation
                                                        Average in #Infrastructure Automation

                                                          kandi-License License

                                                            summary
                                                            atmos has a Non-SPDX License.
                                                            summary
                                                            Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
                                                            atmos License
                                                              Best in #Infrastructure Automation
                                                                Average in #Infrastructure Automation
                                                                atmos License
                                                                  Best in #Infrastructure Automation
                                                                    Average in #Infrastructure Automation

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        atmos releases are not available. You will need to build from source code and install.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        summary
                                                                        atmos saves you 5374 person hours of effort in developing the same functionality from scratch.
                                                                        summary
                                                                        It has 11273 lines of code, 313 functions and 103 files.
                                                                        summary
                                                                        It has medium code complexity. Code complexity directly impacts maintainability of the code.
                                                                        atmos Reuse
                                                                          Best in #Infrastructure Automation
                                                                            Average in #Infrastructure Automation
                                                                            atmos Reuse
                                                                              Best in #Infrastructure Automation
                                                                                Average in #Infrastructure Automation
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
                                                                                  Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
                                                                                  Get all kandi verified functions for this library.
                                                                                  Get all kandi verified functions for this library.

                                                                                  atmos Key Features

                                                                                  The whole is greater than the sum of its parts. Assist in creating a cloud infrastructure system rather than just discrete infrastructure components. Learning aws and terraform is a lot to bite off when getting started. It's much easier to start with a working system, and learn incrementally as you go by making changes to it.
                                                                                  The command line is king. Using a CLI to iterate on and manage core infrastructure has always been more effective for me, so I aim to make things as convenient and usable as possible from there.
                                                                                  No lock-in. Since atmos just provides you convenience on top of using terraform, and the templates for defining your infrastructure are entirely in terraform, its possible to migrate away (albeit giving up all the convenience atmos provides) if your goals ever diverge from those of atmos.
                                                                                  Your infrastructure is an important product. It should have its own repo and be tracked under configuration management, not just clickety-click-clicked on in a UI and promptly forgotten what it is you actually did to get there. The only guarantee you have, is that things are going to need to change, and you'll be much better off with a system that allows you to iterate easily. Atmos gets you started with minimal up-front knowledge, but provides a path for your infrastructure to evolve.

                                                                                  atmos Examples and Code Snippets

                                                                                  No Code Snippets are available at this moment for atmos.
                                                                                  Community Discussions

                                                                                  Trending Discussions on atmos

                                                                                  Get C FILE pointer from bytes::Bytes in Rust
                                                                                  chevron right
                                                                                  HTML Custom Audio Player - Get Current Time and Total Time
                                                                                  chevron right
                                                                                  How do you take a partial derivative symbolically in sympy while holding a parameter constant/having a fixed parameter?
                                                                                  chevron right
                                                                                  Audio in audio and video HTML5 elements are muted while using WebAudio API
                                                                                  chevron right
                                                                                  Install xplanet version 0.95a on a modern Linux or update code to xplanet 1.3
                                                                                  chevron right
                                                                                  php error preg_match Unknown modifier '2'
                                                                                  chevron right
                                                                                  Flattening nested dictionary React? - Cannot read property 'standard' of undefined
                                                                                  chevron right
                                                                                  How do I formate spaces in terminal for FFMPEG metadata
                                                                                  chevron right
                                                                                  Add or subtract one array in the Z dimension from another, where latitude (Y dimension) and longitude (X) are different
                                                                                  chevron right
                                                                                  Pull multiple values instead of just one
                                                                                  chevron right

                                                                                  QUESTION

                                                                                  Get C FILE pointer from bytes::Bytes in Rust
                                                                                  Asked 2021-Jun-12 at 13:29

                                                                                  I would like to read a GRIB file downloaded from server using ecCodes library in Rust. However, my current solution results in segmentation fault. The extracted example, replicating the problem, is below.

                                                                                  I download the file using reqwest crate and get the response as Bytes1 using bytes(). To read the file with ecCodes I need to create a codes_handle using codes_grib_handle_new_from_file()2, which as argument requires *FILE usually get from fopen(). However, I would like to skip IO operations. So I figured I could use libc::fmemopen() to get *FILE from Bytes. But when I pass the *mut FILE from fmemopen() to codes_grib_handle_new_from_file() segmentation fault occurs.

                                                                                  I suspect the issue is when I get from Bytes a *mut c_void required by fmemopen(). I figured I can do this like that:

                                                                                  //get a *mut c_void pointer fom Bytes
                                                                                  //file has &Bytes type
                                                                                  let mut buf = BytesMut::from(file.as_ref());
                                                                                  let ptr = buf.as_mut_ptr();
                                                                                  let ptr = ptr as *mut c_void;
                                                                                  

                                                                                  Because *mut is required, I create BytesMut from which I can then get mut pointer. I think those conversion are problematic, because in debugger info ptr contains a diffrent memory adress than ptr field of file.

                                                                                  Using *FILE got from libc::fopen() for the same file does not result in segfault. So the problem is somwhere around fmemopen().

                                                                                  The ecCodes library is correctly built (passes all tests and works in C) and linked (the calls in callstack are correct).

                                                                                  The full extracted example:

                                                                                  #![allow(unused)]
                                                                                  #![allow(non_camel_case_types)]
                                                                                  
                                                                                  use bytes::{Bytes, BytesMut};
                                                                                  use libc::{c_char, c_void, fmemopen, size_t, FILE};
                                                                                  use reqwest;
                                                                                  use tokio;
                                                                                  
                                                                                  // generated by bindgen
                                                                                  #[repr(C)]
                                                                                  #[derive(Debug, Copy, Clone)]
                                                                                  pub struct codes_handle {
                                                                                      _unused: [u8; 0],
                                                                                  }
                                                                                  
                                                                                  // generated by bindgen
                                                                                  #[repr(C)]
                                                                                  #[derive(Debug, Copy, Clone)]
                                                                                  pub struct codes_context {
                                                                                      _unused: [u8; 0],
                                                                                  }
                                                                                  
                                                                                  #[tokio::main]
                                                                                  async fn main() {
                                                                                      // download the grib file from server
                                                                                      // then get response as bytes
                                                                                      let url = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20210612/00/atmos/gfs.t00z.pgrb2.1p00.f000";
                                                                                      let file = reqwest::get(url).await.unwrap().bytes().await.unwrap();
                                                                                  
                                                                                      // get Bytes from *FILE with fmemopen
                                                                                      // file must outlive the pointer so it is borrowed here
                                                                                      let file_handle = open_with_fmemopen(&file);
                                                                                  
                                                                                      let grib_handle = open_with_codes(file_handle);
                                                                                  }
                                                                                  
                                                                                  pub fn open_with_fmemopen(file: &Bytes) -> *mut FILE {
                                                                                      // size of buffer and mode to be read with
                                                                                      let size = file.len() as size_t;
                                                                                      let mode = "r".as_ptr() as *const c_char;
                                                                                  
                                                                                      // get a *mut c_void pointer fom Bytes
                                                                                      let mut buf = BytesMut::from(file.as_ref());
                                                                                      let ptr = buf.as_mut_ptr();
                                                                                      let ptr = ptr as *mut c_void;
                                                                                  
                                                                                      // get *FILE with fmemopen
                                                                                      let obj;
                                                                                      unsafe {
                                                                                          obj = fmemopen(ptr, size, mode);
                                                                                      }
                                                                                      
                                                                                      obj
                                                                                  }
                                                                                  
                                                                                  pub fn open_with_codes(file_handle: *mut FILE) -> *mut codes_handle {
                                                                                      
                                                                                      // default context for ecCodes
                                                                                      let context: *mut codes_context = std::ptr::null_mut();
                                                                                  
                                                                                      // variable to hold error code
                                                                                      let mut error: i32 = 0;
                                                                                  
                                                                                      // get codes_handle from *FILE
                                                                                      let grib_handle;
                                                                                      unsafe {
                                                                                          // segmentation fault occurs here
                                                                                          grib_handle = codes_grib_handle_new_from_file(context, file_handle, &mut error as *mut i32);
                                                                                      }
                                                                                  
                                                                                      grib_handle
                                                                                  }
                                                                                  
                                                                                  // binding to ecCodes C library
                                                                                  #[link(name = "eccodes")]
                                                                                  extern "C" {
                                                                                      pub fn codes_grib_handle_new_from_file(
                                                                                          c: *mut codes_context,
                                                                                          f: *mut FILE,
                                                                                          error: *mut i32,
                                                                                      ) -> *mut codes_handle;
                                                                                  }
                                                                                  

                                                                                  And because the example might require considerable effort to set up I also attach the call stack from GDB of the seg fault:

                                                                                  __memmove_avx_unaligned_erms 0x00007f738b415fa6
                                                                                  fmemopen_read 0x00007f738b31c9b4
                                                                                  _IO_new_file_underflow 0x00007f738b31fd51
                                                                                  __GI___underflow 0x00007f738b32142e
                                                                                  __GI___underflow 0x00007f738b32142e
                                                                                  __GI__IO_default_xsgetn 0x00007f738b32142e
                                                                                  __GI__IO_fread 0x00007f738b312493
                                                                                  stdio_read 0x00007f738bb8db37
                                                                                  _read_any 0x00007f738bb8cf1b
                                                                                  read_any 0x00007f738bb8cfa3
                                                                                  _wmo_read_any_from_file_malloc 0x00007f738bb8e6f7
                                                                                  wmo_read_grib_from_file_malloc 0x00007f738bb8e7d7
                                                                                  grib_handle_new_from_file_no_multi 0x00007f738bb872a2
                                                                                  grib_new_from_file 0x00007f738bb8678f
                                                                                  grib_handle_new_from_file 0x00007f738bb85998
                                                                                  codes_grib_handle_new_from_file 0x00007f738bb8532b
                                                                                  example::open_with_codes main.rs:68
                                                                                  example::main::{{closure}} main.rs:34
                                                                                  core::future::from_generator::{{impl}}::poll mod.rs:80
                                                                                  tokio::park::thread::{{impl}}::block_on::{{closure}}> thread.rs:263
                                                                                  tokio::coop::with_budget::{{closure}}<()>,closure-0> coop.rs:106
                                                                                  std::thread::local::LocalKey>::try_with,closure-0,core::task::poll::Poll<()>> local.rs:272
                                                                                  std::thread::local::LocalKey>::with,closure-0,core::task::poll::Poll<()>> local.rs:248
                                                                                  tokio::coop::with_budget<()>,closure-0> coop.rs:99
                                                                                  tokio::coop::budget<()>,closure-0> coop.rs:76
                                                                                  tokio::park::thread::CachedParkThread::block_on> thread.rs:263
                                                                                  tokio::runtime::enter::Enter::block_on> enter.rs:151
                                                                                  tokio::runtime::thread_pool::ThreadPool::block_on> mod.rs:71
                                                                                  tokio::runtime::Runtime::block_on> mod.rs:452
                                                                                  example::main main.rs:34
                                                                                  core::ops::function::FnOnce::call_once function.rs:227
                                                                                  std::sys_common::backtrace::__rust_begin_short_backtrace backtrace.rs:125
                                                                                  std::rt::lang_start::{{closure}}<()> rt.rs:66
                                                                                  core::ops::function::impls::{{impl}}::call_once<(),Fn<()>> function.rs:259
                                                                                  std::panicking::try::do_call<&Fn<()>,i32> panicking.rs:379
                                                                                  std::panicking::try<()>> panicking.rs:343
                                                                                  std::panic::catch_unwind<&Fn<()>,i32> panic.rs:431
                                                                                  std::rt::lang_start_internal rt.rs:51
                                                                                  std::rt::lang_start<()> rt.rs:65
                                                                                  main 0x0000560f1d93c76c
                                                                                  __libc_start_main 0x00007f738b2bb565
                                                                                  _start 0x0000560f1d935f0e
                                                                                  

                                                                                  1 From bytes crate, not std::io
                                                                                  2 grib_handle returned by the function is just an alias of codes_handle

                                                                                  ANSWER

                                                                                  Answered 2021-Jun-12 at 13:29

                                                                                  1- Try changing

                                                                                  let mode = "r".as_ptr() as *const c_char;
                                                                                  

                                                                                  to

                                                                                  let mode = "r\0".as_ptr() as *const c_char;
                                                                                  

                                                                                  Rust's &str is not null-terminated, while you're passing it to C where string literals are expected to be null-terminated.

                                                                                  2- Try the following implementation for open_with_fmemopen:

                                                                                  pub fn open_with_fmemopen(file: &Bytes) -> *mut FILE {
                                                                                      unsafe {
                                                                                          let obj = fmemopen(file.as_ref() as *const _ as _, file.len(), "r\0".as_ptr() as _);
                                                                                          obj
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/67948101

                                                                                  QUESTION

                                                                                  HTML Custom Audio Player - Get Current Time and Total Time
                                                                                  Asked 2021-Mar-23 at 09:21

                                                                                  So I'm in the process of creating a customised MP3, I've just managed to update the part where you can skip to a certain section of the track.

                                                                                  But I have no idea how I can set this up so it displays the current time played in hh:mm:ss as well as displaying the total time in hh:mm:ss

                                                                                  Here is the CodePen for the player. Can anybody help?

                                                                                  HTML:

                                                                                  
                                                                                      
                                                                                          
                                                                                              
                                                                                              
                                                                                              
                                                                                                         
                                                                                          
                                                                                          
                                                                                  
                                                                                              
                                                                                                  
                                                                                              
                                                                                  
                                                                                              
                                                                                                      
                                                                                                      
                                                                                              
                                                                                  
                                                                                              
                                                                                  
                                                                                              
                                                                                          
                                                                                      
                                                                                      
                                                                                          

                                                                                  JS

                                                                                  $(document).ready(function () {
                                                                                      var audioElement = document.createElement('audio');
                                                                                      audioElement.setAttribute('src', $('.active-song').attr('data-src'));
                                                                                  
                                                                                      var tl = new TimelineMax();
                                                                                      tl.to('.player__albumImg', 3, {
                                                                                          rotation: '360deg',
                                                                                          repeat: -1,
                                                                                          ease: Power0.easeNone
                                                                                      }, '-=0.2');
                                                                                      tl.pause();
                                                                                  
                                                                                      $('.player__play').click(function () {
                                                                                  
                                                                                          if ($('.player').hasClass('play')) {
                                                                                              $('.player').removeClass('play');
                                                                                              audioElement.pause();
                                                                                              TweenMax.to('.player__albumImg', 0.2, {
                                                                                                  scale: 1,
                                                                                                  ease: Power0.easeNone
                                                                                              })
                                                                                              tl.pause();
                                                                                          } else {
                                                                                              $('.player').addClass('play');
                                                                                              audioElement.play();
                                                                                              TweenMax.to('.player__albumImg', 0.2, {
                                                                                                  scale: 1.1,
                                                                                                  ease: Power0.easeNone
                                                                                              })
                                                                                              tl.resume();
                                                                                          }
                                                                                  
                                                                                      });
                                                                                  
                                                                                  
                                                                                      var playhead = document.getElementById("playhead");
                                                                                      audioElement.addEventListener("timeupdate", function () {
                                                                                          var duration = this.duration;
                                                                                          var currentTime = this.currentTime;
                                                                                          var percentage = (currentTime / duration) * 100;
                                                                                          playhead.style.width = percentage + '%';
                                                                                      });
                                                                                  
                                                                                      function updateInfo() {
                                                                                          $('.player__author').text($('.active-song').attr('data-author'));
                                                                                          $('.player__song').text($('.active-song').attr('data-song'));
                                                                                      }
                                                                                      updateInfo();
                                                                                  
                                                                                      $('.player__next').click(function () {
                                                                                          if ($('.player .player__albumImg.active-song').is(':last-child')) {
                                                                                              $('.player__albumImg.active-song').removeClass('active-song');
                                                                                              $('.player .player__albumImg:first-child').addClass('active-song');
                                                                                              audioElement.addEventListener("timeupdate", function () {
                                                                                                  var duration = this.duration;
                                                                                                  var currentTime = this.currentTime;
                                                                                                  var percentage = (currentTime / duration) * 100;
                                                                                                  playhead.style.width = percentage + '%';
                                                                                              });
                                                                                          } else {
                                                                                              $('.player__albumImg.active-song').removeClass('active-song').next().addClass('active-song');
                                                                                              audioElement.addEventListener("timeupdate", function () {
                                                                                                  var duration = this.duration;
                                                                                                  var currentTime = this.currentTime;
                                                                                                  var percentage = (currentTime / duration) * 100;
                                                                                                  playhead.style.width = percentage + '%';
                                                                                              });
                                                                                          }
                                                                                          updateInfo();
                                                                                          audioElement.setAttribute('src', $('.active-song').attr('data-src'));
                                                                                          audioElement.play();
                                                                                      });
                                                                                  
                                                                                      $('.player__prev').click(function () {
                                                                                          if ($('.player .player__albumImg.active-song').is(':first-child')) {
                                                                                              $('.player__albumImg.active-song').removeClass('active-song');
                                                                                              $('.player .player__albumImg:last-child').addClass('active-song');
                                                                                              audioElement.addEventListener("timeupdate", function () {
                                                                                                  var duration = this.duration;
                                                                                                  var currentTime = this.currentTime;
                                                                                                  var percentage = (currentTime / duration) * 100;
                                                                                                  playhead.style.width = percentage + '%';
                                                                                              });
                                                                                          } else {
                                                                                              $('.player__albumImg.active-song').removeClass('active-song').prev().addClass('active-song');
                                                                                              audioElement.addEventListener("timeupdate", function () {
                                                                                                  var duration = this.duration;
                                                                                                  var currentTime = this.currentTime;
                                                                                                  var percentage = (currentTime / duration) * 100;
                                                                                                  playhead.style.width = percentage + '%';
                                                                                              });
                                                                                          }
                                                                                          updateInfo();
                                                                                          audioElement.setAttribute('src', $('.active-song').attr('data-src'));
                                                                                          audioElement.play();
                                                                                      });
                                                                                    
                                                                                      $('.player__timelineBar').click(function (ev) {
                                                                                          var $div = $(ev.target);
                                                                                          var $display = $div.find('.playhead');
                                                                                  
                                                                                          var offset = $div.offset();
                                                                                          var x = ev.clientX - offset.left;
                                                                                  
                                                                                          var ratio = x / $(this).width();
                                                                                          var duration = audioElement.duration;
                                                                                  
                                                                                          var newCurrentTime = ratio * duration;
                                                                                          audioElement.currentTime = newCurrentTime;
                                                                                  
                                                                                      });  
                                                                                  
                                                                                  });
                                                                                  

                                                                                  SCSS

                                                                                  .icon {
                                                                                      display: inline-block;
                                                                                      width: 2em;
                                                                                      height: 2em;
                                                                                      font-size: 30px;
                                                                                      fill: #D7DCE2;
                                                                                      transition: all .2s ease-in-out;
                                                                                  }
                                                                                  
                                                                                  html, body {
                                                                                      height: 100%;
                                                                                  }
                                                                                  
                                                                                  body {
                                                                                      background: #000;
                                                                                      position: relative;
                                                                                  }
                                                                                  
                                                                                  .player {
                                                                                      position: absolute;
                                                                                      top: 50%;
                                                                                      left: 50%;
                                                                                      transform: translate(-50%, -50%);
                                                                                      &.play {
                                                                                          .player__timeline {
                                                                                              transform: translateY(-90%);
                                                                                          }
                                                                                          .player__album:after {
                                                                                              box-shadow: 0px 30px 28px -10px rgba(0,0,0,.2);
                                                                                          }
                                                                                          .player__album {
                                                                                              top: -65px;
                                                                                          }
                                                                                          .pause {
                                                                                              display: inline-block;
                                                                                          }
                                                                                          .play {
                                                                                              display: none;
                                                                                          }
                                                                                      }
                                                                                      &__album {
                                                                                          width: 112px;
                                                                                          height: 112px;      
                                                                                          border-radius: 50%;
                                                                                          margin-right: 22px;
                                                                                          position: relative;
                                                                                          top: -50px;
                                                                                          transition: all .4s ease-in-out;
                                                                                          &:before {
                                                                                              content: '';
                                                                                              width: 25px;
                                                                                              height: 25px;
                                                                                              position: absolute;
                                                                                              z-index: 3;
                                                                                              top: 50%;
                                                                                              left: 50%;
                                                                                              transform: translate(-50%, -50%);
                                                                                              background: #fff;
                                                                                              border-radius: 50%;
                                                                                          }
                                                                                          &:after {
                                                                                              content: '';
                                                                                              position: absolute;
                                                                                              top: 0;
                                                                                              right: 0;
                                                                                              bottom: 0;
                                                                                              left: 0;
                                                                                              border-radius: 50%;
                                                                                              box-shadow: none;
                                                                                              transition: all .3s ease-in-out;
                                                                                          }
                                                                                      }
                                                                                      &__albumImg {
                                                                                          background-size: cover;
                                                                                          background-position: center;
                                                                                          background-repeat: no-repeat;
                                                                                          width: 100%;
                                                                                          height: 100%;
                                                                                          border-radius: 50%;
                                                                                          position: relative;
                                                                                          z-index: 2;
                                                                                          display: none;
                                                                                          &.active-song {
                                                                                              display: block;
                                                                                          }
                                                                                      }
                                                                                      &__bar {
                                                                                          background: #fff;
                                                                                          padding: 10px 25px;
                                                                                          height: 100px;
                                                                                          display: flex;
                                                                                          justify-content: space-between;
                                                                                          border-radius: 15px;
                                                                                          box-shadow: 0 30px 56px 6px rgba(0,0,0,0.1);
                                                                                          position: relative;
                                                                                          z-index: 3;
                                                                                      }
                                                                                      &__controls {
                                                                                          display: flex;
                                                                                          align-items: center;
                                                                                      }
                                                                                      &__prev {
                                                                                          transform: rotate(180deg);
                                                                                          height: 80px;
                                                                                          width: 80px;
                                                                                          display: flex;
                                                                                          justify-content: center;
                                                                                          align-items: center;
                                                                                          cursor: pointer;
                                                                                          border-radius: 15px;
                                                                                          transition: all .2s ease-in-out;
                                                                                          margin-right: 3px;
                                                                                          &:hover {
                                                                                              background: #D7DCE2;
                                                                                              svg {
                                                                                                  fill: #fff;
                                                                                              }
                                                                                          }
                                                                                      }
                                                                                      &__play {
                                                                                          cursor: pointer;
                                                                                          height: 80px;
                                                                                          width: 80px;
                                                                                          display: flex;
                                                                                          justify-content: center;
                                                                                          align-items: center;
                                                                                          border-radius: 15px;
                                                                                          transition: all .2s ease-in-out;
                                                                                          margin-right: 3px;      
                                                                                          position: relative;
                                                                                          &:hover {
                                                                                              background: #D7DCE2;
                                                                                              svg {
                                                                                                  fill: #fff;
                                                                                              }
                                                                                          }
                                                                                          svg {
                                                                                              font-size: 20px;
                                                                                              position: absolute;
                                                                                              top: 50%;
                                                                                              left: 50%;
                                                                                              transform: translate(-50%, -50%);
                                                                                              &.pause {
                                                                                                  display: none;
                                                                                              }
                                                                                          }
                                                                                      }
                                                                                      &__next {
                                                                                          cursor: pointer;
                                                                                          height: 80px;
                                                                                          width: 80px;
                                                                                          display: flex;
                                                                                          justify-content: center;
                                                                                          align-items: center;
                                                                                          border-radius: 15px;
                                                                                          transition: all .2s ease-in-out;
                                                                                          margin-left: -8px;
                                                                                          &:hover {
                                                                                              background: #D7DCE2;
                                                                                              svg {
                                                                                                  fill: #fff;
                                                                                              }
                                                                                          }
                                                                                      }
                                                                                      &__timeline {
                                                                                          background: #FFF;;
                                                                                          height: 95px;
                                                                                          border-radius: 15px;
                                                                                          position: absolute;
                                                                                          bottom: 0;
                                                                                          left: 10px;
                                                                                          right: 10px;
                                                                                          transform: translateY(0);
                                                                                          transition: all .3s ease-in-out;
                                                                                          z-index: 1;
                                                                                          padding-left: 160px;
                                                                                          flex-direction: column;
                                                                                          justify-content: center;
                                                                                      }
                                                                                      &__timelineBar {
                                                                                          background: #E7E7E7;
                                                                                          width: 95%;
                                                                                          height: 4px;
                                                                                          border-radius: 15px;
                                                                                          margin-top: 13px;
                                                                                          position: relative;
                                                                                      }
                                                                                      #playhead {
                                                                                          position: absolute;
                                                                                          top: 0;
                                                                                          left: 0;
                                                                                          border-radius: 15px;
                                                                                          width: 0;
                                                                                          height: 100%;
                                                                                          background: #fd6d94;
                                                                                      }
                                                                                      &__author {
                                                                                          line-height: 1;
                                                                                          font-weight: bold;
                                                                                          margin-bottom: 6px;
                                                                                          margin-top: 15px;
                                                                                      }
                                                                                      &__song {
                                                                                          line-height: 1;
                                                                                          margin: 0;
                                                                                          font-size: 12px;
                                                                                          color: #949494;
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2021-Mar-23 at 09:21

                                                                                  The duration and the currentTime are measured in seconds.

                                                                                  displaying them in the format you want is just a matter of doing some simple calculations:

                                                                                  const formatTime = time => {
                                                                                    const hours = Math.floor(time / 3600);
                                                                                    const remainder = time % 3600;
                                                                                    const minutes = Math.floor(remainder / 60);
                                                                                    const seconds = Math.floor(remainder % 60);
                                                                                  
                                                                                    const hh = hours.toString().padStart(2, '0');
                                                                                    const mm = minutes.toString().padStart(2, '0');
                                                                                    const ss = seconds.toString().padStart(2, '0');
                                                                                  
                                                                                    return `${hh}:${mm}:${ss}`;
                                                                                  }
                                                                                  

                                                                                  here's your updated working codepen: https://codepen.io/ptcc/pen/WNReqPx

                                                                                  Source https://stackoverflow.com/questions/66721110

                                                                                  QUESTION

                                                                                  How do you take a partial derivative symbolically in sympy while holding a parameter constant/having a fixed parameter?
                                                                                  Asked 2021-Jan-19 at 11:41

                                                                                  I am trying to get a partial derivative in the form seen here on page 2 in equation 6.1. The meaning of the subscripts in this equation is that one of parameters that the variable having a derivative taken of it depends on is being held constant. Is there any argument in the Derivative() function in Sympy that allows one to do this?

                                                                                  Here is my code so far:

                                                                                  from sympy import*
                                                                                  init_printing(use_unicode=True)
                                                                                  #Create the variables
                                                                                  s = symbols('s') #x, y, and t
                                                                                  z = symbols('z') #vertical coordinate
                                                                                  
                                                                                  #Create the functions that depend on those variables
                                                                                  zeta = Function('zeta')(s,z)
                                                                                  A = Function('A')(s,zeta)
                                                                                  
                                                                                  #Here we actually take the derivative
                                                                                  expr = Derivative(A,z)
                                                                                  expr = expr.doit()
                                                                                  #This gives a basic partial derivative, but does not give a partial derivative with one of the parameters held constant
                                                                                  

                                                                                  Is there some type of kwargs that I can pass into Derivative function that allows for this?

                                                                                  ANSWER

                                                                                  Answered 2021-Jan-19 at 11:41

                                                                                  There isn't a direct way to represent a derivative wrt the "nth argument" in sympy but you can use a dummy variable and subs. Something like:

                                                                                  In [24]: x, y, z = symbols('x, y, z')
                                                                                  
                                                                                  In [25]: A = Function('A')
                                                                                  
                                                                                  In [26]: f = Function('f')
                                                                                  
                                                                                  In [27]: A(x, z).diff(x).subs(z, f(x, y))
                                                                                  Out[27]: 
                                                                                  ⎛∂          ⎞│         
                                                                                  ⎜──(A(x, z))⎟│         
                                                                                  ⎝∂x         ⎠│z=f(x, y)
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/65786687

                                                                                  QUESTION

                                                                                  Audio in audio and video HTML5 elements are muted while using WebAudio API
                                                                                  Asked 2020-Dec-08 at 05:30

                                                                                  I'm trying to get audio from video to work with Web Audio API. But audio in video is muted. HTML5 audio is working when I am testing this code locally (on jsfiddle it is not working when Web Audio API is on) but locally and on jsfiddle video has no audio (it is muted and user can not change that). No errors shows in the console. I've added function to apply to Autoplay Policy Changes: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio. Here is my code:

                                                                                  // Required by new google policy more here: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio
                                                                                  
                                                                                  var context = null;
                                                                                  
                                                                                  var myAudio, source, splitter, listener = null;
                                                                                  
                                                                                  var FrontLeft, FrontCenter, FrontRight, SurroundLeft, SurroundRight, Sub = null;
                                                                                  
                                                                                  var pannerNodesObjects = [FrontLeft, FrontCenter, FrontRight, SurroundLeft, SurroundRight, Sub];
                                                                                  
                                                                                  var distanceFromScreen, screenCenterY = null;
                                                                                  
                                                                                  var x_FrontLeft, y_FrontLeft, z_FrontLeft = null;
                                                                                  var x_FrontCenter, y_FrontCenter, z_FrontCenter = null;
                                                                                  var x_FrontRight, y_FrontRight, z_FrontRight = null;
                                                                                  var x_SurroundLeft, y_SurroundLeft, z_SurroundLeft = null;
                                                                                  var x_SurroundRight, y_SurroundRight, z_SurroundRight = null;
                                                                                  var x_Sub, y_Sub, z_Sub = null;
                                                                                  
                                                                                  var web_Audio_enable = false;
                                                                                  
                                                                                  var initailPosition = [[x_FrontLeft, y_FrontLeft, z_FrontLeft],
                                                                                  [x_FrontCenter, y_FrontCenter, z_FrontCenter],
                                                                                  [x_FrontRight, y_FrontRight, z_FrontRight],
                                                                                  [x_SurroundLeft, y_SurroundLeft, z_SurroundLeft],
                                                                                  [x_SurroundRight, y_SurroundRight, z_SurroundRight],
                                                                                  [x_Sub, y_Sub, z_Sub]];
                                                                                      
                                                                                  // One-liner to resume playback when user interacted with the page.
                                                                                  function startFunction() {
                                                                                        // Create splitter
                                                                                        context = new AudioContext();
                                                                                  
                                                                                        // get the audio element
                                                                                        myAudio = document.getElementById('video');
                                                                                        
                                                                                        // myAudio = document.querySelector('video');
                                                                                        source = context.createMediaElementSource(myAudio);
                                                                                  
                                                                                        // var dest = context.createMediaStreamDestination();
                                                                                  
                                                                                        //Spliter channels L, R, SL, SR, C, LFE
                                                                                        splitter = new ChannelSplitterNode(context, { numberOfOutputs: 6 });
                                                                                  
                                                                                        // let channel_merger = new ChannelMergerNode(context, {numberOfInputs: 2});
                                                                                  
                                                                                        listener = context.listener;
                                                                                  
                                                                                        source.connect(splitter);
                                                                                  
                                                                                        web_Audio_enable = true;
                                                                                        start_function();
                                                                                        console.log('Playback resumed successfully');
                                                                                    }
                                                                                  
                                                                                  //Estimate screen width for sound source placement
                                                                                  //NOTE: this is estimation it is not very accurate but for this project it is acurate enought
                                                                                  // Used by create_BabylonCamera
                                                                                  function estimate_ScreenParams() {
                                                                                      var $el = document.createElement('div');
                                                                                      $el.style.width = '1cm';
                                                                                      $el.style.height = '1cm';
                                                                                      $el.style.backgroundColor = '#ff0000';
                                                                                      $el.style.position = 'fixed';
                                                                                      $el.style.bottom = 0;
                                                                                      document.body.appendChild($el);
                                                                                      var screenHeight = window.screen.height / $el.offsetHeight;
                                                                                      var screenWidth = window.screen.width / $el.offsetWidth;
                                                                                      console.log("Screen Width in cm: " + screenWidth);
                                                                                      console.log("Screen Height in cm: " + screenHeight);
                                                                                      var screenDiagonalInches = Math.sqrt(Math.pow((window.screen.width / $el.offsetWidth), 2) + Math.pow((window.screen.height / $el.offsetHeight), 2)) / 2.54;
                                                                                      console.log("Screen Diagonal in in: " + screenDiagonalInches);
                                                                                      document.body.removeChild($el);
                                                                                      //Screen center height in meters
                                                                                      var screenCenterY = (screenHeight / 2) / 100;
                                                                                  
                                                                                      //Calculate distance form screen based on estimated screen diagonal length and resolution
                                                                                      //Screen resolution
                                                                                      var screenResWidth = window.screen.width * window.devicePixelRatio;
                                                                                      var screenResHeight = window.screen.height * window.devicePixelRatio;
                                                                                  
                                                                                      var loc_distanceFromScreen = null;
                                                                                  
                                                                                      //distanceFromScreen will be used for initial positioning of the  Surround Left and Right speakers
                                                                                      // Distance is in meters
                                                                                      if (screenDiagonalInches < 14) {
                                                                                          loc_distanceFromScreen = 0.61; //minimum distance
                                                                                      }
                                                                                      else {
                                                                                          loc_distanceFromScreen = 0.61 + (Math.round(screenDiagonalInches - 14) / 2) * 0.15;
                                                                                      }
                                                                                      console.log("Estimated distance from screen: " + loc_distanceFromScreen);
                                                                                  
                                                                                      distanceFromScreen = loc_distanceFromScreen;
                                                                                  
                                                                                      return screenCenterY;
                                                                                  }
                                                                                  
                                                                                  function set_pannerNode(node, panningModel /* 'HRTF' */, distanceModel /* Possible values are "linear", "inverse" and "exponential". The default value is "inverse". */, refDistance, maxDistance, rolloffFactor, coneInnerAngle, coneOuterAngle, coneOuterGain, x, y, z /* position */, n /* index of the pannerNodesObjects */) {
                                                                                  
                                                                                      node = context.createPanner();
                                                                                  
                                                                                      // Seting options
                                                                                      node.panningModel = panningModel;
                                                                                      node.distanceModel = distanceModel;
                                                                                      node.refDistance = refDistance;
                                                                                      node.maxDistance = maxDistance;
                                                                                      node.rolloffFactor = rolloffFactor;
                                                                                      node.coneInnerAngle = coneInnerAngle;
                                                                                      node.coneOuterAngle = coneOuterAngle;
                                                                                      node.coneOuterGain = coneOuterGain;
                                                                                  
                                                                                      // Setting position
                                                                                      if (node.positionX) {
                                                                                          node.positionX.setValueAtTime(x, context.currentTime);
                                                                                          node.positionY.setValueAtTime(y, context.currentTime);
                                                                                          node.positionZ.setValueAtTime(z, context.currentTime);
                                                                                      } else {
                                                                                          node.setPosition(x, y, z);
                                                                                      }
                                                                                      pannerNodesObjects[n] = node;
                                                                                  }
                                                                                  
                                                                                  // Function to rotate 
                                                                                  // cx, cy, cz - global center of rotation
                                                                                  
                                                                                  var temp_position = [[-0.12, 0.835, 0], /* Front left */
                                                                                                       [0.12, 0.835, 0], /* Front right */
                                                                                                       [0.0, 0.85, 0], /* Front center */
                                                                                                       [0.08, 0.84, 0], /* Sub */
                                                                                                       [-0.17, -0.83, 0], /* Surround left */
                                                                                                       [0.17, -0.83, 0]]; /* Surround right */
                                                                                  
                                                                                  function set_rotation(x, y, angle, n /* n is a int that says what initial position to change it is the index of the speaker 0 - FL, 1 - FC, 2 - FR etc. */) {
                                                                                  
                                                                                      /* 
                                                                                      Currently not used
                                                                                      */
                                                                                      initailPosition[n][0] = temp_position[n][0];
                                                                                      initailPosition[n][1] = temp_position[n][1];
                                                                                      initailPosition[n][2] = temp_position[n][2];
                                                                                  
                                                                                      console.log(n + " x: " + initailPosition[n][0] + " y: " + initailPosition[n][1] + " z: "+initailPosition[n][2]);
                                                                                      return [initailPosition[n][0], initailPosition[n][1], initailPosition[n][2]];
                                                                                  }
                                                                                  
                                                                                  function rotate(node_obj, pitch, roll, yaw, i) {
                                                                                      var cosa = Math.cos(yaw);
                                                                                      var sina = Math.sin(yaw);
                                                                                  
                                                                                      var cosb = Math.cos(pitch);
                                                                                      var sinb = Math.sin(pitch);
                                                                                  
                                                                                      var cosc = Math.cos(roll);
                                                                                      var sinc = Math.sin(roll);
                                                                                  
                                                                                      var Axx = cosa*cosb;
                                                                                      var Axy = cosa*sinb*sinc - sina*cosc;
                                                                                      var Axz = cosa*sinb*cosc + sina*sinc;
                                                                                  
                                                                                      var Ayx = sina*cosb;
                                                                                      var Ayy = sina*sinb*sinc + cosa*cosc;
                                                                                      var Ayz = sina*sinb*cosc - cosa*sinc;
                                                                                  
                                                                                      var Azx = -sinb;
                                                                                      var Azy = cosb*sinc;
                                                                                      var Azz = cosb*cosc;
                                                                                  
                                                                                      px = temp_position[i][0];
                                                                                      py = temp_position[i][1];
                                                                                      pz = temp_position[i][2];
                                                                                  
                                                                                      node_x = Axx*px + Axy*py + Axz*pz;
                                                                                      node_y = Ayx*px + Ayy*py + Ayz*pz;
                                                                                      node_z = Azx*px + Azy*py + Azz*pz;
                                                                                  
                                                                                      // Setting position
                                                                                      if (node_obj.positionX) {
                                                                                          // node_obj.positionX.value = node_x;
                                                                                          // node_obj.positionY.value = node_y;
                                                                                          // node_obj.positionZ.value = node_z;
                                                                                          // node_obj.positionX.setValueAtTime(node_x, context.currentTime);
                                                                                          // node_obj.positionY.setValueAtTime(node_y, context.currentTime);
                                                                                          // node_obj.positionZ.setValueAtTime(node_z, context.currentTime);
                                                                                          node_obj.positionX.linearRampToValueAtTime(node_x, context.currentTime + 0.1);
                                                                                          node_obj.positionY.linearRampToValueAtTime(node_y, context.currentTime + 0.1);
                                                                                          node_obj.positionZ.linearRampToValueAtTime(node_z, context.currentTime + 0.1);
                                                                                      } else {
                                                                                          node_obj.setPosition(node_x, node_y, node_z);
                                                                                      }
                                                                                      pannerNodesObjects[i] = node_obj;
                                                                                      if(i==0){
                                                                                          console.log("Front Left x: " + pannerNodesObjects[i].positionX.value + " y: " + pannerNodesObjects[i].positionY.value  + " z: " + pannerNodesObjects[i].positionZ.value );
                                                                                      }
                                                                                      if(i==1){
                                                                                          console.log("Front Right x: " + pannerNodesObjects[i].positionX.value + " y: " + pannerNodesObjects[i].positionY.value + " z: " + pannerNodesObjects[i].positionZ.value );
                                                                                      }
                                                                                      if(i==2){
                                                                                          console.log("Front Center x: " + pannerNodesObjects[i].positionX.value + " y: " + pannerNodesObjects[i].positionY.value + " z: " + pannerNodesObjects[i].positionZ.value );
                                                                                      }
                                                                                      
                                                                                  }
                                                                                  
                                                                                  
                                                                                  // Starting function creates PannerNodes and adds parameters to them
                                                                                  function start_function() {
                                                                                  
                                                                                      screenCenterY = estimate_ScreenParams();
                                                                                  
                                                                                      console.log("Distance from screen in start_function: " + distanceFromScreen);
                                                                                      console.log("screenCenterY in start_function: " + screenCenterY);
                                                                                  
                                                                                      if (listener.forwardX) {
                                                                                          listener.forwardX.setValueAtTime(0, context.currentTime);
                                                                                          listener.forwardY.setValueAtTime(0, context.currentTime);
                                                                                          listener.forwardZ.setValueAtTime(-1, context.currentTime);
                                                                                          listener.upX.setValueAtTime(0, context.currentTime);
                                                                                          listener.upY.setValueAtTime(1, context.currentTime);
                                                                                          listener.upZ.setValueAtTime(0, context.currentTime);
                                                                                      } else {
                                                                                          listener.setOrientation(0, 0, -1, 0, 1, 0);
                                                                                      }
                                                                                  
                                                                                      var angleList = [90, -90, 0, -110, 110, -20];
                                                                                      for (i = 0; i < pannerNodesObjects.length; i++) {
                                                                                          [nx, ny, nz] = set_rotation(distanceFromScreen, screenCenterY, angleList[i], i);
                                                                                          set_pannerNode(pannerNodesObjects[i], 'HRTF', "exponential", 1, 100, 2, 360, 0, 0, nx, ny, nz, i);
                                                                                          splitter.connect(pannerNodesObjects[i], i);
                                                                                          pannerNodesObjects[i].connect(context.destination);
                                                                                      }
                                                                                      console.log(context.destination);
                                                                                      console.log("start_function Finished!");
                                                                                  }
                                                                                  
                                                                                  
                                                                                  
                                                                                    
                                                                                    MyTitle
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                  
                                                                                  
                                                                                    Click to allow Web Audio 

                                                                                  Required to start webaudio API due to changes in autoplay policy on modern browsers

                                                                                  ANSWER

                                                                                  Answered 2020-Dec-08 at 03:38

                                                                                  You'll need to pause the audio until a user explicitly interacts (e.g. clicks) the page. This is a modern requirement to prevent audio from autoplaying without explicit invocation from users.

                                                                                  Source https://stackoverflow.com/questions/65115065

                                                                                  QUESTION

                                                                                  Install xplanet version 0.95a on a modern Linux or update code to xplanet 1.3
                                                                                  Asked 2020-Dec-04 at 16:51

                                                                                  I have an old tcl script, that I used to generate planets, but it needs to run with xplanet version 0.95a, because xplanet v1 is a complete rewrite and don't work with all the options I used.

                                                                                  The old version is still available here but how do I install it on Ubuntu 20.04?

                                                                                  Or would it be easy to convert the tcl script, so it will run on v1.3?

                                                                                  #! /usr/bin/wish
                                                                                  
                                                                                  # create the file planet_conf with
                                                                                  # echo "1">planet_conf
                                                                                  #
                                                                                  # create maps from png with
                                                                                  # convert foo.ppm -compress none color_maps/colormap{0-27}.ppm
                                                                                  
                                                                                  set fileid [open planet_conf r]
                                                                                      set numb [read $fileid]
                                                                                  close $fileid
                                                                                  
                                                                                  while {$numb < 10000} {
                                                                                      set numb [expr {$numb +1}]
                                                                                      set mixer [expr {0.1+(rand()*0.3)}]
                                                                                      set crater [expr {int(rand()*3)}]
                                                                                      set fade_number [expr {10+ int(rand()*7)}]  
                                                                                      set randmap [expr {int(rand()*28)}]
                                                                                      set randmap_crat [expr {int(rand()*28)}] 
                                                                                      set randmap_atmos [expr {int(rand()*28)}]
                                                                                      set dimensiona [expr {(rand()*3.1)}]
                                                                                      set modus [expr {int(rand()*7)}]
                                                                                      set dim [expr {0.5+$dimensiona}]
                                                                                      set pow [expr {0.5+(rand()*1)}]
                                                                                      set dim_atmos [expr {0.3+$dimensiona}]
                                                                                          set pow_atmos [expr {0.3+(rand()*1)}]
                                                                                      set degree [expr {96+(int(rand()*50))}]
                                                                                      set invert [expr {(rand()*1)}]
                                                                                      set size [expr {0.06+(rand()*0.15)}]
                                                                                      puts $numb 
                                                                                      puts "atmosphere map..."
                                                                                      catch { exec  ppmforge -clouds -power $pow_atmos -width 600 -height 300 -mesh 1024 -dimension $dim_atmos > atmos.ppm } result
                                                                                      catch {exec pnmremap -map=./color_maps/colormap$randmap_atmos.ppm atmos.ppm > atmos_remap.ppm} result
                                                                                      catch { exec pnmsmooth -size 9 9 atmos_remap.ppm > atmos_cut.ppm } result
                                                                                      catch { exec pnmcut atmos_cut.ppm -left 30 -right 286 -top 30 -bottom 286 > ./images/atmos_day_vorlage.ppm } result
                                                                                      catch { exec pnmcut atmos_cut.ppm -left 287 -right 542 -top 30 -bottom 286 > atmos_dark.ppm } result
                                                                                      catch { exec ppmbrighten -v -60 atmos_dark.ppm > ./images/atmos_night_vorlage.ppm } result
                                                                                      puts "premapping..."
                                                                                      if { $crater == 1 } {
                                                                                          puts "crater"
                                                                                          catch { exec pgmcrater -height 300 -width 600 > crater.pgm } result
                                                                                          catch { exec pgmtoppm -map color_maps/colormap$randmap_crat.ppm  crater.pgm > crater.ppm  } result 
                                                                                          puts $result    
                                                                                          catch { exec  ppmforge -clouds -power $pow -width 600 -height 300 -mesh 1024 -dimension $dim > test.ppm } result
                                                                                          puts $result
                                                                                          if { $modus == 1} {
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -shift } result
                                                                                          } elseif { $modus == 5} {
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -mix } result
                                                                                          } elseif { $modus == 2} { 
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -spread } result
                                                                                          } elseif { $modus == 3} { 
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -edge } result
                                                                                          } elseif { $modus == 4} {
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -bentley } result
                                                                                          } else {
                                                                                              catch { exec /usr/bin/ppmfade -f test.ppm -l crater.ppm -relief } result
                                                                                          }
                                                                                          puts $result
                                                                                          catch { exec cp fade.00$fade_number.ppm test.ppm } result
                                                                                          puts $result
                                                                                      } else {
                                                                                           catch { exec  /usr/bin/ppmforge -clouds -power $pow -width 600 -height 300 -mesh 1024 -dimension $dim > test.ppm } result
                                                                                      }
                                                                                      puts $result
                                                                                      puts "smoothing..."
                                                                                      catch { exec pnmsmooth -size 5 5 test.ppm > test_smooth.ppm } result
                                                                                      puts $result
                                                                                      catch {exec pnmremap -map=./color_maps/colormap$randmap.ppm test_smooth.ppm > test_remap.ppm } result
                                                                                      if { $invert < 0.5 } {
                                                                                          puts "inverted"
                                                                                          catch { exec pnminvert test_remap.ppm > test_middle.ppm } result
                                                                                      } else {
                                                                                          catch { exec cp test_remap.ppm test_middle.ppm } result
                                                                                      }
                                                                                      catch { exec pnmcut test_middle.ppm -left 30 -right 286 -top 30 -bottom 286 > ./images/vorlage_day.ppm } result
                                                                                      catch { exec pnmcut test_remap.ppm -left 287 -right 542 -top 30 -bottom 286 > test_dark.ppm } result
                                                                                      catch { exec ppmbrighten -v -70 test_dark.ppm > ./images/vorlage_night.ppm } result
                                                                                      puts $result
                                                                                      puts "planet generating ..."
                                                                                      catch {exec xplanet -starfreq 0 -date "24 Jun 1999 11:02:17" -image vorlage_day.ppm -night_image vorlage_night.ppm -blend -radius 40 -output planet.ppm } result
                                                                                      if {$result == ""} {
                                                                                          puts "ok"
                                                                                      } else {
                                                                                          puts $result
                                                                                      }
                                                                                       catch {exec xplanet -starfreq 0 -date "24 Jun 1999 11:02:17" -image atmos_vorlage.ppm -night_image atmos_night_vorlage.ppm -blend -radius 41 -output atmos_ready.ppm } result
                                                                                          if {$result == ""} {
                                                                                              puts "ok"
                                                                                          } else {
                                                                                              puts $result
                                                                                          }
                                                                                      catch { exec ppmmix $mixer planet.ppm atmos_ready.ppm > complete.ppm } result 
                                                                                      puts "scaling"  
                                                                                      catch { exec pnmscale $size complete.ppm > planet_s1.ppm } result
                                                                                      catch { exec ppmtojpeg planet_s1.ppm > planet_s1_$numb.jpg } result
                                                                                  
                                                                                      puts "" 
                                                                                      set fileid [open planet_conf w]
                                                                                          puts $fileid $numb
                                                                                      close $fileid
                                                                                      after 10 exec sleep 4
                                                                                      #catch {exec display test$numb.jpg } result
                                                                                  }
                                                                                  
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2020-Dec-04 at 16:51

                                                                                  I managed to convert it to xplanet v1.3:

                                                                                  1.

                                                                                  I had to create two config files, I use for the two xplanet calls:

                                                                                  configs/xplanet_night.conf:

                                                                                  [default]
                                                                                  min_radius_for_label=1000
                                                                                  [mars]
                                                                                  map=temp/atmos_vorlage.ppm
                                                                                  night_map=temp/atmos_night_vorlage.ppm
                                                                                  

                                                                                  and configs/xplanet_day.conf

                                                                                  [default]
                                                                                  min_radius_for_label=1000
                                                                                  [mars]
                                                                                  map=temp/vorlage_day.ppm
                                                                                  night_map=temp/vorlage_night.ppm
                                                                                  
                                                                                  2.

                                                                                  Then i adapted the script so it looks like this:
                                                                                  https://github.com/rubo77/spacetrace-planet-generator

                                                                                  Source https://stackoverflow.com/questions/65096442

                                                                                  QUESTION

                                                                                  php error preg_match Unknown modifier '2'
                                                                                  Asked 2020-Oct-02 at 23:03

                                                                                  i not understandy i am getting the error preg_match(): Unknown modifier '2' here is my code i trying to parse the audio format.

                                                                                  /**
                                                                                   * @param string $name
                                                                                   * @return string|null
                                                                                   */
                                                                                  public static function parseAudioFormat(string $name): ?string
                                                                                  {
                                                                                      $Audios = ['AAC', 'AC-3', 'DTS', 'DTS-HD Master Audio', 'DTS-ES', 'DTS 96/24', 'E-AC-3', 'FLAC', 'MP2', 'MP3', 'Opus', 'PCM', 'TrueHD', 'Atmos', 'Vorbis'];
                                                                                      foreach ($Audios as $audio) {
                                                                                          if (preg_match("/\b($audio)\b/i", $name, $m)) {
                                                                                              return $m[0];
                                                                                          }
                                                                                  
                                                                                      }
                                                                                      return false;
                                                                                  }
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2020-Oct-02 at 23:01

                                                                                  This is because you are using what are called meta-characters in your search strings and must be escaped in order to be used literally.

                                                                                  Source https://stackoverflow.com/questions/64179125

                                                                                  QUESTION

                                                                                  Flattening nested dictionary React? - Cannot read property 'standard' of undefined
                                                                                  Asked 2020-Sep-22 at 21:00

                                                                                  I am working on a personal WebApp project in React. I am new to this technology but very eager to learn it. I came across a problem. I am using axios to fetch data from Google Youtube API response and it works but I am unable to parse obtained data that is nested. What i mean by that: Inside Items there are multiple snippets

                                                                                  {
                                                                                      "items": [
                                                                                          {
                                                                                              "snippet": {
                                                                                                  "title": "Dolby Atmos - usłysz więcej!",
                                                                                                  "description": "W dzisiejszym odcinku opowiem wam o tym czym jest nagłośnienie i system dolby atmos. System i nagłośnienie Dolby atmos znajdziemy obecnie w najlepszych kinach. System wspierają takie filmy jak \"Zjawa\" czy \"Kapitan Ameryka wojna bohaterów\". Jakość dźwięk docenią kinomani i prawdziwi audiofile. Istnieje również stworzenia systemu składającego się z głośników dolby atmos kina domowego, ale jest poważna inwestycja.\nJeżeli jesteś z Łodzi i chcesz poczuć Dolby Atmos na własnej skórze kliknij tutaj:\nhttp://www.helios.pl/47,Lodz/StronaGlowna/\n\nJeżeli dzisiejszym odcinek Ci się spodobał zostaw like'a albo subskrybcję :D\nFanPage:\nhttp://facebook.com/RuchOpornikow\nGoogle+:\nhttps://plus.google.com/u/0/+RuchOpor...\nTwitter:\nhttps://twitter.com/RuchOpornikow",
                                                                                                  "thumbnails": {
                                                                                                      "standard": {
                                                                                                          "url": "https://i.ytimg.com/vi/QWTk3vnztRw/sddefault.jpg",
                                                                                                          "width": 640,
                                                                                                          "height": 480
                                                                                                      },
                                                                                                      "maxres": {
                                                                                                          "url": "https://i.ytimg.com/vi/QWTk3vnztRw/maxresdefault.jpg",
                                                                                                          "width": 1280,
                                                                                                          "height": 720
                                                                                                      }
                                                                                                  },
                                                                                                  "resourceId": {
                                                                                                      "videoId": "QWTk3vnztRw"
                                                                                                  }
                                                                                              }
                                                                                          },
                                                                                  

                                                                                  I want to get a random snippet from items and use it's title attribute, description and thumbnails. At this point I can access description and title but accessing movie.description.thumbnails.standard.url or movie.resourceId.videoId gives me an error.

                                                                                      TypeError: Cannot read property 'standard' of undefined
                                                                                    31 |     backgroundPosition: "center center",
                                                                                    32 |   }}
                                                                                    33 | >
                                                                                  > 34 |   
                                                                                    35 |     
                                                                                    36 |     {/* edge cases */}
                                                                                    37 |     
                                                                                  

                                                                                  Here is my full code :

                                                                                  function Banner() {
                                                                                    const [movie, setMovie] = useState([]);
                                                                                    useEffect(() => {
                                                                                      async function fetchData() {
                                                                                        const request = await axios.get("./data.json");
                                                                                        setMovie(
                                                                                          request.data.items[
                                                                                            Math.floor(Math.random() * (request.data.items.length-1))
                                                                                          ].snippet
                                                                                        );
                                                                                  
                                                                                        return request;
                                                                                      }
                                                                                      fetchData();
                                                                                    }, []);
                                                                                    return (
                                                                                      
                                                                                        
                                                                                        
                                                                                          {/* edge cases */}
                                                                                          
                                                                                            {movie.title}
                                                                                          
                                                                                          
                                                                                            Play
                                                                                            Original
                                                                                          
                                                                                          {movie.description}
                                                                                        
                                                                                        
                                                                                      
                                                                                    );
                                                                                  }
                                                                                  
                                                                                  export default Banner;
                                                                                  

                                                                                  Do you know what could be an error and how to fix it? Console.log and JSON.stringify show that those attributes are there.

                                                                                  ANSWER

                                                                                  Answered 2020-Sep-22 at 21:00

                                                                                  initial movie is an empty array and it will take some time to fetch from API. refactor to the below

                                                                                    const [movie, setMovie] = useState();
                                                                                  

                                                                                  and check movie if it's not null before rendering

                                                                                  return movie?(
                                                                                  
                                                                                    
                                                                                    
                                                                                      {/* edge cases */}
                                                                                      
                                                                                        {movie.title}
                                                                                      
                                                                                      
                                                                                        Play
                                                                                        Original
                                                                                      
                                                                                      {movie.description}
                                                                                    
                                                                                    
                                                                                  
                                                                                  ):null;
                                                                                  

                                                                                  Source https://stackoverflow.com/questions/64017254

                                                                                  QUESTION

                                                                                  How do I formate spaces in terminal for FFMPEG metadata
                                                                                  Asked 2020-Jul-22 at 21:18

                                                                                  I can't get FFMPEG to accept any spaces when I try to assign it to the metadata. Below is the command I am using in Terminal on MacOS. It gives me an error: [NULL @ 0x7fce76026600] Unable to find a suitable output format for 'World' World: Invalid argument

                                                                                  ffmpeg -hide_banner \
                                                                                  -i Trolls.World.Tour.2020.Bluray-2160p.m2ts \
                                                                                  -ss 00:10:00 -t 00:1:00 \
                                                                                  -pix_fmt yuv420p10le \
                                                                                  -map_chapters 0 \
                                                                                  -metadata:s:t:0 filename="" -metadata:s:t:0 mimetype="image/jpeg" \
                                                                                  -metadata title=“Trolls World Tour” \
                                                                                  -map 0:0 -metadata:s:v:0 language=eng -metadata:s:v:0 title=“Trolls World Tour” \
                                                                                  -map 0:2 -metadata:s:a:0 language=eng -metadata:s:a:0 title=“Dolby TrueHD 7.1 Atmos” \
                                                                                  -map 0:6 -metadata:s:a:0 language=eng -metadata:s:a:1 title=“AC-3 2.0” \
                                                                                  -c:v libx265 -preset slow -crf 16 \
                                                                                  -x265-params keyint=60:bframes=3:vbv-bufsize=75000:vbv-maxrate=75000:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)" \
                                                                                  -c:a copy \
                                                                                  Trolls.World.Tour.2020.2160p.BluRay.REMUX.HEVC.TrueHD.7.1.Atmos.mkv
                                                                                  

                                                                                  I have tried 'title="Trolls World Tour"' title=Trolls" "World" "Tour to no luck.

                                                                                  Using title="Trolls\ World\ Tour" works but then the title includes the backslashes.

                                                                                  Any thoughts?

                                                                                  ANSWER

                                                                                  Answered 2020-Jul-22 at 21:18

                                                                                  Replace the “smart / fancy” quotes with "normal double quotes".

                                                                                  • Bad: &
                                                                                  • Good: "

                                                                                  Source https://stackoverflow.com/questions/63042075

                                                                                  QUESTION

                                                                                  Add or subtract one array in the Z dimension from another, where latitude (Y dimension) and longitude (X) are different
                                                                                  Asked 2020-Jun-29 at 09:05

                                                                                  Ultimately, I want to calculate the difference between modelled and measured air quality. I have two netcdf files. The first one (A) contains air particle data from a model with latitude (y1) index-length 100 and longitude (x1) index-length 200. From this A, I want to subtract observation data (B) with latitude (y2) index-length 1300 and longitude (x2) index-length 1300. The actual latitude values of B (in degrees North and East) are present in A, although not exactly, i.e. values in A are evenly spaced (e.g. 55.95°, 55.85°, 55.75°, etc.) but the values in B have 3 decimals and are spaced by changing increments of roughly 0.001 to 0.003.

                                                                                  It feels like this should be straight forward: take obs data in a lat/lon range (e.g. 50.5 to 51°N and 8.1 to 8.2°E) and subtract it from model data in the same lat/lon range.

                                                                                  At first I tried with numpy adapting from this example of calculating 'departure from global temperature'. But I keep running into dead ends.

                                                                                  Then, I tried a gazillion variations of something along the lines of this (which is obviously wrong, but I am no coding wizzard):

                                                                                  anomaly=[]
                                                                                  for j in range(len(100)):
                                                                                      for k in range(len(200)):
                                                                                          for i in range(len(1300)):
                                                                                              if latitude_model[j] == latitude_observation[i] and longitude_model[k] == longitude_observation[i]:
                                                                                                  departure = model_data[0,0,j,k] - observation_data[i,i] #the first two dimensions of the model data are 'time' and 'level'
                                                                                                  anomaly = np.append(departure)
                                                                                  

                                                                                  My third approach was with xarray adapting from this example. Xarray would allow to use method='nearest' and tolerance = 0.1 functions which would help with the not-matching lat/lon data (as far as I understand). But after loading the two netcdf files I can't even find an entrance point to how to continue the code. Plus I would probably have to reshape (but how?) the model data to match the observations. Or subtract observation data from the same model grid, if several observation points fall within the same grid.

                                                                                  PS: This question is eventually related to my other question, which is about the same data and problem.

                                                                                  ANSWER

                                                                                  Answered 2020-Jun-11 at 15:38

                                                                                  When calculating for the bias between the model and observed, it is important that you match the grids before conducting your analysis. In other words, pre-processing is always a must. So you'll either have to match the grid of the model to the observed or vice-versa before subtracting both files, else, your output won't make sense at all because of the difference. The easiest way to do this is to use special operators like CDO, NCO, NCL, etc.

                                                                                  In your command line (though CDO is available in Python as well but with a different syntax needed than below)

                                                                                  ### Match the grids ###
                                                                                  cdo remapbil,obs.nc model.nc model1.nc
                                                                                  
                                                                                  ### Subtract the files ###
                                                                                  cdo sub model1.nc obs.nc bias.nc
                                                                                  

                                                                                  You can then easily map the difference in Python. I prefer this method just because it's easier and lighter than pre-processing the data in Python.

                                                                                  (sent from smartphone)

                                                                                  Source https://stackoverflow.com/questions/62308401

                                                                                  QUESTION

                                                                                  Pull multiple values instead of just one
                                                                                  Asked 2020-Jun-23 at 02:10

                                                                                  Value the user sends:

                                                                                  General
                                                                                  Complete name : G:\VIDEO_TS\VTS_04_1.VOB
                                                                                  Format : MPEG-PS
                                                                                  File size : 1 024 MiB
                                                                                  Duration : 29 min 25 s
                                                                                  Overall bit rate mode : Variable
                                                                                  Overall bit rate : 4 867 kb/s
                                                                                  
                                                                                  Video
                                                                                  ID : 224 (0xE0)
                                                                                  Format : MPEG Video
                                                                                  Format version : Version 2
                                                                                  Format profile : Main@Main
                                                                                  Format settings : CustomMatrix / BVOP
                                                                                  Format settings, BVOP : Yes
                                                                                  Format settings, Matrix : Custom
                                                                                  Format settings, GOP : M=3, N=15
                                                                                  Format settings, picture structure : Frame
                                                                                  Duration : 29 min 25 s
                                                                                  Bit rate mode : Variable
                                                                                  Bit rate : 3 650 kb/s
                                                                                  Maximum bit rate : 8 500 kb/s
                                                                                  Width : 720 pixels
                                                                                  Height : 480 pixels
                                                                                  Display aspect ratio : 16:9
                                                                                  Frame rate : 29.970 (30000/1001) FPS
                                                                                  Standard : NTSC
                                                                                  Color space : YUV
                                                                                  Chroma subsampling : 4:2:0
                                                                                  Bit depth : 8 bits
                                                                                  Scan type : Interlaced
                                                                                  Scan order : Top Field First
                                                                                  Compression mode : Lossy
                                                                                  Bits/(Pixel*Frame) : 0.352
                                                                                  Time code of first frame : 00:59:59:15
                                                                                  Time code source : Group of pictures header
                                                                                  GOP, Open/Closed : Closed
                                                                                  Stream size : 768 MiB (75%)
                                                                                  
                                                                                  Audio #1
                                                                                  ID : 189 (0xBD)-128 (0x80)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 448 kb/s
                                                                                  Channel(s) : 2 channels
                                                                                  Channel layout : L R
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 94.2 MiB (9%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Audio #2
                                                                                  ID : 189 (0xBD)-129 (0x81)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 448 kb/s
                                                                                  Channel(s) : 6 channels
                                                                                  Channel layout : L R C LFE Ls Rs
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 94.2 MiB (9%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Audio #3
                                                                                  ID : 189 (0xBD)-130 (0x82)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 224 kb/s
                                                                                  Channel(s) : 2 channels
                                                                                  Channel layout : L R
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 47.1 MiB (5%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Text
                                                                                  ID : 189 (0xBD)-33 (0x21)
                                                                                  Format : RLE
                                                                                  Format/Info : Run-length encoding
                                                                                  Muxing mode : DVD-Video
                                                                                  Delay relative to video : 7 s 874 ms
                                                                                  
                                                                                  General
                                                                                  Complete name : G:\VIDEO_TS\VTS_04_0.IFO
                                                                                  Format : DVD Video
                                                                                  Format profile : Program
                                                                                  File size : 68.0 KiB
                                                                                  Duration : 1 h 37 min
                                                                                  Overall bit rate mode : Variable
                                                                                  Overall bit rate : 95 b/s
                                                                                  
                                                                                  Video
                                                                                  ID : 224 (0xE0)
                                                                                  Format : MPEG Video
                                                                                  Format version : Version 2
                                                                                  Duration : 1 h 37 min
                                                                                  Bit rate mode : Variable
                                                                                  Width : 720 pixels
                                                                                  Height : 480 pixels
                                                                                  Display aspect ratio : 16:9
                                                                                  Frame rate : 29.970 (29970/1000) FPS
                                                                                  Standard : NTSC
                                                                                  Compression mode : Lossy
                                                                                  Duration_Source : General_Duration
                                                                                  
                                                                                  Audio #1
                                                                                  ID : 128 (0x80)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Duration : 1 h 37 min
                                                                                  Channel(s) : 2 channels
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Compression mode : Lossy
                                                                                  Language : Chinese
                                                                                  Duration_Source : General_Duration
                                                                                  
                                                                                  Audio #2
                                                                                  ID : 129 (0x81)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Duration : 1 h 37 min
                                                                                  Channel(s) : 6 channels
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Compression mode : Lossy
                                                                                  Language : Chinese
                                                                                  Duration_Source : General_Duration
                                                                                  
                                                                                  Audio #3
                                                                                  ID : 130 (0x82)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Duration : 1 h 37 min
                                                                                  Channel(s) : 2 channels
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Compression mode : Lossy
                                                                                  Language : Portuguese
                                                                                  Duration_Source : General_Duration
                                                                                  
                                                                                  Text #1
                                                                                  ID : 32 (0x20)
                                                                                  Format : RLE
                                                                                  Format/Info : Run-length encoding
                                                                                  Bit depth : 2 bits
                                                                                  Language : Portuguese
                                                                                  
                                                                                  Text #2
                                                                                  ID : 33 (0x21)
                                                                                  Format : RLE
                                                                                  Format/Info : Run-length encoding
                                                                                  Bit depth : 2 bits
                                                                                  
                                                                                  Menu
                                                                                  Duration : 1 h 37 min
                                                                                  00:00:00.000 : Chapter 1
                                                                                  00:07:10.500 : Chapter 2
                                                                                  00:14:26.500 : Chapter 3
                                                                                  00:23:42.000 : Chapter 4
                                                                                  00:31:12.000 : Chapter 5
                                                                                  00:39:38.000 : Chapter 6
                                                                                  00:46:15.500 : Chapter 7
                                                                                  00:55:23.500 : Chapter 8
                                                                                  01:02:27.500 : Chapter 9
                                                                                  01:10:12.500 : Chapter 10
                                                                                  01:19:13.500 : Chapter 11
                                                                                  01:26:13.000 : Chapter 12
                                                                                  01:37:46.200 : Chapter 13
                                                                                  List (Audio) : 0 / 1 / 2
                                                                                  List (Subtitles 4/3) : 0 / 0
                                                                                  List (Subtitles Wide) : 0 / 1
                                                                                  List (Subtitles Letterbox) : 0 / 1
                                                                                  List (Subtitles Pan&Scan) : 0 / 1
                                                                                  
                                                                                  General
                                                                                  Unique ID : 265651434810034235117589437423295755026 (0xC7DA9AF5666AD1527A66985978717312)
                                                                                  Complete name : Aladdin.1992.2160p.UHD.BluRay.x265-TERMiNAL.DUAL-Lannister.mkv
                                                                                  Format : Matroska
                                                                                  Format version : Version 4
                                                                                  File size : 8.02 GiB
                                                                                  Duration : 1 h 30 min
                                                                                  Overall bit rate mode : Variable
                                                                                  Overall bit rate : 12.7 Mb/s
                                                                                  Encoded date : UTC 2019-09-12 17:17:31
                                                                                  Writing application : mkvmerge v22.0.0 ('At The End Of The World') 64-bit
                                                                                  Writing library : libebml v1.3.5 + libmatroska v1.4.8
                                                                                  
                                                                                  Video
                                                                                  ID : 1
                                                                                  Format : HEVC
                                                                                  Format/Info : High Efficiency Video Coding
                                                                                  Format profile : Main 10@L5.1@High
                                                                                  HDR format : SMPTE ST 2086, HDR10 compatible
                                                                                  Codec ID : V_MPEGH/ISO/HEVC
                                                                                  Duration : 1 h 30 min
                                                                                  Bit rate : 6 532 kb/s
                                                                                  Width : 3 584 pixels
                                                                                  Height : 2 160 pixels
                                                                                  Display aspect ratio : 5:3
                                                                                  Frame rate mode : Constant
                                                                                  Frame rate : 23.976 (24000/1001) FPS
                                                                                  Color space : YUV
                                                                                  Chroma subsampling : 4:2:0 (Type 2)
                                                                                  Bit depth : 10 bits
                                                                                  Bits/(Pixel*Frame) : 0.035
                                                                                  Stream size : 4.14 GiB (52%)
                                                                                  Writing library : x265 3.1+11-de920e0a3183:[Windows][GCC 6.3.0][64 bit] 10bit
                                                                                  Encoding settings : cpuid=1176575 / frame-threads=6 / numa-pools=36 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3584x2160 / interlace=0 / total-frames=130417 / level-idc=51 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / repeat-headers / annexb / aud / hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=1 / keyint=24 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / no-strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=-3:-3 / no-sao / no-sao-non-deblock / rd=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=17.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=160000 / vbv-bufsize=160000 / vbv-init=0.9 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=16 / colormatrix=9 / chromaloc=1 / chromaloc-top=2 / chromaloc-bottom=2 / display-window=0 / master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,20)cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / hdr / hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=0 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00
                                                                                  Default : Yes
                                                                                  Forced : No
                                                                                  Color range : Limited
                                                                                  Color primaries : BT.2020
                                                                                  Transfer characteristics : PQ
                                                                                  Matrix coefficients : BT.2020 non-constant
                                                                                  Mastering display color primaries : Display P3
                                                                                  Mastering display luminance : min: 0.0020 cd/m2, max: 1000 cd/m2
                                                                                  
                                                                                  Audio #1
                                                                                  ID : 2
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Codec ID : A_AC3
                                                                                  Duration : 1 h 30 min
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 640 kb/s
                                                                                  Channel(s) : 6 channels
                                                                                  Channel layout : L R C LFE Ls Rs
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Bit depth : 16 bits
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 415 MiB (5%)
                                                                                  Title : by Lannister
                                                                                  Language: Portuguese
                                                                                  Service kind : Complete Main
                                                                                  Default : Yes
                                                                                  Forced : Yes
                                                                                  
                                                                                  Audio #2
                                                                                  ID : 3
                                                                                  Format : MLP FBA 16-ch
                                                                                  Format/Info : Meridian Lossless Packing FBA with 16-channel presentation
                                                                                  Commercial name : Dolby TrueHD with Dolby Atmos
                                                                                  Codec ID : A_TRUEHD
                                                                                  Duration : 1 h 30 min
                                                                                  Bit rate mode : Variable
                                                                                  Bit rate : 4 768 kb/s
                                                                                  Maximum bit rate : 6 816 kb/s
                                                                                  Channel(s) : 8 channels
                                                                                  Channel layout : L R C LFE Ls Rs Lb Rb
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 1 200.000 FPS (40 SPF)
                                                                                  Compression mode : Lossless
                                                                                  Stream size : 3.02 GiB (38%)
                                                                                  Language : English
                                                                                  Default : No
                                                                                  Forced : No
                                                                                  Number of dynamic objects : 13
                                                                                  Bed channel count : 1 channel
                                                                                  Bed channel configuration : LFE
                                                                                  
                                                                                  Audio #3
                                                                                  ID : 4
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Codec ID : A_AC3
                                                                                  Duration : 1 h 30 min
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 640 kb/s
                                                                                  Channel(s) : 6 channels
                                                                                  Channel layout : L R C LFE Ls Rs
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Bit depth : 16 bits
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 415 MiB (5%)
                                                                                  Language : English
                                                                                  Service kind : Complete Main
                                                                                  Default : No
                                                                                  Forced : No
                                                                                  
                                                                                  Text
                                                                                  ID : 5
                                                                                  Format : PGS
                                                                                  Muxing mode : zlib
                                                                                  Codec ID : S_HDMV/PGS
                                                                                  Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
                                                                                  Duration : 1 h 29 min
                                                                                  Bit rate : 35.9 kb/s
                                                                                  Count of elements : 2352
                                                                                  Stream size : 23.0 MiB (0%)
                                                                                  Language : Portuguese
                                                                                  Default : No
                                                                                  Forced : No
                                                                                  
                                                                                  General
                                                                                  Unique ID : 96295411837011032641642823181481344850 (0x4871D25C0188DBA1F9468FCC41F8FF52)
                                                                                  Complete name : Coração Valente 1995 4k 2160p Dual Audio.mkv
                                                                                  Format : Matroska
                                                                                  Format version : Version 4
                                                                                  File size : 45.7 GiB
                                                                                  Duration : 2 h 57 min
                                                                                  Overall bit rate : 36.9 Mb/s
                                                                                  Movie name : Coração Valente
                                                                                  Encoded date : UTC 2019-09-24 12:13:44
                                                                                  Writing application : mkvmerge v37.0.0 ('Leave It') 64-bit
                                                                                  Writing library : libebml v1.3.9 + libmatroska v1.5.2
                                                                                  Cover : Yes
                                                                                  Attachments : cover3.jpeg
                                                                                  
                                                                                  Video
                                                                                  ID : 1
                                                                                  Format : HEVC
                                                                                  Format/Info : High Efficiency Video Coding
                                                                                  Format profile : Main 10@L5.1@High
                                                                                  HDR format : SMPTE ST 2086, HDR10 compatible
                                                                                  Codec ID : V_MPEGH/ISO/HEVC
                                                                                  Duration : 2 h 57 min
                                                                                  Bit rate : 36.0 Mb/s
                                                                                  Width : 3 840 pixels
                                                                                  Height : 1 634 pixels
                                                                                  Display aspect ratio : 2.35:1
                                                                                  Frame rate mode : Constant
                                                                                  Frame rate : 23.976 (24000/1001) FPS
                                                                                  Color space : YUV
                                                                                  Chroma subsampling : 4:2:0 (Type 2)
                                                                                  Bit depth : 10 bits
                                                                                  Bits/(Pixel*Frame) : 0.239
                                                                                  Stream size : 44.7 GiB (98%)
                                                                                  Title : DUAL AUDIO
                                                                                  Writing library : x265 2.7+348-0968a46d6ba4:[Windows][GCC 7.3.0][64 bit] 10bit
                                                                                  Encoding settings : cpuid=1176575 / frame-threads=5 / numa-pools=32 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x1634 / interlace=0 / total-frames=255642 / level-idc=51 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / repeat-headers / annexb / aud / hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=24 / keyint=240 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / radl=0 / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / no-strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / weightp / no-weightb / no-analyze-src-pics / deblock=-3:-3 / no-sao / no-sao-non-deblock / rd=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=18.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=160000 / vbv-bufsize=160000 / vbv-init=0.9 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=1 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=16 / colormatrix=9 / chromaloc=1 / chromaloc-top=2 / chromaloc-bottom=2 / display-window=0 / master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1) / max-cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / hdr / hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-mv-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei
                                                                                  Language : Portuguese
                                                                                  Default : Yes
                                                                                  Forced : Yes
                                                                                  Color range : Limited
                                                                                  Color primaries : BT.2020
                                                                                  Transfer characteristics : PQ
                                                                                  Matrix coefficients : BT.2020 non-constant
                                                                                  Mastering display color primaries : Display P3
                                                                                  Mastering display luminance : min: 0.0001 cd/m2, max: 1000 cd/m2
                                                                                  
                                                                                  Audio #1
                                                                                  ID : 2
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Codec ID : A_AC3
                                                                                  Duration : 2 h 57 min
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 192 kb/s
                                                                                  Channel(s) : 2 channels
                                                                                  Channel layout : L R
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Bit depth : 16 bits
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 244 MiB (1%)
                                                                                  Title : AC3 2.0
                                                                                  Language : Portuguese
                                                                                  Service kind : Complete Main
                                                                                  Default : Yes
                                                                                  Forced : Yes
                                                                                  
                                                                                  Audio #2ID : 3
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Codec ID : A_AC3
                                                                                  Duration : 2 h 57 min
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 640 kb/s
                                                                                  Channel(s) : 6 channels
                                                                                  Channel layout : L R C LFE Ls Rs
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Bit depth : 16 bits
                                                                                  Compression mode : Lossy
                                                                                  Delay relative to video : 2 s 169 ms
                                                                                  Stream size : 813 MiB (2%)
                                                                                  Title : AC-3 5.1
                                                                                  Language : English
                                                                                  Service kind : Complete Main
                                                                                  Default : No
                                                                                  Forced : No
                                                                                  

                                                                                  Value I'd like to take (not only this one, but the others as well):

                                                                                  General
                                                                                  Complete name : G:\\VIDEO_TS\\VTS_04_1.VOB
                                                                                  Format : MPEG-PS
                                                                                  File size : 1 024 MiB
                                                                                  Duration : 29 min 25 s
                                                                                  Overall bit rate mode : Variable
                                                                                  Overall bit rate : 4 867 kb/s
                                                                                  
                                                                                  Video
                                                                                  ID : 224 (0xE0)
                                                                                  Format : MPEG Video
                                                                                  Format version : Version 2
                                                                                  Format profile : Main@Main
                                                                                  Format settings : CustomMatrix / BVOP
                                                                                  Format settings, BVOP : Yes
                                                                                  Format settings, Matrix : Custom
                                                                                  Format settings, GOP : M=3, N=15
                                                                                  Format settings, picture structure : Frame
                                                                                  Duration : 29 min 25 s
                                                                                  Bit rate mode : Variable
                                                                                  Bit rate : 3 650 kb/s
                                                                                  Maximum bit rate : 8 500 kb/s
                                                                                  Width : 720 pixels
                                                                                  Height : 480 pixels
                                                                                  Display aspect ratio : 16:9
                                                                                  Frame rate : 29.970 (30000/1001) FPS
                                                                                  Standard : NTSC
                                                                                  Color space : YUV
                                                                                  Chroma subsampling : 4:2:0
                                                                                  Bit depth : 8 bits
                                                                                  Scan type : Interlaced
                                                                                  Scan order : Top Field First
                                                                                  Compression mode : Lossy
                                                                                  Bits/(Pixel*Frame) : 0.352
                                                                                  Time code of first frame : 00:59:59:15
                                                                                  Time code source : Group of pictures header
                                                                                  GOP, Open/Closed : Closed
                                                                                  Stream size : 768 MiB (75%)
                                                                                  
                                                                                  Audio #1
                                                                                  ID : 189 (0xBD)-128 (0x80)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 448 kb/s
                                                                                  Channel(s) : 2 channels
                                                                                  Channel layout : L R
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 94.2 MiB (9%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Audio #2
                                                                                  ID : 189 (0xBD)-129 (0x81)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 448 kb/s
                                                                                  Channel(s) : 6 channels
                                                                                  Channel layout : L R C LFE Ls Rs
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 94.2 MiB (9%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Audio #3
                                                                                  ID : 189 (0xBD)-130 (0x82)
                                                                                  Format : AC-3
                                                                                  Format/Info : Audio Coding 3
                                                                                  Commercial name : Dolby Digital
                                                                                  Muxing mode : DVD-Video
                                                                                  Duration : 29 min 24 s
                                                                                  Bit rate mode : Constant
                                                                                  Bit rate : 224 kb/s
                                                                                  Channel(s) : 2 channels
                                                                                  Channel layout : L R
                                                                                  Sampling rate : 48.0 kHz
                                                                                  Frame rate : 31.250 FPS (1536 SPF)
                                                                                  Compression mode : Lossy
                                                                                  Stream size : 47.1 MiB (5%)
                                                                                  Service kind : Complete Main
                                                                                  
                                                                                  Text
                                                                                  ID : 189 (0xBD)-33 (0x21)
                                                                                  Format : RLE
                                                                                  Format/Info : Run-length encoding
                                                                                  Muxing mode : DVD-Video
                                                                                  Delay relative to video : 7 s 874 ms
                                                                                  

                                                                                  I'm using PHP 7 + regex, this site is helping me: https://regex101.com/r/fQXzx7/1

                                                                                  Regex: ^General(.*?)^General|[\s]

                                                                                  What I imagined in my head with this regex:

                                                                                  ^General -> Take what starts with General
                                                                                  
                                                                                  (.*?) -> Take the values between the two general or space blank
                                                                                  
                                                                                  ^General|[\s] -> Starts with general or blank
                                                                                  

                                                                                  I am a beginner in regex and my English is basic.

                                                                                  *Edit:I added the codes in the text.

                                                                                  ANSWER

                                                                                  Answered 2020-Jun-23 at 02:10

                                                                                  The problem with your regex is that the second ^General absorbs those characters and prevents them matching on the second group. Also I'm not sure what you are trying to achieve with [\s] as that will match any space character when not matching the first part of the regex. I think what you actually want is to use a positive lookahead for General at the start of the line (or end of string) i.e.

                                                                                  (?:^|\n)General(.*?)(?=\nGeneral|$)
                                                                                  

                                                                                  Use only the s flag (in PHP, with preg_match_all) so that . matches newline.

                                                                                  Demo on regex101

                                                                                  PHP demo on 3v4l.org

                                                                                  Source https://stackoverflow.com/questions/62526060

                                                                                  Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                  Vulnerabilities

                                                                                  The XML parser in EMC Atmos before 2.2.3.426 and 2.3.x before 2.3.1.0 allows remote authenticated users to read arbitrary files or cause a denial of service (CPU and memory consumption) via an external entity declaration in conjunction with an entity reference, related to an XML External Entity (XXE) issue.
                                                                                  EMC Atmos before 2.1.4 has a blank password for the PostgreSQL account, which allows remote attackers to obtain sensitive administrative information via a database-server connection.

                                                                                  Install atmos

                                                                                  First install the dependencies:.
                                                                                  Install docker for deploying containers
                                                                                  Install terraform (optional if running atmos as a docker image): e.g. brew install terraform@0.11 on macOS or Linux
                                                                                  Install the aws cli (optional, useful for managing aws credentials): e.g. brew install awscli on macOS or Linux
                                                                                  gem install simplygenius-atmos
                                                                                  verify: atmos --help
                                                                                  curl -sL https://raw.githubusercontent.com/simplygenius/atmos/master/exe/atmos-docker > /usr/local/bin/atmos
                                                                                  chmod +x /usr/local/bin/atmos
                                                                                  verify: atmos --help
                                                                                  See the screencast for a detailed walkthrough (~1 hour) of the quickstart. Or try the condensed screencast if you just want to take a quick look (~7m). Create an AWS account Setup root account access keys, make note of the numeric account id.

                                                                                  Support

                                                                                  Bug reports and pull requests are welcome on GitHub at https://github.com/simplygenius/atmos.
                                                                                  Find more information at:
                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit
                                                                                  CLONE
                                                                                • HTTPS

                                                                                  https://github.com/simplygenius/atmos.git

                                                                                • CLI

                                                                                  gh repo clone simplygenius/atmos

                                                                                • sshUrl

                                                                                  git@github.com:simplygenius/atmos.git

                                                                                • Share this Page

                                                                                  share link

                                                                                  Reuse Pre-built Kits with atmos

                                                                                  Consider Popular Infrastructure Automation Libraries

                                                                                  Try Top Libraries by simplygenius

                                                                                  atmos-example-app

                                                                                  by simplygeniusRuby

                                                                                  Compare Infrastructure Automation Libraries with Highest Support

                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit