satoshi-2000/llms-suitable huggingface dataset:
Question: Resolving a library projects SASS files from an application in the same workspace?

Is it possible to resolve SASS contained in a workspace library using an approach that is similar to resolving ts files from an application within the same workspace?  For context I'll setup a real workspace as follows:
ng new theme-workspace --create-application=false
cd theme-workspace
ng g library theme
mkdir projects/theme/src/lib/styles
touch projects/theme/src/lib/styles/index.scss
ng g application playground

Within the directory projects/theme/src/lib/styles we will add the following content to index.scss.
$color: red;

And in order to include the style assets we need to update ng-package.json with an asset block like this:
  "assets": [
    { "input": "src/lib/styles", "glob": "**/*.scss", "output": "styles" }
  ]

If we build this project library like this:
ng build theme

We see that dist/theme/styles contains index.scss.
We can access the generated ts component ThemeComponent like this from the playground.
import { ThemeComponent } from 'theme';


When using @use to import the SASS index.scss module is it possible to use a similar namespace?
For example if we try this from the playground styles.scss module it fails:
@use `theme/styles` as t;

This is the error.
SassError: Can't find stylesheet to import.
  ╷
2 │ @use 'theme/styles' as t;

Now we could resolve by using a relative file import, but I'm curious whether there's a "Shorthand" way of doing it that uses the library name space?


Answer:
Currently this is not supported, but there is a feature request for it.
Question: How to increase the compression ratio of a JPEG2000 file with "avenc_jpeg2000" GStreamer encoder?

I'm using the plugin avenc_jpeg2000, from gst-libav module, combined with videotestsrc and  filesink plugins for encoding a raw picture to a JPEG2000 picture:
gst-launch-1.0 videotestsrc num-buffers=1 ! avenc_jpeg2000 ! filesink location=/tmp/picture-ref.jp2

This pipeline works and produce a 31.85 KiB (32,616) file.
enter image description here
Now, I want to divide the size of my output file by two by increasing the compression ratio of the encoder avenc_jpeg2000. To achieve this, I want to minimize the number of bits required to represent the image with an allowable level of distortion. I know JPEG2000 standard support lossless and lossy compression mode. For my use case, the lossy compression mode is acceptable.
How should I proceed to increase the compression of my output file ? What encoder's properties should I play with for doing that ?
My test configuration:

i.MX 8M Plus

GStreamer 1.18.0

libav 1.18.0 (Release date: 2020-09-08)


I tried to play with "bitrate" and "bitrate-tolerance" properties, but it seems to have no effect on the size of the output file:
gst-launch-1.0 videotestsrc num-buffers=1 ! avenc_jpeg2000 bitrate=100000 bitrate-tolerance=10000 ! filesink location=/tmp/picture-test-01.jp2

I compare files by doing a checksum with sha224sum command :
d0da9118a9c93a0420d6d62f104e0d99fe6e50cda5e87a46cef126f9  /tmp/picture-ref.jp2

d0da9118a9c93a0420d6d62f104e0d99fe6e50cda5e87a46cef126f9  /tmp/picture-test-01.jp2



Answer:
For lossy compression, you can increase the value of the quantization.
First, set the encoding type of the encoder to "Constant Quantizer" and then, find an appropriated quantizer value.
In my case, to produce a 15 KiB file, I used the following pipeline:
gst-launch-1.0 videotestsrc num-buffers=1 ! avenc_jpeg2000 pass=2 quantizer=10  ! filesink location=/tmp/picture-test-02.jp2
Question: How to execute code every time a Composable is shown (and execute only once)

I am creating a Composable which is responsible for showing notifications to users. Every time the user goes to that Composable, I want to execute a query which will clear the notification count. I only want to execute that query when the Composable has appeared, not every time the Composable is recomposed due to configuration change and anything.
Essentially I am looking for an equivalent of https://developer.apple.com/documentation/swiftui/view/onappear(perform:).
Is there any method I can use in Jetpack Compose?


Answer:
Use LaunchedEffect (link)
LaunchedEffect(Unit) {
    // Actions to perform when LaunchedEffect enters the Composition 
}

