问:
Creating a data structure of integers and finding which component a given integer lies in
I have a set of 32 bit integers with which I will be making a data structure that will put these integers in different components ( like dsu ) the join operation has to be performed using bitwise and, if the bitwise and is not zero of two integers they lie in the same component, now given an integer how do I get ( assuming the data structure is already created for the prefix of this current integer ) the component in which this integer will lie? ex say [1,5,3,8] are given set of integers than (1,5,8) lie in one component because lsb for any pair will ensure non zero "bit and" and (8) will lie in it's own component, Or quite possibly entirely different algorithm that is much simpler if you can think of,

Edit :

It is possible however that two integers have bit and as zero but if third integer is introduced which has pairwise bit and non zero with both of them then all three will lie in same component ex [2,12, 6] 2 and 12 on operation give 0 but 2 and 6 do not and 12 and 6 do not so 6 will unify all three in one component.

Edit 2 : I am able to think of a naive algorithm that uses 32 length array for which one entry consists of linked list like structure ( like adjecentcy list ) that is if i'th bit is set then index i will contain all the integers with i'th set bit, but it could give me O(n) search, I'm thinking more towards dsu, but finding it difficult how to create it.

答:
Here's some go code (runnable link) that represents components as a list of disjoint bitmasks. A previously seen integer is in the component that it has non-zero bitwise AND with (or the zero component if it is zero).

The list of components can be updated with a new integer by finding all components that it has non-zero bitwise AND with, and replacing them with a single component that is the bitwise OR of those components and the new element.

There is at most one component per bit in any input value, plus one if there's a zero component. That's 32 components at most here, because the input values are stated to be 32-bits.

```<code>package main

import (
    "fmt"
)

// makeComponents returns a slice of disjoint bitmasks
// that represent the different components in the input.
func makeComponents(xs []uint32) []uint32 {
    var cs []uint32
    for _, x := range xs {
        j := 0
        for i, c := range cs {
            cs[j] = cs[i]
            if c & x != 0 || (x == 0 && c == 0) {
                x |= c
            } else {
                j++
            }
        }
        cs = append(cs[:j], x)
    }
    return cs
}

// component returns the component (from cs) that x is in.
func component(cs []uint32, x uint32) int {
    for i, c := range cs {
        if x==c || x & c != 0 {
            return i
        }
    }
    panic("no component")
}

// showComponents outputs the input values with those in the same
// component on the same line.
func showComponents(xs []uint32) {
    cs := makeComponents(xs)
    xperc := make([][]uint32, len(cs))
    for _, x := range xs {
        c := component(cs, x)
        xperc[c] = append(xperc[c], x)
    }
    for _, xc := range xperc {
        fmt.Println(xc)
    }
}

func main() {
    xs := []uint32{0, 1, 3, 6, 8, 16, 48, 65}
    showComponents(xs)
}
</code>```

Body:
Here's some go code (runnable link) that represents components as a list of disjoint bitmasks. A previously seen integer is in the component that it has non-zero bitwise AND with (or the zero component if it is zero).

The list of components can be updated with a new integer by finding all components that it has non-zero bitwise AND with, and replacing them with a single component that is the bitwise OR of those components and the new element.

There is at most one component per bit in any input value, plus one if there's a zero component. That's 32 components at most here, because the input values are stated to be 32-bits.

package main

import (
    "fmt"
)

// makeComponents returns a slice of disjoint bitmasks
// that represent the different components in the input.
func makeComponents(xs []uint32) []uint32 {
    var cs []uint32
    for _, x := range xs {
        j := 0
        for i, c := range cs {
            cs[j] = cs[i]
            if c & x != 0 || (x == 0 && c == 0) {
                x |= c
            } else {
                j++
            }
        }
        cs = append(cs[:j], x)
    }
    return cs
}

// component returns the component (from cs) that x is in.
func component(cs []uint32, x uint32) int {
    for i, c := range cs {
        if x==c || x & c != 0 {
            return i
        }
    }
    panic("no component")
}

// showComponents outputs the input values with those in the same
// component on the same line.
func showComponents(xs []uint32) {
    cs := makeComponents(xs)
    xperc := make([][]uint32, len(cs))
    for _, x := range xs {
        c := component(cs, x)
        xperc[c] = append(xperc[c], x)
    }
    for _, xc := range xperc {
        fmt.Println(xc)
    }
}

func main() {
    xs := []uint32{0, 1, 3, 6, 8, 16, 48, 65}
    showComponents(xs)
}


来源: stackexchange

问:
Copy elision in initializer list?
Consider this class

```<code>class A {
public:
    tracker tra;
    A(tracker _t) : tra(_t) {}
};
</code>```

And call it through

```<code>A a {tracker()};
</code>```

The object created by tracker() is never used until being stored in a.tra

Why don't the compiler optimize all the copy constructions away?

.

The tracker is defined here:

```<code>class tracker {
public:
    void mark(const char* v) {
        std::cout << v << ' ' << this << std::endl;
    }

    tracker() {
        mark("con");
    }

    tracker(const tracker& o) {
        mark("cpy");
    }

    tracker(tracker&& o) {
        mark("mov");
    }

    ~tracker() {
        mark("des");
    }

    tracker& operator=(const tracker&) {
        mark("=cp");
        return *this;
    }

    tracker& operator=(tracker&&) {
        mark("=mv");
        return *this;
    }
};
</code>```

答:
The compiler can't optimize out the copy construction of tracker in this case because the copy constructor and the destructor of tracker has observable side-effects. If the compiler optimizes out the copy construction ignoring that, it will change the observable behavior of the program thus violating the as-if rule.

There are exception to the as-if rule that allows the compiler to optimize out the copy/move construction even if the copy/move constructor and/or the destructor have observable side-effects. (copy elision)

But that exception rule is only applicable in some cases, and your code is not one of those. You are (copy-)constructing the member variable tra with the lvalue of type tracker. This is not the case that's mentioned in the copy elision rule.

ContentLicense: CC BY-SA 4.0

Title: Copy elision in initializer list?

Body:
Consider this class

class A {
public:
    tracker tra;
    A(tracker _t) : tra(_t) {}
};

And call it through

A a {tracker()};

The object created by tracker() is never used until being stored in a.tra

Why don't the compiler optimize all the copy constructions away?

.

The tracker is defined here:

class tracker {
public:
    void mark(const char* v) {
        std::cout << v << ' ' << this << std::endl;
    }

    tracker() {
        mark("con");
    }

    tracker(const tracker& o) {
        mark("cpy");
    }

    tracker(tracker&& o) {
        mark("mov");
    }

    ~tracker() {
        mark("des");
    }

    tracker& operator=(const tracker&) {
        mark("=cp");
        return *this;
    }

    tracker& operator=(tracker&&) {
        mark("=mv");
        return *this;
    }
};


问:
SwiftUI @State var initialization issue
I would like to initialise the value of a @State var in SwiftUI through the init() method of a Struct, so it can take the proper text from a prepared dictionary for manipulation purposes in a TextField.
The source code looks like this:

```<code>struct StateFromOutside: View {
    let list = [
        "a": "Letter A",
        "b": "Letter B",
        // ...
    ]
    @State var fullText: String = ""

    init(letter: String) {
        self.fullText = list[letter]!
    }

    var body: some View {
        TextField($fullText)
    }
}
</code>```

Unfortunately the execution fails with the error Thread 1: Fatal error: Accessing State<String> outside View.body

How can I resolve the situation? Thank you very much in advance!

答:
It's not an issue nowadays to set a default value of the @State variables inside the init method. But you MUST just get rid of the default value which you gave to the state and it will work as desired:

```<code>,,,
    @State var fullText: String // <- No default value here

    init(letter: String) {
        self.fullText = list[letter]!
    }

    var body: some View {
        TextField("", text: $fullText)
    }
}
</code>```

Title: SwiftUI @State var initialization issue

Body:
I would like to initialise the value of a @State var in SwiftUI through the init() method of a Struct, so it can take the proper text from a prepared dictionary for manipulation purposes in a TextField.
The source code looks like this:

struct StateFromOutside: View {
    let list = [
        "a": "Letter A",
        "b": "Letter B",
        // ...
    ]
    @State var fullText: String = ""

    init(letter: String) {
        self.fullText = list[letter]!
    }

    var body: some View {
        TextField($fullText)
    }
}

Unfortunately the execution fails with the error Thread 1: Fatal error: Accessing State<String> outside View.body

How can I resolve the situation? Thank you very much in advance!

Body:
It's not an issue nowadays to set a default value of the @State variables inside the init method. But you MUST just get rid of the default value which you gave to the state and it will work as desired:

,,,
    @State var fullText: String // <- No default value here

    init(letter: String) {
        self.fullText = list[letter]!
    }

    var body: some View {
        TextField("", text: $fullText)
    }
}


问:
Is there a way to add an intersection to a set in python?
For example:

```<code>A=set(frozenset[x,x+1]for x in range (10))
B=set()
C=set()
Result=set()
for B in A:
      for C in A:
            if B!=C:
                 Result.add(frozenset(B.intersection(C)))
</code>```

#Error: descriptor 'intersection' for 'frozenset' objects doesn't apply to a 'types.GenericAlias' object

答:
Thank you  @"user2357112 supports Monica",
that was infact the Problem...
if I interchange it with

```<code>frozenset({x,x+1})
</code>```

it totally works.

Body:
For example:

A=set(frozenset[x,x+1]for x in range (10))
B=set()
C=set()
Result=set()
for B in A:
      for C in A:
            if B!=C:
                 Result.add(frozenset(B.intersection(C)))

#Error: descriptor 'intersection' for 'frozenset' objects doesn't apply to a 'types.GenericAlias' object

Body:
Thank you  @"user2357112 supports Monica",
that was infact the Problem...
if I interchange it with

frozenset({x,x+1})

it totally works.


问:
Cxfreeze not copy Qt6 Styles in mingw-w64
I Installed PyQt6 and cxfreeze on msys2-mingw-w64

But After Compiling python file, shown in console Just ['Windows', 'Fusion'] Style

here is setup.py of cxfreeze

```<code>from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
build_options = {'packages': [], 'excludes': []}

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [ Executable('un.py', base=base)]

setup(name='qt',
      version = '1.0',
      description = '',
      options = {'build_exe': build_options},
      executables = executables)
</code>```

And The python file:

