qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,205,122 | <p>I have a linear regression with a hundred values. Now I want to know how the coefficient was only at a certain sub-range of values. For example all 10 values.</p>
<p>Result should be similar to this:</p>
<p>Coefficient from 1-10: 0.5</p>
<p>Coefficient from 11-20: 0.33</p>
<p>Coefficient from 21-30: 0.306</p>
<p>......</p>
<p>I need a reproducible solution as the truth is I have a much larger data set.</p>
<p>Example:</p>
<pre><code>set.seed(111)
a <- rnorm(100)
b <- rnorm(100)
abc <- lm(a ~ b)
summary(abc)
</code></pre>
<p>Thanks in advance!</p>
| [
{
"answer_id": 74205230,
"author": "Roland",
"author_id": 1412059,
"author_profile": "https://Stackoverflow.com/users/1412059",
"pm_score": 2,
"selected": false,
"text": "lmList"
},
{
"answer_id": 74205595,
"author": "zephryl",
"author_id": 17303805,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20241827/"
] |
74,205,128 | <p>I upgrade MacOS Ventura 13. When I brew install git, appeared error:</p>
<pre><code>Warning: You are using macOS 13.
We do not provide support for this pre-release version.
</code></pre>
| [
{
"answer_id": 74205129,
"author": "Mike Petrov",
"author_id": 16623057,
"author_profile": "https://Stackoverflow.com/users/16623057",
"pm_score": -1,
"selected": false,
"text": "xcode-select --install\n"
},
{
"answer_id": 74214621,
"author": "Yannick De Turck",
"author_i... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16623057/"
] |
74,205,154 | <p>I have a procedure I need to call it from my code using <code>EFCore</code></p>
<p>Below is my procedure structure</p>
<pre><code>Create PROCEDURE [dbo].[BusinessOrders]
(
@StatusID INT ,
@BusinessBranchID INT,
@LangID INT ,
@PurchasedOn NVARCHAR(MAX) ,
@Search NVARCHAR(MAX),
@PageSize INT,
@PageNo INT
)
AS
BEGIN
END
</code></pre>
<p>This is my code function</p>
<pre><code>public IEnumerable<BusinessOrderEntity.BODB> GetBusinessOrders(int StatusID, int BusinessBranchID, int LangID, string PurchasedOn = "", string Search = "", int PageSize = 10, int PageNo = 1)
{
// here need to call procedure.
}
</code></pre>
<p>I've find different solution but it does not working with my context class</p>
| [
{
"answer_id": 74206500,
"author": "neena",
"author_id": 20211089,
"author_profile": "https://Stackoverflow.com/users/20211089",
"pm_score": 0,
"selected": false,
"text": "private async Task ExecuteStoredProc()\n{\n DbCommand cmd = _context.Database.GetDbConnection().CreateCommand();\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4231821/"
] |
74,205,155 | <pre><code>if (item + 600 === itemNew) {
list.push(obj[i]);
} else {
list.push({,
Time: item
});
if (item + 1200 !== itemNew) {
list.push({
Time: item + 600
});
if (item + 1800 !== itemNew) {
list.push({
Time: item + 1200
});
if (item + 2400 !== itemNew) {
list.push({
Time: item + 1800
});
if (item + 3000 !== itemNew) {
list.push({
Time: item + 2400
});
if (item + 3600 !== itemNew) {
list.push({
Time: item + 3000
});
if (item + 4200 !== itemNew) {
list.push({
Time: item + 3600
});
}
}
}
}
}
}
}
</code></pre>
<p>I want to check and get the distance of two numbers relative to the value of 600. There is a loop that has a condition and must be traversed.
We check the previous value and if it is not the same as the next value, we add 600 to reach the condition</p>
| [
{
"answer_id": 74205273,
"author": "mgm793",
"author_id": 5689074,
"author_profile": "https://Stackoverflow.com/users/5689074",
"pm_score": 2,
"selected": false,
"text": "for"
},
{
"answer_id": 74205856,
"author": "Volodymyr Sichka",
"author_id": 5333324,
"author_prof... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9371475/"
] |
74,205,197 | <p>I am getting data from two different API calls. One gets me "customer" data and the other "towns" data. Each customer has a town reference, so in my application, I need to have the actual town object referenced by the customer object. Here is a vastly simplified representation of my classes:</p>
<pre class="lang-cs prettyprint-override"><code>public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public int townId { get; set; }
public Town town { get; set; }
}
public class Town
{
public int townId { get; set; }
public string townName { get; set; }
}
</code></pre>
<p>The only way I can think of achieving my objective is as follows (assume I am actually getting the lists from my API calls, the following is just for the sake of explanation of the problem):</p>
<pre class="lang-cs prettyprint-override"><code>List<Customer> customers = new List<Customer>();
customers.Add(new Customer { Id = 1, Name = "First Customer", townId = 10 });
customers.Add(new Customer { Id = 2, Name = "Second Customer", townId = 20 });
customers.Add(new Customer { Id = 2, Name = "Third Customer", townId = 20 });
List<Town> towns = new List<Town>();
towns.Add(new Town { townId = 10, townName = "Eton" });
towns.Add(new Town { townId = 20, townName = "Harrow" });
towns.Add(new Town { townId = 30, townName = "Cambridge" });
foreach(Customer c in customers)
{
c.town = towns.Where(t => t.townId == c.townId).FirstOrDefault();
}
</code></pre>
<p>This does not feel like an efficient way of achieving my objective, especially when I have dozens of other places where I would need to do the same thing.</p>
| [
{
"answer_id": 74205273,
"author": "mgm793",
"author_id": 5689074,
"author_profile": "https://Stackoverflow.com/users/5689074",
"pm_score": 2,
"selected": false,
"text": "for"
},
{
"answer_id": 74205856,
"author": "Volodymyr Sichka",
"author_id": 5333324,
"author_prof... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1184003/"
] |
74,205,201 | <p>I'm trying to reproduce a COM client in c++ in the non MFC way. I'm able to connect to the com interface and call some methods that require simple values as parameter, but I'm not able to call a method with a pointer as argument, the function is this:</p>
<pre><code>short sProdGetCurrentMachineType(short* p_psMachineType)
</code></pre>
<p>and in the <code>short</code> variable pointed by <code>p_psMachineType</code> will be stored the result value.</p>
<p>I tried this:</p>
<pre><code>DISPID dispid; //omitted for brevity, i get it from QueryInterface() on the com
VARIANT pVarResult;
EXCEPINFO pExcepInfo;
unsigned int* puArgErr = 0;
DISPPARAMS dispparams{};
VARIANTARG rgvarg[1];
short *p_psMachineType;
rgvarg[0].vt = VT_I2;
rgvarg[0].piVal = p_psMachineType;
dispparams.rgvarg = rgvarg;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 0;
hresult = (*pDisp)->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
&dispparams, &pVarResult, &pExcepInfo, puArgErr
);
</code></pre>
<p>but I get a <code>TYPE_MISMATCH ERROR</code>..</p>
<p>Instead I saw that using it as named argument I don't get error in the call but the pointer value is not populated, but i cannot find any example of pointers passed as named arguments.</p>
<p>Does anybody know how to handle it?</p>
| [
{
"answer_id": 74205273,
"author": "mgm793",
"author_id": 5689074,
"author_profile": "https://Stackoverflow.com/users/5689074",
"pm_score": 2,
"selected": false,
"text": "for"
},
{
"answer_id": 74205856,
"author": "Volodymyr Sichka",
"author_id": 5333324,
"author_prof... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13810783/"
] |
74,205,217 | <p>I am working on a Ruby on Rails project. From the given list, I want to retrieve all the Courses that start with a <code>1</code> (basically, Year 1 Courses).</p>
<p><a href="https://i.stack.imgur.com/IfUnh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IfUnh.png" alt="enter image description here" /></a></p>
<p>For example, I would like</p>
<pre><code>ELEC ENG 1100 Analog Electronics
ENG 1001 Introduction to Engineering
MATHS 1011 Mathematics IA
</code></pre>
<p>And not</p>
<pre><code>COMP SCI 2201 Algorithm & Data Structure Analysis
COMP SCI 3001 Computer Networks & Applications
</code></pre>
<p>(even they contain <code>1</code> in them, but not in the starting position).</p>
<p>I have stored my Course names as one string. How could I go about querying this? I tried</p>
<pre><code>Course.where("name LIKE '%1%'")
</code></pre>
<p>and this returns all the Courses that contain <code>1</code> in them. But this is not what I want. How could I generate a query for what I require?</p>
| [
{
"answer_id": 74205273,
"author": "mgm793",
"author_id": 5689074,
"author_profile": "https://Stackoverflow.com/users/5689074",
"pm_score": 2,
"selected": false,
"text": "for"
},
{
"answer_id": 74205856,
"author": "Volodymyr Sichka",
"author_id": 5333324,
"author_prof... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18487436/"
] |
74,205,308 | <p>I think I'm missing something very simple but this is the setup I have:</p>
<p>I'm using conan to install zstandard:</p>
<pre><code>[requires]
...
zstd/1.5.1
</code></pre>
<p>with following config:</p>
<pre><code>[settings]
os=Linux
arch=x86_64
build_type=Release
compiler=clang
compiler.version=12
compiler.libcxx=libstdc++
[env]
CC=/usr/bin/clang-12
CXX=/usr/bin/clang++-12
</code></pre>
<p>My <code>CMakeLists.txt</code> is as follows:</p>
<pre><code>set(LIBRARY_ZSTDSTREAM_SOURCES
zstdstream.cpp
)
set(LIBRARY_ZSTDSTREAM_HEADERS
circularbuffer.h
zstdstream.h
)
add_library(${LIBRARY_ZSTDSTREAM_NAME} STATIC
${LIBRARY_ZSTDSTREAM_SOURCES}
${LIBRARY_ZSTDSTREAM_HEADERS})
target_link_libraries(${LIBRARY_ZSTDSTREAM_NAME} PUBLIC
${CONAN_ZSTD}
${LIBRARY_FORMAT_NAME}
)
target_include_directories(${LIBRARY_ZSTDSTREAM_NAME} PUBLIC
"./"
"${CMAKE_BINARY_DIR}/configured_files/include"
)
</code></pre>
<p>The error message I get is the following:</p>
<pre><code>zstdstream.cpp:(.text+0x3b): undefined reference to `ZSTD_getErrorName'
/usr/bin/ld: ../../lib/libzstdstream.a(zstdstream.cpp.o): in function `common::zstdstream::cstream::cstream()':
zstdstream.cpp:(.text+0xc5): undefined reference to `ZSTD_createCStream'
/usr/bin/ld: ../../lib/libzstdstream.a(zstdstream.cpp.o): in function `common::zstdstream::cstream::~cstream()':
zstdstream.cpp:(.text+0xd8): undefined reference to `ZSTD_freeCStream'
/usr/bin/ld: zstdstream.cpp:(.text+0xe3): undefined reference to `ZSTD_isError'
/usr/bin/ld: ../../lib/libzstdstream.a(zstdstream.cpp.o): in function `common::zstdstream::cstream::init(int)':
zstdstream.cpp:(.text+0x148): undefined reference to `ZSTD_initCStream'
/usr/bin/ld: zstdstream.cpp:(.text+0x153): undefined reference to `ZSTD_isError'
</code></pre>
<p>I checked the linker by setting <code>VERBOSE=1</code> running makefile:</p>
<pre><code>-Wl,-rpath,/home/worker/.conan/data/zstd/1.5.1/_/_/package/4d1e52cb9a38d07b5e682edec92bb71d7afcd534/lib:
</code></pre>
<pre><code>-L/home/worker/.conan/data/zstd/1.5.1/_/_/package/4d1e52cb9a38d07b5e682edec92bb71d7afcd534/lib
</code></pre>
<p>so zstd library is there and linked properly.</p>
<p>I am so confused to what is going on..</p>
| [
{
"answer_id": 74229572,
"author": "MoneyBall",
"author_id": 5192123,
"author_profile": "https://Stackoverflow.com/users/5192123",
"pm_score": 0,
"selected": false,
"text": "${CONAN_ZSTD}"
},
{
"answer_id": 74232691,
"author": "SpacePotatoes",
"author_id": 8390473,
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5192123/"
] |
74,205,320 | <p>I have a dataframe like this:</p>
<pre><code> TermReason Termcount
1 Another position 20
2 unhappy 14
3 more money 11
4 career change 9
</code></pre>
<p>I want to combine <code>Another position</code> & <code>career change</code> into <code>Better oppotinutity</code> and also sum up their numerical data, so does the other tow columns.</p>
<p>I would like to know how to make dataframe like this:</p>
<pre><code> Termgroup Termcount
1 Better oppotinutity 29
2 Unsatisfied with job 25
</code></pre>
<p>Thanks.</p>
| [
{
"answer_id": 74205409,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "TermReason"
},
{
"answer_id": 74205411,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19297989/"
] |
74,205,352 | <p>Can anyone please suggest me how to add translate button in my HTML,CSS website so that the costumer can easily choose the language as their preference..
Please refer the following image..
<a href="https://i.stack.imgur.com/q1scJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q1scJ.png" alt="Refer this image" /></a></p>
<p>I am creating a website for the client in French language but I've created the whole website in English language so please enlighten me how I can make it readable by the French users.</p>
| [
{
"answer_id": 74205409,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "TermReason"
},
{
"answer_id": 74205411,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20158177/"
] |
74,205,358 | <p>Currently i have a perfectly functioning VBA Macro. Does everything it is required to. However, i do need some advice and help on speeding this macro up as it takes a LONG time to get things done. This macro takes aroung 5 minutes to sort through around 4k-5k populated rows, which then it hides some of the rows.</p>
<p>How this macro works is that it will sort through Column A, sorting through the names and comparing it to a list in Sheet1, where if the name matches the list in sheet1, it will proceed to hide the row.
Thanks in advance.</p>
<pre><code> Sub FilterNameDuplicate()
Application.ScreenUpdating = False
Dim iListCount As Integer
Dim iCtr As Integer
Dim a As Long
Dim b As Long
Dim c As Long
Dim D As Long
a = Worksheets("Default").Cells(Rows.Count, "G").End(xlUp).Row
For c = 1 To a
b = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For D = 1 To b
If StrComp(Worksheets("Sheet1").Cells(D, "A"), (Worksheets("Default").Cells(c, "G")), vbTextCompare) = 0 Then
Worksheets("Default").Rows(c).EntireRow.Hidden = True
End If
Next
Next
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
</code></pre>
| [
{
"answer_id": 74205521,
"author": "EuanM28",
"author_id": 12200628,
"author_profile": "https://Stackoverflow.com/users/12200628",
"pm_score": 2,
"selected": false,
"text": "Call TurnOffCode\n"
},
{
"answer_id": 74206181,
"author": "TinMan",
"author_id": 9912714,
"aut... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20146197/"
] |
74,205,361 | <p>In Python, I am trying to break a SMILES string into a list of valid SMILES elements. I wanted to ask if RDKit already has a method to do this kind of deconstruction of the SMILES string? I DO have created a list of valid SMILES elements separately.</p>
<p>For example, I want to convert this string CC(Cl)c1ccn(C)c1 into this list ['C', 'C', '(', 'Cl', ')', 'c', '1', 'c', 'c', 'n', '(', 'C', ')', 'c', '1']. Unfortunately, this is not as straightforward as simply getting the characters from the string: occurrence of a lower case alphabet could either mean that it is an element denoted by more than one character (like Cl for Chlorine) or indicate that the element is part of an aromatic ring (like n for Nitrogen). Examples of other valid SMILE elements that are not a single character are Mg, Ca, Uub, %13, +2, @@, etc.</p>
<p>Before I write a parsing algorithm to accomplish this, which I think would be less than ideal because I might miss a SMILES rule here and there (I am neither an expert at SMILES, nor at parsing). For example, occurrence of two digit numbers are another complication that I know I will have to deal with when creating my own parsing algorithm.</p>
| [
{
"answer_id": 74214916,
"author": "wikke",
"author_id": 20037581,
"author_profile": "https://Stackoverflow.com/users/20037581",
"pm_score": 0,
"selected": false,
"text": "import rdkit\nfrom rdkit import Chem\ndef get_atom_chars(smi):\n atoms_chars=[]\n mol = Chem.MolFromSmiles(smi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2369240/"
] |
74,205,381 | <p>In the following image, I am using the post method to send the data, which is successfully done and when the server returns the response which is can be seen in the user's console, now how do I display those responses in text widgets in another class?</p>
<p><strong>This is my Api class where I use post method.</strong></p>
<pre><code>class APIService {
Future<DoctorResponseLoginModels> register(
DoctorRequestLoginModels doctorLoginRequestModels) async {
String url = "http://202.51.75.142:9028/api/PatientMaster/PostPatientLogin";
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var globalToken = sharedPreferences.getString("token");
print("$globalToken");
http.Response response = await http.post(Uri.parse(url),
headers: {
"Content-Type": "application/json",
'Accept': 'application/json',
'Authorization': 'Bearer $globalToken',
},
body: jsonEncode(doctorLoginRequestModels));
var responseJson = json.decode(response.body.toString());
DoctorResponseLoginModels responseModel =
DoctorResponseLoginModels.fromJson(responseJson);
print("This is ${response.body}");
if (response.statusCode == 200) {
sharedPreferences.setInt('code', response.statusCode);
var StatusCode = sharedPreferences.getInt('code');
print("This contains : $StatusCode");
print(response.statusCode);
return DoctorResponseLoginModels.fromJson(jsonDecode(response.body));
} else {
throw Exception('Failed');
}
}
}
</code></pre>
<p><strong>This is my Request Class model which I sent to server</strong></p>
<pre><code>DoctorRequestLoginModels doctorRequestLoginModelsFromJson(String str) =>
DoctorRequestLoginModels.fromJson(json.decode(str));
String doctorRequestLoginModelsToJson(DoctorRequestLoginModels data) =>
json.encode(data.toJson());
class DoctorRequestLoginModels {
DoctorRequestLoginModels({
required this.code,
required this.username,
required this.password,
});
String code;
String username;
String password;
factory DoctorRequestLoginModels.fromJson(Map<String, dynamic> json) =>
DoctorRequestLoginModels(
code: json["code"],
username: json["username"],
password: json["password"],
);
Map<String, dynamic> toJson() => {
"code": code,
"username": username,
"password": password,
};
}
</code></pre>
<p><strong>This is my Response Models class which I need to display in text</strong></p>
<pre><code>DoctorResponseLoginModels doctorResponseLoginModelsFromJson(String str) =>
DoctorResponseLoginModels.fromJson(json.decode(str));
String doctorResponseLoginModelsToJson(DoctorResponseLoginModels data) =>
json.encode(data.toJson());
class DoctorResponseLoginModels {
DoctorResponseLoginModels({
this.doctorId,
this.nmCno,
this.doctorName,
this.contactNo,
this.username,
this.emailId,
this.strEmail,
this.id,
this.intMobile,
this.gender,
this.currentAddress,
this.depId,
this.entryDate,
this.password,
this.code,
this.isActive,
this.hospitalName,
this.department,
this.deviceId,
this.profile,
this.token,
this.role,
});
int? doctorId;
String? nmCno;
String? doctorName;
String? contactNo;
dynamic? username;
String? emailId;
String? strEmail;
int? id;
String? intMobile;
dynamic? gender;
String? currentAddress;
int? depId;
String? entryDate;
dynamic? password;
dynamic? code;
bool? isActive;
dynamic? hospitalName;
dynamic? department;
dynamic? deviceId;
String? profile;
String? token;
String? role;
factory DoctorResponseLoginModels.fromJson(Map<String, dynamic> json) =>
DoctorResponseLoginModels(
doctorId: json["doctorID"],
nmCno: json["nmCno"],
doctorName: json["doctorName"],
contactNo: json["contactNo"],
username: json["username"],
emailId: json["emailID"],
strEmail: json["strEmail"],
id: json["id"],
intMobile: json["intMobile"],
gender: json["gender"],
currentAddress: json["currentAddress"],
depId: json["depId"],
entryDate: json["entryDate"],
password: json["password"],
code: json["code"],
isActive: json["isActive"],
hospitalName: json["hospitalName"],
department: json["department"],
deviceId: json["deviceId"],
profile: json["profile"],
token: json["token"],
role: json["role"],
);
Map<String, dynamic> toJson() => {
"doctorID": doctorId,
"nmCno": nmCno,
"doctorName": doctorName,
"contactNo": contactNo,
"username": username,
"emailID": emailId,
"strEmail": strEmail,
"id": id,
"intMobile": intMobile,
"gender": gender,
"currentAddress": currentAddress,
"depId": depId,
"entryDate": entryDate,
"password": password,
"code": code,
"isActive": isActive,
"hospitalName": hospitalName,
"department": department,
"deviceId": deviceId,
"profile": profile,
"token": token,
"role": role,
};
}
</code></pre>
<p><strong>This is where I am using Future Builder to display in Text</strong></p>
<pre><code>return Scaffold(
backgroundColor: const Color.fromRGBO(249, 249, 249, 10),
body: Column(
children: [
Expanded(
child: Container(
height: 150.0,
width: 150.0,
color: Colors.grey.shade100,
child: FutureBuilder<DoctorResponseLoginModels>(
future: APIService().register(DoctorRequestLoginModels(
code: "code", username: "username", password: "password")),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Text('Loading....');
default:
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
DoctorResponseLoginModels data = snapshot.data!;
return Column(
children: [
Text(data.doctorName!),
],
);
}
}
},
),
)),
],
));
</code></pre>
<p><strong>And this is the image of response I get in my console after I use post method and this is the response which I need to display in my text widgets</strong></p>
<p><a href="https://i.stack.imgur.com/VCWHo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VCWHo.png" alt="And this is the image of response I get in my console after I use post method and this is the response which I need to display in my text widgets " /></a></p>
| [
{
"answer_id": 74214916,
"author": "wikke",
"author_id": 20037581,
"author_profile": "https://Stackoverflow.com/users/20037581",
"pm_score": 0,
"selected": false,
"text": "import rdkit\nfrom rdkit import Chem\ndef get_atom_chars(smi):\n atoms_chars=[]\n mol = Chem.MolFromSmiles(smi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19717967/"
] |
74,205,390 | <pre><code>class One:
def __init__(self):
self.one = 1
class Two:
def __init__(self):
self.two = 2
class Three(One, Two):
def __init__(self):
self.three = 3
super().__init__()
obj = Three()
print(obj.one)
print(obj.two)
print(obj.three)
</code></pre>
<p>i am currently self learning OOP, i am having a hard time understanding why the object was able to print the attribute from Class One but not also the one from Class Two despite me using the super function, the error raised is <code>AttributeError: 'Three' object has no attribute 'two'</code>. How do we inherit from multiple classes?</p>
| [
{
"answer_id": 74214916,
"author": "wikke",
"author_id": 20037581,
"author_profile": "https://Stackoverflow.com/users/20037581",
"pm_score": 0,
"selected": false,
"text": "import rdkit\nfrom rdkit import Chem\ndef get_atom_chars(smi):\n atoms_chars=[]\n mol = Chem.MolFromSmiles(smi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19792349/"
] |
74,205,394 | <p>I have a svelte store that has the following code</p>
<pre><code>import { writable } from "svelte/store";
import { onMount, onDestroy } from "svelte";
export const modalStore = () => {
const { subscribe, update } = writable({
showModal: false,
});
onMount(() => {
window.addEventListener("keydown", handleKeyDown);
});
onDestroy(() => {
window.removeEventListener("keydown", handleKeyDown);
});
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
update(stateObj => ({...stateObj, showModal: false}));
}
}
return {
subscribe,
openModal: () => update(stateObj => ({ ...stateObj, modal: true })),
closeModal: () => update(stateObj => ({ ...stateObj, modal: false })),
handleKeyDown,
}
}
</code></pre>
<p><strong>Edit</strong></p>
<p>I have accessed the store by the following code</p>
<pre><code>let modalState = modalStore();
</code></pre>
<p>Then checked the state by <strong>$modalState</strong> and the accessed the function by modalStore.openModal();</p>
<p>It throws 500 error with - window is not defined</p>
<p>How can I solve it?</p>
| [
{
"answer_id": 74208734,
"author": "jeff",
"author_id": 7065562,
"author_profile": "https://Stackoverflow.com/users/7065562",
"pm_score": 0,
"selected": false,
"text": "export const modalStore = () => {\n const { subscribe, update } = writable({\n showModal: false,\n });\n\n... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7065562/"
] |
74,205,398 | <pre><code>sum = []
def s(d):
d = list[int]
sum = []
for i in d:
sum += i
return(sum)
s([1, 2, 3])
</code></pre>
<p>Python gives me the following message:
<code>TypeError: 'type' object is not iterable.</code></p>
<p>How can I make the code work?</p>
| [
{
"answer_id": 74428327,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "int"
},
{
"answer_id": 74428443,
"author": "Dmitry Anfimov",
"author_id": 16706319,
"author_profile": "ht... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19796395/"
] |
74,205,420 | <p>I am building a DataGrid with DataGridTemplateColumns. The CellTemplate is created as DataTemplate in XAML:</p>
<pre><code><DataTemplate x:Key="StringCell">
<Grid DataContext="{Binding Path=Cells.Values[3]}">
<TextBlock Text="{Binding Path=AttributeValue.ObjectValue, Mode=OneWay}"
TextWrapping="Wrap"/>
</Grid>
</DataTemplate>
</code></pre>
<p>This is actually working, but I want to set the DataContext of the Grid in code when creating the Column. I tried this:</p>
<pre><code>DataTemplate dt = cellTemplates["StringCell"] as DataTemplate;
(dt.LoadContent() as Grid).SetBinding(DataContextProperty, new Binding("Cells.Values[3]") { Mode = BindingMode.OneWay });
DataGridTemplateColumn dataGridTemplateColumn = new DataGridTemplateColumn()
{
CellTemplate = dt
};
</code></pre>
<p>but it's not working because LoadContent creates a new instance and doesn't change the template. Is there a way to set the DataContext in code?</p>
| [
{
"answer_id": 74207333,
"author": "EldHasp",
"author_id": 13349759,
"author_profile": "https://Stackoverflow.com/users/13349759",
"pm_score": 1,
"selected": false,
"text": "namespace Core2022.SO.ottoKranz\n{\n public class SomeClass\n {\n public SomeItem[]? Cells { get; set... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9669454/"
] |
74,205,433 | <p>$headerTitles has 4 values, but i always receive value with "1" index... Why?</p>
<pre><code>`<xsl:variable name="tgroup" select="../../.."/>
<xsl:variable name="colspecs" select="$tgroup/colspec"/>
<xsl:variable name="headerTitles" select="$tgroup/thead/row/entry"/>
<xsl:variable name="columnNumber">
<xsl:call-template name="entry.getColspecAttributeValue">
<xsl:with-param name="colspecs" select="$colspecs" />
<xsl:with-param name="attrName">colNum</xsl:with-param>
<xsl:with-param name="isLastEmpty">false</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:attribute name="columnName">
**<xsl:value-of select="$headerTitles[$columnNumber]"/>**
</xsl:attribute>`
</code></pre>
<p>$headerTitles has 4 values, but i always receive value with "1" index... Why?</p>
| [
{
"answer_id": 74205865,
"author": "michael.hor257k",
"author_id": 3016153,
"author_profile": "https://Stackoverflow.com/users/3016153",
"pm_score": 1,
"selected": false,
"text": "<xsl:value-of select=\"$headerTitles[3]\"/>\n"
},
{
"answer_id": 74221812,
"author": "Martin Hon... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16554654/"
] |
74,205,441 | <p>I have Implemented a bottomTab Navigation in my App. I got this error</p>
<pre><code>Error: Text strings must be rendered within a <Text> component.
This error is located at:
in BottomTabBar (at SceneView.tsx:132)
in StaticContainer
in StaticContainer (at SceneView.tsx:125)
in EnsureSingleNavigator (at SceneView.tsx:124)
in SceneView (at useDescriptors.tsx:217)
in RCTView (at View.js:34)
in View (at CardContainer.tsx:281)
</code></pre>
<p>I have tried to solve this issue but i unable to solve this issue. because i unable to understand that , This error is related to code OR node modules. Please suggest the solution.</p>
<pre><code>const BottomTabBar = (tabProps) => (
<>
{bottomTabData.tabs && bottomTabData.tabs.length && (
<BottomTab.Navigator
tabBarOptions={{
safeAreaInset: { bottom: 'never', top: 'never' },
}}
lazy
// eslint-disable-next-line react/jsx-props-no-spreading
tabBar={(props) => <BottomTabComp {...props} tabsData={bottomTabData} />}
initialRouteName={bottomTabData && bottomTabData.tabs && bottomTabData.tabs[(notifyData && notifyData.bottom_tab_index) || bottomTabData.highlighted_tab_index].title}
// initialRouteName={bottomTabData && bottomTabData.tabs && bottomTabData.tabs[2].title}
>
{bottomTabData.tabs && bottomTabData.tabs.length && bottomTabData.tabs.map((tab) => (
<BottomTab.Screen
key={tab.id}
name={tab.title}
initialParams={{
data: tabProps.route && tabProps.route.params && tabProps.route.params.data,
notifyData,
}}
component={tab && tab.page_type === 'DISCOVER' ? DiscoverStack : tab.page_type === 'NOTIFICATION' ? NotificationTabStack : HomeStack}
/>
))}
</BottomTab.Navigator>
)}
</>
);
</code></pre>
| [
{
"answer_id": 74205865,
"author": "michael.hor257k",
"author_id": 3016153,
"author_profile": "https://Stackoverflow.com/users/3016153",
"pm_score": 1,
"selected": false,
"text": "<xsl:value-of select=\"$headerTitles[3]\"/>\n"
},
{
"answer_id": 74221812,
"author": "Martin Hon... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14072690/"
] |
74,205,461 | <p>I've got the following structure of classes and I want my generic side to be able to access these two lists but I cannot get the conversion to work. I've tried various permutations of type guards and cast<> calls.</p>
<pre><code>abstract class B {}
class X : B {}
class Y : B {}
class MyList<T> : List<T> where T : B {}
class Data
{
MyList<X> XList;
MyList<Y> YList;
MyList<T> GetList<T>() where T : B
{
if (typeof(T) == typeof(X))
return (MyList<T>)XList;
if (typeof(T) == typeof(Y))
return (MyList<T>)YList;
return new MyList<T>() { };
}
}
</code></pre>
<p>Pretty much the only constraint for all of this is that Data needs to be able to be loaded from a Blazor <code>appsettings.json</code> <em>somehow</em>. Currently the structure looks like this:</p>
<pre><code>{
"Configs": {
"XList": [
{
"Name": "X1",
// more data
},
{
"Name": "X2",
// more data
},
{
"Name": "X3",
// more data
}
],
"YList": [
{
"Name": "Y1",
// more data
},
{
"Name": "Y2",
// more data
}
]
},
}
</code></pre>
| [
{
"answer_id": 74205865,
"author": "michael.hor257k",
"author_id": 3016153,
"author_profile": "https://Stackoverflow.com/users/3016153",
"pm_score": 1,
"selected": false,
"text": "<xsl:value-of select=\"$headerTitles[3]\"/>\n"
},
{
"answer_id": 74221812,
"author": "Martin Hon... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/362432/"
] |
74,205,493 | <p>I tried to run bash script which is like that :</p>
<pre><code>#!/bin/bash
export LD_LIBRARY_PATH=X ## censored
export PATH=$PATH:$LD_LIBRARY_PATH
CONNECTION='X' ## censored
echo $CONNECTION
RETVAL=`sqlplus -silent $CONNECTION <<EOF
SET PAGESIZE 50 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT 'Alive' FROM dual;
EXIT;
EOF`
echo $RETVAL
if [ "$RETVAL" = "Alive" ];
then
echo 'Database is running.'
exit 1
else
echo 'Database is NOT running.'
fi
exit
</code></pre>
<p>When I run this sh result is like that :</p>
<pre><code>sh checkdbstatus.sh
X
Alive
Database is NOT Running.
</code></pre>
<p>Why result is not Database is running ?</p>
<p>$RETVAL and Alive are equal ? And I am sure db is running.</p>
<p>Thank you</p>
<p>I expect to see result is Database is running.</p>
| [
{
"answer_id": 74209450,
"author": "sinclair",
"author_id": 2315162,
"author_profile": "https://Stackoverflow.com/users/2315162",
"pm_score": -1,
"selected": false,
"text": "sqlplus"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19471663/"
] |
74,205,511 | <p>I have an object with several keys and values, I would like to add its values to inputs corresponding to the key of the object. But I want to do this dynamically and generically using a method of array (<code>forEach</code>) in a two line code.</p>
<p>My object:</p>
<pre class="lang-js prettyprint-override"><code>const createNewBill = {
type: "Hôtel et logement",
name: "bill test",
date: "2020-04-08",
amount: 130,
pct: 25,
file: 'hotel.jpg'
}
</code></pre>
<p>I found this way but it is not dynamic and scalable :</p>
<pre class="lang-js prettyprint-override"><code>document.getByTestId("expense-type").value = createNewBill.type
document.getByTestId("expense-name").value = createNewBill.name
document.getByTestId("datepicker").value = createNewBill.datepicker
document.getByTestId("amount").value = createNewBill.amount
document.getByTestId("pct").value = createNewBill.pct
document.getByTestId("file").value = createNewBill.file
</code></pre>
| [
{
"answer_id": 74209450,
"author": "sinclair",
"author_id": 2315162,
"author_profile": "https://Stackoverflow.com/users/2315162",
"pm_score": -1,
"selected": false,
"text": "sqlplus"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17976831/"
] |
74,205,524 | <p>I am new to the Terraform world. I have started working on IaC for Azure using TF.</p>
<p>I have below three queries regarding using TF:</p>
<ol>
<li>In case the state file gets accidentally deleted, is there a way to recover/recreate the state file from the current state of the Azure resources?</li>
<li>In the case of Azure, if one makes some direct changes to the Azure resources from the Azure portal, is there a way to retrofit those changes automatically into the Terraform .tf or state files?</li>
<li>Is there a way to generate terraform files for any existing Azure resources created directly from the portal?</li>
</ol>
| [
{
"answer_id": 74205817,
"author": "Nuno Oliveira",
"author_id": 20241541,
"author_profile": "https://Stackoverflow.com/users/20241541",
"pm_score": 0,
"selected": false,
"text": "terraform import"
},
{
"answer_id": 74207343,
"author": "Mark B",
"author_id": 13070,
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/363170/"
] |
74,205,545 | <p>I have a program that asks me for 5 numbers and then prints the minimum. But now, I need a program that writes the minimum and the second minimum.</p>
<pre class="lang-py prettyprint-override"><code>train=[]
min=100
for i in range(5):
train.append(int(input("Enter a number")))
for carriage in train:
if min>carriage:
min=carriage
print("Minimum is ",min)
</code></pre>
<p>Can somebody please help me?</p>
| [
{
"answer_id": 74205754,
"author": "Kaktuts",
"author_id": 17072352,
"author_profile": "https://Stackoverflow.com/users/17072352",
"pm_score": 2,
"selected": true,
"text": "train=[]\nmin1 = 100 #only 100, u sure?\nmin2 = 100\nfor i in range(5):\n train.append(int(input(\"Enter a numbe... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16988396/"
] |
74,205,558 | <p>I'm working on a project which uses Quarkus to spin up a few REST endpoints. I have multiple integration tests which run with different test profiles or completely without a test profile. Heres an example:</p>
<pre><code>@QuarkusTest
@Tag("integration")
@TestProfile(SomeProfile::class)
class IntegrationTestWithSomeProfile {
@Test
fun someTest() { ... }
}
@QuarkusTest
@Tag("integration")
class IntegrationTestWithoutProfile {
@Test
fun someTest() { ... }
}
</code></pre>
<p>Now I would like to execute a piece of code before the first test runs (or after the last test has finished). The problem is that @BeforeAll can only be used per class and I can't use Quarkus' start and stop events since Quarkus is started and shutdown multiple times - once for each different test profile.</p>
<p>Is there any hook (or hack - i don't mind dirty stuff as long as it works) which I could use, which would execute only once at the very beginning?</p>
| [
{
"answer_id": 74206271,
"author": "Bruno Baptista",
"author_id": 6935180,
"author_profile": "https://Stackoverflow.com/users/6935180",
"pm_score": 1,
"selected": false,
"text": "@QuarkusTestResource"
},
{
"answer_id": 74222961,
"author": "xxtesaxx",
"author_id": 1708462,... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1708462/"
] |
74,205,580 | <p><a href="https://i.stack.imgur.com/YmHrU.png" rel="nofollow noreferrer">enter image description here</a>I am a beginner and i am trying to add and remove menuItem dynamically.
Here is my MainActivity.kt
I have two popups where in one popup i am asking for first name, last name, email, phone number.
and in second popup i am asking for an otp which is hardcoded to "1". After entering "1" as OTP signUp and logIn menuItem should be removed and Orders,Cart,Profile,Logout menuItems should appears.
But someHow it is not happening
Please help me!</p>
<pre><code>package com.example.gobikes
import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.*
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.cardview.widget.CardView
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.example.gobikes.models.searchInputs
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.drawableLayout
import kotlinx.android.synthetic.main.signup_popup.*
import java.io.Serializable
import java.text.SimpleDateFormat
import java.util.*
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
private var drawerLayout: DrawerLayout? = null
private var actionBarDrawerToggle: ActionBarDrawerToggle? = null
private var popupView: View? = null
private var popupWindow: PopupWindow? = null
private var myMenu: Menu? = null
public var LOGIN_FLAG: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
drawerLayout = drawableLayout
actionBarDrawerToggle = ActionBarDrawerToggle(this,drawerLayout,customToolbar,R.string.open,R.string.close)
drawerLayout!!.addDrawerListener(actionBarDrawerToggle!!)
actionBarDrawerToggle!!.syncState()
setSupportActionBar(customToolbar)
supportActionBar!!.title = ""
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
navigationView.setNavigationItemSelectedListener(this);
}
fun onClickSignUpButton(view: View){
if(signupNullCheck()){
val signUp = popupView!!.findViewById<View>(R.id.signUpCardView) as CardView
val signUpOTP = popupView!!.findViewById<View>(R.id.signUpOTPCardView) as CardView
signUp.visibility = View.GONE
signUpOTP.visibility = View.VISIBLE
}
else{
Toast.makeText(this, "Please provide valid inputs", Toast.LENGTH_LONG).show()
}
}
fun onClickVerifyButton(view: View){
val otp = popupView!!.findViewById<View>(R.id.OTPBox) as EditText
if(otp.text!!.isNotEmpty()){
if(otp.text!!.toString() == "1"){
LOGIN_FLAG = true
popupWindow!!.dismiss()
invalidateOptionsMenu()
}
else{
Log.e("OTP", otp.text.toString())
Log.e("OTP", otp.text.toString().trim())
Toast.makeText(this, "Incorrect OTP. Try Again", Toast.LENGTH_LONG).show()
}
}
else{
Toast.makeText(this, "Please enter OTP", Toast.LENGTH_LONG).show()
}
}
private fun signupNullCheck(): Boolean{
val firstName = popupView!!.findViewById<View>(R.id.firstNameBox) as EditText
val lastName = popupView!!.findViewById<View>(R.id.lastNameBox) as EditText
val email = popupView!!.findViewById<View>(R.id.emailBox) as EditText
val phoneNumber = popupView!!.findViewById<View>(R.id.phoneNumberBox) as EditText
return firstName.text!!.isNotEmpty() && lastName.text!!.isNotEmpty() && email.text!!.isNotEmpty() && phoneNumber.text!!.isNotEmpty()
}
private fun showSignupPopup(view: View){
// inflate the layout of the popup window
val inflater:LayoutInflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
popupView = inflater.inflate(R.layout.signup_popup, null)
// create the popup window
val width = LinearLayout.LayoutParams.MATCH_PARENT
val height = LinearLayout.LayoutParams.WRAP_CONTENT
val focusable = true
// show the popup window
// which view you pass in doesn't matter, it is only used for the window token
popupWindow = PopupWindow(popupView, width,height, focusable)
popupWindow!!.showAtLocation(view, Gravity.CENTER, 0,0)
}
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
menu!!.removeItem(R.id.loginMenu)
menu.removeItem(R.id.signUpMenu)
var cartMenu = menu!!.add(Menu.NONE, R.id.cartMenu,2, "Cart")
cartMenu.setIcon(R.drawable.ic_cart_menu_icon)
var profileMenu = menu.add(Menu.NONE, R.id.profileMenu,3, "Profile")
profileMenu.setIcon(R.drawable.ic_profile_menu_icon)
var ordersMenu = menu.add(Menu.NONE, R.id.ordersMenu,4, "Order")
ordersMenu.setIcon(R.drawable.ic_order_menu_icon)
var logoutMenu = menu.add(Menu.NONE, R.id.logoutMenu,5, "Logout")
logoutMenu.setIcon(R.drawable.ic_logout_menu_icon)
return super.onPrepareOptionsMenu(menu)
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
when(item.itemId){
R.id.signUpMenu -> showSignupPopup(navigationView)
}
drawableLayout.closeDrawer(GravityCompat.START)
return true
}
}
</code></pre>
| [
{
"answer_id": 74206271,
"author": "Bruno Baptista",
"author_id": 6935180,
"author_profile": "https://Stackoverflow.com/users/6935180",
"pm_score": 1,
"selected": false,
"text": "@QuarkusTestResource"
},
{
"answer_id": 74222961,
"author": "xxtesaxx",
"author_id": 1708462,... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8719925/"
] |
74,205,592 | <p>I have a query that orders the result by a specific none-unique column. Now I want to get the first <code>N</code> rows after a specific ID (the primary key).</p>
<p>I have a table similar to this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>8</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>10</td>
</tr>
<tr>
<td>5</td>
<td>7</td>
</tr>
</tbody>
</table>
</div>
<p>Now I order it by the Size (and ID to make the order stable) like this:</p>
<pre class="lang-sql prettyprint-override"><code>SELECT * FROM FOO
ORDER BY Size ASC, ID ASC;
</code></pre>
<p>which results in:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>8</td>
</tr>
<tr>
<td>4</td>
<td>10</td>
</tr>
</tbody>
</table>
</div>
<p>now I want the first 3 elements after the row where <code>ID == 2</code> so the result should be:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>8</td>
</tr>
</tbody>
</table>
</div>
<p>I tried:</p>
<pre class="lang-sql prettyprint-override"><code>SELECT *
FROM foo
WHERE Size > (SELECT size FROM foo WHERE ID = 2)
ORDER BY Size ASC, ID ASC
LIMIT 3;
</code></pre>
<p>which results in:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>8</td>
</tr>
<tr>
<td>4</td>
<td>10</td>
</tr>
</tbody>
</table>
</div>
<p>I also tried:</p>
<pre class="lang-sql prettyprint-override"><code>SELECT *
FROM foo
WHERE Size >= (SELECT size FROM foo WHERE ID = 2)
ORDER BY Size ASC, ID ASC
LIMIT 3;
</code></pre>
<p>which results in:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>5</td>
<td>7</td>
</tr>
</tbody>
</table>
</div>
<p>I can't figure out how to get the expected result.</p>
| [
{
"answer_id": 74205695,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": false,
"text": "WHERE"
},
{
"answer_id": 74208783,
"author": "forpas",
"author_id": 10498828,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15125036/"
] |
74,205,599 | <p>I need a regex in which -</p>
<ol>
<li>No lowercase letters</li>
<li>No leading or trailing whitespace</li>
<li>Length should be less than or equal to 18</li>
</ol>
<p>I tried</p>
<pre><code>^[^\s][A-Z0-9\W]{0,18}
</code></pre>
| [
{
"answer_id": 74205695,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": false,
"text": "WHERE"
},
{
"answer_id": 74208783,
"author": "forpas",
"author_id": 10498828,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14532702/"
] |
74,205,602 | <p>Given the following setup how do I make the inherited <code>producerId</code> field be <code>updatable = false, insertable = false</code> from within <code>Book</code>.</p>
<pre class="lang-java prettyprint-override"><code>@MappedSuperclass
public class StockItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "producer_id")
private Integer producerId;
}
@Entity
public class Producer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "name")
private Integer name;
}
@Entity
@Table(name = "stock_item")
public class Book extends StockItem {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "producer_id")
private Producer producer;
// make inherited producerId field updatable = false, insertable = false here
}
</code></pre>
<p>I specifically do NOT want to do the following as I need that property to stay updatable and insertable for other inheritors:</p>
<pre class="lang-java prettyprint-override"><code>@MappedSuperclass
public class StockItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "producer_id", updatable = false, insertable = false)
private Integer producerId;
}
</code></pre>
<p>UPDATE: another constraint is that all classes extending the @MappedSuperclass represent the same table</p>
| [
{
"answer_id": 74205695,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": false,
"text": "WHERE"
},
{
"answer_id": 74208783,
"author": "forpas",
"author_id": 10498828,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12302982/"
] |
74,205,668 | <p><strong>What i want to achieve:</strong> Let say that i have a physical cluster consist of 20 worker nodes, and the customer want to rollout a new version of an docker-image to DaemonSet. But, the costumer does not want to rollout to the entire cluster, they want to dedicate the update to just 3 nodes "pilot" nodes. We use keel to automatically update the image. Is there a way to just update these pilots with the new image, and let the other 17 nodes use the "old" image?</p>
<p>We have a k8s cluster with a DeamonSet with nodeSelector=worker that "installs" a pod with a specific container. I don't see how i can achieve this without using two different DeamonSets. Is there any solution to this problem i have.</p>
<p>I don't really know how to tackle this at all and have search the internet for some solutions. But could not find anything.</p>
| [
{
"answer_id": 74205695,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": false,
"text": "WHERE"
},
{
"answer_id": 74208783,
"author": "forpas",
"author_id": 10498828,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20337975/"
] |
74,205,672 | <p>This function returns a closure. Using <code>impl Fn()</code> as the closure type is OK:</p>
<pre><code>fn foo() -> impl Fn() {
|| ()
}
</code></pre>
<p>But this won't work:</p>
<pre><code>fn foo<T: Fn()>() -> T {
|| ()
}
</code></pre>
<p>Nor this:</p>
<pre><code>fn foo<T>() -> T
where
T: Fn(),
{
|| ()
}
</code></pre>
<p>Why do the last two examples not work?</p>
| [
{
"answer_id": 74205743,
"author": "Peter Hall",
"author_id": 493729,
"author_profile": "https://Stackoverflow.com/users/493729",
"pm_score": 4,
"selected": true,
"text": "T"
},
{
"answer_id": 74205749,
"author": "Aleksander Krauze",
"author_id": 13078067,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20312298/"
] |
74,205,680 | <p>I'm trying the code below:</p>
<pre><code>Erick = input ("Kobia, what's ur favourite team ?")
print (" ")
if Erick.upper() == "manchester city":
print ('All hail Pep.')
print ('Heri nyinyi kuliko Man united,')
print ('Liverpool have been awful this season.')
else:
print ('Arsenal gladly sit on top of the table.')
print (" ")
</code></pre>
<p>When I input the string <code>'manchester city'</code>, the code only prints out the '<code>else</code>' part of the function</p>
<p>Whatever I type in, the code prints out the '<code>else</code>' part of the function</p>
<p>What might the problem be ?</p>
| [
{
"answer_id": 74205743,
"author": "Peter Hall",
"author_id": 493729,
"author_profile": "https://Stackoverflow.com/users/493729",
"pm_score": 4,
"selected": true,
"text": "T"
},
{
"answer_id": 74205749,
"author": "Aleksander Krauze",
"author_id": 13078067,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20244277/"
] |
74,205,722 | <p>i have a table named 'balance' like this</p>
<pre><code>user_id date transaction_amount
123 2021-08-30 1000
123 2021-08-31 500
456 2021-09-30 -750
789 2021-09-30 50
</code></pre>
<p>i need to know total buy/sell/net transaction on monthly level (end-of-period/eop)
which :</p>
<pre><code>buy = transaction > 0
sell = transaction < 0
net = total buy = total sell
</code></pre>
<p>how to write the code?</p>
<p>so far i've tried</p>
<pre><code>eop_trans = df_balance.groupby([df_balance['user_id'], df_balance['date'].dt.to_period('M')])['transaction_amount'].sum()
eop_trans
</code></pre>
<p>that code only return total amount of transaction per user_id per month</p>
<p>anyone can help? thank you very much</p>
| [
{
"answer_id": 74205743,
"author": "Peter Hall",
"author_id": 493729,
"author_profile": "https://Stackoverflow.com/users/493729",
"pm_score": 4,
"selected": true,
"text": "T"
},
{
"answer_id": 74205749,
"author": "Aleksander Krauze",
"author_id": 13078067,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20236691/"
] |
74,205,747 | <p>The site has a window (done with <code>Dialog mui</code>) that opens to get information (Device with id {} is at the user's) .
There is a static text in this window (which is always present) and I want to finish off the text (in my case ID), which will change depending on the data.</p>
<p>My data is stored in the <code>selectedItem</code> object. But here the problem is, when the window (<code>Dialog mui</code>) is closed, then <code>selectedItem === null</code>.</p>
<p>Please tell me how to get ID correctly</p>
<pre><code>export default function Table() {
const records = useRecords(firestore)
const [selectedItem, setSelectedItem] = useState();
const handleClose = () => {
setSelectedItem(null);
}
return (
<div>
<Dialog open={!!selectedItem} onClose={handleClose}>
Device with id {} is at the user's
</Dialog>
{records.map((record) =>
<TableCell record={record}
onDeleteButtonPress={() => setSelectedItem(record)}
key={record.id} />)}
</div>
)
}
</code></pre>
| [
{
"answer_id": 74205795,
"author": "Dirk jnr Odendaal",
"author_id": 9816682,
"author_profile": "https://Stackoverflow.com/users/9816682",
"pm_score": 0,
"selected": false,
"text": "setSelectedItem(null) \n"
},
{
"answer_id": 74205922,
"author": "Nick Vu",
"author_id": 92... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17122431/"
] |
74,205,759 | <p>I have an ASP.NET Core API that reads in config from a appsettings.json file. This is ran as a Windows service and can be installed/uninstalled. This means that updating will overwrite the appsettings.json file. To solve this, I want to be able to create a appsettings.custom.json, that contains only the settings from appsettings.json that I want a different value for. So basically this appsettings.custom.json file should overrule the settings from appsettings.json. I've been playing around, but the settings that are used are always from appsettings.json, it basically ignores the appsettings.custom.json.</p>
<pre><code>
private const string CustomAppSettingsJson = "appsettings.custom.json";
private const string DefaultAppSettingsJson = "appsettings.json";
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(DefaultAppSettingsJson, optional: false, reloadOnChange: true)
.AddJsonFile(CustomAppSettingsJson, optional: true, reloadOnChange: true)
.Build();
</code></pre>
<p>Is something like this possible? Can I make some sort of hierarchic order in the files?</p>
<p>I tried switching the order of the adding of the json files, but without success.</p>
| [
{
"answer_id": 74205795,
"author": "Dirk jnr Odendaal",
"author_id": 9816682,
"author_profile": "https://Stackoverflow.com/users/9816682",
"pm_score": 0,
"selected": false,
"text": "setSelectedItem(null) \n"
},
{
"answer_id": 74205922,
"author": "Nick Vu",
"author_id": 92... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16934528/"
] |
74,205,784 | <p>In the code below, the userprinciplename will output strings like "LLL_John.Smith@email.com" and XXXX_Jane.Doe@email.com" but i am hoping to extract a substring from that, that being the codes before the "_" character, so LLL and XXXX.</p>
<p>There may be some which do not have an underscore character however and so these would need to be ignored / have the original string it would have returned.</p>
<pre><code>##Check bottom of script for setting specific OU
Function Get-LastLogon {
param(
[string]$OUName
)
# Get all matching OUs on any level
$OUs = Get-ADOrganizationalUnit -Filter "Name -like '$OUName'"
$DCs = Get-ADDomainController -Filter *
# Get all users from each OU from each DC
$ADUsers = Foreach ($OU in $OUs) {
Foreach ($DC in $DCs.HostName) {
Get-ADUser -SearchBase $OU.DistinguishedName -Filter * -Properties LastLogon -server $dc |
Select-Object Name,userPrincipalName, @{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}
}
}
# return most recent LastLogon date for each user
$ADUsers |
Group Name,userPrincipalName |
Select Name,userprinciplename, @{n='LastLogon';e={$_.Group.LastLogon | sort -desc | select -First 1}}
} ## End function
##Enter the OU here
Get-LastLogon -OUName 'Clients'
##Un-comment below to export to csv
## | Export-Csv -Path 'C:\temp\UserExport.csv'
</code></pre>
<p>Here is what the script looks like now in full:</p>
<pre><code>##Check bottom of script for setting specific OU
Function Get-LastLogon {
param(
[string]$OUName
)
# Get all matching OUs on any level
$OUs = Get-ADOrganizationalUnit -Filter "Name -like '$OUName'"
$DCs = Get-ADDomainController -Filter *
$ADUsers = foreach ($OU in $OUs) {
foreach ($dc in $DCs.HostName) {
Get-ADUser -SearchBase $OU.DistinguishedName -Filter * -Properties lastLogonTimeStamp -Server $dc |
Select-Object Name,UserPrincipalName,
@{Name = 'LastLogon';Expression = {[DateTime]::FromFileTime($_.lastLogonTimeStamp)}},
@{Name = 'UserCode'; Expression = {([regex]'^([^_]+)_.*').Match($_.UserPrincipalName).Groups[1].Value}}
}
} }
# return the most recent LastLogon date for each user
# (only the users with a code prefix in the UserPrincipalName)
$ADUsers | Where-Object { ![string]::IsNullOrWhiteSpace($_.UserCode) } |
Group-Object UserPrincipalName | ForEach-Object {
[PsCustomObject]@{
Name = $_.Group[0].Name
UserCode = $_.Group[0].UserCode
LastLogon = $_.Group.LastLogon | Sort-Object -Descending | Select-Object -First 1
}
}
## End function
$OUcustom = Read-Host -prompt 'Enter OU here or "Clients" for all'
##Enter the OU here
Get-LastLogon -OUName $OUcustom |
##export csv
Export-Csv -path "C:\temp\UserExport_$((Get-Date).ToString("ddMM_HHmm")).csv" -NoTypeInformation
".csv extracted to C:\temp"
pause
</code></pre>
| [
{
"answer_id": 74207379,
"author": "Theo",
"author_id": 9898643,
"author_profile": "https://Stackoverflow.com/users/9898643",
"pm_score": 1,
"selected": false,
"text": "$ADUsers = foreach ($OU in $OUs) {\n foreach ($dc in $DCs.HostName) {\n Get-ADUser -SearchBase $OU.Distinguis... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5581245/"
] |
74,205,789 | <p>How can i eliminate the duplicate inside the assets?</p>
<p>See the image, i need to eliminate the list with ID duplicate, where is the cross. I try with this map and filter, but the problem i lost the rest of the attribute, as a results i need to have the same structure but with out the duplicate id inside the assets[]</p>
<pre><code> let known = new Set();
let listArrayDoc = this.documentsfiltered.map(subarray => subarray['assets'].filter(item => !known.has(item.id) && known.add(item.id)));
[
{
"id": 198406,
"description": "4. Monitor, assess, discuss and report on the implementation of all Development Agenda Recommendations",
"additionalInfo": [],
"assets": [
{
"id": 22116,
"name": "Completion Report of the Development Agenda (DA) Project on Tools for Successful DA Project Proposals.",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22114,
"name": "Progress Reports – Ongoing Development Agenda Projects",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22122,
"name": "Progress Report on the Implementation of the 45 Development Agenda Recommendations",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
}
],
"refId": null
},
{
"id": 198407,
"description": "5. Consideration of work program for implementation of adopted recommendations",
"additionalInfo": [],
"assets": [
{
"id": 22115,
"name": "C Proposal by the African Group concerning the biennial organization of an International Conference on Intellectual Property and Development.",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22118,
"name": "CDImplementation of the Adopted Recommendations of the Independent Review – Updated Proposal by the Secretariat and Member States Inputs",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
}
],
"refId": null
},
{
"id": 198408,
"description": "4. Monitor, assess, discuss and report on the implementation of all Development Agenda Recommendations",
"additionalInfo": [],
"assets": [
{
"id": 22116,
"name": "Completion Report of the Development Agenda (DA) Project on Tools for Successful DA Project Proposals.",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22114,
"name": " Ongoing Development Agenda Projects",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22122,
"name": "Progress Report on the Implementation of the 45 Development Agenda Recommendations",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
}
],
"refId": null
}
]
</code></pre>
<p>RESULTS NEED TO BE:
the last assets empty</p>
<pre><code>[
{
"id": 198406,
"description": "4. Monitor, assess, discuss and report on the implementation of all Development Agenda Recommendations",
"additionalInfo": [],
"assets": [
{
"id": 22116,
"name": "Completion Report of the Development Agenda (DA) Project on Tools for Successful DA Project Proposals.",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22114,
"name": "Progress Reports – Ongoing Development Agenda Projects",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22122,
"name": "Progress Report on the Implementation of the 45 Development Agenda Recommendations",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
}
],
"refId": null
},
{
"id": 198407,
"description": "5. Consideration of work program for implementation of adopted recommendations",
"additionalInfo": [],
"assets": [
{
"id": 22115,
"name": "C Proposal by the African Group concerning the biennial organization of an International Conference on Intellectual Property and Development.",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
},
{
"id": 22118,
"name": "CDImplementation of the Adopted Recommendations of the Independent Review – Updated Proposal by the Secretariat and Member States Inputs",
"isActive": true,
"sizekb": null,
"isLocal": false,
"type": "FILE",
"url": ""
}
],
"refId": null
},
{
"id": 198408,
"description": "4. Monitor, assess, discuss and report on the implementation of all Development Agenda Recommendations",
"additionalInfo": [],
"assets": [],
"refId": null
}
]
</code></pre>
| [
{
"answer_id": 74207379,
"author": "Theo",
"author_id": 9898643,
"author_profile": "https://Stackoverflow.com/users/9898643",
"pm_score": 1,
"selected": false,
"text": "$ADUsers = foreach ($OU in $OUs) {\n foreach ($dc in $DCs.HostName) {\n Get-ADUser -SearchBase $OU.Distinguis... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2696767/"
] |
74,205,793 | <p>I'm faced with the following tuple containing several various datatypes:</p>
<pre><code>my_test_tuple = ( ["David", 3.14], [34, "Zak"], ["Colin", 54], [34, "Xerxes", True], ["Fred"] )
</code></pre>
<p>I need to sort it by the names alphabetically in descending order.</p>
<p>The output should look the following:</p>
<pre><code>print(sort_tuple (my_test_tuple))
(['Colin', 54], ['David', 3.14], ['Fred'], [34, 'Xerxes', True], [34, 'Zak'])
</code></pre>
<p>There are numerous resources on how to sort a tuple by the first position in the tuple, problem here is that not all the names are in the first position.</p>
<p>Any help on how to proceed would be appreciated!</p>
<p>Tried using lambda but it was only useful for when data types are stored in a specific position.</p>
| [
{
"answer_id": 74207379,
"author": "Theo",
"author_id": 9898643,
"author_profile": "https://Stackoverflow.com/users/9898643",
"pm_score": 1,
"selected": false,
"text": "$ADUsers = foreach ($OU in $OUs) {\n foreach ($dc in $DCs.HostName) {\n Get-ADUser -SearchBase $OU.Distinguis... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5251693/"
] |
74,205,801 | <p>I have a data frame containing 30 bacteria (columns), and the genes they have (rows). Values in the data frame are <strong>0</strong> if the bacteria lacks the gene, while values are <strong>1</strong> when bacteria have the gene.</p>
<p>I want to see which genes are common but still vary between the 30 bacteria and the genes that are rarely found.</p>
<p><code>cleansymbols3</code> is my data frame and I want to create a new data frame, <code>commonsymbols</code> that contains only genes that are found in at least 20, but not all, bacteria.</p>
<p>The line below selects genes that are common in 20 or more bacteria, but how do you set a range <code>20:29</code>?</p>
<pre class="lang-r prettyprint-override"><code>commonsymbols <- cleansymbols3[rowSums(cleansymbols3) >= 20, ]
</code></pre>
<p>I tried this line</p>
<pre><code>commonsymbols <- cleansymbols3[ which( rowSums(cleansymbols3) >= 20 | rowSums(cleansymbols3) <= 29 ), ]
</code></pre>
<p>but it selects all genes, probably because it first looks for <code>rowSums > 20</code> and then <code>rowSums < 29</code>, which together are all rows.</p>
| [
{
"answer_id": 74207379,
"author": "Theo",
"author_id": 9898643,
"author_profile": "https://Stackoverflow.com/users/9898643",
"pm_score": 1,
"selected": false,
"text": "$ADUsers = foreach ($OU in $OUs) {\n foreach ($dc in $DCs.HostName) {\n Get-ADUser -SearchBase $OU.Distinguis... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20337948/"
] |
74,205,847 | <p>While closures are powerful, they can lead to bugs if used carelessly. An example is a closure that modifies its captured variables when this is not wanted. Sometimes we only need an anonymous function that has no free variables. That is, it captures nothing. Can I specify a closure as capturing nothing and get this checked by the compiler? Something like <code>none |...| {...}</code> looks ideal. I know I can define a function in current scope but it's not as elegant as a variable containing an anonymous function.</p>
| [
{
"answer_id": 74206127,
"author": "prog-fh",
"author_id": 11527076,
"author_profile": "https://Stackoverflow.com/users/11527076",
"pm_score": 2,
"selected": false,
"text": "fnct2()"
},
{
"answer_id": 74206139,
"author": "Finomnis",
"author_id": 2902833,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20312298/"
] |
74,205,859 | <p>I am trying to initialize a static variable at runtime using <code>lazy_static</code> crate. But I'm getting <code>no rules expected the token E1</code> error while compiling. This is the link <a href="https://stackoverflow.com/questions/37405835/populating-a-static-const-with-an-environment-variable-at-runtime-in-rust">lazy_static</a> I followed</p>
<pre><code>use lazy_static::lazy_static;
lazy_static! {
static E1: f64 = (1.0 - f64::sqrt(1.5)) / (1.0 + f64::sqrt(0.5));
}
fn main() {
println!("{}", E1);
}
</code></pre>
| [
{
"answer_id": 74206127,
"author": "prog-fh",
"author_id": 11527076,
"author_profile": "https://Stackoverflow.com/users/11527076",
"pm_score": 2,
"selected": false,
"text": "fnct2()"
},
{
"answer_id": 74206139,
"author": "Finomnis",
"author_id": 2902833,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3938402/"
] |
74,205,860 | <p>I have copied a table with three columns from a pdf file. I am attaching the screenshot from the PDF here:</p>
<p><a href="https://i.stack.imgur.com/xQIx1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQIx1.png" alt="enter image description here" /></a></p>
<p>The values in the column <strong>padj</strong> are exponential values, however, when you copy from the pdf to an excel and then open it with pandas, these are strings or object data types. Hence, these values cannot be parsed as floats or numeric values. I need these values as floats, not as strings. Can someone help me with some suggestions?
So far this is what I have tried.</p>
<p>The excel or the <code>csv</code> file is then opened in python using the <code>escape_unicode</code> encoding in order to circumvent the <strong>UnicodeDecodeError</strong></p>
<pre><code>## open the file
df = pd.read_csv("S2_GSE184956.csv",header=0,sep=',',encoding='unicode_escape')[["DEGs","LFC","padj"]]
df.head()
DEGs padj LFC
0 JUNB 1.5 ×10-8 -1.273329
1 HOOK2 2.39×10-7 -1.109320
2 EGR1 3.17×10-6 -4.187828
3 DUSP1 3.95×10-6 -3.251030
4 IL6 3.95×10-6 -3.415500
5 ARL4C 5.06×10-6 -2.147519
6 NR4A2 2.94×10-4 -3.001167
7 CCL3L1 4.026×10-4 -5.293694
# Convert the string to float by replacing the x10- with exponential sign
df['padj'] = df['padj'].apply(lambda x: (unidecode(x).replace('x10-','x10-e'))).astype(float)
That threw an error,
ValueError: could not convert string to float: '1.5 x10-e8'
</code></pre>
<p>Any suggestions would be appreciated. Thanks</p>
| [
{
"answer_id": 74206127,
"author": "prog-fh",
"author_id": 11527076,
"author_profile": "https://Stackoverflow.com/users/11527076",
"pm_score": 2,
"selected": false,
"text": "fnct2()"
},
{
"answer_id": 74206139,
"author": "Finomnis",
"author_id": 2902833,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1017373/"
] |
74,205,868 | <pre><code>TextField(
keyboard Type: TextInputType.emailAddress,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide.none),
filled: true,
hintText: "Mot de passe",
prefixIcon: Icon(
Icons.lock,
color: Color(0xfff28800),
),
),
),
</code></pre>
<p>this is my code and I want to add the icon that control the show/hide password in flutter</p>
| [
{
"answer_id": 74205994,
"author": "Fugipe",
"author_id": 17626346,
"author_profile": "https://Stackoverflow.com/users/17626346",
"pm_score": 0,
"selected": false,
"text": "bool obscurePassword = true;\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n resi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183851/"
] |
74,205,872 | <p>Today I suddenly got error:</p>
<pre><code>Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
</code></pre>
<p>Out of nowhere. Invalidate cache & restart & clean does not work. Checkout to old version which 100% worked before, does not work.</p>
<p>Also already tried the solution from other thread:</p>
<pre><code>implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
</code></pre>
<p>Changed into this & clean & rebuild does not work, same error.</p>
<p>AndroidStudio Version is Bumblebee 2021.1.1
targetSDKVersion is 31, everything's fine until just now.</p>
<p>Thank you</p>
| [
{
"answer_id": 74217648,
"author": "Kartik Agarwal",
"author_id": 6952373,
"author_profile": "https://Stackoverflow.com/users/6952373",
"pm_score": 1,
"selected": false,
"text": "implementation 'androidx.appcompat:appcompat:1.4.2'\nimplementation 'com.google.android.material:material:1.6... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10439038/"
] |
74,205,880 | <p>Hello everyone I have a question regarding a parsing of string and this is the code I have so far:</p>
<pre><code>sentence =' '
while sentence != 'q':
sentence = input('Please enter your input: ').split(',')
if len(sentence) > 1:
print('First word: {sentence[0]}')
print('Second word: {sentence[1]}')
continue
elif len(sentence) == 1:
print('Error no comma.')
continue
elif sentence == 'q':
break
</code></pre>
<p>And the output will be if there is no comma inputted will give me the following:</p>
<pre><code> Enter input string:
Jill Allen
Error: No comma in string.
</code></pre>
<p>and it will keep on asking me for a string until I entered q for quit and the program exits as follows:</p>
<pre><code> Enter input string:
Jill, Allen
First word: Jill
Second word: Allen
Enter input string:
Golden , Monkey
First word: Golden
Second word: Monkey
Enter input string:
Washington,DC
First word: Washington
Second word: DC
Enter input string:
q
</code></pre>
<p>My problem is I am unable to quit the infinite loop. Can anyone help me on this? I think the program is unable to distinguish 'Jill Allen' from 'q' since both of them have len(sentence) == 1 and that is the problem as it gives me Error no comma and asked for an input over and over.</p>
| [
{
"answer_id": 74205975,
"author": "Ali",
"author_id": 19623776,
"author_profile": "https://Stackoverflow.com/users/19623776",
"pm_score": 0,
"selected": false,
"text": "q"
},
{
"answer_id": 74206006,
"author": "Olzhas",
"author_id": 18241248,
"author_profile": "https... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20245959/"
] |
74,205,905 | <p>I am having a weird issue where a setState is not setting the state correctly and I can't figure out why is this happening. I have a component that has a useState <code>batch</code> property and I have created an event listener in the useEffect that listens for the <code>test</code> event and adds it to the <code>batch</code> state property.</p>
<p>Unfortunately, it seems that even if I emit a couple of test events, they don't get saved in the batch property correctly. I imagine the fact that the setState is in an event listener has something to do with this</p>
<pre><code>const AnalyticsProvider= ({ children }) => {
const [batch, setBatch] = useState([]);
useEffect(() => {
Doorman.test((event) => setBatch((previousBatch) => [...previousBatch, event]));
}, [])
}
</code></pre>
| [
{
"answer_id": 74205975,
"author": "Ali",
"author_id": 19623776,
"author_profile": "https://Stackoverflow.com/users/19623776",
"pm_score": 0,
"selected": false,
"text": "q"
},
{
"answer_id": 74206006,
"author": "Olzhas",
"author_id": 18241248,
"author_profile": "https... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8618818/"
] |
74,205,930 | <p>Currently I am trying to understand Angular a bit better, especially under the hood. And I noticed that if I have Angular Router set up, and I am adding multiple selectors that these actualy get added. Because under the hood its all just 'ng-container' made by Angular Router.</p>
<p>I was wondering if someone has a bit more in-depth information about how this works? Because I don't realy understand how this is possible. According to angular the selector should be used to select HTML.</p>
<p>Kind regards</p>
<p>Edit: My question seemed to be unclear accoridng to MGX, so here is some more context then.</p>
<p>If you look at this sandbox:
<a href="https://codesandbox.io/s/angular-45-router-demo-forked-9d14bx?file=/src/app/product-list/product-list.component.ts" rel="nofollow noreferrer">https://codesandbox.io/s/angular-45-router-demo-forked-9d14bx?file=/src/app/product-list/product-list.component.ts</a></p>
<p>There is a product-list component. If I change the selector, the page breaks. Because angular wants me to put in a valid selector in the component decorator.</p>
<p>But if you look at this sandbox:
<a href="https://codesandbox.io/s/angular-45-router-demo-forked-h87emi?file=/src/app/product-list/product-list.component.ts" rel="nofollow noreferrer">https://codesandbox.io/s/angular-45-router-demo-forked-h87emi?file=/src/app/product-list/product-list.component.ts</a></p>
<p>There is a router involved, and when I put in a random class 'monkey' into the selector. It suddenly gets added, instead of a breaking page.</p>
<p>So the question is: How does the angular router does this? And why does this work? Why wont this break.</p>
| [
{
"answer_id": 74205975,
"author": "Ali",
"author_id": 19623776,
"author_profile": "https://Stackoverflow.com/users/19623776",
"pm_score": 0,
"selected": false,
"text": "q"
},
{
"answer_id": 74206006,
"author": "Olzhas",
"author_id": 18241248,
"author_profile": "https... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4428552/"
] |
74,205,934 | <p>I have a data set as following. To keep it simple I am showing only one column i.e qty but there are multiples for example (dates, prices etc). if any of the value within a single row is a mismatch then that row should show up as output along with the values from both sources, for example:</p>
<p>source 1</p>
<pre><code>id qty
1 100
2 null
3 0
4 50
</code></pre>
<p>source 2</p>
<pre><code>id_ qty_
1 100
2 80
3 100
</code></pre>
<p>expected output:</p>
<pre><code>id qty id_ qty_
2 null 2 80
3 0 3 100
4 50 null null
</code></pre>
<p>What i am trying to achieve is to fetch all the rows from source 2 that doesn't match with the source 1. Source 1 is taken as main source/table.</p>
<p>In the end the output should show only row 2,3,4 with both values so that i can build a boolean saying:</p>
<p>if (qty != qty_ , false, true) as is_qty_matching</p>
<p>An example with multiple values:</p>
<p>source 1</p>
<pre><code>id qty price
1 100 10
2 null 0
3 0 0
4 50 0
5 100 30
</code></pre>
<p>source 2</p>
<pre><code>id_ qty_ price
1 100 10
2 80 0
3 100 0
5 100 33
</code></pre>
<p>expected output:</p>
<pre><code> id qty price id_ qty_ price_
2 null 0 2 80 0
3 0 0 3 100 0
4 50 0 null null 0
5 100 30 5 100 33
</code></pre>
<p>In this case now id 5 has price mismatch</p>
<p>so my two new columns (is_price_matching) would show false for id 5 while true for other id', while the column (is_qty_matching) will show true for id 5 and false for others.</p>
<p>Similarly i will have multiple other columns and therefore multiple other boolean fields for each of the mismatch entry for example is_date_matching, is_time_matching etc.</p>
<p>what's important is that:</p>
<ul>
<li>The values can be null in either of source for any of the column, this might mess up the boolean maybe</li>
<li>only the rows that has even one single mismatch value should show up in the final output, if there is no mismatch in any of the column values it should not show up</li>
</ul>
<p>I have tried the following query:</p>
<pre><code>with main as (
select 1 as id , 100 as qty , 50 as price
union all
select 2 as id , 0 as qty , 100 as price
union all
select 3 as id , 0 as qty ,80 as price
union all
select 4 as id , 50 as qty , 90 as price
union all
select 5 as id , 20 as qty , 100 as price
union all
select 6 as id , 20 as qty , 100 as price
),
main2 as (
select 1 as id_, 100 as qty_ , 50 as price_
union all
select 2 as id_, 80 as qty_ , 100 as price_
union all
select 3 as id_, 100 as qty_ , 80 as price_
union all
select 5 as id_, 20 as qty_ , 100 as price_
union all
select 6 as id_, 20 as qty_ , 40 as price_
)
select
main.*,
main2.*
from main
left join main2
on (main.id = main2.id_)
WHERE coalesce(qty,0) != coalesce(qty_,0)
or coalesce(main.price,0) != coalesce(main2.price_,0)
</code></pre>
<p>it seems to work but i was wondering if there is a better solution ? plus if i add the following line of code</p>
<pre><code>if(qty != qty_ , true , false) as is_qty_mismatch
</code></pre>
<p>it will return incorrect output where the values are null</p>
| [
{
"answer_id": 74206447,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 0,
"selected": false,
"text": "ifnull"
},
{
"answer_id": 74207766,
"author": "Jaytiger",
"author_id": 19039920,
"author_profil... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12513693/"
] |
74,205,966 | <p>I have a react js web application project. I need to develop the same project as mobile application.</p>
<p>Can i convert my reactjs web application project to react-native mobile application project?</p>
<p>If it is yes, How can i do it?</p>
| [
{
"answer_id": 74206447,
"author": "AlienDeg",
"author_id": 4208407,
"author_profile": "https://Stackoverflow.com/users/4208407",
"pm_score": 0,
"selected": false,
"text": "ifnull"
},
{
"answer_id": 74207766,
"author": "Jaytiger",
"author_id": 19039920,
"author_profil... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17679327/"
] |
74,205,993 | <p>I have this table:</p>
<pre><code>MeasureId | Tag
----------------------
1 | CODE-ABC
1 | CODE-EFG
1 | CODE-HGT
2 | CODE-XXX
2 | CODE-YYY
</code></pre>
<p>given that each Measure has a maximum of 3 Tags what I need is</p>
<pre><code>MeasureId | Tag1 | Tag2 | Tag3
--------------------------------------------
1 | CODE-ABC | CODE-EFG | CODE-HGT
2 | CODE-XXX | CODE-YYY | <null>
</code></pre>
<p>i.e. I should group by MeasureId but I don't know how to access a single element using an index in the select part, something like this:</p>
<pre><code>SELECT MeasureId, Tag[0], Tag[1], Tag[2] FROM Measures GROUP BY MeasureId
</code></pre>
<p>So far I just came up with something like this:</p>
<pre><code>SELECT MeasureId, STRING_ADD(Tag, ',') as Tag FROM Measures GROUP BY MeasureId
</code></pre>
<p>resulting in this:</p>
<pre><code>MeasureId | Tag
--------------------------------------------
1 | CODE-ABC,CODE-EFG,CODE-HGT
2 | CODE-XXX,CODE-YYY
</code></pre>
<p>Is something doable in TSQL (Azure Sql)?</p>
| [
{
"answer_id": 74206352,
"author": "Sergey",
"author_id": 14535517,
"author_profile": "https://Stackoverflow.com/users/14535517",
"pm_score": 0,
"selected": false,
"text": "WITH TABLE_DATA(MeasureId,Tag) AS\n(\n SELECT 1 , 'CODE-ABC' UNION ALL\n SELECT 1 , 'CODE-EFG'UNI... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74205993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1113681/"
] |
74,206,005 | <p>I'm not a native Excel user (much more of a SQL man) and I have the following scenario that is doing my head in. Mainly because I'm sure it's relatively simple, but because I'm not super-familiar with all the advanced functions of Excel.</p>
<p>I have a 2 sheets in question.</p>
<p>Sheet One has the following columns:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>SKU</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>1234</td>
<td>$10</td>
</tr>
<tr>
<td>1235</td>
<td>$20</td>
</tr>
</tbody>
</table>
</div>
<p>Sheet Two has the following Columns:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>SKU</th>
<th>Business Unit</th>
</tr>
</thead>
<tbody>
<tr>
<td>1234</td>
<td>BU1</td>
</tr>
<tr>
<td>1235</td>
<td>BU1</td>
</tr>
<tr>
<td>1234</td>
<td>BU1</td>
</tr>
<tr>
<td>1234</td>
<td>BU2</td>
</tr>
<tr>
<td>1234</td>
<td>BU2</td>
</tr>
<tr>
<td>1234</td>
<td>BU2</td>
</tr>
</tbody>
</table>
</div>
<p>And I have the following Formula:</p>
<p>=SUMIF('Sheet1'[SKU], VLOOKUP($F$2, sheet2, 2, FALSE), 'Sheet1'[Price])</p>
<p>(Which admittedly is copy-pasta from the Internets and then I've tried to mash together to get it to do what I want)</p>
<p>What I am trying to do is grouping by Business Unit, look up the SKUs and multiply the total, based on Business Unit by the Price - so it would look like the following:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Business Unit</th>
<th>Total Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>BU1</td>
<td>$40</td>
</tr>
<tr>
<td>BU2</td>
<td>$30</td>
</tr>
</tbody>
</table>
</div>
<p>And my limitations in Excel are causing my hair to fall out as I bang my head against my keyboard - as I'm sure it's relatively simple - but I'm missing something key.</p>
| [
{
"answer_id": 74206300,
"author": "shrivallabha.redij",
"author_id": 8759927,
"author_profile": "https://Stackoverflow.com/users/8759927",
"pm_score": 0,
"selected": false,
"text": "=UNIQUE($B$2:$B$7,FALSE)"
},
{
"answer_id": 74206954,
"author": "Mayukh Bhattacharya",
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7643846/"
] |
74,206,008 | <p>Is it possible to customize the index of array in Laravel Builder?</p>
<p>I need the index is not incremented from 0 but with some integer</p>
<p><a href="https://i.stack.imgur.com/e8RWa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e8RWa.png" alt="enter image description here" /></a></p>
<p>This is my code:</p>
<pre><code>foreach ($members as $member) {
$check[$member->id] = TransactionInNon::where('member_id', $member->id)
->whereYear('created_at', $year)
->orderBy('date', 'ASC')
->limit(12)
->get()
->toArray();
}
</code></pre>
<p>I need the index of array can be customizable like</p>
<p><code>7 => array:11</code>
<code>10 => array:11</code></p>
<p>instead of</p>
<p><code>0 => array:11</code>
<code>1 => array:11</code></p>
| [
{
"answer_id": 74206818,
"author": "Tural Rzaxanov",
"author_id": 9922647,
"author_profile": "https://Stackoverflow.com/users/9922647",
"pm_score": 2,
"selected": true,
"text": "#start from\n$i = 33;\n\nforeach ($members as $member) {\n $check[$member->id] = TransactionInNon::where('m... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16816391/"
] |
74,206,033 | <p>Is there a way to disable a product for buying before the release date.</p>
<p>We added a release date for a product, the product has also an available stock. By doing this it is possible to add the product to the cart and buy it. Even if the release date is still in the future. The reason is that the product should automatically become availalbe when the release date (time) is reached, without the requirement to update the stock or anything.
Also disableing the product is no option, because it should be shown as coming soon.</p>
<p>The question is about how to disable it in a shopware-pwa setup, the store should not be allowed to add products to a chart nor to sell them before the release date. Disabeling this on the UI side only does not solve the problem because bots/scripts would still be able to do it by calling the API.</p>
<p>I did not find a setting for this. Does it require to update the logic of the shop?</p>
| [
{
"answer_id": 74206818,
"author": "Tural Rzaxanov",
"author_id": 9922647,
"author_profile": "https://Stackoverflow.com/users/9922647",
"pm_score": 2,
"selected": true,
"text": "#start from\n$i = 33;\n\nforeach ($members as $member) {\n $check[$member->id] = TransactionInNon::where('m... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10851607/"
] |
74,206,060 | <p>I am trying to improve my python skills and tried to reproduce a guess game where the machine tries to guess one number. You can find below the function. After the first input, the machine does not continue and have the following output:</p>
<pre><code>We will play a guess game.
Is this 50 your number?
0 means too low, 1 this is the number and 2 means too high 1
0 means too low, 1 this is the number and 2 means too high 1
Congrats ! You guess after 1 tries
</code></pre>
<p>You can see that we have a line <code>"0 means too low, 1 this is the number and 2 means too high 1"</code> for nothing while it should directly say 'Congrats ! You guess after 1 tries'. Did I misplace the input?</p>
<p>Below you can see the function I wrote (any suggestions for improvement are welcome !!)</p>
<pre class="lang-py prettyprint-override"><code>def guess_game():
m = 50
count = 0
print('We will play a guess game.')
print('Is this ' + str(m) + ' your number?')
myinput = input('0 means too low, 1 this is the number and 2 means too high')
while myinput != 1:
myinput = input('0 means too low, 1 this is the number and 2 means too high')
count += 1
if myinput == '0':
print('Not the right one. Too low')
for m in range(m,m+1):
m += 1
print('Is this ' + str(m) + ' your number?')
elif myinput == '2':
print('Not the right one. Too high.')
for m in range(m,m+1):
m -= 1
print('Is this ' + str(m) + ' your number?')
else:
print('Congrats ! You guess after ' + str(count) + ' tries')
break
</code></pre>
<p>I tried to change the place of the <code>input()</code> but it seems like the error is recurring.</p>
| [
{
"answer_id": 74206818,
"author": "Tural Rzaxanov",
"author_id": 9922647,
"author_profile": "https://Stackoverflow.com/users/9922647",
"pm_score": 2,
"selected": true,
"text": "#start from\n$i = 33;\n\nforeach ($members as $member) {\n $check[$member->id] = TransactionInNon::where('m... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15193158/"
] |
74,206,067 | <p>I'm struggling with removing the array from the memory.. it was allocated dynamically. I'd love some help, thanks!</p>
<pre><code> void RemoveAllocationOfIntegerArray(int** arr, int size) {
for (int i = size - 1; i >= 0; i--) {
delete arr[i];
arr[i] = NULL;
}
delete[] arr;
arr = NULL;
}
</code></pre>
| [
{
"answer_id": 74206156,
"author": "Özgür Murat Sağdıçoğlu",
"author_id": 5106317,
"author_profile": "https://Stackoverflow.com/users/5106317",
"pm_score": 2,
"selected": false,
"text": "arr[i] = NULL;\n// or\narr = NULL;\n"
},
{
"answer_id": 74207117,
"author": "Pepijn Krame... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18133824/"
] |
74,206,082 | <p>I have this problem where I would like to add a value to a dictionary but the key is duplicate.
I would like the key to to hold a list with multiple values</p>
<p>this is what I have tried</p>
<pre><code>def storingPassword():
username=("bob")#key,
password=("PASSWROD1")#value
allpasswords={
"jeff":"jeff 123 ",
"bob" : "bob 123"
}
if username not in allpasswords:
allpasswords[username]=password
else:
allpasswords[username].append(password)
return allpasswords
</code></pre>
<p>but i keep getting this error
"AttributeError: 'str' object has no attribute 'append'"</p>
<p>I expect a output something like this;</p>
<pre><code> "jeff":"jeff 123 ",
"bob" : ["bob 123","PASSWORD1"]
</code></pre>
| [
{
"answer_id": 74206166,
"author": "Stuart",
"author_id": 567595,
"author_profile": "https://Stackoverflow.com/users/567595",
"pm_score": 1,
"selected": false,
"text": "allpasswords[username] = [password] # List containing a single password\n"
},
{
"answer_id": 74206197,
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338278/"
] |
74,206,096 | <p>I want to run a script on a PHP file, but it is not running. It runs the header before the function runs so don't know how to run first the script</p>
<pre><code>iniciales();
header('Location: Lista_libros.php');//This runs before the funtion
function iniciales(){
echo '<script type="text/javascript">
alert("test");
</script>';
}
</code></pre>
| [
{
"answer_id": 74206166,
"author": "Stuart",
"author_id": 567595,
"author_profile": "https://Stackoverflow.com/users/567595",
"pm_score": 1,
"selected": false,
"text": "allpasswords[username] = [password] # List containing a single password\n"
},
{
"answer_id": 74206197,
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17158294/"
] |
74,206,115 | <p>I have a time class which tracks the time.</p>
<p>I want my other classes to be able to register a callback function if the day changes.</p>
<p>I have this working snippet:</p>
<pre><code>#define MAX_CB_CHANGE_FUNCTIONS 50
typedef void (*dayChangeFunc)(int prevDay,int nowDay);
class TimeSystem {
private:
// array for the function pointers.
dayChangeFunc dayChangeFunctions[MAX_CB_CHANGE_FUNCTIONS];
// emit function if the day changes.
void emitDayChange(int prev, int now);
public:
void regDayChange(dayChangeFunc);
};
/*
* Registering a day change function.
* Maximum function pointer count is MAX_CB_CHANGE_FUNCTIONS ( see timeSys.h )
*/
void TimeSystem::regDayChange(void (*dayChangeFunc)(int prevDay,int nowDay)){
if( currDayCbIndex >= MAX_CB_CHANGE_FUNCTIONS ){
if(isDebugOn){
debug.print(DEBUG_WARN,"[Time_sys] - Can not register an other day change function.\n");
return;
}
}
dayChangeFunctions[currDayCbIndex] = dayChangeFunc;
currDayCbIndex++;
}
/*
* Emitting day change to every registered function.
*/
void TimeSystem::emitDayChange(int prev, int now){
// Preventing change on initialization.
if( prev == 0 ){ return; }
for (size_t i = 0; i < MAX_CB_CHANGE_FUNCTIONS; i++){
if(dayChangeFunctions[i]){
dayChangeFunctions[i](prev,now);
}
}
}
</code></pre>
<p><strong>This works and other calsses can use this like this:</strong></p>
<pre><code>timeSys.regDayChange([](int prevDay,int nowDay){
Serial.printf("Day changed from prev: %d to now: %d\n",prevDay,nowDay);
});
</code></pre>
<p><strong>Now i want to capture the 'this' pointer in the lambda to be able to call some internal function of a class.</strong></p>
<pre><code>timeSys.regDayChange([this](int prevDay,int nowDay){
callSomeInternalFunction();
});
</code></pre>
<p><em>Error i get:</em></p>
<pre><code>no suitable conversion function from "lambda [](int prevDay, int nowDay)->void" to "dayChangeFunc"
</code></pre>
<p><strong>How could i define my lambda to be able to capture the 'this' pointer?</strong></p>
<p>******** <strong>EDIT: SOLVED</strong> ********</p>
<p>Here are the modifications:</p>
<p>I had to define my lambda function type like this:</p>
<pre><code>using dayChangeFunc = std::function<void(int, int)>;
</code></pre>
<p>Define the function pointer register function like this:</p>
<pre><code>void regDayChange(dayChangeFunc cb);
</code></pre>
<p>And rewrite the declaration like this:</p>
<pre><code>/*
* Registering a day change function.
* Maximum function pointer count is MAX_CB_CHANGE_FUNCTIONS ( see timeSys.h )
*/
void TimeSystem::regDayChange( dayChangeFunc cb ){
if( currDayCbIndex >= MAX_CB_CHANGE_FUNCTIONS ){
if(isDebugOn){
debug.print(DEBUG_WARN,"[Time_sys] - Can not register an other day change function.\n");
return;
}
}
dayChangeFunctions[currDayCbIndex] = cb;
currDayCbIndex++;
}
</code></pre>
<p>And now i can use it in any class like this:</p>
<pre><code>class SampleClass(){
private:
int exampleCounter = 0;
public:
void init(){
TimeSystem timeSys;
timeSys.regDayChange([this](int prevDay,int nowDay){
Serial.printf("Day changed from prev: %d to now: %d\n",prevDay,nowDay);
exampleCounter++;
});
}
}
</code></pre>
| [
{
"answer_id": 74206157,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 0,
"selected": false,
"text": "this"
},
{
"answer_id": 74206752,
"author": "molbdnilo",
"author_id": 404970,
"author_profile": "h... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13258459/"
] |
74,206,119 | <p>I am leaning the topic <strong>templates</strong> in C++, it says I can also assign the datatype in the template syntax. But if I pass a different datatype in the object of class and call the method of my class it should throw an error or a garbage output, but it does not whereas it gives the correct output if I assign the datatype while declaring the object of the class and calling it. Why is so?</p>
<p>Here is the program I was practicing on</p>
<pre><code>#include <iostream>
using namespace std;
template <class t1 = int, class t2 = int>
class Abhi
{
public:
t1 a;
t2 b;
Abhi(t1 x, t2 y)
{
a = x;
b = y;**your text**
}
void display()
{
cout << "the value of a is " << a << endl;
cout << "the value of b is " << b << endl;
}
};
int main()
{
Abhi A(5,'a');
A.display();
Abhi <float,int>N(5.3,8.88);
N.display();
return 0;
}
</code></pre>
<p>I am facing the issue in the first object <strong>A</strong> while the second object <strong>N</strong> gives the correct output</p>
<p>The output of the above program for the first object is
<code>the value of a is 5</code>
<code>the value of b is a</code></p>
<p>The output of the above program for the second object is
<code>the value of a is 5.3</code>
<code>the value of b is 8</code></p>
| [
{
"answer_id": 74206336,
"author": "bitmask",
"author_id": 430766,
"author_profile": "https://Stackoverflow.com/users/430766",
"pm_score": 2,
"selected": true,
"text": "char"
},
{
"answer_id": 74207153,
"author": "Caleth",
"author_id": 2610810,
"author_profile": "http... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16958953/"
] |
74,206,129 | <p>Given a R dataframe with two columns:</p>
<pre><code>dfc <- data.frame(col1=c(1,4,3,3,2),col2=c(3,5,11,10,4))
dfc
col1 col2
1 3
4 5
3 11
3 10
2 4
</code></pre>
<p>I would like to sort first by <code>col1</code> then <code>col2</code></p>
<p>where I have the names stored in a vector <code>cols</code> of strings with the column names</p>
<pre><code>cols=c("col1","col2")
</code></pre>
<p>however, I would like to have a way to sometimes use descending order for <code>col1</code> and maybe ascending for <code>col2</code></p>
<p>most guides (<a href="https://chartio.com/resources/tutorials/how-to-sort-a-data-frame-by-multiple-columns-in-r/" rel="nofollow noreferrer">here</a> and <a href="https://statisticsglobe.com/sort-variables-of-data-frame-by-column-names-in-r" rel="nofollow noreferrer">here</a>) don't use character vector of column names
although this is answered in a <a href="https://stackoverflow.com/questions/43897262/order-a-data-frame-programmatically-using-a-character-vector-of-column-names">similar question</a>, although this does not answer the question of descending/ascending - and a way to switch between them easily and throw in another column for example.</p>
<p>I got so tired of not finding the answer since I need this quite often, so I wrote a function that uses <code>eval(parse(text="EXPRESSION_HERE"))</code></p>
<pre><code>order_dataframe_by_cols <- function(dfc,cols=c("col1","col2"),dec_ace=NA) {
# takes a data frame "dfc", and sorts it by each column in "cols",
# in a descending or ascending order, defined by dec_ace by each col
if (length(dec_ace) == 1) {
if (is.na(dec_ace)) {dec_ace <- rep("",length(cols))}
}
str_eval <- "dfc <- dfc[order("
ix2 <- ""
for (ix in 1:length(cols)){
if (ix > 1) {ix2 <- ","}
str_eval <- paste(str_eval,ix2,dec_ace[ix],"dfc[,'",cols[ix],"']",sep="")
}
str_eval <- paste(str_eval,"),]")
eval(parse(text=str_eval))
return(dfc)
}
</code></pre>
<p>so ascending <code>col1</code> and descending <code>col2</code></p>
<pre><code>order_dataframe_by_cols(dfc,cols=c("col1","col2"),dec_ace=c("","-"))
col1 col2
1 3
2 4
3 11
3 10
4 5
</code></pre>
<p>and then ascending <code>col1</code> and ascending <code>col2</code></p>
<pre><code> order_dataframe_by_cols(dfc,cols=c("col1","col2"),dec_ace=c("",""))
col1 col2
1 3
2 4
3 10
3 11
4 5
</code></pre>
<p>notice that the 10 and 11 change place</p>
<p><strong>The problem:</strong></p>
<p>what if I have a <code>as.Date</code> variable, or <code>as.POSIXct</code> variable I also want to sort</p>
<pre><code>dfc2 <- data.frame(col1=c(1,4,3,3,2),col2=c(3,5,11,10,4),col3=c(as.Date(c("2015-04-11","2016-04-11","2017-04-11","2018-04-11","2019-04-11"))))
dfc2
col1 col2 col3
1 3 2015-04-11
4 5 2016-04-11
3 11 2017-04-11
3 10 2018-04-11
2 4 2019-04-11
order_dataframe_by_cols(dfc2,cols=c("col1","col3","col2"),dec_ace=c("","-",""))
Error in `-.Date`(dfc[, "col3"]) : unary - is not defined for "Date" objects
</code></pre>
<p>This cannot be done; I can't sort dates in this fashion while sorting other variables.</p>
<p>I can sort it, but only that column</p>
<pre><code>dfc[order(dfc[,"col3"]),]
</code></pre>
<p>So I need a way to sort a data frame using a column vector of column names, with a way to define separate sorting ascending and descending that works on date variables.
Thank you for reading.</p>
| [
{
"answer_id": 74206333,
"author": "B. Christian Kamgang",
"author_id": 10848898,
"author_profile": "https://Stackoverflow.com/users/10848898",
"pm_score": 2,
"selected": true,
"text": "dfc[do.call(order, c(dfc[cols], decreasing=list(c(FALSE, TRUE)), method=\"radix\")), ]\n\n col1 col2\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2673238/"
] |
74,206,130 | <p>I write this code and declare the <code>c</code> variable in if chains,
but the compiler gives me an error saying you did not declare this variable.</p>
<pre><code>#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
int k = atoi(argv[1]);
printf ("%i\n", k);
string p = get_string ("Plaintext: \n");
for (int i = 0; i < strlen(p); i++)
{
if (isalpha(p[i]))
{
if (islower(p[i]))
{
char c = (((p[i] - 97) + k) % 26) + 97;
return 0;
}
else if (isupper(p[i]))
{
char c = (((p[i] - 65) + k) % 26) + 65;
return 0;
}
else{
char c = (((p[i] - 65) + k) % 26) + 65;
}
p[i] = c;
}
}
printf ("%s\n", p);
return 0;
}
</code></pre>
<p>Error message:</p>
<pre class="lang-none prettyprint-override"><code>test2.c: In function ‘main’:
test2.c:34:20: error: ‘c’ undeclared (first use in this function)
34 | p[i] = c;
| ^
test2.c:34:20: note: each undeclared identifier is reported only once for each function it appears in
</code></pre>
| [
{
"answer_id": 74206377,
"author": "Huynh Son",
"author_id": 16389288,
"author_profile": "https://Stackoverflow.com/users/16389288",
"pm_score": 2,
"selected": false,
"text": "char c = ' ';\nfor ...\n"
},
{
"answer_id": 74206808,
"author": "ThongDT",
"author_id": 19344229... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14786756/"
] |
74,206,174 | <p>I am using a for loop to reuse existing data frames.</p>
<p><strong>Sample Code:</strong></p>
<pre><code>for i in range(0, 5, 1):
RGU_TT_TempX = pd.DataFrame()
RGU_TT_TempX = RGU_TT_Temp
#Merging Regular Ambulance TT with MSUs TT
#Updating MSUs TT according to the Formula
RGU_TT_TempX["MSU_X_DURATION"] = 0.05 + df_temp_MSU1["MSU_X_DURATION"].values + 0.25 + 0.25
RGU_TT_TempX["MSU_Y_DURATION"] = 0.05 + df_temp_MSU2["MSU_Y_DURATION"].values + 0.25 + 0.25
RGU_TT_TempX["MSU_Z_DURATION"] = 0.05 + df_temp_MSU3["MSU_Z_DURATION"].values + 0.25 + 0.25
</code></pre>
<p>This gives me the error:</p>
<pre><code>---> 44 RGU_TT_TempX["MSU_X_DURATION"] = 0.05 + df_temp_MSU1["MSU_X_DURATION"].values + 0.25 + 0.25
ValueError: Length of values (0) does not match length of index (16622)
</code></pre>
<p>In each data frame, I have <code>16622</code> values. Still, this gives me the length of the index error.</p>
<p><strong>Full Error Track:</strong></p>
<pre><code>ValueError Traceback (most recent call last)
Input In [21], in <cell line: 16>()
41 RGU_TT_TempX = RGU_TT_Temp
42 #Merging Regular Ambulance TT with MSUs TT
43 #Updating MSUs TT according to the Formula
---> 44 RGU_TT_TempX["MSU_X_DURATION"] = 0.05 + df_temp_MSU1["MSU_X_DURATION"].values + 0.25 + 0.25
45 RGU_TT_TempX["MSU_Y_DURATION"] = 0.05 + df_temp_MSU2["MSU_Y_DURATION"].values + 0.25 + 0.25
46 RGU_TT_TempX["MSU_Z_DURATION"] = 0.05 + df_temp_MSU3["MSU_Z_DURATION"].values + 0.25 + 0.25
File ~/opt/anaconda3/envs/geo_env/lib/python3.10/site-packages/pandas/core/frame.py:3977, in DataFrame.__setitem__(self, key, value)
3974 self._setitem_array([key], value)
3975 else:
3976 # set column
-> 3977 self._set_item(key, value)
File ~/opt/anaconda3/envs/geo_env/lib/python3.10/site-packages/pandas/core/frame.py:4171, in DataFrame._set_item(self, key, value)
4161 def _set_item(self, key, value) -> None:
4162 """
4163 Add series to DataFrame in specified column.
4164
(...)
4169 ensure homogeneity.
4170 """
-> 4171 value = self._sanitize_column(value)
4173 if (
4174 key in self.columns
4175 and value.ndim == 1
4176 and not is_extension_array_dtype(value)
4177 ):
4178 # broadcast across multiple columns if necessary
4179 if not self.columns.is_unique or isinstance(self.columns, MultiIndex):
File ~/opt/anaconda3/envs/geo_env/lib/python3.10/site-packages/pandas/core/frame.py:4904, in DataFrame._sanitize_column(self, value)
4901 return _reindex_for_setitem(Series(value), self.index)
4903 if is_list_like(value):
-> 4904 com.require_length_match(value, self.index)
4905 return sanitize_array(value, self.index, copy=True, allow_2d=True)
File ~/opt/anaconda3/envs/geo_env/lib/python3.10/site-packages/pandas/core/common.py:561, in require_length_match(data, index)
557 """
558 Check the length of data matches the length of the index.
559 """
560 if len(data) != len(index):
--> 561 raise ValueError(
562 "Length of values "
563 f"({len(data)}) "
564 "does not match length of index "
565 f"({len(index)})"
566 )
ValueError: Length of values (0) does not match length of index (16622)
</code></pre>
<p>I am really stuck here. Any suggestions will be highly appreciated.</p>
<p><strong>Data Frame (MSU_TT_Temp) Samples:</strong></p>
<pre><code>FROM_ID TO_ID DURATION_H DIST_KM
1 7 0.528556 38.43980
1 26 0.512511 37.38515
1 71 0.432453 32.57571
1 83 0.599486 39.26188
1 98 0.590517 35.53107
</code></pre>
<p><strong>Data Frame (RGU_TT_Temp) Samples:</strong></p>
<pre><code>Ambulance_ID Centroid_ID Hospital_ID Regular_Ambu_TT
37 1 6 1.871885
39 2 13 1.599971
6 3 6 1.307165
42 4 12 1.411554
37 5 14 1.968138
</code></pre>
<p>The problem is, if I iterate my loop once, the code works absolutely fine.</p>
<p><strong>Sample Code:</strong></p>
<pre><code>for i in range(0, 1, 1):
s = my_chrome_list[i]
MSU_X,MSU_Y,MSU_Z = s
#print (MSU_X,MSU_Y,MSU_Z)
#Three scenario
df_temp_MSU1 = pd.DataFrame()
df_temp_MSU2 = pd.DataFrame()
df_temp_MSU3 = pd.DataFrame()
df_temp_MSU1 = MSU_TT_Temp.loc[(MSU_TT_Temp['FROM_ID'] == MSU_X)]
df_temp_MSU1.rename(columns = {'DURATION_H':'MSU_X_DURATION'}, inplace = True)
#df_temp_MSU1
df_temp_MSU2 = MSU_TT_Temp.loc[(MSU_TT_Temp['FROM_ID'] == MSU_Y)]
df_temp_MSU2.rename(columns = {'DURATION_H':'MSU_Y_DURATION'}, inplace = True)
#df_temp_MSU2
df_temp_MSU3 = MSU_TT_Temp.loc[(MSU_TT_Temp['FROM_ID'] == MSU_Z)]
df_temp_MSU3.rename(columns = {'DURATION_H':'MSU_Z_DURATION'}, inplace = True)
#df_temp_MSU3
RGU_TT_TempX = pd.DataFrame()
RGU_TT_TempX = RGU_TT_Temp
#Merging Regular Ambulance TT with MSUs TT
#Updating MSUs TT according to the Formula
RGU_TT_TempX["MSU_X_DURATION"] = 0.05 + df_temp_MSU1["MSU_X_DURATION"].values + 0.25 + 0.25
RGU_TT_TempX["MSU_Y_DURATION"] = 0.05 + df_temp_MSU2["MSU_Y_DURATION"].values + 0.25 + 0.25
RGU_TT_TempX["MSU_Z_DURATION"] = 0.05 + df_temp_MSU3["MSU_Z_DURATION"].values + 0.25 + 0.25
#RGU_TT_TempX
#MSUs Average Time to Treatment
MSU1=RGU_TT_TempX["MSU_X_DURATION"].mean()
MSU2=RGU_TT_TempX["MSU_Y_DURATION"].mean()
MSU3=RGU_TT_TempX["MSU_Z_DURATION"].mean()
MSU_AVG_TT = (MSU1+MSU2+MSU3)/3
parents_chromosomes_list.append(MSU_AVG_TT)
</code></pre>
<p><strong>Output:</strong></p>
<pre><code>[2.0241383927258387]
</code></pre>
<p><strong>Note:</strong> The data length in the three data frames are equal: Indexes are the same length</p>
<p><strong>Loop for multiple iteration:Erorr</strong></p>
<pre><code>for i in range(0, 5, 1):
</code></pre>
<p><strong>What is the problem?</strong></p>
| [
{
"answer_id": 74253449,
"author": "LearningLogic",
"author_id": 13373167,
"author_profile": "https://Stackoverflow.com/users/13373167",
"pm_score": 0,
"selected": false,
"text": "MSU_X,MSU_Y,MSU_Z"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20184312/"
] |
74,206,186 | <p>Should Spring Boot Data JPA automatically create EntityManagerFactory bean?</p>
<p>I have added a table using Liquibase called Fred to my code, and now I wish to add JPA support for this.</p>
<p>Upon adding:</p>
<pre><code>public interface FredRepository extends JpaRepository<Fred, Long> {
}
</code></pre>
<p>I get</p>
<pre><code>org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
</code></pre>
<p>I understood that this bean should be created by spring. Can anyone explain when spring creates this bean for me? If it doesn't, why not?</p>
<p>SpringBoot TRACE logs containing EntityManager</p>
<pre><code>o.s.b.a.condition.OnClassCondition : Condition OnClassCondition on org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$CacheManagerEntityManagerFactoryDependsOnPostProcessor matched due to @ConditionalOnClass found required class 'org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'
Configuration$BootstrapExecutorCondition : Condition JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition on org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration#entityManagerFactoryBootstrapExecutorCustomizer did not match due to AnyNestedCondition 0 matched 2 did not; NestedCondition on JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition.LazyBootstrapMode @ConditionalOnProperty (spring.data.jpa.repositories.bootstrap-mode=lazy) did not find property 'bootstrap-mode'; NestedCondition on JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition.DeferredBootstrapMode @ConditionalOnProperty (spring.data.jpa.repositories.bootstrap-mode=deferred) did not find property 'bootstrap-mode'
o.s.beans.CachedIntrospectionResults : Found bean property 'entityManager' of type [javax.persistence.EntityManager]
o.s.b.f.s.DefaultListableBeanFactory : No bean named 'entityManagerFactory' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@4ba89729: defining beans (shortened for brevity)
WARN 43335 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fredRepository' defined in org.xxx.jpa.FredRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot create inner bean '(inner bean)#492d38a2' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#492d38a2': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
CacheAutoConfiguration.CacheManagerEntityManagerFactoryDependsOnPostProcessor:
Did not match:
- Ancestor org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration did not match (ConditionEvaluationReport.AncestorsMatchedCondition)
Matched:
- @ConditionalOnClass found required class 'org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean' (OnClassCondition)
JpaRepositoriesAutoConfiguration#entityManagerFactoryBootstrapExecutorCustomizer:
Did not match:
- AnyNestedCondition 0 matched 2 did not; NestedCondition on JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition.LazyBootstrapMode @ConditionalOnProperty (spring.data.jpa.repositories.bootstrap-mode=lazy) did not find property 'bootstrap-mode'; NestedCondition on JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition.DeferredBootstrapMode @ConditionalOnProperty (spring.data.jpa.repositories.bootstrap-mode=deferred) did not find property 'bootstrap-mode' (JpaRepositoriesAutoConfiguration.BootstrapExecutorCondition)
</code></pre>
<p>Entity class:</p>
<pre><code>@Getter
@Setter
@RequiredArgsConstructor
@Entity
public class Fred {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@NotNull
private String integrationkey;
}
</code></pre>
<p>pom.xml (recently added spring-boot-starter-data-jpa)</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.company</groupId>
<artifactId>company-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.company</groupId>
<artifactId>component</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>company :: component</name>
<description>component</description>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>11</java.version>
<company.shared.lib.version>0.1.0-SNAPSHOT</company.shared.lib.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>${spring-kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot.version}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibaseVersion}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>${spring-security.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>${spring-kafka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.company.shared</groupId>
<artifactId>dto-model</artifactId>
<version>${company.shared.lib.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.1.212</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-adapter-core</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.13.2.Final</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>${keycloak.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
</plugins>
</build>
</project>
</code></pre>
<p>version numbers from parent</p>
<pre><code> <properties>
<dropwizard.metrics.version>4.2.10</dropwizard.metrics.version>
<activemq.version>5.17.1</activemq.version>
<aries.jax.rs.whiteboard.version>2.0.1</aries.jax.rs.whiteboard.version>
<aries.jpa.api.version>2.7.3</aries.jpa.api.version>
<bsf.version>2.4.0</bsf.version>
<eclipselink.version>2.5.1</eclipselink.version>
<camel.version>3.15.0</camel.version>
<commons.io.version>2.11.0</commons.io.version>
<commons.lang.version>2.6</commons.lang.version>
<cucumber.version>7.1.0</cucumber.version>
<cxf.version>3.5.1</cxf.version>
<dhcp4java.version>1.1.0</dhcp4java.version>
<drools.version>7.31.0.Final</drools.version>
<geohash.version>1.4.0</geohash.version>
<glassfish.jaxb.version>2.3.2</glassfish.jaxb.version>
<grpc.version>1.43.2</grpc.version>
<gson.version>2.8.6</gson.version>
<guava.version>31.0.1-jre</guava.version>
<hamcrest.version>1.3</hamcrest.version>
<hibernate.version>6.1.4.Final</hibernate.version>
<httpcore.version>4.4.4</httpcore.version>
<httpclient.version>4.5.13</httpclient.version>
<ignite.version>2.14.0</ignite.version>
<jackson.version>2.13.1</jackson.version>
<jaeger.version>0.34.0</jaeger.version>
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
<jakarta.xml.version>2.3.3</jakarta.xml.version>
<jakarta.mail.version>1.6.7</jakarta.mail.version>
<javax.validation.version>2.0.1.Final</javax.validation.version>
<jaxrs.version>2.1</jaxrs.version>
<jboss-logging.version>3.4.1.Final</jboss-logging.version>
<jcifs.version>2.1.6</jcifs.version>
<jexl.version>2.1.1</jexl.version>
<jicmp.version>3.0.0</jicmp.version>
<jicmp6.version>2.0.1</jicmp6.version>
<jna.version>4.4.0</jna.version>
<joda.time.version>2.1</joda.time.version>
<junit.version>4.13.2</junit.version>
<jsonPatch.version>1.13</jsonPatch.version>
<jacksonCoreUtils.version>2.0</jacksonCoreUtils.version>
<fgeMsgSimple.version>1.2</fgeMsgSimple.version>
<fgeBtf.version>1.3</fgeBtf.version>
<json.version>20171018</json.version>
<jsr250.version>1.0</jsr250.version>
<jsr305.version>3.0.2</jsr305.version>
<karaf.version>4.3.6</karaf.version>
<keycloak.version>18.0.0</keycloak.version>
<liquibaseVersion>4.17.0</liquibaseVersion>
<log4j2.version>2.17.1</log4j2.version>
<mapstruct.version>1.4.1.Final</mapstruct.version>
<mina.version>2.1.5</mina.version>
<netty3.version>3.10.6.Final</netty3.version>
<netty4.version>4.1.78.Final</netty4.version>
<xxx.tracker.version>0.7</xxx.tracker.version>
<opentracing.version>0.31.0</opentracing.version>
<org.osgi.service.jdbc.version>1.0.0</org.osgi.service.jdbc.version>
<osgi.version>7.0.0</osgi.version>
<pax.jdbc.version>1.5.2</pax.jdbc.version>
<postgresql.version>42.5.0</postgresql.version>
<testcontainers.version>1.17.4</testcontainers.version>
<prometheus.version>0.16.0</prometheus.version>
<protobuf.version>3.17.3</protobuf.version> <!-- WARNING: this also controls the version of the protobuf compiler, change at your risk!-->
<rate.limitted.logger.version>2.0.2</rate.limitted.logger.version>
<rest-assured.version>4.3.3</rest-assured.version>
<slf4j.version>1.7.33</slf4j.version>
<snmp4j.version>2.5.5</snmp4j.version>
<snmp4j.agent.version>2.5.3</snmp4j.agent.version>
<spring.version>5.3.23</spring.version>
<spring-boot.version>2.7.4</spring-boot.version>
<spring-security.version>5.7.3</spring-security.version>
<spring-kafka.version>2.8.6</spring-kafka.version>
<swagger.version>2.1.1</swagger.version>
<xxx.shared.lib.version>0.1.0-SNAPSHOT</xxx.shared.lib.version>
<testcontainers.version>1.16.3</testcontainers.version>
<lombok.version>1.18.24</lombok.version>
<lombok.binding.version>0.2.0</lombok.binding.version>
<mockito.version>4.8.0</mockito.version>
<jupiter.version>5.9.0</jupiter.version>
<jib.version>3.2.1</jib.version>
<surefire.version>3.0.0-M5</surefire.version>
<failsafe.version>3.0.0-M5</failsafe.version>
</properties>
</code></pre>
<p>stack trace</p>
<pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.postProcessFields(MockitoTestExecutionListener.java:110)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:94)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:61)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271)
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fredRepository' defined in org.xxx.jpa.FredRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot create inner bean '(inner bean)#4c57ca10' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4c57ca10': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:389)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:936)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
... 72 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4c57ca10': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:693)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:374)
... 91 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:874)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:309)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330)
... 99 more
</code></pre>
<p>application.yml</p>
<pre><code>spring:
application:
name: xxx
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://postgres:5432/xxx
username: xxx
password: xxx
jpa:
hibernate:
ddl-auto: validate
liquibase:
change-log: db/changelog/changelog.xml
</code></pre>
| [
{
"answer_id": 74211901,
"author": "ch4mp",
"author_id": 619830,
"author_profile": "https://Stackoverflow.com/users/619830",
"pm_score": 1,
"selected": false,
"text": "src/main/resources/application.yaml"
},
{
"answer_id": 74279537,
"author": "James Hutchinson",
"author_i... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023726/"
] |
74,206,188 | <p>I have two h1 side by side and I want a space between the two textes.I tried it with just adding space with the spacebar, but it doesn´t work.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>header div {
display: flex;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><header>
<div>
<h1 id="heading1">Hello my name is </h1>
<h1 id="heading2"> Paul</h1>
</div>
</header></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74206329,
"author": "Loïc",
"author_id": 7105427,
"author_profile": "https://Stackoverflow.com/users/7105427",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74206331,
"author": "user11877521",
"author_id": 11877521,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20332178/"
] |
74,206,218 | <p>I have this serializer:</p>
<pre><code>class OrderLineSerializer(serializers.ModelSerializer):
id = serializers.ReadOnlyField(source="item.id")
name = serializers.ReadOnlyField(source="item.name")
price = serializers.ReadOnlyField(source="item.price")
quantity = serializers.IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(MAXNUMBERSIZE)]
)
class Meta:
model = OrderLine
fields = ("id", "name", "price", "quantity", "sub_total")
</code></pre>
<p>and it's fine when I send data to the user but is there a way to serialize data that I receive from the API without creating another serializer.</p>
<p>if I receive some API request with this content</p>
<pre><code>{id : 123, quantity : 10}
</code></pre>
<p>It doesn't get the item from the db.</p>
<p>is there a way to do it or I have to create a dedicated serializer?</p>
| [
{
"answer_id": 74223887,
"author": "Axeltherabbit",
"author_id": 8340761,
"author_profile": "https://Stackoverflow.com/users/8340761",
"pm_score": 1,
"selected": true,
"text": "required=False"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8340761/"
] |
74,206,233 | <p>I have those two df's:</p>
<pre><code>ID1 <- c("TRZ00897", "AAR9832", "NZU44447683209", "sxc89898989M", "RSU765th89", "FFF")
Date1 <- c("2022-08-21","2022-03-22","2022-09-24", "2022-09-21", "2022-09-22", "2022-09-22")
Data1 <- data.frame(ID1,Date1)
ID <- c("RSU765th89", "NZU44447683209", "AAR9832", "TRZ00897","ERD895655", "FFF", "IUHG0" )
Date <- c("2022-09-22","2022-09-21", "2022-03-22", "2022-08-21", "2022-09-21", "2022-09-22", "2022-09-22" )
Data2 <- data.frame(ID,Date)
</code></pre>
<p>I tried to get exact matches. An exact match is if ID and Date are the same in both df's, for example: "TRZ00897" "2022-08-21" is an exact match, because it is present in both df's</p>
<p>With the following line of code:</p>
<pre><code>match(Data1$ID1, Data2$ID) == match(Data1$Date1, Data2$Date)
</code></pre>
<p>the output is:</p>
<pre><code>TRUE TRUE NA NA TRUE FALSE
</code></pre>
<p>Obviously the last one should not be FALSE because "FFF" "2022-09-22" is in both df. The reason why it is FALSE is, that the Date"2022-09-22" occurred already in Data2 at index position 1.</p>
<pre><code>match(Data1$ID1, Data2$ID)
4 3 2 NA 1 6
match(Data1$Date1, Data2$Date)
4 3 NA 2 1 1
</code></pre>
<p>So at the end, there is index position 6 and 1 which is not equal --> FALSE</p>
<p>How can I change this? Which function should I use to get the correct answer.</p>
<p>Note, I don't need to merge or join etc. I'm really looking for a function that can detect those patterns.</p>
| [
{
"answer_id": 74206479,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "mapply"
},
{
"answer_id": 74206481,
"author": "zx8754",
"author_id": 680068,
"author_profile": "h... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371833/"
] |
74,206,234 | <p>We have a project with many submodules. Since today I seem to break my <strong>local</strong> repos when I commit something in a submodule.</p>
<p>I get a warning first, and afterwards the <code>.git</code> folder is shown as a file instead of a directory. The biggest problem is, that even when I delete the submodule and reinitialize it, it's restored in the same broken state. The only way to get out of this situation is to delete the local repository and clone it again.</p>
<p>It gets broken when I:</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(develop -> origin)
λ git commit -m "SEC-165 - fix typo"
</code></pre>
<p>Now the .git folder no longer seems to be a folder</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(develop -> origin)
λ ls -all
total 89
drwxr-xr-x 1 BPR 1049089 0 Oct 26 12:15 ./
drwxr-xr-x 1 BPR 1049089 0 Oct 25 16:00 ../
-rw-r--r-- 1 BPR 1049089 55 Oct 26 12:15 .git
</code></pre>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(develop -> origin)
λ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
</code></pre>
<p>Deleting the submodule from disk and reinitialing it results in the same broken situation</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(develop -> origin)
λ rm -rf *
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(develop -> origin)
λ cd ..
C:\dev\iai.common.devices.exhaust\Common(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git submodule update --init --recursive
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
fatal: Unable to checkout '159486a04efd86eceaad5e3adb74263b0ddc5d7e' in submodule path 'BuildEnvironment'
I never seen this weird behavior before, and remain clueless of how to fix it. Anybody and help / ideas?
</code></pre>
<h3>update</h3>
<p>I am not sure how git deals with submodules, but it seems that the <code>.git</code> item in a <em>submodule</em> simply not is a directory (??). So not sure if that has anything to do with the problem at hand. I really hope somebody can shed a light on this.</p>
<p>A full reproduction scenario, I didn't leave any action out:</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(HEAD detached at 159486a)
λ git status
HEAD detached at 159486a
nothing to commit, working tree clean
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(HEAD detached at 159486a)
λ git checkout feature/SEC-165-software-update-should-contains-plc-updates
Switched to a new branch 'feature/SEC-165-software-update-should-contains-plc-updates'
branch 'feature/SEC-165-software-update-should-contains-plc-updates' set up to track 'origin/feature/SEC-165-software-update-should-contains-plc-
updates'.
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ code .
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git add .
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git commit -m "fix typo"
warning: core.bare and core.worktree do not make sense
[feature/SEC-165-software-update-should-contains-plc-updates a3b1440] SEC-165 - fix typo
1 file changed, 1 insertion(+), 1 deletion(-)
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
</code></pre>
<h2>Update 2</h2>
<p>Found something <a href="https://www.spinics.net/lists/git/msg252042.html" rel="nofollow noreferrer">here</a>.
<code>git -c core.bare=false config --unset core.bare</code></p>
<p>That restore the broken situation, which at least saves me the trouble of cloning the entire repo again. It <strong>does not solve</strong> the root cause though. A new commit will destroy stuff again...</p>
<p>Below the actions for the workaround.</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git -c core.bare=false config --unset core.bare
warning: core.bare and core.worktree do not make sense
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git status
On branch feature/SEC-165-software-update-should-contains-plc-updates
Your branch is up to date with 'origin/feature/SEC-165-software-update-should-contains-plc-updates'.
nothing to commit, working tree clean
</code></pre>
<p>Breaking things reproduces again with the known sequence</p>
<pre><code>C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ touch bla
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git add . && git commit
warning: core.bare and core.worktree do not make sense
[feature/SEC-165-software-update-should-contains-plc-updates d053a92] SEC-165 - bla
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bla
C:\dev\iai.common.devices.exhaust\Common\BuildEnvironment(feature/SEC-165-software-update-should-contains-plc-updates -> origin)
λ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
</code></pre>
<p>What the hell is going on here. Why is git doing this? What can I have done what causes this insanely annoying behavior?</p>
| [
{
"answer_id": 74206479,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "mapply"
},
{
"answer_id": 74206481,
"author": "zx8754",
"author_id": 680068,
"author_profile": "h... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1470327/"
] |
74,206,263 | <p>I have queueTrigger azure functions. I am receiving warning about function runtime version update. To update runtime version, I have followed some steps like I update value of "FUNCTIONS_EXTENSION_VERSION" key to "~4" and check "Function runtime settings" tab where Runtime version showing as custom(~4)
<a href="https://i.stack.imgur.com/5QI1y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5QI1y.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/OFB6S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OFB6S.png" alt="enter image description here" /></a></p>
<p>Also I update versions inside setting.json file of function application and update "extensionBundle" version values in host.json file</p>
<p><a href="https://i.stack.imgur.com/NIwNl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NIwNl.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/Zrewl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zrewl.png" alt="enter image description here" /></a></p>
<p>After updating those files, I update function by docker deployment. But it still showing me warning about runtime version update.</p>
<p><a href="https://i.stack.imgur.com/TFanH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TFanH.png" alt="enter image description here" /></a></p>
<p>I had updated runtime version of another function app which has <strong>httpTrigger</strong> trigger functions.</p>
<p><a href="https://i.stack.imgur.com/MzMQV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MzMQV.png" alt="enter image description here" /></a></p>
<p>As you can also there is some UI difference also between <strong>Function runtime settings</strong> tabs of both function applications (In 1st Runtime version is with <strong>custom</strong> string and in 2nd it without that string). In this <strong>queueTrigger</strong> function app its not updating runtime version as it still showing warning. Is it something which I doing wrong? How can I update it then? Can someone help me regarding this?</p>
| [
{
"answer_id": 74213073,
"author": "Pravallika Kothaveerannagari",
"author_id": 19991670,
"author_profile": "https://Stackoverflow.com/users/19991670",
"pm_score": 1,
"selected": false,
"text": "settings.json"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11143079/"
] |
74,206,282 | <p>Can't build my project on new Xcode 14.1</p>
<p>I'm using <em>MaterialComponents/ActivityIndicator</em></p>
<pre><code> "_MDMMotionCurveMakeBezier", referenced from:
+[MDCActivityIndicatorMotionSpec loopIndeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeToDeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeToIndeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeProgress] in MDCActivityIndicatorMotionSpec.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
| [
{
"answer_id": 74206283,
"author": "getmemd",
"author_id": 13202428,
"author_profile": "https://Stackoverflow.com/users/13202428",
"pm_score": 0,
"selected": false,
"text": "config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'"
},
{
"answer_id": 74592984,
"author": "W... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13202428/"
] |
74,206,311 | <p>I am using facade pattern with ngrx. I am calling facade methods inside the ngrx effects but I have read that it is not a good practice. I would like to know how can I resolve it.</p>
<p>My code is given below:</p>
<p>**My Effects code :
**</p>
<pre><code>closeCountSuccess$ = createEffect(() =>
this.actions$.pipe(
ofType(CountActions.CountActionTypes.CLOSE_COUNT_SUCCESS),
switchMap((action: fromActions.CountSuccess) => {
this.facade.resetCountList();
this.facade.setPageNumber({ pageNumber: 0 });
this.facade.fetchCountList({ page: 0, size: 20 });
this.facade.setCount();
this.openSimpleSnackbar(
this.translateService.instant('content.count-is-successfully-closed'),
5000,
G3SnackType.Success
);
return of(new fromActions.WizardCloseDialog());
})
)
);
</code></pre>
<p>My Facade code:</p>
<pre><code>import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import * as detailsActions from '../../count-details/store/count-details.actions';
import * as actions from '../../count-list/store/count-list.actions';
import { CountDef, CurrentBalanceResponseDef } from '../../shared/interfaces/current-balance-def.interface';
import * as fromActions from './count.actions';
import * as fromSelectors from './count.selectors';
import { CountState } from './count.state';
@Injectable({ providedIn: 'root' })
export class CountFacade {
constructor(private store$: Store<CountState>) {}
openDialog(): void {
this.store$.dispatch(new fromActions.WizardOpenDialog());
}
closeDialog(): void {
this.store$.dispatch(new fromActions.WizardCloseDialog());
}
getDialogOpened$(): Observable<boolean> {
return this.store$.select(fromSelectors.isOpened);
}
fetchCountList({ page, size }) {
this.store$.dispatch(new actions.GetCountListRequest({ page: page, size: size }));
}
resetCountList() {
this.store$.dispatch(new actions.Reset());
}
setPageNumber({ pageNumber }): void {
this.store$.dispatch(new actions.SetPageNumber({ pageNumber: pageNumber }));
}
setCurrentCount(): void {
this.store$.dispatch(new detailsActions.SetCurrentCountRequest());
}
}
</code></pre>
<p>If you know how it can be done in better way then please let me know.</p>
| [
{
"answer_id": 74206317,
"author": "H S W",
"author_id": 8584904,
"author_profile": "https://Stackoverflow.com/users/8584904",
"pm_score": 2,
"selected": true,
"text": "import * as CountListActions from '../../count-list/store/count-list.actions';\nimport * as CountDetailsActions from '.... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338231/"
] |
74,206,332 | <p>I'm receiving response data from an API, when I'm trying to decode it by using json decoder, the nested json data won't be decoded because it returns null.</p>
<p>json data as follow:</p>
<pre><code>{
"token": "string",
"details": {
"ID": "string",
"Name": "string",
"Message": null
}
}
</code></pre>
<p>Decoding model is:</p>
<pre><code>struct response: Codable {
let token: String?
let usrData: userData?
}
struct userData:Codable{
let ID,Name,Message: String?
}
</code></pre>
<pre><code>URLSession.shared.dataTask(with: request) { (data, response, error) in
guard let data = data, error == nil else {
completion(.failure(.custom(errorMessage: "Please check internet connection")))
return
}
guard let loginResponse = try? JSONDecoder().decode(response.self, from:data) else
{
completion(.failure(.invalidCredentials))
return
}
print(loginResponse.userData?.userID as Any) //returns nil
print(loginResponse.token) //token printed
guard let token = loginResponse.token else {
completion(.failure(.invalidCredentials))
return
}
completion(.success(token))
}.resume()
</code></pre>
<p>The token from the response will be successfully decoded, but the userData returns null.</p>
<pre><code>
</code></pre>
| [
{
"answer_id": 74206317,
"author": "H S W",
"author_id": 8584904,
"author_profile": "https://Stackoverflow.com/users/8584904",
"pm_score": 2,
"selected": true,
"text": "import * as CountListActions from '../../count-list/store/count-list.actions';\nimport * as CountDetailsActions from '.... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19323753/"
] |
74,206,335 | <p>I am working with Ansible and I have defined a var (varx) in inventory file (inventory1.yml) like this (only for env2):</p>
<pre><code>env1:
hosts:
env1.domain.com:
env2:
hosts:
env2.domain.com:
vars:
varx: 'valuex'
</code></pre>
<p>I am running playbook1 and calling playbook2 like this:</p>
<pre><code>ansible-playbook -i inventory/inventory1.yml playbooks/playbook1.yml --extra-vars "env=env1"
</code></pre>
<p>playbook1.yml:</p>
<pre><code>---
roles:
- role1
</code></pre>
<p>role1 - main.yml:</p>
<pre><code>---
- name: role1
command: bash script.sh {{ env }} {{ 'varx='~varx if varx is defined else '' }}
</code></pre>
<p>Inside <strong>script.sh</strong> (linux bash) I am calling playbook2:</p>
<pre><code>#!/bin/bash
ENV=$1
varx=$2
do_stuff() {
local arguments= "env=$ENV { 'varx='~varx if varx is defined else '' }}"
ansible-playbook -i inventory/inventory2.yml playbook2.yml --extra-vars "$arguments"
}
do_stuff
</code></pre>
<p>The idea is to pass varx from inventory1.yml if it exists in inventory1.yml to script.sh when it runs playbook2.yml. If it doesn't exist in inventory1.yml it will look for it in inventory2.yml.
The code as it is its looking for it in inventory2.yml, so I am not being able to retrieve it from inventory1.yml.
I believe that there is some issue in script.sh.</p>
<p>How can I achieve to bring varx from inventory1.yml and if doesn't exist to capture it from inventory2.yml?</p>
<p>I want to make some changes in <strong>role1</strong> so that I can pass the vars to script.sh (in a string for example,or in a better way - using ansible-playbook and passing the vars) and than capturing the vars in script.sh and launching playbook2. Any ideas how I can acomplish that?</p>
<p>Basically what I want to do is something like this:</p>
<pre><code>bash script.sh args
</code></pre>
<p>and the arguments should all go inside args variable (args= env varx).</p>
<p>What i have done is:</p>
<p>role1 - main.yml:</p>
<pre><code>---
- name: role1
command: bash script.sh arguments
arguments: "{{ env }} {{ 'varx='~varx if varx is defined else '' }}"
</code></pre>
<p>But when It reaches script.sh the varx is not being read.</p>
| [
{
"answer_id": 74206317,
"author": "H S W",
"author_id": 8584904,
"author_profile": "https://Stackoverflow.com/users/8584904",
"pm_score": 2,
"selected": true,
"text": "import * as CountListActions from '../../count-list/store/count-list.actions';\nimport * as CountDetailsActions from '.... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740839/"
] |
74,206,339 | <p>What im trying to do is to update one or more users with some data.
I receive the user phone numbers in an array, exp: <code>["+1234555", "+1222222"]</code>. I loop through them and I check if they exist or not.
If they exist I update the data in the user model.
The problem is that let's say I have two users to update. When I execute the function only the second user is updated, the first one is not.</p>
<pre><code>exports.createNotifications= asyncHandler(async (req, res, next) => {
const { userPhone, someData } = req.body;
let createUserData;
let updateUserData;
let findUser;
const createData = async () => {
userPhone.map(async (phone) => {
findUser = await Users.findOne({ phone: phone}).then(
async (user) => {
if (user) {
updateUserData= await Users.findOneAndUpdate(
{ phone: phone},
{ $push: { someData : someData } },
{ new: true }
);
}
}
);
});
};
await createNotifications();
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log(updateUserData)
res.status(200).json({
success: true,
});
});
</code></pre>
<p>How can I update both users?</p>
| [
{
"answer_id": 74206452,
"author": "Ji aSH",
"author_id": 6108947,
"author_profile": "https://Stackoverflow.com/users/6108947",
"pm_score": 1,
"selected": false,
"text": "const createNotifications = () => {\n return userPhone.map(async (phone) => {\n const user = await Users.findOne(... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20051604/"
] |
74,206,357 | <br>
I am following some Reactjs course and faced issue which seems not to appear in this course..
<br>
<br>
<b>Customer.js:</b>
<pre><code>import React, { useState } from "react";
const Customer = () => {
const [customerState, setCustomerState] = useState(
{
names: ['Martin', 'Andrea', 'Carol'],
pickedName: 'Martin'
}
);
const switchName = () => {
const namePool = customerState.names;
const number = Math.floor(Math.random()*3); //losowanie liczby w zakresie 0-2
setCustomerState({pickedName: namePool[number]});
}
return(
<div>
<h2>Customer:</h2>
<h3>{customerState.pickedName}</h3>
<button onClick={switchName}>Change name</button>
</div>
);
}
export default Customer;
</code></pre>
<p>Mentioned code gives me error for line <code>setCustomerState({pickedName: namePool[number]});</code>:</p>
<p><a href="https://i.stack.imgur.com/7wx3g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7wx3g.png" alt="enter image description here" /></a></p>
<p>and in Browser console i can see:
<br>
<a href="https://i.stack.imgur.com/dQldo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dQldo.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74206407,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": false,
"text": "names"
},
{
"answer_id": 74206846,
"author": "gipcu",
"author_id": 11164450,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11164450/"
] |
74,206,381 | <p>I searched for a built in function to convert an integer to float type, but there isn't any. I want to convert a number 1000 into 1000.0</p>
| [
{
"answer_id": 74209056,
"author": "simbabque",
"author_id": 1331451,
"author_profile": "https://Stackoverflow.com/users/1331451",
"pm_score": 3,
"selected": false,
"text": "sprintf"
},
{
"answer_id": 74209212,
"author": "ikegami",
"author_id": 589924,
"author_profile... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9055654/"
] |
74,206,415 | <p>I have two dataframes that are as follows:</p>
<p>Dataframe <code>df1</code>:</p>
<pre><code> Rep
0 ec21b_AI_154OH
1 m2010_AI_066UW
2 20wh1_DS_416FC
</code></pre>
<p>Dataframe <code>df2</code>:</p>
<pre><code> Address FirstPart SecondPart
0 address13 m2010 066UW
1 address22 2020e 999GV
2 address26 2020c 513DT
3 address35 evd18 874GO
4 address36 ep21b 986CG
5 address493 20wh1 416FC
6 address628 ec21b 154OH
</code></pre>
<p>I want to add an <code>Address</code> column in dataframe <code>df1</code> using pandas, so that it looks as follows:</p>
<pre><code> Rep Address
0 ec21b_AI_154OH address628
1 m2010_AI_066UW address13
2 20wh1_DS_416FC address493
</code></pre>
<p>For every row in <code>df2</code>, I can search for matches in <code>df1</code>, and put the address.
However, is there a better way to do it?</p>
<p>My minimum working example is as follows:</p>
<pre><code>for First, Second, Add in zip(list(df2['FirstPart']),list(df2['SecondPart']),list(df2['Address'])):
condition = df1['Rep'].str.contains(First) & df1['Rep'].str.contains(Second)
df1.loc[condition,"Address"] = Add
</code></pre>
<p><strong>Note:</strong> It is not necessary to find <code>_</code> as a delimiter, and there can be other delimiters as well.</p>
| [
{
"answer_id": 74206906,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "extract"
},
{
"answer_id": 74209821,
"author": "Picard",
"author_id": 20339387,
"author_profile... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5673905/"
] |
74,206,429 | <p>My task is to allow users to type arabic text in my input field, however they are unable to do so due to a function named <code>isNumber()</code> in the code. Without the <code>isNumber()</code> function, the users are able to type arabic text. I'm inspecting the code and I can't figure out why that function isn't allowing users to accepting arabic input.</p>
<p><a href="https://codesandbox.io/s/hidden-leaf-g21k5w" rel="nofollow noreferrer">I've reproduced this error in code sandbox</a></p>
<p>The next provided example code is the boiled down variant of the above linked sandbox code.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function validateLength(value, maxLength) {
if (value.length >= maxLength) {
return false;
}
return true;
}
function isNumber(evt, maxLength = 30/*1000000*/) {
// evt = evt || window.event;
const value = evt.target.value;
if (!/*this.*/validateLength(value, maxLength)) {
evt.preventDefault();
return false;
}
const charCode = evt.which ? evt.which : evt.keyCode;
if (
charCode > 31 &&
(charCode < 48 || charCode > 57) &&
charCode !== 46
) {
evt.preventDefault();
} else {
return true;
}
}
document
.querySelector('input')
.addEventListener('keypress', isNumber);</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>[type="text"] { display: block; width: 50%; }</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="text" value="01234٠١٢٣٤٥٦٧٨٩56789" /></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74206906,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "extract"
},
{
"answer_id": 74209821,
"author": "Picard",
"author_id": 20339387,
"author_profile... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15475301/"
] |
74,206,455 | <p>I have the following dataframe:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>expNumber</th>
<th>attempt</th>
<th>finished</th>
<th>successful</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>true</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>2</td>
<td>false</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>3</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>1</td>
<td>false</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>2</td>
<td>true</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>true</td>
<td>true</td>
</tr>
<tr>
<td>1</td>
<td>4</td>
<td>1</td>
<td>false</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>4</td>
<td>2</td>
<td>false</td>
<td>false</td>
</tr>
</tbody>
</table>
</div>
<pre><code>id,expNumber,attempt,finished,successful,
1,1,1,true,false,
1,1,2,false,false,
1,1,3,true,true,
1,2,1,false,false,
1,2,2,true,false,
1,2,3,true,true,
1,4,1,false,false,
1,4,2,false,false,
</code></pre>
<p>And I want to create a dataframe which counts the data grouped by the value of the column. Here is what I expect:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>true</td>
<td>4</td>
</tr>
<tr>
<td>false</td>
<td>4</td>
</tr>
</tbody>
</table>
</div>
<p>I tried the following code but when I print the result, its just empty.</p>
<pre><code>df = df.groupby('finished'.sum())
print("test", df)
</code></pre>
| [
{
"answer_id": 74206906,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "extract"
},
{
"answer_id": 74209821,
"author": "Picard",
"author_id": 20339387,
"author_profile... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18532798/"
] |
74,206,462 | <p>There is a <strong>.txt</strong> file with data like following:</p>
<pre><code>1 00000001.setts 0x
2 00000002.setts 0x
3 00000003.setts 0x
4 00000004.setts 0x
...
59876 0000e9e4.setts 0x
59877 0000e9e5.setts 0x
59878 0000e9e6.setts 0x
</code></pre>
<p>the number of strings are always dynamic and far from ending in a round number (there are about 100k of them). How is it possible to implement in the form of code the division of such a large file with strings into smaller files (1500 for each small file) of the txt format?</p>
<p>I should clarify that I tried to implement this task, but unfortunately I encounter the fact that it doesn't read everything and some of the data is lost
( Read only 59514 strings out of 59878 )</p>
<p>The file is pretty big, the structure consists of two values, followed by a space and /n</p>
| [
{
"answer_id": 74206737,
"author": "marek",
"author_id": 20282919,
"author_profile": "https://Stackoverflow.com/users/20282919",
"pm_score": 1,
"selected": true,
"text": "def split_file(filename, filename_prefix, filename_suffix, maximal_filesize):\n line_counter = 1\n file_counter... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19843805/"
] |
74,206,488 | <p>Is putting "yes" in do while loop statement possible because I cannot figure out how. It's not working.</p>
<pre><code>#include <stdio.h>
int main ()
{
char choice [3];
do
{
printf ("Do you want to try again? ");
scanf ("%s", &choice);
} while (choice == "yes");
}
</code></pre>
| [
{
"answer_id": 74206771,
"author": "Vlad from Moscow",
"author_id": 2877241,
"author_profile": "https://Stackoverflow.com/users/2877241",
"pm_score": 3,
"selected": true,
"text": "\"yes\""
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338381/"
] |
74,206,504 | <p>I'm trying to install <code>twarc2</code> in my <code>conda</code> environment (from <a href="https://anaconda.org/brown-data-science/twarc" rel="nofollow noreferrer">here</a>) :</p>
<pre><code>conda install -c brown-data-science twarc
</code></pre>
<p>The above command runs fine, if I try it again I get <code>All requested packages already installed.</code></p>
<p>However when I try to import the module in python:</p>
<pre><code>>>> import twarc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'twarc'
</code></pre>
<p>What am I missing?</p>
| [
{
"answer_id": 74210103,
"author": "Erwan",
"author_id": 891919,
"author_profile": "https://Stackoverflow.com/users/891919",
"pm_score": 0,
"selected": false,
"text": "twarc"
},
{
"answer_id": 74213619,
"author": "merv",
"author_id": 570918,
"author_profile": "https:/... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/891919/"
] |
74,206,509 | <p>I'm making a struct <code>Box<T></code> that handles some data. The specifics are unimportant.<br />
An important note however is that <code>Box<T></code> can store a pointer, but it might not. So both <code>Box<int></code> and <code>Box<int *></code> are valid. Obviously, if we own <code>Box.data</code>, we're going to need to <code>delete</code> data if it is a pointer type.
Here's a solution I came up with that works in C++11:</p>
<pre class="lang-cpp prettyprint-override"><code>template <typename T> struct BoxTraits;
template <typename T> struct Box {
using traits_t = BoxTraits<T>;
T data;
~Box() = default; // not required, I know
T get_data() { return traits_t::get_data(this); }
};
template <typename T> struct Box<T *> {
using traits_t = BoxTraits<T *>;
T *data;
~Box() { delete data; }
T *get_data() { return traits_t::get_data(this); }
};
template <typename T> struct BoxTraits {
static T get_data(Box<T> *const box) { return box->data; }
};
</code></pre>
<p><code>Box::get_data</code> is here to illustrate an issue with this design pattern. For every single method I want to add to <code>Box</code>, I need to add some boiler plate in each specialisation. Note that I would also need a <code>Box<T *const></code> specialisation.</p>
<p>This seems like quite a rubbish solution. In C++14, I could use <code>if constexpr</code> with a <code>is_ptr<T></code> trait and only have to write extra code in the methods that need specialising... Is there any way I can do this is in C++11?</p>
<p>This solution is shorter, cleaner <em>and</em> works for <code>Box<U *const></code>!</p>
<pre class="lang-cpp prettyprint-override"><code>template <typename T> struct is_ptr { static const bool value = false; };
template <typename U> struct is_ptr<U *> { static const bool value = true; };
template <typename U> struct is_ptr<U *const> {
static const bool value = true;
};
template <typename T> struct Box {
T data;
~Box() {
if constexpr (is_ptr<T>::value) {
delete data;
}
}
T get_data() { return data; }
};
</code></pre>
| [
{
"answer_id": 74206865,
"author": "bitmask",
"author_id": 430766,
"author_profile": "https://Stackoverflow.com/users/430766",
"pm_score": 1,
"selected": false,
"text": "template <typename B, typename T>\nstruct BoxTraits {\n static T& get_data(B *const box) { return box->data; }\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12155405/"
] |
74,206,514 | <p>So I have a string that has some numbers in it. This string is going to be specified by the user and therefore, must be able to detect the numbers in the string and change them into the word equivalent. This is what I have so far:</p>
<pre><code>string[] numwords = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
int[] nums = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
string sample = "Hello MY naMe is Joe Bloggs 1234567 :-)";
for(int x=0; x<nums.Length; x++)
{
if (sample.Contains(Convert.ToString(nums[x])))
{
int index1 = sample.IndexOf(Convert.ToString(nums[x]));
sample = sample.Remove(sample[index1],1 );
sample = sample.Insert(sample[index1], Convert.ToString(numwords[x]));
}
}
Console.WriteLine(sample);
</code></pre>
<p>I am getting this error:
System.ArgumentOutOfRangeException: 'Index and count must refer to a location within the string. Arg_ParamName_Name'</p>
| [
{
"answer_id": 74206584,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "string.Replace"
},
{
"answer_id": 74206628,
"author": "Dmitry Bychenko",
"author_id": 2319407,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14573230/"
] |
74,206,545 | <p>Because latest iOS is making problems with Appium 1.x, Appium team is no longer supporting it,
and Appium 2 is working ok - I need to use v2...</p>
<p>CodeceptJS 3.3.x is using Appium 1.x now and because of the '/wd/path' used by default in CodeceptJS Appium helper, I can't set it to use Appium 2.
When starting a test, CodeceptJS fails with:</p>
<pre><code>Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Please make sure Selenium Server is running and accessible
Error: Can't connect to WebDriver.
Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Please make sure Selenium Server is running and accessible
</code></pre>
<p>And Appium 2 fails with:</p>
<pre><code>[debug] [HTTP] No route found for /wd/hub/session
[HTTP] <-- POST /wd/hub/session 404 1 ms - 211
</code></pre>
<p>Is there a way to change the default '/wd/path' to just '/' ?
Or is there another helper or something for Appium 2?</p>
<p>Part of the codecept.config.js file:</p>
<pre><code> Appium: {
host: process.env.CLOUD_HOST || 'localhost',
port: parseInt(process.env.CLOUD_PORT) || 4723,
app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
desiredCapabilities: {
platformName: process.env.PLATFORM_NAME || 'iOS',
platformVersion: process.env.PLATFORM_VERSION || '16.0',
automationName: process.env.AUTOMATION_NAME || 'xcuitest',
deviceName: process.env.DEVICE_NAME || 'iPhone Xs',
appPackage: process.env.APP_PACKAGE,
appActivity: process.env.APP_ACTIVITY,
xcodeOrgId: process.env.XCODE_ORG_ID,
// udid: process.env.UDID, // used only for real iOS device
},
},
</code></pre>
<p>=========================================</p>
<ul>
<li><strong>UPDATE:</strong></li>
</ul>
<p>I started Appium with --base-path /wd/hub (appium --base-path /wd/hub) but now another error appears:</p>
<pre><code>Error: Can't connect to WebDriver.
Error: Failed to create session.
All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: platformVersion,automationName,deviceName,appPackage,appActivity,xcodeOrgId,app
Please make sure Selenium Server is running and accessible
</code></pre>
<p>I tried updating the <strong>capabilities</strong> in <em>codecept.conf.js</em> with <em>appium:</em> prefix, but either I do it wrong or it doesn't work:</p>
<p>The Update:</p>
<pre><code> Appium: {
host: process.env.CLOUD_HOST || 'localhost',
port: parseInt(process.env.CLOUD_PORT) || 4723,
app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
desiredCapabilities: {
'appium:platformName': process.env.PLATFORM_NAME || 'iOS',
'appium:platformVersion': process.env.PLATFORM_VERSION || '16.0',
'appium:automationName': process.env.AUTOMATION_NAME || 'xcuitest',
'appium:deviceName': process.env.DEVICE_NAME || 'iPhone Xs',
'appium:appPackage': process.env.APP_PACKAGE, // not needed for iOS
'appium:appActivity': process.env.APP_ACTIVITY, // not needed for iOS
'xcodeOrgId': process.env.XCODE_ORG_ID, // not needed for Android
udid: process.env.UDID, // used only for real iOS device testing
},
},
</code></pre>
<p>Error:</p>
<pre><code>Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("platformVersion", "deviceName", "appPackage", "appActivity", "xcodeOrgId", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.
Please make sure Selenium Server is running and accessible
</code></pre>
<p>Error#2:</p>
<pre><code>Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("deviceName", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.
Please make sure Selenium Server is running and accessible
</code></pre>
| [
{
"answer_id": 74206584,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "string.Replace"
},
{
"answer_id": 74206628,
"author": "Dmitry Bychenko",
"author_id": 2319407,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8346030/"
] |
74,206,548 | <pre><code>a = [1, 2, 3, 4, 7, 9, 12]
df_1 = pd.DataFrame(a, columns=['X'])
b=[4, 8, 9, 11]
df_2 = pd.DataFrame(b, columns=['Y'])
df_f= pd.concat([df_1, df_2], axis=1)
</code></pre>
<p>Final data frame is looks like</p>
<pre><code> X Y
0 1 4.0
1 2 8.0
2 3 9.0
3 4 11.0
4 7 NaN
5 9 NaN
6 12 NaN
</code></pre>
<p>I need to find the common elements. For example, in the above case, the answer is 4 and 9.</p>
| [
{
"answer_id": 74206584,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "string.Replace"
},
{
"answer_id": 74206628,
"author": "Dmitry Bychenko",
"author_id": 2319407,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19523905/"
] |
74,206,553 | <p>I have SQL Server database and application using EF. I want to check a list of word combinations as validation before proceeding with certain functionality.</p>
<p>Table in DB:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>WordCombination</th>
</tr>
</thead>
<tbody>
<tr>
<td>%lorem%ipsum%</td>
</tr>
<tr>
<td>...</td>
</tr>
</tbody>
</table>
</div>
<p><strong>I have the %lorem%ipsum% in the DB and want to check a string in the .NET application for likeness against it and get boolean result for example "ipsum lorem" should return TRUE</strong></p>
<p>Currently I have</p>
<pre><code>context.Table.Select(row=>row.WordCombination).Any(combination=>EF.Functions.Like(myString,combination))
</code></pre>
<p><strong>notice I use the combination from the DB as a pattern</strong></p>
<p>I try to make the solution as optimal as possible so I don't want to enumerate the table since it may have many rows and I don't want to add any duplicates. Also i try to get only the combination of the two so separating the entry in "lorem" and "ipsum" is not a variant for now.</p>
<p>Is there a way to find both "lorem ipsum","ipsum lorem" and other combinations like "ipsum1234lorem" without adding "ipsum%lorem" entry and without enumerating the table? (with just a query)</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74206584,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "string.Replace"
},
{
"answer_id": 74206628,
"author": "Dmitry Bychenko",
"author_id": 2319407,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19788043/"
] |
74,206,593 | <p>My goal is to add a method printStars to the program that prints a line of stars and use this method in the existing method write to print “Hello, World!” in a box made of stars, like so:</p>
<pre><code>*******************
** Hello, World! **
*******************
</code></pre>
<p>I have the following code for now but it just prints a line above and below the Hello World.
I'd also want to have a case where it outputs the following:</p>
<pre><code>*******************
*** ***
** **
* Hello, World! *
** **
*** ***
*******************
</code></pre>
<p>Have this code for now but it doesn't really wrap the String "Hello, World". It just prints a line of stars above and below.</p>
<pre><code>public class StarWriter {
/**
* yk prints stars
*/
void printStars(int n) {
for(int i=1; i <= 14; i++) {
System.out.print("*");
}
}
/**
* Say hello
*/
void writeBox() {
printStars(15);
printStars(2);
System.out.println("\nHello World");
printStars(2);
printStars(15);
}
public static void main(String[] args) {
new StarWriter().writeBox();
}
}
</code></pre>
| [
{
"answer_id": 74206763,
"author": "mmartinez04",
"author_id": 20131874,
"author_profile": "https://Stackoverflow.com/users/20131874",
"pm_score": 0,
"selected": false,
"text": "printStars"
},
{
"answer_id": 74207140,
"author": "Cactusroot",
"author_id": 14669853,
"au... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338616/"
] |
74,206,629 | <p>I am trying to squash come commits but the guides I find on the internet (e.g.<a href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History" rel="nofollow noreferrer">this from Git</a>) do not work for me:</p>
<pre><code>> git checkout master
> git checkout -b masterBAK
> git log --oneline --graph --decorate -n 4
* 047687e (HEAD) Merged PR 100: Fix pytest using marker
|\
| * 8ca0695 (origin/correct_bug) add something to pytest
| * 7b247c8 mock some function
|/
* 5c5c75a (tag: v1.4.0) Merged PR 090: cleanup imports
> git rebase -i HEAD~3
</code></pre>
<p>I am now expecting to see a list of commits followed by a list of commands as in the link above. Instead I see a blank page in vi, i.e. a cursor where I can write using vim commands followed by tilde symbols. I can quit with ":q". What can I do to see the commits and squash them as described in the guide above?</p>
<p>I don't think it matters, but I use meld in some settings:</p>
<pre><code>> git config -l
diff.tool=meld
merge.tool=meld
difftool.prompt=false
..
core.editor=/usr/bin/vi -w [Solution: faulty -w flag]
</code></pre>
| [
{
"answer_id": 74207693,
"author": "user13182570",
"author_id": 13182570,
"author_profile": "https://Stackoverflow.com/users/13182570",
"pm_score": 1,
"selected": false,
"text": "diff.tool=vimdiff\nmerge.tool=vimdiff\ncore.editor=vim # I think this is the important point\n# I don't have ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3592827/"
] |
74,206,636 | <p>I have a list <code>['a','b','c','d']</code>, want to make another list, like this: <code>['a', 'ab', abc', 'abcd']</code>?</p>
<p>Thanks</p>
<p>Tried:</p>
<pre><code>list1=['a','b','c', 'd']
for i in range(1, (len(list1)+1)):
for j in range(1, 1+i):
print(*[list1[j-1]], end = "")
print()
</code></pre>
<p>returns:</p>
<pre><code>a
ab
abc
abcd
</code></pre>
<p>It does print what i want, but not sure,how to add it to a list to look like <code>['a', 'ab', abc', 'abcd']</code></p>
| [
{
"answer_id": 74206679,
"author": "John Coleman",
"author_id": 4996248,
"author_profile": "https://Stackoverflow.com/users/4996248",
"pm_score": 2,
"selected": false,
"text": "list1=['a','b','c', 'd']\nlist2 = []\ns = ''\nfor c in list1:\n s += c\n list2.append(s)\n \nprint(lis... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17003136/"
] |
74,206,658 | <p>In this, I used a Agree checkbox and in there is unselecting, when the click can select check box then value is true, That works perfectly. But I wanna add shared Preferences to this When added that, after the selected word and close the app and reopened again then should show the check box value true that is selected at the last.
like this
<a href="https://i.stack.imgur.com/8IQsD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8IQsD.png" alt="enter image description here" /></a></p>
<p>my code</p>
<pre><code>import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AgreeScreen extends StatefulWidget {
const AgreeScreen({Key? key}) : super(key: key);
@override
State<AgreeScreen> createState() => _AgreeScreenState();
}
class _AgreeScreenState extends State<AgreeScreen> {
// 1st dropdown button
@override
void initState() {
super.initState();
valueAgree;
checkValueAgree();
}
// // are you agree button
String? valueAgree;
// //boolean value (are you agree)
bool isChecked = false;
checkValueAgree() {
_getDataAgree();
}
_saveDataAgree(bool isChecked) async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
sharedPreferences.setBool("Agree", isChecked);
}
_getDataAgree() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var result = sharedPreferences.getBool("Agree");
if (result != null) {
isChecked;
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 100, left: 15.0),
child: Row(
children: <Widget>[
const Icon(
Icons.brightness_1,
color: Colors.black,
size: 10,
),
const Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text(
"Are you agree",
style:
TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
),
),
const Padding(
padding: EdgeInsets.only(left: 30),
child: Text(
'yes',
style:
TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
),
Checkbox(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
side: MaterialStateBorderSide.resolveWith(
(states) =>
BorderSide(width: 3.0, color: Colors.blueAccent),
),
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 0.0, top: 150),
child: SizedBox(
width: 160.0,
height: 35.0,
child: ElevatedButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: const BorderSide(
color: Colors.blueAccent,
),
),
),
),
onPressed: () {
//do null check 1st
_saveDataAgree(isChecked);
},
child: const Text('next')),
),
),
],
),
),
);
}
}
</code></pre>
| [
{
"answer_id": 74206767,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "SharedPreferences"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20000775/"
] |
74,206,661 | <p>I am try to find the angle of line</p>
<p>i know the coordinate points</p>
<p>Start Point : 404, 119
Mid Point : 279, 214
End Point : 154, 310</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
def findangle(x1,y1,x2,y2,x3,y3):
ria = np.arctan2(y2 - y1, x2 - x1) - np.arctan2(y3 - y1, x3 - x1)
webangle = int(np.abs(ria * 180 / np.pi))
return webangle
</code></pre>
<p>result</p>
<p><a href="https://i.stack.imgur.com/0UZKR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0UZKR.png" alt="my output" /></a></p>
<p>Its return 270. But actual angle is 85-90.</p>
<p>Now, I want formula to calculate the angle (Either i Will rotate the image clockwise or Anticlockwise that time also return actual angle) in python code</p>
| [
{
"answer_id": 74206767,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "SharedPreferences"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19773004/"
] |
74,206,692 | <p>I'm using flask for my website application. It consists of reading certain files that contain a large number of dictionaries. I extracted that information on a list of dictionaries that looks like something like this (It's really importante to know that some dictionaries have the same value for the key "Event" but different information):</p>
<pre><code>[
{
"Evento": 100
"Descrición": "This is a event 100 description",
"CardID": 10,
"Title": "This is a event 100 title",
"Result": 1,
},
{
"Evento": 107
"Descrición": "This is a event 107 description",
"CardID": 20,
"Title": "This is a event 107 title",
"Result": 3,
},
{
"Evento": 107
"Descrición": "This is a event 107 description",
"CardID": 30,
"Title": "This is a event 107 title",
"Result": 1,
},
{
"Evento": 118
"Descrición": "This is a event 118 description",
"CardID": 50,
"Title": "This is a event 118 title",
"Result": 10,
}
...
]
</code></pre>
<p>In the flask app i render a template which has a table, which iterates over other list with another information related with the dictionary from above but with less information (the event and a brief description). The first value of the body table has a link to open a modal which would show the information of the event and depending the button that is presses, it should show the information of the next event with the same number or the information of the next event.</p>
<p>I can't add images since is one of my first questiones but the modal that is shown when the link on the table is clicked, shows the information from all the events but i only want the information from one event (100 in this case) and, when the button "Siguiente validación ->" is pressed it should show the information of the next event 100 and, when "Siguiente Evento" is pressed it should show the information of the next event on the table (e.g.: 200)</p>
<p>This is the template code for the table and the modal:</p>
<pre><code>{% extends './layout.html' %}
{% block body %}
<div class="container mb-5">
<table border="1" id="tablaEventos" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>Evento</th>
<th>Descripción</th>
</tr>
</thead>
<tbody>
{% for eventInformation in listEventInformation %}
<tr>
<td>
<a href="" data-bs-toggle="modal" data-bs-target="#modal_Event{{ eventInformation.Evento }}">
{{ eventInformation.Evento }}
</a>
</td>
<td>{{ eventInformation.Descripción }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- Modal -->
{% for eventInformation in listEventInformation %}
<div class="modal fade" data-bs-backdrop="static" id="modal_Event{{ eventInformation.Evento }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">{{ eventInformation.Evento }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<button type="button" class="btn btn-outline-primary btn-sm col-md-3">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"/>
</svg>
Validación Anterior
</button>
<!-- I used showModal(100) with data-current-result='1' here to demonstrate fetching the next result. Change here to match your logic -->
<button type="button" class="btn btn-outline-primary btn-sm col-md-3 ms-auto" data-current-result="1" onclick="showModal(this, 100)">
Siguiente Validación
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
</svg>
</button>
</div>
<div class="container mt-3 mb-3" id="modalContent">
<!-- Modal content goes here -->
{% for eventKey, eventValue in eventInformation.items() %}
<li>{{eventKey}}: {{eventValue}}</li>
{% endfor %}
</div>
</div>
<div class="modal-footer">
<div class="container-fluid">
<div class="row">
<button type="button" class="btn btn-primary col-md-4">Evento anterior</button>
<!-- I used showModal(200) here to demonstrate fetching the next event. Change here to match your logic -->
<button type="button" class="btn btn-primary col-md-4 ms-auto" data-bs-toggle="modal" data-bs-target="#modal_Event{{ eventInformation.Evento }}" onclick="showModal(this, 200)">Siguiente Evento</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<!-- CDN MODAL-->
<script src="//cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!-- CDN DATA TABLES-->
<script src="//code.jquery.com/jquery-3.5.1.js"></script>
<script src="//cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="//cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
<script>
$(document).ready(function () {
$('#tablaEventos').DataTable({
"language":{
"url": "//cdn.datatables.net/plug-ins/1.12.1/i18n/es-ES.json"
}
});
});
const eventInfo = {{ eventInformation }}; // Use the value of eventInformation as a JS variable
----------
function showModal(elementClicked, eventId) {
var eventModalElement = document.getElementById('modal_Event');
// Use getOrCreateInstance to prevent 'ghosting' that would result if a new modal were created
var eventModal = bootstrap.Modal.getOrCreateInstance(eventModalElement);
var currentResult = elementClicked.getAttribute("data-current-result");
if (currentResult) {
// Use the Start and End values to determine whether to increase the value of the currentResult or go to the next event
// if currentResult less than end currentResult + 1
// else eventId + 100 and currentResult = 1
}
// Fetch the modal content element
var modalContent = document.getElementById("modalContent");
// Set the HTML of the modal content element
modalContent.innerHTML = getEventModalHtml(eventId);
// Show the
eventModal.show();
}
function getEventModalHtml(eventId) {
html = "";
for([eventKey, eventValue] of Object.entries(eventInfo)) {
if (eventInfo["Evento"] === eventId) {
html += <li>''+eventKey+': '+eventValue</li>>;
}
}
return html;
}
</script>
{% endblock %}
</code></pre>
<p>The real problem I think is how to show only the dictionary you are iterating over in the list and when you press the button, show the information of the next iteration.</p>
| [
{
"answer_id": 74206767,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "SharedPreferences"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20174697/"
] |
74,206,705 | <p>I have just upgraded from Typescript 4.2.4 to Typescript 4.8.4 and am now getting errors because the types in node_modules/typescript/lib/lib.dom.d.ts conflict with the types node_modules/@types/filesystem/index.d.ts which is used by the "chrome" type in the types entry of the tsconfig file.</p>
<p>The errors are:</p>
<pre><code>node_modules/@types/filesystem/index.d.ts:107:5 - error TS2687: All declarations of 'name' must have identical modifiers.
107 name: string;
~~~~
node_modules/@types/filesystem/index.d.ts:113:5 - error TS2687: All declarations of 'root' must have identical modifiers.
113 root: DirectoryEntry;
~~~~
node_modules/@types/filesystem/index.d.ts:113:5 - error TS2717: Subsequent property declarations must have the same type. Property 'root' must be of type 'FileSystemDirectoryEntry', but here has type 'DirectoryEntry'.
113 root: DirectoryEntry;
~~~~
node_modules/typescript/lib/lib.dom.d.ts:5248:14
5248 readonly root: FileSystemDirectoryEntry;
~~~~
'root' was also declared here.
node_modules/@types/filesystem/index.d.ts:369:11 - error TS2304: Cannot find name 'DOMError'.
369 (err: DOMError): void;
~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:5247:14 - error TS2687: All declarations of 'name' must have identical modifiers.
5247 readonly name: string;
~~~~
node_modules/typescript/lib/lib.dom.d.ts:5248:14 - error TS2687: All declarations of 'root' must have identical modifiers.
</code></pre>
<p>Apart from the missing "DomError" the errors are occurring because FileSystem is declared differently in the 2 declaration files.</p>
<p>filesystem.index.d.ts has an interface called FileSystem</p>
<pre><code>interface FileSystem {
/**
* This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems.
* @readonly
*/
name: string;
/**
* The root directory of the file system.
* @readonly
*/
root: DirectoryEntry;
}
</code></pre>
<p>lib/lib.dom.d.ts also has an interface called FileSystem that looks like this:</p>
<pre><code>interface FileSystem {
readonly name: string;
readonly root: FileSystemDirectoryEntry;
}
</code></pre>
<p>How do I fix this?</p>
| [
{
"answer_id": 74206777,
"author": "Matthieu Riegler",
"author_id": 884123,
"author_profile": "https://Stackoverflow.com/users/884123",
"pm_score": 1,
"selected": false,
"text": "FileSystem"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1090110/"
] |
74,206,712 | <p>I have Androud telephone connected via USB cable to my computer and I want to take screenshot when test fails:</p>
<p>I have the following code that returns error:</p>
<p>thisline returns error "File source = driver.getScreenshotAs(OutputType.FILE);" - is there any different solution ?</p>
<pre><code>public String getScreenshotPath(String testCaseName, AppiumDriver driver) throws IOException {
File source = driver.getScreenshotAs(OutputType.FILE);
String destinationFile = System.getProperty("user.dir")+"//reports"+testCaseName+".png";
FileUtils.copyFile(source, new File(destinationFile));
return destinationFile;
}
</code></pre>
<p>it returns error:</p>
<pre><code>java.lang.IllegalArgumentException: Illegal base64 character a
at java.base/java.util.Base64$Decoder.decode0(Base64.java:746)
at java.base/java.util.Base64$Decoder.decode(Base64.java:538)
at java.base/java.util.Base64$Decoder.decode(Base64.java:561)
at org.openqa.selenium.OutputType$2.convertFromBase64Png(OutputType.java:58)
at org.openqa.selenium.OutputType$2.convertFromBase64Png(OutputType.java:55)
at org.openqa.selenium.OutputType$3.convertFromBase64Png(OutputType.java:78)
at org.openqa.selenium.OutputType$3.convertFromBase64Png(OutputType.java:75)
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:335)
at utils.AppiumUtils.getScreenshotPath(AppiumUtils.java:73)
at Appium.AppiumMaven.Listeners.onTestFailure(Listeners.java:47)
at org.testng.internal.TestListenerHelper.runTestListeners(TestListenerHelper.java:99)
at org.testng.internal.invokers.TestInvoker.runTestResultListener(TestInvoker.java:277)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:978)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:806)
at org.testng.TestRunner.run(TestRunner.java:601)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:433)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:427)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:387)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
</code></pre>
| [
{
"answer_id": 74222427,
"author": "kenneth",
"author_id": 9877340,
"author_profile": "https://Stackoverflow.com/users/9877340",
"pm_score": 2,
"selected": false,
"text": "\"Z3Rlc2dyZXNncmdyZWFncmVzZ3Jlc2dyZWFncmVzZ3Jlc2dlaW93YWpm\\n\"\n\"ZW9ndGVzZ3Jlc2dyZ3JlYWdyZXNncmVzZ3JlYWdyZXNncmVzZ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19225605/"
] |
74,206,738 | <p>I have a display ad container <code><div class="sponsor">...ad here...</div></code></p>
<p>If the injected ad is 200x300 i want to make <code>.sponsor</code> 200x300. Is that possible with css or do I need some javascript.</p>
| [
{
"answer_id": 74207165,
"author": "Damzaky",
"author_id": 7552340,
"author_profile": "https://Stackoverflow.com/users/7552340",
"pm_score": 0,
"selected": false,
"text": "display: table"
},
{
"answer_id": 74207222,
"author": "Vollfeiw",
"author_id": 11982933,
"author... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33522/"
] |
74,206,776 | <p>in my java book it told me to not directly compare 2 different float(type) numbers when storing them in variables. Because it gives an approx of a number in the variable. Instead it suggested checking the absolute value of the difference and see if it equals 0. If it does they are the same. How is this helpful? What if I store 5 in variable a and 5 in variable b, how can they not be the same? And how does it help if I compare absolute value??</p>
<pre><code>double a=5,b=5;
if (Math.abs(a-b)==0)
//run code
if (a==b)
//run code
</code></pre>
<p>I don't see at all why the above method would be more accurate? Since if 'a' is not equal to 'b' it wont matter if I use Math.abs.</p>
<p>I appreciate replies and thank you for your time.</p>
<p>I tried both methods.</p>
| [
{
"answer_id": 74206886,
"author": "Ali Hamed",
"author_id": 20277138,
"author_profile": "https://Stackoverflow.com/users/20277138",
"pm_score": 3,
"selected": true,
"text": "double d1 = 0;\nfor (int i = 1; i <= 8; i++) {\nd1 += 0.1;\n}\n\ndouble d2 = 0.1 * 8;\n\nSystem.out.println(d1);\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338751/"
] |
74,206,790 | <pre><code>function OK() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Modal>
<Text>OK</Text>
</Modal>
</View>
)
}
const choice1 = () => {
return (OK)
}
function MyButton () {
return (
<View>
<TouchableOpacity onPress={choice1}>
myButton Touch
</TouchableOpacity>
</View>
);
}
function App() {
return (
<View>
<MyButton />
<View>
)}
</code></pre>
<p>When myButton is pressed, I want to display Ok through some conditional.<br />
The conditional will be put in choice1.<br />
How can I execute OK through choice1?<br></p>
<p>+)My end goal is to get the ok character to appear when mybutton is pressed. <br>
And I want to put a conditional statement in the process. <br>
In other words, when the mybutton is pressed, choice1 containing the conditional statement is executed, and when the condition is satisfied, I want to display the OK character. <br>I want to know what is the error in my code or how to implement the above.</p>
| [
{
"answer_id": 74206886,
"author": "Ali Hamed",
"author_id": 20277138,
"author_profile": "https://Stackoverflow.com/users/20277138",
"pm_score": 3,
"selected": true,
"text": "double d1 = 0;\nfor (int i = 1; i <= 8; i++) {\nd1 += 0.1;\n}\n\ndouble d2 = 0.1 * 8;\n\nSystem.out.println(d1);\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20330416/"
] |
74,206,824 | <p>With Spring Boot 3.0 RC1 spring team decided to moved all of the graalvm <strong>native-maven-plugin</strong> configuration to spring-boot-parent...and we simply inherit the native profile. I like this move but we have lost the possibility of passing the native image build arguments... buildArgs.</p>
<p>Is there any possibility to pass native image build arguments to native-maven-plugin with Spring Boot 3.0 RC1 except of complete overriding of "native-maven-plugin" definition in the child pom.xml?</p>
<p>I mean buildArgs:</p>
<pre><code><configuration>
<imageName>${binary-name}</imageName>
<skip>${skip-native-build}</skip>
<buildArgs>
<buildArg>-H:+ReportExceptionStackTraces ${native-image-extra-flags}. </buildArg>
</buildArgs>
</configuration>
</code></pre>
<p>thanks.</p>
| [
{
"answer_id": 74206886,
"author": "Ali Hamed",
"author_id": 20277138,
"author_profile": "https://Stackoverflow.com/users/20277138",
"pm_score": 3,
"selected": true,
"text": "double d1 = 0;\nfor (int i = 1; i <= 8; i++) {\nd1 += 0.1;\n}\n\ndouble d2 = 0.1 * 8;\n\nSystem.out.println(d1);\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5249424/"
] |
74,206,831 | <p>I'm trying to use IOptionsMonitor to change ILogger log level at runtime in appsettings.json, but despite that I have used IOptionsMonitor for other settings like email settings used in application, in this case it returns old or default values..</p>
<p>I can change the values, I can open appsettings.json to see that values are changed, but loading values from appsettings.json returns, I guess, default values.. Anyone had this issue before?</p>
<p>IOptionsMonitor mapping class:</p>
<pre><code>public class LoggingSettings
{
public const string SectionName = "Logging";
public LogLevelSettings LogLevel { get; set; }
}
public class LogLevelSettings
{
public const string SectionName = "LogLevel";
[ConfigurationKeyName(name: "Default")]
public string DefaultSetting { get; set; }
[ConfigurationKeyName(name: "Microsoft.AspNetCore")]
public string MicrosoftAspNetCore { get; set; }
}
</code></pre>
<p>section in appsettings.json:</p>
<pre><code> "Logging": {
"LogLevel": {
"Default": "Critical",
"Microsoft.AspNetCore": "None"
}
}
</code></pre>
<p>excerpt from LogSettingsModel.cshtml.cs constructor (page):</p>
<pre><code>public LogSettingsModel(IOptionsMonitor<LoggingSettings> logSettings)
{
//this returns values "Information" and "Warning" for "Default" and "Microsoft.AspNetCore" keys instead "Critical" and "None"
_logSettings = logSettings.CurrentValue;
//this also returns "Information" for "Default" key, configurationHelper is static class made for accessing options..
var sec = ConfigurationHelper.config.GetSection("Logging:LogLevel:Default");
}
</code></pre>
<p>Thanks!</p>
<p>edit:</p>
<p>ConfigurationHelper class (created if I need to access config from static methods and for testing):</p>
<pre><code>public static class ConfigurationHelper
{
public static IConfiguration config;
public static IWebHostEnvironment env;
public static void Initialize(IConfiguration configuration, IWebHostEnvironment environment)
{
config = configuration;
env = environment;
}
}
</code></pre>
<p>btw. I have noticed that issue seems to happend because all other settings are loaded from "appsetings.json" (when running locally) - but this specific values are (I believe) loaded from "appsettings.Development.json", not sure why this is happening. so, if I manually change LogLevel:Default to "None" in appsettings.json, it still will be loaded with setting "Information". when inspecting with debugger breakpoint set at LogSettingsModel.cshtml.cs, I can see that there are settings in appsettings.Development.json.. it seems that when appsettings.Development.json has some values inside, that values are loaded instead appsettings.json values..</p>
| [
{
"answer_id": 74309176,
"author": "Marek",
"author_id": 13540124,
"author_profile": "https://Stackoverflow.com/users/13540124",
"pm_score": 1,
"selected": false,
"text": "appsettings.Development.json"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19033053/"
] |
74,206,845 | <p>I have this list as an input but i want to give each alphabet an index
for example k = 1 , i = 2 , s = 3 , s=3 ,a = 4</p>
<pre><code>['k', 'i', 's', 's', 'a']
</code></pre>
<p>is there way to use map function effectively in this case</p>
<p>I have tried to use map function but it returns</p>
<pre><code><map object at 0x0000015513F6B4C0>
</code></pre>
<p>which is not readble even using list()</p>
| [
{
"answer_id": 74206883,
"author": "Kungfu panda",
"author_id": 15349625,
"author_profile": "https://Stackoverflow.com/users/15349625",
"pm_score": 0,
"selected": false,
"text": "# you can use dictionary datatype in python which maps key and value.\na = {'k':1, 'i':2, 's':3, 'a':4,}\n"
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18501755/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.