It takes one or more key parameters that are used to cancel the running effect and start a new one. Since you need to execute your code only once use something immutable as a key like Unit or true.
Question: I have a Blazor server app with windows authentication. But the username and password dialog is just coming when page is opened from the server side

I have a Blazor server app (.Net6) with windows authentication on a Win 2019 Server with IIS. But the username and password dialog is just coming when I open the web page from the google chrome browser directly on the server where the Blazor app is running. When I try to open the page from another PC in the same domain (Chrome, Firefox...), then the page is opening directly without asking username and password.
What could be the reason for that?


Answer:
The reason you are not prompted for a username and password when accessing the Blazor server app from another PC in the same domain is likely due to the integrated Windows authentication and the Single Sign-On (SSO) capabilities of the browser and the server. Here's a brief explanation of how this works:

Integrated Windows Authentication: When using integrated Windows authentication, the browser automatically sends the user's Windows credentials (username and password) to the server without prompting the user for them. This is possible because the browser and the server negotiate the authentication process using various protocols like Kerberos or NTLM.
Single Sign-On (SSO): SSO allows users to authenticate once and then access multiple resources without being prompted for credentials again. In your case, since the client PC and the server are in the same domain, and integrated Windows authentication is enabled, the user's credentials from the client PC's Windows session are automatically passed to the server without requiring a separate prompt.

To ensure that the username and password prompt appears consistently, you can try the following:

Check Browser Settings: Make sure that the browser settings on the client PC are configured to send Windows credentials. In Chrome, go to Settings > Privacy and Security > Site Settings > Additional permissions > Manage permissions. Ensure that the server's URL is listed and set to "Allow" or "Automatic."
Verify IIS Settings: Ensure that the IIS configuration on the server is set up correctly for integrated Windows authentication. Open IIS Manager, select the Blazor server app, and go to the Authentication settings. Make sure that only Windows Authentication is enabled, and other authentication methods like Anonymous Authentication are disabled.
Cross-Domain Considerations: If the Blazor server app is hosted on a different domain, you may encounter additional challenges with SSO due to browser security restrictions. In such cases, you may need to configure your server and browser settings to enable cross-domain SSO.
Clear Browser Cache: Clear the cache and cookies in the browser on the client PC to ensure that any cached credentials or settings are not causing unexpected behavior.

By checking these settings and ensuring that integrated Windows authentication is correctly configured on the server and the client PC, you should be able to consistently prompt for a username and password when accessing the Blazor server app.
Question: Write to Google sheet skipping 1st row

When using the package googlesheets4 is there any method for writing data to a sheet skipping the first row so that the data being written to a sheet starts at row 2? I am hoping to leverage something similar to when you read a sheet and utilize ex. skip = 2 to read data starting at the 3rd row
I have tried the following which does not work
write_sheet(data = df, ss = "google_sheet_url", skip = 1, sheet = "test")



Answer:
skip=n is only for read_excel()
in the googlesheets4 library to start at a specified range, you'd use range_write(). This is similar to the startRow=n in the xlsx library.
range_write(ss = "google_sheet_url", data = df, range = "B1", sheet = "test")
Question: spark DF multiple Iterations on Rows

From the below data- col5 is holding the no of fruits to be distributed among plates from col1 to col4(4plates). Each time find the min from the plates(col1 to col4) add 1 fruit and reduce the fruit from col5 and repeat this process till col5(fruits becomes zero). Below is some sample code to find the min and add 1 fruit there. but how to do this recursively in spark - Scala.
Expected output:

  plate1 plate2 plate3  plate4  fruits  
  1 2   3   4   3   
  6 7   8   1   2   
  2 4   6   8   5   

Iteration 1:
  2 2   3   4   2   
  6 7   8   2   1   
  3 4   6   8   4   

Iteration 2:
  3 2   3   4   1   (If 2 plates has the same min value , left precedence)
  6 7   8   3   0   
  4 4   6   8   3   

Iteration 3:
  3 3   3   4   0   
  6 7   8   3   0   
  5 4   6   8   2   

Iteration 4:
  3 3   3   4   0   
  6 7   8   3   0   
  5 5   6   8   1   

Iteration 5:
  3 3   3   4   0   
  6 7   8   3   0   
  6 5   6   8   0   