```<code>from PyQt6 import QtCore, QtGui, QtWidgets
import sys

print(QtWidgets.QStyleFactory().keys()) # Print Available Qt6 Styles

class Ui_MainWindow(object):

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setGeometry(QtCore.QRect(30, 260, 731, 23))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName("progressBar")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(220, 380, 371, 25))
        self.pushButton.setObjectName("pushButton")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Win"))
        self.pushButton.setText(_translate("MainWindow", "Button"))

if __name__ == "__main__":

    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec())
</code>```

I Tried to copy C:\msys2\mingw64\usr\share\qt6\plugins to Output EXE Directory andlib\PyQt6.

答:
Try setting the environment variable QT_PLUGIN_PATH, for example in a Command Prompt, before running the EXE file, like this:

```<code>SET QT_PLUGIN_PATH=C:\msys2\mingw64\usr\share\qt6\plugins
</code>```

You can also run the EXE files that are not working through Dependency Walker to see if any dependency DLL files are missing. Because you definitely have them all in the same folder as the EXE files (e.g. DLLs from Qt and all its dependencies).

I wrote a tool as part of the pedeps project to copy dependency DLL files along with EXE file(s) (copypedeps -r). You can use that to automatically copy all dependencies.

Body:
I Installed PyQt6 and cxfreeze on msys2-mingw-w64

But After Compiling python file, shown in console Just ['Windows', 'Fusion'] Style

here is setup.py of cxfreeze

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
build_options = {'packages': [], 'excludes': []}

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [ Executable('un.py', base=base)]

setup(name='qt',
      version = '1.0',
      description = '',
      options = {'build_exe': build_options},
      executables = executables)

And The python file:

from PyQt6 import QtCore, QtGui, QtWidgets
import sys

print(QtWidgets.QStyleFactory().keys()) # Print Available Qt6 Styles

class Ui_MainWindow(object):

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setGeometry(QtCore.QRect(30, 260, 731, 23))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName("progressBar")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(220, 380, 371, 25))
        self.pushButton.setObjectName("pushButton")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Win"))
        self.pushButton.setText(_translate("MainWindow", "Button"))

if __name__ == "__main__":

    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec())

I Tried to copy C:\msys2\mingw64\usr\share\qt6\plugins to Output EXE Directory andlib\PyQt6.

Body:
Try setting the environment variable QT_PLUGIN_PATH, for example in a Command Prompt, before running the EXE file, like this:

SET QT_PLUGIN_PATH=C:\msys2\mingw64\usr\share\qt6\plugins

You can also run the EXE files that are not working through Dependency Walker to see if any dependency DLL files are missing. Because you definitely have them all in the same folder as the EXE files (e.g. DLLs from Qt and all its dependencies).

I wrote a tool as part of the pedeps project to copy dependency DLL files along with EXE file(s) (copypedeps -r). You can use that to automatically copy all dependencies.


问:
Typescript: conditional generic type base on optional property
currently I have the following code in my React/Typescript app -

export type GetPricingParams = {
    search_id: number,
    promo_code?: string,
};
export type GetPricingData = {
    amount: number,
    currency: string,
    search_id: number,
    applied_promocode?: {
        type: 'AMOUNT' | 'PERCENT',
        discount: number,
    },
};
export const getPricing = api.post<GetPricingData, GetPricingParams>('/api/v1/pricing');
```
<p><code>api.post</code> method is a wrapper under axios post method -</p>
<pre class="lang-ts prettyprint-override"><code>post: <D = unknown, P = undefined>(uri: string): ReturnType<D, P> => (params, config) =>
{
    return axios.post(uri, params, config).then(r => Promise.resolve(r.data));
},
</code>```

I'd like to specify applied_promocode as required parameter in GetPricingData if promo_code parameter has been specified in GetPricingParams.
I tried the following variant, but unfortunately it doesn't work -

export type GetPricingParams = {
    search_id: number,
    promo_code?: string,
};
export type GetPricingDataCommon = {
    amount: number,
    currency: string,
    search_id: number,
};
export type GetPricingDataWithPromocode = GetPricingDataCommon & {
    applied_promocode: {
        type: 'AMOUNT' | 'PERCENT',
        discount: number,
    },
};
export const getPricing =
(params: P) =>
{
    return api.post<
        P extends {promo_code: string} ? GetPricingDataWithPromocode : GetPricingData,
        GetPricingParams
    >('/api/v1/pricing')(params);
}
```

答:
I think you were close, you basically just needed to specify GetPricingDataCommon as the second part of your conditional.

Here's code that works (I removed the actual API call part as its not critical to the typing issue):

export type GetPricingParams = {
  search_id: number
  promo_code?: string
}
export type GetPricingDataCommon = {
  amount: number
  currency: string
  search_id: number
}
export type GetPricingDataWithPromocode = GetPricingDataCommon & {
  applied_promocode: {
    type: "AMOUNT" | "PERCENT"
    discount: number
  }
}
export const getPricing =
(params: P) => {
  return (
    data: P extends { promo_code: string }
      ? GetPricingDataWithPromocode
      : GetPricingDataCommon
  ) => {}
}

getPricing({ search_id: 2 })({ amount: 3, currency: "dollar", search_id: 7 })

// error as expected
getPricing({ search_id: 2, promo_code: "promo" })({
  amount: 3,
  currency: "dollar",
  search_id: 7
})

getPricing({ search_id: 2, promo_code: "promo" })({
  amount: 3,
  currency: "dollar",
  search_id: 7,
  applied_promocode: {
    type: "AMOUNT",
    discount: 50
  }
})
```

In a playground.

If there's an issue I'm missing, please clarify.

Body:
currently I have the following code in my React/Typescript app -

export type GetPricingParams = {
    search_id: number,
    promo_code?: string,
};
export type GetPricingData = {
    amount: number,
    currency: string,
    search_id: number,
    applied_promocode?: {
        type: 'AMOUNT' | 'PERCENT',
        discount: number,
    },
};
export const getPricing = api.post<GetPricingData, GetPricingParams>('/api/v1/pricing');

api.post method is a wrapper under axios post method -

post: <D = unknown, P = undefined>(uri: string): ReturnType<D, P> => (params, config) =>
{
    return axios.post(uri, params, config).then(r => Promise.resolve(r.data));
},

I'd like to specify applied_promocode as required parameter in GetPricingData if promo_code parameter has been specified in GetPricingParams.
I tried the following variant, but unfortunately it doesn't work -

export type GetPricingParams = {
    search_id: number,
    promo_code?: string,
};
export type GetPricingDataCommon = {
    amount: number,
    currency: string,
    search_id: number,
};
export type GetPricingDataWithPromocode = GetPricingDataCommon & {
    applied_promocode: {
        type: 'AMOUNT' | 'PERCENT',
        discount: number,
    },
};
export const getPricing =
(params: P) =>
{
    return api.post<
        P extends {promo_code: string} ? GetPricingDataWithPromocode : GetPricingData,
        GetPricingParams
    >('/api/v1/pricing')(params);
}

Body:
I think you were close, you basically just needed to specify GetPricingDataCommon as the second part of your conditional.

Here's code that works (I removed the actual API call part as its not critical to the typing issue):

export type GetPricingParams = {
  search_id: number
  promo_code?: string
}
export type GetPricingDataCommon = {
  amount: number
  currency: string
  search_id: number
}
export type GetPricingDataWithPromocode = GetPricingDataCommon & {
  applied_promocode: {
    type: "AMOUNT" | "PERCENT"
    discount: number
  }
}
export const getPricing = <P extends GetPricingParams>(params: P) => {
  return (
    data: P extends { promo_code: string }
      ? GetPricingDataWithPromocode
      : GetPricingDataCommon
  ) => {}
}

getPricing({ search_id: 2 })({ amount: 3, currency: "dollar", search_id: 7 })

// error as expected
getPricing({ search_id: 2, promo_code: "promo" })({
  amount: 3,
  currency: "dollar",
  search_id: 7
})

getPricing({ search_id: 2, promo_code: "promo" })({
  amount: 3,
  currency: "dollar",
  search_id: 7,
  applied_promocode: {
    type: "AMOUNT",
    discount: 50
  }
})

In a <a href="https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBDAnmYcDiwYAUoEsDGuAdgOZYCGU5AtgM5wC8cA3gFBxy3CX4AWA%20rgAmALjhEArtQBGwKOzhgoEahH74IQ4AH4xtGHlKsAvq1CRYCZKgzY8hUgBFyMcgGEVqooxYKaECSIYMUkZOQV8CSgoYCJ8RD0DYhIFLh4BYRCpWXlTc2h4JBR0TBwCZOdXAHVcGF4cFQgNLR9bMocSSvdPCG8AMl8OcjAwABtcYCF%20JUbm4DE2Dg4i%20bgAIgBBAFkAeQBVADkAFTW4AB91rABRACU3K%20O1hQ4hXFoNQODxbPCOUzzwAU4BoiPo4CRSvZkj4ADxYOCgGCxIT0NpQ0gUKh0AB8AAowJQaLQxFgAJSMbGDOAxGBRby455wIQucgkhEgJFEFEsRTKVTqTSrfSGEhwUxLJbaEp2cpOFk1OoNVRzRkcMRo2WdFkeaheBTkhiU5j-VisCEyjq45icbhQPiCURwABMYtJVrg-k%20YgAzAAaYFRGJxBLrIQQUajShrf1pO0ZR0AdldpoA9CmEdFoB76OZgPgkUIzZDNe7Y-bMs7-TN%20XMxGtqxBTsY3YsPaovXA-RFA7F4nWwxGo77Urby4mTKTTeb2slS6P42InVW%20Wpa%20sG02W3520EfcOOJFor2Q2sB5GoNGR%20kHWIE-uPSNxpNpiu163ltY69t9o97y83h8u5wAArAADAo-ykkAA" rel="nofollow noreferrer">playground.

If there's an issue I'm missing, please clarify.


问:
can html5 do this- change color x to color y (floodfill) on image?
I dont have any html5 knowldge.

I need to do  a simple floodfill - change color x to color y on existing images.

Can HTML5 do that?
Could you provide an  example on how to do that?

Thanks !

答:
I imagine it would be possible but I'm not sure of anyone who has done it yet.  Here is an example of grayscaling an image.  I imagine a similar technique would work.

http://spyrestudios.com/html5-canvas-image-effects-black-white/

ContentLicense: CC BY-SA 3.0


