satoshi-2000/llms-suitable huggingface dataset:
Question: How to align text vertically according to the highest point of the text and lowest point?

I want to center a text vertically such that the highest point of the text and the lowest point of text are on equal distance from the ending div that it is enclosed in.
I have the following css code:
padding-left: 30px;
font-family: 'Playfair Display', serif;
font-weight: 100;
width: 140%;
line-height: 68px;
color: #fff;
font-size: 46px;
border-style: solid;
border-color: #1faf2d;
background-color: #1faf2d;
margin-bottom: 0 !important;
margin-top: 38px;

This is what gives the colour and height etc to the font and it look like the below image.



Answer:
This can only be done by adding padding at the bottom or Top and this may vary as per different Fonts. I question is why do you want to do this? As anigning center as per your way would further discurb the balance.
Also, The positioning of certain letters, such as "p," "g," "y," and "q," are lower than the center line is due to their design and the rules of typography. These letters have descenders, which are the parts of the letterforms that extend below the baseline.
Descenders are common in lowercase letters and serve to maintain the overall balance and legibility of the text. They allow for differentiation between similar letterforms and help to create a visually pleasing text block.
When aligning text vertically, the descenders are taken into account to ensure proper spacing and balance. By aligning the baseline of the text, which includes the descenders, it maintains the overall visual harmony of the text and prevents the descenders from interfering with the line spacing or overlapping other elements.
In the case of vertically aligning text to the highest point and lowest point, the descenders will naturally make the text appear lower as they extend below the baseline. This is considered the correct alignment for maintaining legibility and preserving the intended design of the typeface.
It's worth noting that the alignment of text can vary depending on the context and the specific design choices made by the typographer or designer. Different fonts may have slightly different alignments, and some artistic or decorative fonts may intentionally deviate from traditional alignment principles for creative purposes.
Question: Is it possible to run a sudo command in go without running the program itsself as sudo

The program runs multiple commands that require sudo privileges (such as sudo dnf update). Since the program should be installed using the go install command, it can't be run as sudo its self without configuration done by the user (afaik).
The program doesn't show the output to the user to keep the output clean. To show that a process is running, it uses a spinner from the spinner library.
Is it possible to do any of these things?

Obtain sudo privileges from within the program
Make the program runnable as sudo, even when installed using go install
Show the output of the sudo command (including the password request) without it being overwritten by the spinner

Here is a shortened version of what I would like my code to do:
package main

import (
    "fmt"
    "os"
    "os/exec"
    "time"

    "github.com/briandowns/spinner"
)

func main() {
    // Spinner to show that it's running
    s := spinner.New(spinner.CharSets[14], time.Millisecond*100)
    s.Start()

    // Somehow execute this with sudo
    _, err := exec.Command(os.Getenv("SHELL"), "-c", "dnf update -y").Output()

    // Stop the spinner and handle any error
    if err != nil {
        fmt.Printf("Err: %s", err)
        os.Exit(1)
    }
    s.Stop()

    // Finish
    fmt.Println("Success")
}



Answer:
_, err := exec.Command(os.Getenv("SHELL"), "-c", "sudo dnf update -y").Output()
In this exapmle, with adding sudo before the command that you want run as sudo, and after running the program, will ask password for sudo, If you apply this to your example code you can't see password request message, because the spinner graphics will overwrite it, but if you try this without spinner graphics you can see it. Even you don't see the message, if you type your correct password and press enter your commands will work as sudo. With this, you don't need run your application as sudo. I have ran similar commands with using this and they have worked.
Question: error: could not find `sui` in https://github.com/MystenLabs/sui.git?branch=devnet with version `*`

When trying to install sui binaries using
cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

as suggested by the official docs,
gives the below error
Updating git repository `https://github.com/MystenLabs/sui.git` 
error: could not find `sui` in https://github.com/MystenLabs/sui.git?branch=devnet with version `*`

What could be the possible reason?


Answer:
I used the below command which includes the tag to install it
cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet --tag devnet-<version> sui

where you can replace version as required (e.g v1.3.0)
Question: Wierd behavior with raising intgers to the negative powers in python