code for first iteration:
      val data = Seq(
        (1.0, 2.0, 3.0, 4.0, 3.0),
        (6.0, 7.0, 8.0, 1.0, 2.0),
        (2.0, 4.0, 6.0, 8.0, 5.0)
      )
      val columns = List("col1", "col2", "col3", "col4", "col5")
      val df = spark.createDataFrame(data).toDF(columns: _*)

      val updatedColumns = columns.map { colName =>
        functions.when(col(colName) === functions.least(columns.map(col): _*), col(colName) + 1).otherwise(col(colName)).alias(colName)
      }

      val updatedDF = df.select(updatedColumns: _*)
      updatedDF.show()



Answer:
Since each row is independent, then I think it is easier to iterate within the mapping function of each row until you get the final result, so that you don't have to iterate over the whole df multiple times.
import spark.implicits._

val data = Seq(
        (1, 2, 3, 4, 3),
        (6, 7, 8, 1, 2),
        (2, 4, 6, 8, 5)
      )

val columns = List("col1", "col2", "col3", "col4", "col5")
val arrayDf = spark.sparkContext.parallelize(data).map(row =>  {
    var plates: List[Int] = row.productIterator.toList.map {case i: Int => i}
    var store: Int = plates.last // Assuming last column is the store 
    plates = plates.dropRight(1) // remove the store column
    (0 until store).toList.foreach(i => {
        val min = plates.min
        val index = plates.indexOf(min)
        store -=1
        plates = plates.updated(index, min + 1)
    })
    plates :+ store // Add the store at the end (which is always 0) 
}).toDF(Seq("result"): _*)

// Convert the list of result into columns again
val df = arrayDf.select(columns.zipWithIndex.map{case (name, idx) => arrayDf("result")(idx).alias(name)}: _*)

df.show()

+----+----+----+----+----+
|col1|col2|col3|col4|col5|
+----+----+----+----+----+
|   3|   3|   3|   4|   0|
|   6|   7|   8|   3|   0|
|   6|   5|   6|   8|   0|
+----+----+----+----+----+
Question: VBA Selenium Dynamic ID (Wildcard)

Is there a possibility to find an element by ID with an wildcard?
I have something like this:
stat = GC.FindElementByXPath("//*[@id='C29_W88_V90_V94_admin_status']").Value
stat = GC.FindElementByXPath("//*[@id='C26_W88_V90_V94_admin_status']").Value
stat = GC.FindElementByXPath("//*[@id='C29_W88_V12_V94_admin_status']").Value

The admin_status part won't change but the values before.
Sometimes I have the same problem with another element with values around it. So the best thing would be to find the element with some wildcard like this:
stat = GC.FindElementByXPath("//*[@id='*admin_status*']").Value



Answer:
This code is tested in Excel VBA using Selenium.
Option Explicit
Sub sbXPathContains()
    Dim driver As ChromeDriver
    Set driver = New ChromeDriver
    Dim sURL As String
    sURL = "https://davetallett26.github.io/table.html"
    Call driver.Start("edge")
    driver.get (sURL)
    driver.Window.Maximize
    sbDelay (100000)
    MsgBox driver.FindElementByXPath("//*[contains(@id, 'ctl03_txtCash')]").Attribute("outerHTML")
    '                                 //* = any element  contains  @id = within id  'ctl03_txtCash' = string to find   .Attribute("outerHTML") = return HTML of the element
    sbDelay (100000)
    driver.Quit
End Sub

Sub sbDelay(delay As Long): Dim i As Long: For i = 1 To delay:  DoEvents: Next i: End Sub
Question: Firebase Firestore Indexes issue: Oops, indexes failed to load

When I visit the Firebase Firestore Index page, it shows an issue as "Oops, indexes failed to load!". I inspect the error and it shows 429. When I view indexes through GCP, it shows as Failed to load indexes: Request throttled at the client by AdaptiveThrottler. We're in the Firebase Blaze plan and I do not see any quota limit reached. This particular account has 5 projects and all of the projects indicate this same issue. What would be the issue?



Answer:
firebase here
That looks off indeed. I can't reproduce myself, but I asked around and will post an update here when I hear back.

7:57 AM PT: Engineering has acknowledged the problem, and is identifying potential causes.