问:
Annoying Blue Color for Button in HTML
Screen shot of problem
I am trying to get rid of this annoying blue color in my Bootstrap button supported with Bootstrap. First, there was an underline with blue color, but when add text-decoration: none underline is cleared but still blue color.

      <button type="button" class="btn btn-outline-dark">
            Instagram
          </button>```

But I still have the blue color as in the screenshot. I have tried variations using span but that does not help either. Am I doing something wrong above?

Thank you in advance.

答:
try this change the color property of anchor tag like this.</p>
```<code>a{
 color: #000; /* this will change the color to black
}
</code>```

Title: Annoying Blue Color for Button in HTML

Body:
Screen shot of problem
I am trying to get rid of this annoying blue color in my Bootstrap button supported with Bootstrap. First, there was an underline with blue color, but when add text-decoration: none underline is cleared but still blue color.

      <button type="button" class="btn btn-outline-dark">
            Instagram
          </button>

But I still have the blue color as in the screenshot. I have tried variations using span but that does not help either. Am I doing something wrong above?

Thank you in advance.

Body:
try this change the color property of anchor tag like this.

a{
 color: #000; /* this will change the color to black
}


问:
How to select last populated cell in table column
I am learning how to use macros/vba and used the record macros function to understand how this works.  For the part "Range("A31").Activate" how do I make it select the last populated cell? Since this column changes everyday- I would like to the code copy the data from this table to another.</p>
```<code>Sub PurshToOutput()
    Range("Inputtable[[#Headers],[UPC]]").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("Inputtable[UPC]").Select
    Range("A31").Activate
    Selection.Copy
    Sheets("OUTPUT").Select
    Range("Outputtable[UPC]").Select
    ActiveSheet.Paste
End Sub
</code>```

答:
Copy Excel Table Column (ListColumn)

This will append the data from one table's column to another table's column. Hopefully, the remaining columns of the latter table have formulas, that will get updated, for this to make sense.

The first 4 rows of the Input section illustrate how to reference the various objects hierarchically while the last 4 rows illustrate how to reference the last non-blank cell (ilCell) and the range (irg) from the first column cell to the last non-blank cell.

Option Explicit

Sub PurshToOutput()

    Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code

    ' Input
    Dim iws As Worksheet: Set iws = wb.Worksheets("INPUT")
    Dim itbl As ListObject: Set itbl = iws.ListObjects("Inputtable")
    Dim ilcl As ListColumn: Set ilcl = itbl.ListColumns("UPC")
    Dim irg As Range: Set irg = ilcl.DataBodyRange
    ' The Last Non-Blank Cell
    Dim ilCell As Range: Set ilCell = irg.Find("*", , xlValues, , , xlPrevious)
    If ilCell Is Nothing Then Exit Sub ' no data in column
    Dim irCount As Long: irCount = ilCell.Row - irg.Row + 1
    ' The Range From the First Cell to the Last Cell
    Set irg = irg.Resize(irCount)

    ' Output
    Dim ows As Worksheet: Set ows = wb.Worksheets("OUTPUT")
    Dim otbl As ListObject: Set otbl = ows.ListObjects("Outputtable")
    Dim olcl As ListColumn: Set olcl = otbl.ListColumns("UPC")
    Dim ofcell As Range
    With olcl.DataBodyRange
        Set ofcell = .Cells(.Cells.Count).Offset(1)
    End With
    Dim org As Range: Set org = ofcell.Resize(irg.Rows.Count)

    ' Copy by Assignment
    org.Value = irg.Value

End Sub
```

Body:
I am learning how to use macros/vba and used the record macros function to understand how this works.  For the part "Range("A31").Activate" how do I make it select the last populated cell? Since this column changes everyday- I would like to the code copy the data from this table to another.

Sub PurshToOutput()
    Range("Inputtable[[#Headers],[UPC]]").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("Inputtable[UPC]").Select
    Range("A31").Activate
    Selection.Copy
    Sheets("OUTPUT").Select
    Range("Outputtable[UPC]").Select
    ActiveSheet.Paste
End Sub


问:
Is Julia not evaluating the Function?
I'm playing around with the Collatz conjecture (see below), and I have this function:

```<code>function txpo(max_n)
    for n ∈ 1:max_n
        x = n
        while x ≥ n  &&  x != 1
            x = iseven(x) ? x÷2 : 3x+1
        end
    end
end
</code>```

On purpose I don't return anything or check anything, to make it as fast as possible. And boy, is it fast... - actually too fast, I think.

```<code>using BenchmarkTools
@btime txpo(100_000_000_000_000_000_000_000_000_000_000_000_000)

2.337 ns (0 allocations: 0 bytes)
</code>```

Running through 10^38 while loops takes only 2ns? Julia is fast, but I would be surprised if it was that fast. It seems like the code is not evaluated. Or what am I missing here?

Collatz Conjecture
Take a whole number and build a series by using the following rule: if the number is even divide by 2; if the number is odd multiply by 3 and add 1. Conjecture: every series will end up in the loop 4-2-1-4.

答:
Indeed, the whole function body is optimized out:

```<code>julia> function txpo(max_n)
           for n ∈ 1:max_n
               x = n
               while x ≥ n  &&  x != 1
                   x = iseven(x) ? x÷2 : 3x+1
               end
           end
       end
txpo (generic function with 1 method)

julia> @code_llvm txpo(100000000000)
;  @ REPL[1]:1 within `txpo`
define void @julia_txpo_179(i64 signext %0) #0 {
top:
;  @ REPL[1]:5 within `txpo`
  ret void
}
</code>```

If you use 10^38, this only changes the function signature to accept 128-bit integers.

The LLVM IR code is basically the same as this Julia code:

```<code>julia_txpo_179(_0::Int64) = nothing
</code>```

This makes perfect sense because why execute a function that doesn't return anything that depends on its computations and has no side-effects?

Finally, the native code that your CPU executes is literally retq, a.k.a. "return to caller":

```<code>julia> @code_native txpo(100000000000)
    .section    __TEXT,__text,regular,pure_instructions
; ┌ @ REPL[1]:5 within `txpo`
    retq
    nopw    %cs:(%rax,%rax)
; └

julia>
</code>```

Title: Is Julia not evaluating the Function?

Body:
I'm playing around with the Collatz conjecture (see below), and I have this function:

function txpo(max_n)
    for n ∈ 1:max_n
        x = n
        while x ≥ n  &&  x != 1
            x = iseven(x) ? x÷2 : 3x+1
        end
    end
end

On purpose I don't return anything or check anything, to make it as fast as possible. And boy, is it fast... - actually too fast, I think.

using BenchmarkTools
@btime txpo(100_000_000_000_000_000_000_000_000_000_000_000_000)

2.337 ns (0 allocations: 0 bytes)

Running through 10^38 while loops takes only 2ns? Julia is fast, but I would be surprised if it was that fast. It seems like the code is not evaluated. Or what am I missing here?

Collatz Conjecture
Take a whole number and build a series by using the following rule: if the number is even divide by 2; if the number is odd multiply by 3 and add 1. Conjecture: every series will end up in the loop 4-2-1-4.

Body:
Indeed, the whole function body is optimized out:

julia> function txpo(max_n)
           for n ∈ 1:max_n
               x = n
               while x ≥ n  &&  x != 1
                   x = iseven(x) ? x÷2 : 3x+1
               end
           end
       end
txpo (generic function with 1 method)

julia> @code_llvm txpo(100000000000)
;  @ REPL[1]:1 within `txpo`
define void @julia_txpo_179(i64 signext %0) #0 {
top:
;  @ REPL[1]:5 within `txpo`
  ret void
}

If you use 10^38, this only changes the function signature to accept 128-bit integers.

The LLVM IR code is basically the same as this Julia code:

julia_txpo_179(_0::Int64) = nothing

This makes perfect sense because why execute a function that doesn't return anything that depends on its computations and has no side-effects?

Finally, the native code that your CPU executes is literally retq, a.k.a. "return to caller":

julia> @code_native txpo(100000000000)
    .section    __TEXT,__text,regular,pure_instructions
; ┌ @ REPL[1]:5 within `txpo`
    retq
    nopw    %cs:(%rax,%rax)
; └

julia>


问:
codeigniter session expires frequently
I'm using codeigniter for my app

what my problem is session is expiring even though user is active on the site.

These are the session settings.. i'm using DB session

```<code>$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'edu_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;
</code>```

any solution for this.

help me i have to fix it

here is the codeigniter  forum link

答:
You may need to set the cookie domain in ,/application/config/config.php

```<code>  PHP Code:
    $config['cookie_prefix']   = '';
    $config['cookie_domain']   = '.domainname.com';
    $config['cookie_path']     = '/';
    $config['cookie_secure']   = FALSE;
    $config['cookie_httponly'] = FALSE;
</code>```

cookie_domain as your host name, this resolve my session expire issue

Title: codeigniter session expires frequently

Body:
I'm using codeigniter for my app

what my problem is session is expiring even though user is active on the site.

These are the session settings.. i'm using DB session

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'edu_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

any solution for this.

help me i have to fix it

here is the codeigniter  forum link

Body:
You may need to set the cookie domain in ,/application/config/config.php

  PHP Code:
    $config['cookie_prefix']   = '';
    $config['cookie_domain']   = '.domainname.com';
    $config['cookie_path']     = '/';
    $config['cookie_secure']   = FALSE;
    $config['cookie_httponly'] = FALSE;

cookie_domain as your host name, this resolve my session expire issue


问:
Windows : How to hide a folder with a specific path in Python
Basically, What I am trying to do is, whenever the assistant is given command that 'hide all the files', it should all the files if a file or folder is open. But, the problem is that if no folder is open, it will hide the current working folder. I want it to search if a folder is open, if not then ask which folder to hide.
Please help me to figure this out.
Thank You in advance.

The code I am currently using is as following:-

```<code>elif "hide all files" in query or "hide this folder" in query:
        try:
            os.system("attrib +h /s /d")
            speak("Sir, all the files in this folder are now hidden")
        except:
            speak("No directory found.")
</code>```

答:
Keep a track of the path using some variable.

path = ""
```
<p>Any query that modifies path should update the variable, and also change the current active directory.</p>
<pre class="lang-py prettyprint-override"><code>path = updated_path
os.system(f"cd {path}")
</code>```

For the hide query, you've just got to check if any file/folder is selected.

try:
    if path:
        os.system("attrib +h /s /d")
        speak("Sir, all the files in this folder are now hidden")
except:
    speak("No directory found.")