I am observing this weird behavior when I am raising an integer to the negative power using an np.array. Specifically, I am doing
import numpy as np

a = 10**(np.arange(-1, -8, -1))

and it results in the following error.

ValueError: Integers to negative integer powers are not allowed.

This is strange as the code 10**(-1) works fine. However the following workaround (where 10 is a float instead of integer) works fine.
import numpy as np

a = 10.**(np.arange(-1, -8, -1)
print(a)  # Prints array([1.e-01, 1.e-02, 1.e-03, 1.e-04, 1.e-05, 1.e-06, 1.e-07])

Why is it not valid for integers? Any explanation is appreciated.


Answer:
This is happening because the input 10 is an integer.
10**(np.arange(-1, -8, -1))

numpy.arange() is designed such a way that that has to give 10**(np.arange(-1, -8, -1)) integers or nothing since input is an integer.
On the contrary;
a = 10.**(np.arange(-1, -8, -1)

gives results happily as 10.0 is a float

Edit: found an answer to back my point; voted for a duplicate:
Why can't I raise to a negative power in numpy?
Question: Get value of a field from a foreigKey in Django Models

I have two classes in my Database in Django
class Test(models.Model):
    sequenzaTest = models.ForeignKey("SequenzaMovimento", null=True, on_delete=models.SET_NULL)

class SequenzaMovimento(models.Model):
    nomeSequenza = models.CharField(max_length=50, blank=False, null=False)
    serieDiMovimenti = models.TextField(blank=False, null=False, default="")

Now, every Test object created can be associated with just one SequenzaMovimento object. Different Test objects can have the same SequenzaMovimento
Now, I know the primary key of my Test. How do I find the serieDiMovimenti inside the SequenzaMovimento object which is linked to the Test object?
I can get the sequenzaTest from the Test object with
testo_sequenza = Test.objects.get(pk=idObj)
testo_sequenza.sequenzaTest

but I can't find to understand how access serieDiMovimenti


Answer:
This should work:
try:
    testo_sequenza = Test.objects.get(pk=idObj)
except Test.DoesNotExist:
    # do here what you need the program to do if not found. maybe a return if function or a continue/break if you're in a loop
    print("Testo Sequenza not found")
sequenza_test = testo_sequenza.sequenzaTest
serie_di_movimenti = sequenza_test.serieDiMovimenti

Also you should check
serieDiMovimenti = models.TextField(blank=False, null=False, default="")

Because if you want it to be "optional field" then it would be blank=True
Question: How to use integer methods using `method`, not their infix form, in Ruby

I am looking to programmatically apply a typically infixed operation (eg: +, -, *, /) on two integers, where the operation is specified via a string. I have had success accessing the method itself using .method
This is a pattern that works, 1.+(2) which correctly resolves to 3
By extension, I'd to define a way that could take a variable string for the operator, like so: 1 + 2 as 1.method('+')(2)
The above causes a syntax error, though up til the point of retrieving the method this way does work, I'm not sure what the syntax needs to be to then pass the second integer argument. e.g:
1.method('+')     # <Method: Integer#+(_)>
1.method('+') 2   # syntax error, unexpected integer literal, expecting end-of-input
1.method('+')(2)  # syntax error, unexpected '(', expecting end-of-input

What is the right syntax to perform an operation 1 + 2 in this way?
I am using: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]


Answer:
The Method class has several instance method of it's own. The one you're looking for here is call
It is also aliased to [] and ===
1.method('+').call(2) #=> 3
1.method('+')[2] #=> 3
1.method('+') === 2 #=> 3
Question: Broadcast receiver change UI

I have searched widely but not found an answer to this question:
Is it possible to change a variable in a Jetpack compose user interface from a broadcast receiver?


Answer:
You can't modify your compose ui from Broadcast receiver directly. Instead, your Broadcast receiver should change some data in your data layer - datastore, preferences, database or just in memory in some Repository singleton class. Then you should make this data observable and observe them from your compose ui.
Question: Automatic template argument deduction fails for return type

I have a template function
template <typename B, typename A>
B func(A x) {/*do something*/}

And in my code I am doing something like
uint32_t a[6] = {1,2,3,4,5,6};
uint64_t b = func(a);

But this fails with
test.cxx:10:16: error: no matching function for call to 'func'
  uint64_t b = func(a);
               ^~~~~~~~~
test.cxx:5:6: note: candidate template ignored: couldn't infer template argument 'B'

So it seems that the type of a is automatically deduced but the type of b not. I can specify it (uint64_t b = <uint64_t>func(a);), sure, but why the compiler is not able to deduce it?
EDIT
Following comments also posting the content of the function (which is actually taking 2 other parameters)
template <typename B, typename A>
B bit_slice(A words[], int start, int end) {
  int wordSize = sizeof(A)*8;
  B s = 0;
  int n = end / wordSize;
  for(int i= 0; i <= n; ++i){
    s = (s << wordSize) + words[i];
  }
  s >>= (n+1) * wordSize - (end+1);
  B mask = (((T)1) << (end - start + 1))- 1;
  s &= mask;
  return s;
};

So basically a bit slicing of an array (representing something).


Answer:
If the argument cannot be deduced from func(a); then it cannot be deduced. auto return type can be deduced from the return statement, but not here. What you assign the return value to is not relevant. It simply doesnt work like this.
It does work however with a templated conversion:
#include <iostream>
#include <cstdio>

template <typename A,typename B>
A the_implementation(B x) { return x*2; }

template <typename B>
struct proxy {
    B b;
    template <typename A>
    operator A() {
        return the_implementation<A>(b);
    }
};

template<typename B>
proxy<B> func(B x) {
    return {x};
}


int main() { 
    int x = 42;
    int y = func(x);
}

func returns a proxy<B>, B is deduced from x. Then proxy<B> can be converted to int via its conversion operator, which calls the actual function (because only now A and B have been deduced).
However, I have doubts that the above is a good idea in your code. Consider to write instead:
auto b = func<uint64_t>(a);
Question: How to increase allocated memory in a k3d cluster

I am on a learning curve with Kubernetes and recently started working with K3D. I am trying to deploy my project on a local K3D cluster. When I created a pod to run an application, I saw it hang in the pending state for some time, and below is the kubectl describe pod output (events).

application.yaml file's resource requirements are as below
resources:
        requests:
          memory: "4Gi"
          cpu: "2"

The output of kubectl decribe node is as below: I assumed this was due to the fact that my node has around 3 GB of memory and the app is requesting 4 GB. I am getting the error in Pod. I looked for an answer to increase the memory but had no luck so far.

How can I increase the memory to get the application up and running? If I reduce the app.yaml resource to --> memory: 3 Gi or 2 Gi, the app starts running, but the actual functionality of the app is not there. Whenever I try to do something in the app, it then gives me Not enough CPU and/or memory is available for error in my application.
I am running this on Linux and k3d version k3d version v5.5.1 k3s version v1.26.4-k3s1 (default)
Thanks!


Answer:
Assuming the machine where you are running has more than 3GB of RAM (you can check by running lsmem or free), you can try re-creating the Kubernetes cluster using k3d, by passing an explicit memory limit. E.g.
k3d cluster create --agents-memory 8G

Or if you are doing a multi-node deployment, by adding a node with sufficient memory, e.g.
k3d node create --memory 8G

But when running on Linux, you typically would not have a memory limit applied to the Kubernetes cluster, unless that limit was requested explicitly. So I would suggest checking your previous cluster creation commands, or double-check any scripts you may have used.
If you are running Linux, another option is to run k3s directly, without k3d. That is unlikely to see limits applied to it as well.
Finally, an alternative is to use an ephemeral cloud environment for this type of testing. For example, using https://namespace.so you can create a Kubernetes cluster with 8GB of RAM in a few seconds, and use it to test your application.
Question: Can not update @State variable via delegate set in View.init()

The following is a minimum example code with the problem.
struct TestView: View {
    @State var text = "Hello"
    let useCase = TestUseCase()

    init() {
        useCase.output = self
    }

    var body: some View {
        Text(text)
            .onAppear {
                // ① useCase.output = self
                useCase.show()
            }
    }
}
extension TestView: TestUseCaseOutput {
    func showText(text: String) {
        self.text = text
    }
}

class TestUseCase {
    var output: TestUseCaseOutput?
    func show() {
        output?.showText(text: "Changed")
    }
}
protocol TestUseCaseOutput {
    func showText(text: String)
}

This code changes the text from "Hello" to "Changed" when the view is displayed, but the change is not reflected. The showText method was called, but it had no effect. I also found that if I set the delegate at ①, the text was updated correctly.
Can anyone tell me the cause of this problem?


Answer:
SwiftUI views are structs, and therefore immutable.  Whenever a SwiftUI changes, a new instance of that view struct is created.
When you update text, SwiftUI needs to create a new instance of TestView.  But, the new instance  has text set to Hello (and it was also have a new instance of TestUseCase) so you don't see any change.
The sequence of events is:

You create an instance of TestView - This is initialised with text = "Hello"
You update text which triggers SwiftUI to recreate TestView
The newly created instance of TestView is initialised with text = "Hello"`

In SwiftUI no object should ever need to hold a reference to a View.
init() {
    useCase.output = self
}

The self you store in your TestUseCase instance will be thrown away as soon as the view is updated.  It simply isn't useful to try and hold references to SwiftUI views.
You should structure your code so that views respond to changes in your model (Via @Published for example).  Your model should never try and update a view directly.
Question: react-number-format Showing Format On inserting value

react-number-format Showing Format On inserting value
I have used this package for the Phone Input format
import { PatternFormat } from 'react-number-format';

<PatternFormat 
   value={value} 
   className='form-control'   
   format="(###) ###-####" 
 />

Due to this format whenever I add any single value, The formatted value show in the input. before the value reaches there.

I want to show the value in This format but when the value reaches there,
when I have entered only a single value it should not show that '-' there.
I want something like below

This is the link to the npm package I am using:
https://s-yadav.github.io/react-number-format/docs/intro


Answer:
You could build the pattern diffrent if the value reaches said length then change   (empty space) for a - (dash)
import { PatternFormat } from 'react-number-format';

let pattern;
if (value.length >= 9) {
    pattern = "(###) ###-####";
} else {
    pattern = "(###) ### ####";
}

<PatternFormat 
   value={value} 
   className='form-control'   
   format={pattern} 
 />
Question: Compiling C++ code using libssh library through vcpkg

I installed libssh through vcpkg on my Windows 8.1 machine.
vcpkg install libssh

Now I am trying to compile my c++ code making use of libssh.
#include <libssh/libssh.h>
#include <stdlib.h>
 
int main()
{
  ssh_session my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    exit(-1);
  ...
  ssh_free(my_ssh_session);
}

But I am receiving following error.
D:\remoteDesktopTimeZone>gcc sample.cpp -o sampl
sample.cpp:1:10: fatal error: libssh/libssh.h: No such file or directory
    1 | #include <libssh/libssh.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.



Answer:
First, you should ensure that you are installing libraries with correct "triplet" matching your compiler and architecture.
I don't know if your gcc is MingW or Cygwin.
See instructions here.
Second, you should either use CMake as described here, or manually point the compiler where to find the library headers and static libraries using the -I and -L command line flags.
Question: Casting a void pointer to a 2D String array pointer (C/CPP)

I'm using a library which requires a function with a void* pointer as a parameter. I have a 2D string array and I want to pass that array through that parameter and extract it inside the function. I successfully passed the array as a pointer but I don't know how to convert that pointer back to my array.
This is my current code:
String str_array[100][10];

int callback(void* data) {

  String* str_array_ptr[100][10] = (String* [100][10])data;

  (*str_array_ptr)[0][0] = "text";

  return 0;

}

void test() {
  callback(&str_array);
}

However, when compiling, I obtain the following error message:

error: ISO C++ forbids casting to an array type 'String* [100][10]' [-fpermissive]

PS: I'm trying to use the SQLite library's sqlite3_exec() function and store the result of a "SELECT SQL query" into a 2D string array.
SQLite C Interface - One-Step Query Execution Interface


Answer:
You cannot cast a pointer to an array. Instead you access your array through another pointer. That pointer has type String (*)[10]. Like this
String str_array[100][10];

int callback(void* data) { 

    String (*str_array_ptr)[10] = (String (*)[10])data;

    str_array_ptr[0][0] = "text"; // Note no '*'

    return 0;

}

void test() {
    callback(str_array); // Note no '&'
}

Both the way you create the pointer, you don't need to use &, and the way you access the pointer, you don't need to use *, are also wrong in your code. See the code above for details.
The fundamental issue here (and maybe the issue you are misunderstanding) is the difference between String *x[10]; and String (*x)[10];. In the first case x is an array of 10 pointers to String, in the second case x is a pointer to an array of ten String. It's the second option that you want.
Question: BizTalk 2020 with BTDF & Azure Pipelines - Application dependencies

Currently transitioning from BizTalk 2013r2 to 2020, and implementing Azure Pipelines to automate deployment with BTDF.
So far, we're able to deploy our Core applications, but we've just realised there are dependencies with the 'child applications' (applications that take schemas from the Core apps).

How should I refer to the Core application within Visual Studio in our dev environment (we used to reference the .dll from the local repos solution)
How can we configure BTDF and CI/CD pipelines to point to the correct application when deploying the child?
What happens if we need to update the Core application via BTDF/Pipeline - we'll need to undeploy all child applications that reference it before we can deploy surely - can this be done via the BTDF config?



Answer:
No, I don't believe that BTDF can take care of that.
You should either.
Version increase your assembly version number of your Core Application and do a side by side deployment (e.g. leave the original ones in place).
Later on when you need the newer version in the dependent application then reference the later DLL (and yes, just have the DLL as an external assembly in the solution).
Or
Have your Core Application Pipeline undeploy all the dependent applications, before undeploying the Core Application and deploying it, and then re-deploying all the dependent applications.
My preference would be for the first option, less complicated.
Question: Nattable Display converter shifts columns when the table is scrolled horizontally

I have used a custom DisplayConverter on some columns of my Nattable.This displayconverter shows long values as hex strings.
Whenever I scroll my Nattable horizontally, this converter shifts one/mulitple columns. This results in columns which show hex values to be shown in default numeral format. On the other hand, columns which should be showing numerals show hex values.
In the following images, the first image shows how it should be displayed, that is column number 2 and 7 should show hex values (these are just long values with my custom converter applied).
When I scroll my table to the right, this converter is then applied to column number 3 and 8.
Default (as it should be)
Scrolled right 
I have applied my CustomDisplayConverter ( column override HEX_FORMAT) to certain columns. LinkerMapHexAddressDisplayConverter is the custom display converter which converts long values to hex strings for display.
'columnLabelAccumulator.registerColumnOverrides(
            pnames.indexOf(ILinkerMapConstants.PROP_KEY_SECTION_SIZE), NUMBER_FORMAT);//column 3
    columnLabelAccumulator.registerColumnOverrides(
            pnames.indexOf(ILinkerMapConstants.PROP_KEY_OBJECT_SIZE), NUMBER_FORMAT);//column 8

    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
            new DefaultLongDisplayConverter(), DisplayMode.NORMAL, NUMBER_FORMAT);

    columnLabelAccumulator.registerColumnOverrides(
            pnames.indexOf(ILinkerMapConstants.PROP_KEY_SECTION_ADDRESS), HEX_FORMAT);//column 2
    columnLabelAccumulator.registerColumnOverrides(
            pnames.indexOf(ILinkerMapConstants.PROP_KEY_OBJECT_MODULE_ADDRESS),
            HEX_FORMAT);//column 7

    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
            new LinkerMapHexAddressDisplayConverter(), DisplayMode.NORMAL,
            HEX_FORMAT);'



Answer:
This happens if you apply your custom labels (HEX_FORMAT in your case) on the ViewportLayer or above. If you have a strong relation on the structure, you should apply the labels on the DataLayer as there is no index-position conversion.