8:12 AM PT: The problem may be isolated to databases in Europe.

9:23 AM PT: This only affects index creation and listing operations. It does not affect the ability read data from or write to the database. Sorry for not mentioning that earlier, as it was the first thing we determined when the problem was reported.

9:29 AM PT: We've identified the root cause, which was a resource exhaustion issue in region eur3, and have increased resources in the region to mitigate.

9:49 AM PT: This issue has been mitigated now. If you are still seeing this problem, please reach out to Firebase support for personalized help in troubleshooting.
The engineering team is planning work to prevent this problem from reoccurring in the future.
Question: Ada2012: Assertion_Policy

According Ada2012 RM Assertion_Policy:

10.2/3    A pragma Assertion_Policy applies to the named assertion aspects in a specific region, and applies to all assertion expressions
specified in that region. A pragma Assertion_Policy given in a
declarative_part or immediately within a package_specification applies
from the place of the pragma to the end of the innermost enclosing
declarative region. The region for a pragma Assertion_Policy given as
a configuration pragma is the declarative region for the entire
compilation unit (or units) to which it applies.

This means that if I have a package hierarchy as per the following example:
└───Root
    ├───Child1
    ├───Child2
    │   └───GrandSon
    └───Child3

And if I define the pragma Assertion_Policy at Root package specification, it will affect to the whole package hierarchy right?


Answer:

And if I define the pragma Assertion_Policy at Root package
specification, it will affect to the whole package hierarchy right?

No.
What your bolded text means is that (a) the pragma is placed immediately in a specification, like so:
Pragme Ada_2012;                -- Placed "immediately".
Pragma Assertion_Policy(Check); -- Also "immediately".

Package Some_Spec is --... and so on.

or (b) in a declarative part:
Procedure Outer_Scope is
   Pragma Assertion_Polucy( Ignore ); -- Declarative region.
   X : Some_Type:= Possibly_Assertion_Failing_Operation;
   Package Inner_Scope is
    -- the stuff in here would ALSO ignore assertions.
   End Inner_Scope;
   Package Body Inner_Scope is Separate;
Begin
  if X'Valid then
    Null; -- Do things on the valid value of X.
  end if; -- Because we're ignoring the invalid case.
End Outer_Scope;

So, they apply not to children, but to the spec/body/declarative-region itself.
Question: in ggplot2, print an expression in the facet_wrap

I want to plot some functions with their gradients using the ggplot2 package in r.
p = 3
n0 = 100
z0 = seq(0.01, 0.99, length = n0)
AB0 = matrix(rbeta(600,4,1), nrow = n0)

library(ggplot2)
ab.names=c(paste("g",1:p,sep=""),paste("g' ",1:p,sep=""))
pl0=ggplot(data.frame(ab = c(AB0), ID = rep(ab.names, each = n0), Z = z0),
           aes(x = Z, y = ab)) +
  geom_point() +
  facet_wrap(~ID, scales = "free",nrow = 2, ncol = p) + theme_bw() +
  ggtitle("Unpenalized VCM",expression(nabla~"g  and  "~"g")) + ylab("")

I want to switch the rows and add the nabla symbol in the title of the plots in the 1st row before switching them to the second row. To be clear, the 1st row is for the functions, and the 2nd row is for the gradients where the nabla symbol should appear in the title.
Here is a screenshot of the outcome



Answer:
the labeller argument to facet_wrap might come in handy, if you set it to "label_parsed". Example:
d <- data.frame(x = rnorm(2),
                y = rnorm(2),
                ID = c(paste0('g~', 1:2),
                       paste0('g~nabla~', 1:2)
                       )
                )


d |>
    ggplot(aes(x, y)) +
    geom_point() +
    facet_wrap(. ~ ID, 
               labeller = label_parsed,
               nrow = 2
               )
Question: Easy to read scientific notation on Rails console

I have a Postgresql table column which's type is numeric(20,4). When I play with the data through rails console, ActiveRecord display the values in scientific notation.
All I can think of adding attribute :column_name, :float to the related modal, but not sure if there will be any side effects because of it.
So the question is; does anyone one if there is anything I can do to make it easier for reading the data on rails console and do not have any side effects on the app itself?