```

Body:
Basically, What I am trying to do is, whenever the assistant is given command that 'hide all the files', it should all the files if a file or folder is open. But, the problem is that if no folder is open, it will hide the current working folder. I want it to search if a folder is open, if not then ask which folder to hide.
Please help me to figure this out.
Thank You in advance.

The code I am currently using is as following:-

elif "hide all files" in query or "hide this folder" in query:
        try:
            os.system("attrib +h /s /d")
            speak("Sir, all the files in this folder are now hidden")
        except:
            speak("No directory found.")

Body:
Keep a track of the path using some variable.

path = ""

Any query that modifies path should update the variable, and also change the current active directory.

path = updated_path
os.system(f"cd {path}")

For the hide query, you've just got to check if any file/folder is selected.

try:
    if path:
        os.system("attrib +h /s /d")
        speak("Sir, all the files in this folder are now hidden")
except:
    speak("No directory found.")


问:
How do I apply a dictionary of functions to a dictionary in KDB?
Let's say I've got a state variable s, and I want to apply a dictionary of functions to it:

```<code>s: `peg`pos`ent`exi!(0n 0n 1 2)
f: `peg`pos`ent`exi!({null x};{null x}; {null x}; {null x})
</code>```

I attempted

```<code>f s
f @ s
</code>```

But neither of these worked. What am I doing wrong? The expected result would be

```<code>`peg`pos`ent`exi!(0b 0b 1b 1b)
</code>```

(Just as background, I'm trying to build a state machine and thought the 'KDB' way of doing it might be a truth table, although if there's a better way please let me know!)

答:
You need to add  ', the each iterator.

```<code>q)f @' s
peg| 1
pos| 1
ent| 0
exi| 0
</code>```

Body:
Let's say I've got a state variable s, and I want to apply a dictionary of functions to it:

s: `peg`pos`ent`exi!(0n 0n 1 2)
f: `peg`pos`ent`exi!({null x};{null x}; {null x}; {null x})

I attempted

f s
f @ s

But neither of these worked. What am I doing wrong? The expected result would be

`peg`pos`ent`exi!(0b 0b 1b 1b)

(Just as background, I'm trying to build a state machine and thought the 'KDB' way of doing it might be a truth table, although if there's a better way please let me know!)

Body:
You need to add  ', the each iterator.

q)f @' s
peg| 1
pos| 1
ent| 0
exi| 0


问:
Python displaying details in flask form when editing item so that user doesn't have to retype the same details
I made a edit product function where you can change stock, name, discount of the product but i cannot seem to retrieve the details and 'GET' method it in the form so that user does not have to retype the details they don't wish to change

I'm using flask forms and python jinja, to do this

This is my routes.py

```<code>@app.route('/updateProduct/<int:id>', methods=['GET','POST]'])
def update_product(id):
    form = UpdateProduct()
    product = AddProduct.query.get_or_404(id)
    if request.method == "POST" and form.validate_on_submit():
        product.name = form.name.data
        product.price = form.price.data
        product.stock = form.stock.data
        product.discount = form.discount.data
        product.desc = form.description.data
        try:
            db.session.add(product)
            db.session.commit()
            flash(f'Your product has been successfully updated!')
            print("a product has been updated")
            return redirect(url_for('retrieve_products', id=product.id))
        except:
            print("error updating product")
            return redirect(url_for('retrieve_products', id=product.id))
    form.name.data = product.name
    form.price.data = product.price
    form.stock.data = product.stock
    form.discount.data = product.discount
    form.description.data = product.desc
    return render_template('retrieveProducts.html', form=form)
</code>```

this is the edit form modal in my retrieveproducts.html

```<code>  <td style="color:black">
              <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#myModal2_{{ product.id }}">
            Edit
              </button>

              <div class="modal" id="myModal2_{{product.id}}">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h4 class="modal-title" style="color:black">Update Inventory</h4>
                      <button type="button" class="btn-close" data-bs-dismiss="modal">X</button>
                    </div>
                    <div class="modal-body">
                  <form action="{{ url_for('update_product',id=product.id) }}" method="POST" enctype="multipart/form-data">
                      {{ form.hidden_tag() }}
              <div class="form-group">
                  {{ form.name.label(class="form-control-label") }}
                  {{ form.name(class="form-control") }}
              </div>
              <div class="form-group">
                  {{ form.price.label(class="form-control-label") }}
                  {{ form.price(class="form-control") }}

              </div>
              <div class="form-group">
                  {{ form.discount.label(class="form-control-label") }}
                  {{ form.discount(class="form-control") }}

              </div>
              <div class="form-group">
                  {{ form.stock.label(class="form-control-label") }}
                  {{ form.stock(class="form-control") }}

              </div>
                  <div class="form-group">
                  {{ form.description.label(class="form-control-label") }}
                      {{ form.description(class="form-control") }}

                </div>

  <div class="modal-footer">
                  {{ form.edit_submit(class="btn btn-primary") }}
                      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                    </div>
        </form>

                    </div>

                  </div>
                </div>
              </div>
             </td>

</code>```

答:
Try this:

```<code>@app.route('/updateProduct/<int:id>', methods=['GET','POST']) #  Remove the extra bracket
</code>```

In your route, you did not passed product variable:

```<code><form action="{{ url_for('update_product',id=product.id) }}" method="POST" enctype="multipart/form-data">
</code>```

This should create an error when you submit the form as product.id does not exist.

[Added]

```<code>return render_template('retrieveProducts.html', form=form, product=product)
</code>```

Although I prefer to pass id variable since the route already has it.

Body:
I made a edit product function where you can change stock, name, discount of the product but i cannot seem to retrieve the details and 'GET' method it in the form so that user does not have to retype the details they don't wish to change

I'm using flask forms and python jinja, to do this

This is my routes.py

@app.route('/updateProduct/<int:id>', methods=['GET','POST]'])
def update_product(id):
    form = UpdateProduct()
    product = AddProduct.query.get_or_404(id)
    if request.method == "POST" and form.validate_on_submit():
        product.name = form.name.data
        product.price = form.price.data
        product.stock = form.stock.data
        product.discount = form.discount.data
        product.desc = form.description.data
        try:
            db.session.add(product)
            db.session.commit()
            flash(f'Your product has been successfully updated!')
            print("a product has been updated")
            return redirect(url_for('retrieve_products', id=product.id))
        except:
            print("error updating product")
            return redirect(url_for('retrieve_products', id=product.id))
    form.name.data = product.name
    form.price.data = product.price
    form.stock.data = product.stock
    form.discount.data = product.discount
    form.description.data = product.desc
    return render_template('retrieveProducts.html', form=form)

this is the edit form modal in my retrieveproducts.html

              <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#myModal2_{{ product.id }}">
            Edit
              </button>

Update Inventory

                      <button type="button" class="btn-close" data-bs-dismiss="modal">X</button>

                  <form action="{{ url_for('update_product',id=product.id) }}" method="POST" enctype="multipart/form-data">
                      {{ form.hidden_tag() }}

                  {{ form.name.label(class="form-control-label") }}
                  {{ form.name(class="form-control") }}

                  {{ form.price.label(class="form-control-label") }}
                  {{ form.price(class="form-control") }}

                  {{ form.discount.label(class="form-control-label") }}
                  {{ form.discount(class="form-control") }}

                  {{ form.stock.label(class="form-control-label") }}
                  {{ form.stock(class="form-control") }}

                  {{ form.description.label(class="form-control-label") }}
                      {{ form.description(class="form-control") }}

                  {{ form.edit_submit(class="btn btn-primary") }}
                      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>

        </form>

Body:
Try this:

@app.route('/updateProduct/<int:id>', methods=['GET','POST']) #  Remove the extra bracket

In your route, you did not passed product variable:

<form action="{{ url_for('update_product',id=product.id) }}" method="POST" enctype="multipart/form-data">

This should create an error when you submit the form as product.id does not exist.

[Added]

return render_template('retrieveProducts.html', form=form, product=product)

Although I prefer to pass id variable since the route already has it.


答:
The only problem is that there are Heywood cases, so the fa analysis isn't trustworthy.

```<code>library(psych)

fa.parallel(
  hwk2,
  n.obs = 93,
  fa = "fa",                # you want only "fa", not "pc"
  show.legend = TRUE,       # show legend
  fm = "minres",
  nfactors = 3,
  main = "Parallel Analysis Scree Plots",
  n.iter = 100,
  error.bars = FALSE,
  se.bars = FALSE,
  SMC = FALSE,
  ylabel = NULL,
  sim = TRUE,
  quant = .95,
  use = "pairwise",
  plot = TRUE,
  correct = .5
)
</code>```

Title: How can I create a parallel analysis scree in R?

Body:
Dataset Dput

structure(list(V1 = structure(c(4, 4, 2, 2, 2, 2, 2, 2, 4, 4,
2, 3, 2, 3, 4, 2, 2, 2, 3, 3, 2, 3, 1, 3, 3, 3, 3, 4, 1, 2, 4,
1, 2, 3, 2, 3, 1, 1, 2, 2, 4, 3, 2, 1, 2, 3, 3, 4, 3, 3, 2, 3,
1, 4, 3, 2, 3, 4, 1, 3, 3, 3, 2, 2, 1, 2, 3, 4, 4, 2, 4, 3, 2,
3, 3, 3, 3, 2, 4, 3, 3, 3, 2, 2, 3, 4, 2, 4, 4, 2, 2, 3, 3), format.spss = "F8.0"),
    V2 = structure(c(4, 4, 3, 4, 3, 4, 3, 2, 4, 1, 3, 3, 3, 4,
    3, 3, 2, 3, 4, 3, 1, 4, 2, 3, 4, 2, 4, 3, 3, 2, 3, 2, 3,
    3, 4, 3, 3, 3, 3, 3, 3, 2, 4, 2, 2, 2, 4, 3, 4, 4, 2, 4,
    2, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3, 4, 4, 4, 4, 4,
    3, 4, 3, 3, 3, 4, 2, 4, 3, 4, 3, 3, 2, 3, 3, 4, 3, 4, 3,
    4, 4, 3), format.spss = "F8.0"), V3 = structure(c(4, 4, 4,
    4, 4, 4, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), format.spss = "F8.0"),
    V4 = structure(c(4, 4, 3, 4, 3, 4, 2, 1, 3, 2, 3, 1, 4, 4,
    2, 3, 2, 2, 2, 4, 1, 2, 2, 2, 3, 2, 3, 2, 2, 1, 3, 1, 1,
    2, 4, 1, 1, 2, 3, 2, 2, 1, 1, 1, 3, 2, 4, 3, 3, 3, 3, 3,
    3, 4, 3, 1, 4, 3, 4, 3, 2, 3, 2, 1, 4, 1, 4, 1, 2, 4, 4,
    4, 3, 3, 3, 2, 2, 1, 4, 3, 2, 3, 2, 1, 3, 4, 1, 2, 4, 3,
    4, 2, 2), format.spss = "F8.0"), V5 = structure(c(3, 3, 3,
    4, 3, 4, 3, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2,
    2, 2, 2, 4, 2, 3, 2, 3, 4, 1, 4, 2, 3, 3, 2, 2, 3, 2, 2,
    3, 3, 2, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3,
    2, 2, 3, 3, 3, 2, 3, 3, 3, 4, 3, 2, 3, 3, 3, 3, 3, 3, 4,
    3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 4, 3, 3), format.spss = "F8.0"),
    V6 = structure(c(4, 4, 3, 4, 3, 4, 4, 1, 3, 3, 3, 3, 2, 3,
    4, 2, 4, 3, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 4, 3, 4, 4, 3,
    3, 3, 4, 2, 2, 3, 3, 3, 4, 2, 4, 3, 4, 4, 4, 3, 4, 2, 4,
    3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 3, 1, 4, 4, 4, 4, 4, 4,
    4, 3, 4, 4, 4, 4, 2, 4, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3,
    4, 4, 4), format.spss = "F8.0"), V7 = structure(c(4, 4, 2,
    4, 2, 4, 4, 3, 3, 3, 2, 2, 4, 4, 3, 3, 1, 4, 3, 3, 1, 2,
    4, 3, 4, 2, 4, 4, 3, 3, 2, 2, 3, 2, 4, 3, 3, 3, 3, 3, 3,
    1, 4, 3, 2, 2, 4, 3, 4, 4, 2, 4, 2, 3, 4, 3, 3, 3, 4, 3,
    4, 4, 3, 4, 4, 3, 4, 4, 4, 4, 3, 4, 4, 4, 3, 3, 4, 3, 4,
    3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 2, 4, 4, 3), format.spss = "F8.0"),
    V8 = structure(c(4, 4, 2, 1, 2, 1, 1, 1, 3, 3, 2, 3, 2, 3,
    4, 2, 2, 2, 3, 3, 2, 3, 1, 3, 3, 3, 3, 4, 1, 2, 4, 1, 2,
    3, 2, 3, 1, 1, 2, 2, 3, 1, 1, 1, 2, 3, 3, 4, 3, 3, 2, 3,
    1, 3, 4, 2, 3, 4, 1, 3, 3, 3, 2, 2, 1, 2, 3, 4, 4, 2, 4,
    3, 4, 4, 4, 4, 3, 2, 4, 3, 3, 3, 2, 2, 3, 4, 2, 4, 4, 2,
    1, 3, 4), format.spss = "F8.0"), V9 = structure(c(4, 4, 4,
    4, 4, 4, 4, 4, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, 4, 4,
    4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 3, 2, 4, 3, 4,
    4, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 3, 4, 3, 2, 4,
    3, 3, 4, 4, 4, 3, 4, 4, 4, 4, 4, 3, 4, 3, 4, 3, 4, 4, 4,
    4, 3, 4, 4, 4, 4, 4, 3, 2, 4, 4, 4, 4, 4), format.spss = "F8.0"),
    V10 = structure(c(4, 4, 2, 4, 2, 4, 3, 2, 3, 3, 3, 2, 4,
    4, 2, 2, 1, 3, 4, 4, 1, 4, 2, 3, 3, 2, 4, 3, 2, 3, 3, 1,
    3, 2, 4, 3, 2, 3, 3, 3, 3, 1, 2, 4, 2, 3, 4, 4, 3, 3, 2,
    4, 2, 4, 3, 3, 4, 3, 4, 3, 4, 4, 4, 1, 4, 3, 3, 4, 3, 4,
    4, 3, 3, 3, 3, 3, 4, 1, 4, 3, 3, 3, 3, 2, 3, 4, 4, 2, 4,
    2, 4, 4, 3), format.spss = "F8.0"), V11 = structure(c(3,
    3, 1, 4, 1, 4, 1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 2, 2, 2, 1,
    2, 3, 1, 2, 3, 3, 2, 1, 2, 2, 2, 3, 2, 2, 3, 2, 1, 2, 2,
    1, 1, 4, 3, 1, 3, 2, 3, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 3,
    2, 2, 2, 2, 2, 2, 1, 1, 1, 3, 3, 4, 2, 1, 2, 2, 3, 3, 3,
    3, 4, 3, 2, 3, 3, 2, 2, 2, 2, 1, 3, 1, 4, 1, 3), format.spss = "F8.0"),
    V12 = structure(c(4, 4, 3, 2, 3, 2, 3, 1, 3, 3, 3, 3, 2,
    3, 3, 2, 4, 3, 3, 4, 4, 3, 3, 4, 4, 3, 3, 3, 4, 3, 4, 4,
    3, 3, 3, 4, 2, 2, 3, 3, 3, 4, 2, 4, 3, 4, 4, 4, 3, 4, 2,
    4, 3, 3, 3, 3, 4, 3, 3, 2, 2, 1, 1, 3, 1, 4, 4, 4, 4, 4,
    4, 4, 3, 3, 2, 2, 2, 2, 4, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
    3, 2, 3, 4), format.spss = "F8.0")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -93L))

EFA Before Scree Plot

I have done the work of performing exploratory factor analysis on the data:

fa3 <- fa(hwk2,
   nfactors = 3,
   n.obs = 93,
   rotate = "oblimin",
   max.iter = 100)
fa3

Which gives me this:

      MR1   MR3   MR2   h2   u2 com
V1   0.03  0.87 -0.05 0.77 0.23 1.0
V2   0.75  0.05  0.09 0.63 0.37 1.0
V3   0.13  0.06  0.67 0.53 0.47 1.1
V4   0.50  0.07  0.08 0.31 0.69 1.1
V5   0.03 -0.06  0.88 0.77 0.23 1.0
V6   0.00  0.47  0.32 0.37 0.63 1.8
V7   0.80 -0.08 -0.04 0.60 0.40 1.0
V8   0.05  0.88 -0.03 0.80 0.20 1.0
V9  -0.22  0.02  0.58 0.34 0.66 1.3
V10  0.75  0.10  0.01 0.63 0.37 1.0
V11  0.03  0.00  0.53 0.29 0.71 1.0
V12 -0.24  0.52  0.14 0.28 0.72 1.6

                       MR1  MR3  MR2
SS loadings           2.18 2.09 2.03
Proportion Var        0.18 0.17 0.17
Cumulative Var        0.18 0.36 0.53
Proportion Explained  0.35 0.33 0.32
Cumulative Proportion 0.35 0.68 1.00

 With factor correlations of
     MR1  MR3  MR2
MR1 1.00 0.32 0.19
MR3 0.32 1.00 0.15
MR2 0.19 0.15 1.00

Basic Scree

Making a normal scree plot from there is quite simple. I just add this to my script:

scree(hwk2,
      pc=T,
      factors = F,
      main = "Scree Plot of Eigenvalues")

Which creates this:

What I Want

However, I want to graph simulated parallel analysis with it. In Jamovi this is super easy to accomplish:

However, I don't see an option for this so far. There is another version of scree I have tried fa.parallel but the legend comes out really strange:

fa.parallel(
  hwk2,
  n.obs = 93,
  fm = "minres",
  nfactors = 3,
  main = "Parallel Analysis Scree Plots",
  n.iter = 100,
  error.bars = FALSE,
  se.bars = FALSE,
  SMC = FALSE,
  ylabel = NULL,
  show.legend = F,
  sim = TRUE,
  quant = .95,
  use = "pairwise",
  plot = TRUE,
  correct = .5
)

I get either this if I remove the legend:

Or I get this annoying one with the legend:

Basically, I just need factor analysis and don't need principal components in the plot, but I can't figure out how to remove it.

Body:
The only problem is that there are Heywood cases, so the fa analysis isn't trustworthy.

library(psych)

fa.parallel(
  hwk2,
  n.obs = 93,
  fa = "fa",                # you want only "fa", not "pc"
  show.legend = TRUE,       # show legend
  fm = "minres",
  nfactors = 3,
  main = "Parallel Analysis Scree Plots",
  n.iter = 100,
  error.bars = FALSE,
  se.bars = FALSE,
  SMC = FALSE,
  ylabel = NULL,
  sim = TRUE,
  quant = .95,
  use = "pairwise",
  plot = TRUE,
  correct = .5
)


问:
a complex computing of the average value in pandas
This is my first question on this forum.

I am conducting experiments in which I measure the current-voltage curve of a device applying different experimental conditions.

The different experimental condition are encoded into a parameter K

I am performing measurements of the current I using back & forth voltage sweeps with V varying from O to 2V then from 2V to -2V and then back to 0V.

Measurements are conducted several times for each value of Kto get an average of the current at each voltage point (backward and forward values). Each measurement is ascribed to a parameter named iter (varying from 0 to 3 for instance).

I have collected all data into a pandas dataframe df and I am putting below a code able of produce the typical dfI have (the real one is way too large):

```<code>import numpy as np
import pandas as pd

K_col=[]
iter_col=[]
V_col=[]
I_col=[]
niter = 3
V_val = [0,1,2,1,0,-1,-2,-1,0]
K_val = [1,2]
for K in K_val:
    for it in range(niter):
        for V in V_val:
            K_col.append(K)
            iter_col.append(it+1)
            V_col.append(V)
            I_col.append((2*K+np.random.random())*V)
d={'K':K_col,'iter':iter_col,'V':V_col,'I':I_col}
df=pd.DataFrame(d)
</code>```

I would like to compute the average value of I at each voltage and compare the impact of the experimental condition K.

For example let's look at 2 measurements conducted for K=1:

```<code>df[(df.K==1)&(df.iter.isin([1,2]))]
</code>```

output:

```<code>
    K iter  V      I