Answer:
You can monkeypatch specifically BigDecimal class specifically for console
development.rb
  console do
    class BigDecimal
      def inspect
        to_f
      end
    end
  end
Question: Laravel auth()->id() not working in prod server

I have one seperate database for saving logs
I have middleware that saves every request with response
 public function handle($request, Closure $next, $logType)
    {
        $response = $next($request);
        CreateLog::dispatch($request, $response, $logType)->onQueue(config('queue.queues.logging'));
        return $response;
    }

Everything related to auth progress works after every work complated. beacuse u used         $response = $next($request);
'user_id' => auth()->id(),

Trying to save user_id like that. Everything is working perfect
But in prod server user_id is being null
In prod server project running using docker


Answer:
you need to double check multiple things:

what session driver are you using?
what is the queue driver are you using?
is your middleware runs after session and auth middleware runs ( based on the configuration in kernal.php )

based on your question and the problem is happening only on production so probably your issue is communication, your queue handler can't access session data which is usually the case if you separate them into different modules and connections to improve performance so to achieve this you need to pass the information you need from one module to another so in your case
public function handle($request, Closure $next, $logType)
    {
        $response = $next($request);
        $userID = auth()->id();
        CreateLog::dispatch($request, $response, $logType, $userID)->onQueue(config('queue.queues.logging'));
        return $response;
    }

and in your CreateLog you store this userID and use it instead of depending on the auth
Question: How can I get the maximum bid value in a blind auction?

I'm trying to create a blind auction as part of my class, and I'm trying to get the max value.
Here is the code, I tried to use the max() function but I get this error:
File "Day_9_Blind_Auction.py", line 30, in <module>print(max(data))TypeError: '>' not supported between instances of 'dict' and 'dict'

import os

data = [
    
    
    
    ]
while True:
    name = input("What is your name?: ")
    bid = input("What is your bid: $")

    other_user = input("Are there any other bidders? Type Yes or No.\n")
    
    if other_user in ['yes', 'Yes']:
        os.system('cls')
 
    def new_user(name, bid):
        brandnew_user = {
            name: bid
            
            },
        
        data.append(brandnew_user)
        
    new_user(name, bid)

    
    
    if other_user in ['no', 'No']:
        print(max(data))
        break

I tried to remove the max() and it prints the output totally fine.  But then I need to get the max value, which is I don't know how to do it.
this is the output if I removed the max() function:
[({'George': '87'},), ({'Josh': '74'},), ({'Eduardo': '89'},)]



Answer:
You are trying to apply the max() function to a list of dictionaries.   The error message is telling you that you haven't specified how to tell when one dictionary is "greater than" another.
It is possible to add a definition for the '>' operator that would allow it to compare dictionaries, but it's probably better if you rethink the data structures you're using. A list of dictionaries, with only one key/value pair per dictionary, is kind of an awkward construction. Why not use one list for the names, another list for the bids, then use max() and indexof() to find the largest bid and get the corresponding name from the other list?
Question: How can I securely manage my client's PayPal merchant account as a web developer freelancer?

Currently, when i need to access my customer's PayPal merchant account (to manage IPNs or to update notifications preferences for examples), i login to the account using his credentials and his 2FA (asking him the SMS code).
Is there a feature similar to Stripe Team which allows team members to access a PayPal merchant dashboard with their own credentials? Right here i am talking about the account dashboard, not the developer dashboard, but my question applies to both!
All of this doesn't seem very efficient and secure, is there another way?
Am i supposed to use my credentials only to develop the website (on developer.paypal.com) and never connect to the actual merchant's PayPal account? And ask the customer to do every manipulation on his account himself telling him the way?


Answer:
Typically you should only need to obtain API credentials to integrate with, which for current solutions are in the developer dashboard. Other account settings and operations in the account are not something web developers need access to, other than maybe some initial setup tweaks to the website preferences page. To the extent other settings matter, it is likely you are making wrong integration choices or using old legacy PayPal products (not good--for instance, you tagged the above with IPN -- what year is it? why would you be using IPN in 2023?)
Anyway, it is possible to create and manage user access within a PayPal account. This is usually only used for in-house staff, not a vendor/contractor since you should not need it, but in theory it can be used for what you're asking.