0   1   1   0   0.000000
1   1   1   1   2.513330
2   1   1   2   4.778719
3   1   1   1   2.430393
4   1   1   0   0.000000
5   1   1   -1  -2.705487
6   1   1   -2  -4.235055
7   1   1   -1  -2.278295
8   1   1   0   0.000000
9   1   2   0   0.000000
10  1   2   1   2.535058
11  1   2   2   4.529292
12  1   2   1   2.426209
13  1   2   0   0.000000
14  1   2   -1  -2.878359
15  1   2   -2  -4.061515
16  1   2   -1  -2.294630
17  1   2   0   0.000000
</code>```

We can see that for experiment 1 (iter=1) V goes multiple times at 0 (indexes 0, 4 and 8). i do not want to loose these different datapoints.

the first data point for I_avg should be  (I[0]+I[9])/2 which would correspond to the first measurement at 0V. The second data point should be (I[1]+I[10])/2 that would correspond the the avg_I measured at 1V with increasing values of V etc...up to  (I[8]+I[17])/2 which would be my last data point at 0V.

My first thought was to use the groupby() method using K and V as keys but this wouldn't work because V is varying back & forth hence we have duplicate values of V for each measurements and the groupby would just focus on unique values of V.

The final dataframe I would like to have should looks like this:

```<code>    K   V   avg_I
0   1   0   0.000000
1   1   1   2.513330
2   1   2   4.778719
3   1   1   2.430393
4   1   0   0.000000
5   1   -1  -2.705487
6   1   -2  -4.235055
7   1   1   -2.278295
8   1   0   0.000000
9   1   0   0.000000
10  2   1   2.513330
11  2   2   4.778719
12  2   1   2.430393
13  2   0   0.000000
14  2   -1  -2.705487
15  2   -2  -4.235055
16  2   1   -2.278295
17  2   0   0.000000
</code>```

Would anyone have an idea on how doing this?

答:
In order to compute the mean taking into consideration also the position of each observation during the iterations you could add an extra column containing this information like this:

```<code>len_iter = 9
num_iter = len(df['iter'].unique())
num_K = len(df['K'].unique())

df['index'] = np.tile(np.arange(len_iter), num_iter*num_K)
</code>```

And then compute the group by and mean to get the desired result:

```<code>df.groupby(['K', 'V', 'index'])['I'].mean().reset_index().drop(['index'], axis=1)
</code>```
```<code>    K    V          I
0   1   -2  -5.070126
1   1   -1  -2.598104
2   1   -1  -2.576927
3   1    0   0.000000
4   1    0   0.000000
5   1    0   0.000000
6   1    1   2.232128
7   1    1   2.359398
8   1    2   4.824657
9   2   -2  -9.031487
10  2   -1  -4.125880
11  2   -1  -4.350776
12  2    0   0.000000
13  2    0   0.000000
14  2    0   0.000000
15  2    1   4.535478
16  2    1   4.492122
17  2    2   8.569701
</code>```

Body:
This is my first question on this forum.

I am conducting experiments in which I measure the current-voltage curve of a device applying different experimental conditions.

The different experimental condition are encoded into a parameter K

I am performing measurements of the current I using back & forth voltage sweeps with V varying from O to 2V then from 2V to -2V and then back to 0V.

Measurements are conducted several times for each value of Kto get an average of the current at each voltage point (backward and forward values). Each measurement is ascribed to a parameter named iter (varying from 0 to 3 for instance).

I have collected all data into a pandas dataframe df and I am putting below a code able of produce the typical dfI have (the real one is way too large):

import numpy as np
import pandas as pd

K_col=[]
iter_col=[]
V_col=[]
I_col=[]
niter = 3
V_val = [0,1,2,1,0,-1,-2,-1,0]
K_val = [1,2]
for K in K_val:
    for it in range(niter):
        for V in V_val:
            K_col.append(K)
            iter_col.append(it+1)
            V_col.append(V)
            I_col.append((2*K+np.random.random())*V)
d={'K':K_col,'iter':iter_col,'V':V_col,'I':I_col}
df=pd.DataFrame(d)

I would like to compute the average value of I at each voltage and compare the impact of the experimental condition K.

For example let's look at 2 measurements conducted for K=1:

df[(df.K==1)&(df.iter.isin([1,2]))]

output:

    K iter  V      I
0   1   1   0   0.000000
1   1   1   1   2.513330
2   1   1   2   4.778719
3   1   1   1   2.430393
4   1   1   0   0.000000
5   1   1   -1  -2.705487
6   1   1   -2  -4.235055
7   1   1   -1  -2.278295
8   1   1   0   0.000000
9   1   2   0   0.000000
10  1   2   1   2.535058
11  1   2   2   4.529292
12  1   2   1   2.426209
13  1   2   0   0.000000
14  1   2   -1  -2.878359
15  1   2   -2  -4.061515
16  1   2   -1  -2.294630
17  1   2   0   0.000000

We can see that for experiment 1 (iter=1) V goes multiple times at 0 (indexes 0, 4 and 8). i do not want to loose these different datapoints.

the first data point for I_avg should be  (I[0]+I[9])/2 which would correspond to the first measurement at 0V. The second data point should be (I[1]+I[10])/2 that would correspond the the avg_I measured at 1V with increasing values of V etc...up to  (I[8]+I[17])/2 which would be my last data point at 0V.

My first thought was to use the groupby() method using K and V as keys but this wouldn't work because V is varying back & forth hence we have duplicate values of V for each measurements and the groupby would just focus on unique values of V.

The final dataframe I would like to have should looks like this:

    K   V   avg_I
0   1   0   0.000000
1   1   1   2.513330
2   1   2   4.778719
3   1   1   2.430393
4   1   0   0.000000
5   1   -1  -2.705487
6   1   -2  -4.235055
7   1   1   -2.278295
8   1   0   0.000000
9   1   0   0.000000
10  2   1   2.513330
11  2   2   4.778719
12  2   1   2.430393
13  2   0   0.000000
14  2   -1  -2.705487
15  2   -2  -4.235055
16  2   1   -2.278295
17  2   0   0.000000

Would anyone have an idea on how doing this?

Body:
In order to compute the mean taking into consideration also the position of each observation during the iterations you could add an extra column containing this information like this:

len_iter = 9
num_iter = len(df['iter'].unique())
num_K = len(df['K'].unique())

df['index'] = np.tile(np.arange(len_iter), num_iter*num_K)

And then compute the group by and mean to get the desired result:

df.groupby(['K', 'V', 'index'])['I'].mean().reset_index().drop(['index'], axis=1)

    K    V          I
0   1   -2  -5.070126
1   1   -1  -2.598104
2   1   -1  -2.576927
3   1    0   0.000000
4   1    0   0.000000
5   1    0   0.000000
6   1    1   2.232128
7   1    1   2.359398
8   1    2   4.824657
9   2   -2  -9.031487
10  2   -1  -4.125880
11  2   -1  -4.350776
12  2    0   0.000000
13  2    0   0.000000
14  2    0   0.000000
15  2    1   4.535478
16  2    1   4.492122
17  2    2   8.569701


问:
How to get all AccountSubTypeEnums for a given AccountTypeEnum?
I am integrating Quickbooks Java API in my project. I am trying to get the AccountSubTypeEnums for a given AccountType. Is there an API to handle this?</p>

答:
There is no API for this.

However, Intuit does publish .XSDs for the schema, which contain all of the constants used, and are available here:

https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/minor-versions


问:
mix-blend-mode stops working when I use transform property
So when I use mix-blend-mode with transform property, mix-blend-mode stops working. Is there a work around? I know this is a duplicate question of Does CSS mix-blend-mode work with transform? but the mentioned question doesn't have an answer.</p>

答:
OP-
adding z-index to the div with mix-blend-mode fixed it.
I found the answer in https://www.sitepoint.com/community/t/mix-blend-mode-conundrum/209068/4 forum</p>


问:
What is the type of a class which implements a interface
can anybody tell me if the  assignment l4 & l5 is correct and why ?  e.g

ArrayList and List implement Serializable interface.

```<code>ArrayList<String> list1 = new ArrayList<String>();

ArrayList<? super Serializable> l4 = list1 ;
ArrayList<Serializable> l5 = list1 ;
</code>```

String is a class which implements Serializable interface, then String is called "a subtype of Serializable" or "a type of Serializable"?

Thanks

答:
Neither is correct.

Line 4 will not work because String is not a supertype of Serializable, it's a subtype.
Line 5 will not work because ArrayList<String> is not a subtype of ArrayList<Serializable>.

This will work though:

```<code>ArrayList<? extends Serializable> l6 = list1; // because String implements Serializable
List<String> l7 = list1; // because ArrayList implements List
List<? extends Serializable> l8 - list1; // both of the above
</code>```

Body:
can anybody tell me if the  assignment l4 & l5 is correct and why ?  e.g

ArrayList and List implement Serializable interface.

ArrayList<String> list1 = new ArrayList<String>();

ArrayList<? super Serializable> l4 = list1 ;
ArrayList<Serializable> l5 = list1 ;

String is a class which implements Serializable interface, then String is called "a subtype of Serializable" or "a type of Serializable"?

Thanks

Body:
Neither is correct.

Line 4 will not work because String is not a supertype of Serializable, it's a subtype.
Line 5 will not work because ArrayList<String> is not a subtype of ArrayList<Serializable>.

This will work though:

ArrayList<? extends Serializable> l6 = list1; // because String implements Serializable
List<String> l7 = list1; // because ArrayList implements List
List<? extends Serializable> l8 - list1; // both of the above


问:
Could not find the .cmi file
I would like to add a makefile for this project. I tried the following makefile:

```<code>SHELL:= /bin/bash
OCAMLC= ocamlfind ocamlc -package ppx_deriving.std -package sedlex.ppx -package sedlex -package MenhirLib
OCAMLYACC=      $(OCAMLPREFIX)menhir -v
OCAMLLEX=       $(OCAMLPREFIX)ocamllex -ml

%.ml %.mli: %.mly
    $(OCAMLYACC) $*.mly
%.ml: %.mll
    $(OCAMLLEX) $*.mll
%.cmi: %.mli
    $(OCAMLC) $(OCAMLFLAGS) -c $*.ml
%.cmo: %.ml
    $(OCAMLC) $(OCAMLFLAGS) -c $*.ml

ML_DOMAIN_MAIN= syntax.ml \
        parser.ml \
        lexer.ml \
        calc.ml
CMO_DOMAIN_MAIN=$(ML_DOMAIN_MAIN:%.ml=%.cmo)

calc:   $(CMO_DOMAIN_MAIN)
        $(OCAMLC) -g -linkpkg -o $@ $+

clean:
    rm -rf calc *.o *.cm[oixa] *.annot *~ *.log *.output *.out *.mli parser.ml parser.mli
</code>```

It returned an error:

```<code>menhir -v parser.mly
ocamlfind ocamlc -package ppx_deriving.std -package sedlex.ppx -package sedlex -package MenhirLib  -c parser.ml
File "parser.ml", line 1:
Error: Could not find the .cmi file for interface parser.mli.
make: *** [parser.cmo] Error 2
rm parser.ml
</code>```

Does anyone know how to fix this?

答:
You have a typo in this rule:

```<code>%.cmi: %.mli
        $(OCAMLC) $(OCAMLFLAGS) -c $*.ml
</code>```

The prerequisite is .mli but you pass .ml to the compiler.

Why don't you just use the $< automatic variable, then you don't have to worry about this?

```<code>%.ml %.mli: %.mly
        $(OCAMLYACC) $<
%.ml: %.mll
        $(OCAMLLEX) $<
%.cmi: %.mli
        $(OCAMLC) $(OCAMLFLAGS) -c $<
%.cmo: %.ml
        $(OCAMLC) $(OCAMLFLAGS) -c $<
</code>```

Title: Could not find the .cmi file

Body:
I would like to add a makefile for this project. I tried the following makefile:

SHELL:= /bin/bash
OCAMLC= ocamlfind ocamlc -package ppx_deriving.std -package sedlex.ppx -package sedlex -package MenhirLib
OCAMLYACC=      $(OCAMLPREFIX)menhir -v
OCAMLLEX=       $(OCAMLPREFIX)ocamllex -ml

%.ml %.mli: %.mly
    $(OCAMLYACC) $*.mly
%.ml: %.mll
    $(OCAMLLEX) $*.mll
%.cmi: %.mli
    $(OCAMLC) $(OCAMLFLAGS) -c $*.ml
%.cmo: %.ml
    $(OCAMLC) $(OCAMLFLAGS) -c $*.ml

ML_DOMAIN_MAIN= syntax.ml \
        parser.ml \
        lexer.ml \
        calc.ml
CMO_DOMAIN_MAIN=$(ML_DOMAIN_MAIN:%.ml=%.cmo)

calc:   $(CMO_DOMAIN_MAIN)
        $(OCAMLC) -g -linkpkg -o $@ $+

clean:
    rm -rf calc *.o *.cm[oixa] *.annot *~ *.log *.output *.out *.mli parser.ml parser.mli

It returned an error:

menhir -v parser.mly
ocamlfind ocamlc -package ppx_deriving.std -package sedlex.ppx -package sedlex -package MenhirLib  -c parser.ml
File "parser.ml", line 1:
Error: Could not find the .cmi file for interface parser.mli.
make: *** [parser.cmo] Error 2
rm parser.ml

Does anyone know how to fix this?

Body:
You have a typo in this rule:

%.cmi: %.mli
        $(OCAMLC) $(OCAMLFLAGS) -c $*.ml

The prerequisite is .mli but you pass .ml to the compiler.

Why don't you just use the $< automatic variable, then you don't have to worry about this?

%.ml %.mli: %.mly
        $(OCAMLYACC) $<
%.ml: %.mll
        $(OCAMLLEX) $<
%.cmi: %.mli
        $(OCAMLC) $(OCAMLFLAGS) -c $<
%.cmo: %.ml
        $(OCAMLC) $(OCAMLFLAGS) -c $<


问:
Laravel first()->count() return more than one
I'm going to count total record of eloquent query using count().

My table looks like this

id
Code
Discount

1
StarterResellerFree30Days
100

2
StarterResellerFree33Days
100

3
StarterResellerFree32Days
100

4
StarterResellerFree31Days
100

5
StarterResellerFree60Days
10

Here is my code

```<code> $eligible = Coupon::where('code', 'StarterResellerFree30Days')->first();
 echo $eligible->discount;
 echo "<br><br>";
 echo $eligible->count();
</code>```

Here is the result

```<code>100

5
</code>```

As you can see $eligible->discount return expected value, meaning $eligible contain only 1 record.

However, when I use $eligible->count(), it is returning 5 which is total records.

$eligible->count() supposed to return 1 because of first() and there is only one record matching the criteria.

Where am I doing wrong?

Thanks

答:
You made a mistake using first() method which is returning MODEL. You have to use get() method to return collection so you can do count() on collection retreived. When you use count on model it will return you number of models in database.

So you want to use

```<code>$eligable = App\Models\Coupon::where('code', 'StarterResellerFree30Days')->get();
</code>```

as per on example below:

Body:
I'm going to count total record of eloquent query using count().

My table looks like this

id
Code
Discount

1
StarterResellerFree30Days
100

2
StarterResellerFree33Days
100

3
StarterResellerFree32Days
100

4
StarterResellerFree31Days
100

5
StarterResellerFree60Days
10

Here is my code

 $eligible = Coupon::where('code', 'StarterResellerFree30Days')->first();
 echo $eligible->discount;
 echo "

";
 echo $eligible->count();

Here is the result

100

5

As you can see $eligible->discount return expected value, meaning $eligible contain only 1 record.

However, when I use $eligible->count(), it is returning 5 which is total records.

$eligible->count() supposed to return 1 because of first() and there is only one record matching the criteria.

Where am I doing wrong?

Thanks

Body:
You made a mistake using first() method which is returning MODEL. You have to use get() method to return collection so you can do count() on collection retreived. When you use count on model it will return you number of models in database.

So you want to use

$eligable = App\Models\Coupon::where('code', 'StarterResellerFree30Days')->get();

as per on example below:


问:
Scroll view does not scroll - Android Studio
I can't make a ScrollView properly scrolling.
I can scroll through the page but the scrollView itself not showing and it always cut off the content on the bottom.
The buttons portion is being cut off in portrait orientation, and not scrolling at all in the  landscape orientation.

Here is my XML code:

```<code><?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".signUp.SignUpFragment">

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".signUp.SignUpFragment">

        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/linearLayoutCompat"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="20dp"
            android:layout_marginTop="10dp"
            android:orientation="vertical"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/signup_logo"
                android:layout_width="match_parent"
                android:layout_height="140dp"
                android:layout_marginTop="20dp"
                android:src="@drawable/logo"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/name"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_name_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/nick_name"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_nickname_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/email"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_email_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/password"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_password_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/verifypassword"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_verifypass_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:maxLines="1" />

            </com.google.android.material.textfield.TextInputLayout>

        </androidx.appcompat.widget.LinearLayoutCompat>

        <TextView
            android:id="@+id/signup_profilepic_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="25dp"
            android:layout_marginTop="12dp"
            android:text="Profile picture"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

        <Button
            android:id="@+id/signup_cancel_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:backgroundTint="#7b9abe"
            android:text="Cancel"
            android:textSize="20sp"
            app:layout_constraintEnd_toStartOf="@+id/signup_save_btn"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/signup_camera_btn" />

        <Button
            android:id="@+id/signup_save_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:backgroundTint="#7b9abe"
            android:text="Sign Up"
            android:textSize="20sp"
            app:layout_constraintBaseline_toBaselineOf="@+id/signup_cancel_btn"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/signup_cancel_btn" />

        <ImageButton
            android:id="@+id/signup_camera_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="12dp"
            android:layout_marginTop="10dp"
            android:src="@android:drawable/ic_menu_camera"
            app:layout_constraintStart_toEndOf="@+id/signup_profilepic_tv"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

        <ImageButton
            android:id="@+id/signup_gallery_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:layout_marginTop="10dp"
            android:src="@android:drawable/ic_menu_gallery"
            app:layout_constraintStart_toEndOf="@+id/signup_camera_btn"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>
</code>```

My device:

Thank you!!!

答: This Is Not A Problem. It Working Fine In Portrait And Landscape.</p>

Body:
I can't make a ScrollView properly scrolling.
I can scroll through the page but the scrollView itself not showing and it always cut off the content on the bottom.
The buttons portion is being cut off in portrait orientation, and not scrolling at all in the  landscape orientation.

Here is my XML code:

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".signUp.SignUpFragment">

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".signUp.SignUpFragment">

        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/linearLayoutCompat"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="20dp"
            android:layout_marginTop="10dp"
            android:orientation="vertical"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/signup_logo"
                android:layout_width="match_parent"
                android:layout_height="140dp"
                android:layout_marginTop="20dp"
                android:src="@drawable/logo"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/name"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_name_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/nick_name"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_nickname_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/email"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_email_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/password"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_password_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:maxLines="1" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:hint="@string/verifypassword"
                android:paddingTop="16dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/signup_verifypass_show"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:maxLines="1" />

            </com.google.android.material.textfield.TextInputLayout>

        </androidx.appcompat.widget.LinearLayoutCompat>

        <TextView
            android:id="@+id/signup_profilepic_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="25dp"
            android:layout_marginTop="12dp"
            android:text="Profile picture"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

        <Button
            android:id="@+id/signup_cancel_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:backgroundTint="#7b9abe"
            android:text="Cancel"
            android:textSize="20sp"
            app:layout_constraintEnd_toStartOf="@+id/signup_save_btn"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/signup_camera_btn" />

        <Button
            android:id="@+id/signup_save_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:backgroundTint="#7b9abe"
            android:text="Sign Up"
            android:textSize="20sp"
            app:layout_constraintBaseline_toBaselineOf="@+id/signup_cancel_btn"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/signup_cancel_btn" />

        <ImageButton
            android:id="@+id/signup_camera_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="12dp"
            android:layout_marginTop="10dp"
            android:src="@android:drawable/ic_menu_camera"
            app:layout_constraintStart_toEndOf="@+id/signup_profilepic_tv"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

        <ImageButton
            android:id="@+id/signup_gallery_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:layout_marginTop="10dp"
            android:src="@android:drawable/ic_menu_gallery"
            app:layout_constraintStart_toEndOf="@+id/signup_camera_btn"
            app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

My device:

Thank you!!!


问:
Error Integration Bitbucket Pipeline and SonarCloud
ALM used Bitbucket Cloud

CI system used Bitbucket Cloud

Languages of the repository: Angular (Other (for JS, TS, Go, Python, PHP, …))

```<code>Error observed
ERROR: Error during SonarScanner execution

ERROR: Not authorized. Please check the property sonar.login or SONAR_TOKEN env variable
</code>```

Steps to reproduce

```<code>SONAR_TOKEN already generated and added to my ENV_VAR
</code>```

Bitbucket.yaml

```<code>image: ‘node:12.22’
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:

step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- sonar
script:
- pipe: sonarsource/sonarcloud-scan:1.2.1
variables:
EXTRA_ARGS: ‘-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN}’

step: &check-quality-gate-sonarcloud
name: Check the Quality Gate on SonarCloud
script:
- pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines:
branches
</code>```

Potential workaround
No idea.

答:
if you already install the sonar cloud app to your workspace environment, there is no need to give the sonar url again. The integration process is handling the URL part. Also, you should add your Sonar token variable to Workspace or repo environment. After that, you should login to Sonar Cloud organization account and bind your repo to SonarCloud to be able to evaluate it by Sonar Cloud. Here is my Sonar Cloud setup;

bitbucket-pipelines.yml file,

```<code>image:
  name: <base image>

clone:
  # SonarCloud scanner needs the full history to assign issues properly
  depth: full

definitions:
  caches:
    # Caching SonarCloud artifacts will speed up your build
    sonar: ~/.sonar/cache

pipelines:
  pull-requests:
    '**':
      - step:
          name: "Code Quality and Security on PR"
          script:
            - pipe: sonarsource/sonarcloud-scan:1.2.1
              variables:
                SONAR_TOKEN: '$SONAR_CLOUD_TOKEN'
                SONAR_SCANNER_OPTS: -Xmx512m
                DEBUG: "true"
  branches:
    master:
      - step:
          name: "Code Quality and Security on master"
          script:
            - pipe: sonarsource/sonarcloud-scan:1.2.1
              variables:
                SONAR_TOKEN: '$SONAR_CLOUD_TOKEN'
                SONAR_SCANNER_OPTS: -Xmx512m
                DEBUG: "true"
  tags:
    '*.*.*-beta*':
      - step:
          name: "Image Build & Push"
          services:
            - docker
          caches:
            - docker
          clone:
            depth: 1
          script:
            - <build script>
      - step:
          name: "Deploy"
          deployment: beta
          clone:
            enabled: false
          script:
            - <deploy script>
    '*.*.*-prod':
      - step:
          name: "Image Build & Push"
          services:
            - docker
          caches:
            - docker
          clone:
            depth: 1
          script:
            - <build script>
      - step:
          name: "Deploy"
          deployment: prod
          clone:
            enabled: false
          script:
            - <deploy script>
</code>```

sonar-project.properties file,

```<code>sonar.organization=<sonar cloud organization name>

sonar.projectKey=<project key>
sonar.projectName=<project name>

sonar.sources=<sonar evaluation path>
sonar.language=<repo language>
sonar.sourceEncoding=UTF-8
</code>```

Body:
ALM used Bitbucket Cloud

CI system used Bitbucket Cloud

Languages of the repository: Angular (Other (for JS, TS, Go, Python, PHP, …))

Error observed
ERROR: Error during SonarScanner execution

ERROR: Not authorized. Please check the property sonar.login or SONAR_TOKEN env variable

Steps to reproduce

SONAR_TOKEN already generated and added to my ENV_VAR

Bitbucket.yaml

image: ‘node:12.22’
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:

step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- sonar
script:
- pipe: sonarsource/sonarcloud-scan:1.2.1
variables:
EXTRA_ARGS: ‘-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN}’

step: &check-quality-gate-sonarcloud
name: Check the Quality Gate on SonarCloud
script:
- pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines:
branches

Potential workaround
No idea.

Body:
if you already install the sonar cloud app to your workspace environment, there is no need to give the sonar url again. The integration process is handling the URL part. Also, you should add your Sonar token variable to Workspace or repo environment. After that, you should login to Sonar Cloud organization account and bind your repo to SonarCloud to be able to evaluate it by Sonar Cloud. Here is my Sonar Cloud setup;

bitbucket-pipelines.yml file,

image:
  name: <base image>

clone:
  # SonarCloud scanner needs the full history to assign issues properly
  depth: full

definitions:
  caches:
    # Caching SonarCloud artifacts will speed up your build
    sonar: ~/.sonar/cache

pipelines:
  pull-requests:
    '**':
      - step:
          name: "Code Quality and Security on PR"
          script:
            - pipe: sonarsource/sonarcloud-scan:1.2.1
              variables:
                SONAR_TOKEN: '$SONAR_CLOUD_TOKEN'
                SONAR_SCANNER_OPTS: -Xmx512m
                DEBUG: "true"
  branches:
    master:
      - step:
          name: "Code Quality and Security on master"
          script:
            - pipe: sonarsource/sonarcloud-scan:1.2.1
              variables:
                SONAR_TOKEN: '$SONAR_CLOUD_TOKEN'
                SONAR_SCANNER_OPTS: -Xmx512m
                DEBUG: "true"
  tags:
    '*.*.*-beta*':
      - step:
          name: "Image Build & Push"
          services:
            - docker
          caches:
            - docker
          clone:
            depth: 1
          script:
            - <build script>
      - step:
          name: "Deploy"
          deployment: beta
          clone:
            enabled: false
          script:
            - <deploy script>
    '*.*.*-prod':
      - step:
          name: "Image Build & Push"
          services:
            - docker
          caches:
            - docker
          clone:
            depth: 1
          script:
            - <build script>
      - step:
          name: "Deploy"
          deployment: prod
          clone:
            enabled: false
          script:
            - <deploy script>

sonar-project.properties file,

sonar.organization=<sonar cloud organization name>

sonar.projectKey=<project key>
sonar.projectName=<project name>

sonar.sources=<sonar evaluation path>
sonar.language=<repo language>
sonar.sourceEncoding=UTF-8


问:
powershell - deleting tab delimited file and matching subfolder
In a folder structure I have .stb files where name is unknown, and subfolders matching the name of the .stb file.

A folder can look like this:

```<code>C:\path\file1.stb
C:\path\file1\...
C:\path\file2.stb
C:\path\file2\..
</code>```

The .stb file is tab delimited and look something like this:

```<code>Call ID Latitude    Longitude   Date and Time   Noe
wasd    12.1241234  12.1243 2021-12-15 07:45:13.123 Noe
wasd    12.1241234  12.1243 2021-12-15 07:45:13.123 Noe
wasd    12.1241234  12.1243 2022-01-15 07:45:13.123 Noe
</code>```

If a .stb contain a line where date is older than "$limit" the file and matching subfolder (and its content) should be deleted.

What I tested is:

```<code>$limit = (Get-Date).AddDays(-41).Date
$test = (Import-Csv -Path  (Get-ChildItem -Path C:\Users\steff\Documents\ -Filter '*.stb').FullName  -Delimiter "`t" | Where-Object {  ([datetime]$_.'Date and Time') -lt $limit }  )
</code>```

But this only gives the output of file, and im not sure how to proceed to know what the actual filename is, in order to delte the .stb file and the matching subfolder. I am limited to Powershell here. Anyone know how to proceed?

答:
In this case, I would do a loop in which you can test if a .stb file indeed has such an older item and if so, you can construct the path for a subfolder with a similar name, test if that exists and if yes, delete that too.

Try

```<code>$limit = (Get-Date).AddDays(-41).Date
Get-ChildItem -Path 'C:\Users\steff\Documents' -Filter '*.stb' -File | ForEach-Object {
    # test if the file contains an item with old date
    $oldInfo = (Import-Csv -Path $_.FullName -Delimiter "`t") | Where-Object { ([datetime]$_.'Date and Time') -lt $limit }
    if ($oldInfo) {
        # create the path for a subfolder with the same basename as the file
        $subFolder = Join-Path -Path $_.DirectoryName -ChildPath $_.BaseName
        if (Test-Path -Path $subFolder -PathType Container) {
            # a matching subfolder exists, delete it
            Remove-Item -Path $subFolder -Recurse -WhatIf
        }
        # now delete the .stb file itself
        Remove-Item -Path $_.FullName -WhatIf
    }
}
</code>```

The code above has -WhatIf safety switches on both Remove-Item cmdlets. This is a safety measure, so you can first see in the console what would be deleted. Only if you are satisfied with that info, remove or comment out the -WhatIf switches and run the code again.

Body:
In a folder structure I have .stb files where name is unknown, and subfolders matching the name of the .stb file.

A folder can look like this:

C:\path\file1.stb
C:\path\file1\...
C:\path\file2.stb
C:\path\file2\..

The .stb file is tab delimited and look something like this:

Call ID Latitude    Longitude   Date and Time   Noe
wasd    12.1241234  12.1243 2021-12-15 07:45:13.123 Noe
wasd    12.1241234  12.1243 2021-12-15 07:45:13.123 Noe
wasd    12.1241234  12.1243 2022-01-15 07:45:13.123 Noe

If a .stb contain a line where date is older than "$limit" the file and matching subfolder (and its content) should be deleted.

What I tested is:

$limit = (Get-Date).AddDays(-41).Date
$test = (Import-Csv -Path  (Get-ChildItem -Path C:\Users\steff\Documents\ -Filter '*.stb').FullName  -Delimiter "`t" | Where-Object {  ([datetime]$_.'Date and Time') -lt $limit }  )

But this only gives the output of file, and im not sure how to proceed to know what the actual filename is, in order to delte the .stb file and the matching subfolder. I am limited to Powershell here. Anyone know how to proceed?

Body:
In this case, I would do a loop in which you can test if a .stb file indeed has such an older item and if so, you can construct the path for a subfolder with a similar name, test if that exists and if yes, delete that too.

Try

$limit = (Get-Date).AddDays(-41).Date
Get-ChildItem -Path 'C:\Users\steff\Documents' -Filter '*.stb' -File | ForEach-Object {
    # test if the file contains an item with old date
    $oldInfo = (Import-Csv -Path $_.FullName -Delimiter "`t") | Where-Object { ([datetime]$_.'Date and Time') -lt $limit }
    if ($oldInfo) {
        # create the path for a subfolder with the same basename as the file
        $subFolder = Join-Path -Path $_.DirectoryName -ChildPath $_.BaseName
        if (Test-Path -Path $subFolder -PathType Container) {
            # a matching subfolder exists, delete it
            Remove-Item -Path $subFolder -Recurse -WhatIf
        }
        # now delete the .stb file itself
        Remove-Item -Path $_.FullName -WhatIf
    }
}

The code above has -WhatIf safety switches on both Remove-Item cmdlets. This is a safety measure, so you can first see in the console what would be deleted. Only if you are satisfied with that info, remove or comment out the -WhatIf switches and run the code again.


问:
aligning the text in a div to the bottom
I have two divs next to each other, one with float: right and the other with float: left. The one on the left contains an image (200x100px) and the div on the right should contain a text. I would like to have the text of the div on the right to start on the bottom left of the div instead of the top left, is that possible somehow?
Thanks

答:
Try this css rule on the span, paragraph or whatever you're placing the text in:</p>

```<code>vertical-align: bottom;
</code>```

Body:
Try this css rule on the span, paragraph or whatever you're placing the text in:

vertical-align: bottom;