qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,346,847 | <p>I am working on a complex web application in which from time to time, I need to fetch data from backend API. Sometimes, I need to call 2 future functions in Future Builder to use their values. However, it makes code messy because for each FutureBuilder I need to check, if it has data or not and return the widget. It looks like this.</p>
<pre><code>return FutureBuilder<object>(
future: func1(),
builder:(context, AsyncSnapshot<object> snapshot1){
if(snapshot1.hasData){
return FutureBuilder<object>(
future: func2(),
builder:(context, AsyncSnapshot<object> snapshot2){
if(snapshot2.hasData){
return widget;
}else{
return CircularProgressIndicator();
}
}
),
}else{
return CircularProgressIndicator();
}
}
);
</code></pre>
<p>Is there any other simpler way? where I can use only one FutureBuilder so that I do not have to return widgets i.e (CircularProgressIndicator)each time. Thanks.</p>
| [
{
"answer_id": 74346934,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 4,
"selected": true,
"text": "class ResultModel{\n final object1 result1;\n final object2 result2;\n ResultModel({required this.result1, required this.result2});\n}\n"
},
{
"answer_id": 74346935,
"author": "SLyHuy",
"author_id": 1122308,
"author_profile": "https://Stackoverflow.com/users/1122308",
"pm_score": 0,
"selected": false,
"text": "func1AndFunc2() async {\n var result = await func1();\n // check result has data\n if (result != null) {\n return func2();\n }\n} \n"
},
{
"answer_id": 74347883,
"author": "Andrija",
"author_id": 14430639,
"author_profile": "https://Stackoverflow.com/users/14430639",
"pm_score": 1,
"selected": false,
"text": "List<dynamic>"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1161518/"
] |
74,346,850 | <p>I am creating a function to view data from 1 of 3, each category has its own unique list of headings.</p>
<p>The function has two args: <code>function openReport(category , report)</code></p>
<p>With types, I want to the category value to be the condition to set the report type.</p>
<pre><code>type reportCategory= 'financial' | 'operational' | 'security'
type financialReports = 'financial workspaces' | 'financial datacenter'
type operationalReports = 'operational information' | 'operational environment'
type securityReports = 'security Accounts' | 'security needing attention'
const openReport async (
catagory: reportCategory
report: financialReports | operationalReports | securityReports,
) => {
}
</code></pre>
<p>The way its currently set up is that the report could be set to be a value that will not correspond with the category and will fail down the line.</p>
<p>I want it so that when you set the category, the report type will be set to one of three to so there will be no user error when calling the function.</p>
| [
{
"answer_id": 74346938,
"author": "mickl",
"author_id": 6238977,
"author_profile": "https://Stackoverflow.com/users/6238977",
"pm_score": 3,
"selected": true,
"text": "reportCategory"
},
{
"answer_id": 74346968,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 1,
"selected": false,
"text": "const openReport = async <C extends ReportCategory>(\n catagory: C,\n report: Extract<\n FinancialReports | OperationalReports | SecurityReports, \n `${C & {}}${string}`\n >\n) => {}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17580280/"
] |
74,346,859 | <p>How to add column named "ref" with value "1" in table DT1, for existing rows in table DT2, using join on 2 columns (id1=id3 and id2=id4)?</p>
<pre><code>DT1 <- data.table(
id1 = c('A','B','C', 'D'),
id2 = c(1,2,3,4)
)
DT2 <- data.table(
id3 = c('B','D','F'),
id4 = c(2,4,5)
)
</code></pre>
<p>DT1:</p>
<pre><code>id1 id2
A 1,00000
B 2,00000
C 3,00000
D 4,00000
</code></pre>
<p>DT2:</p>
<pre><code>id3 id4
B 2,00000
D 4,00000
</code></pre>
<p>Expected result:</p>
<pre><code>id1 id2 ref
A 1,00000 0
B 2,00000 1
C 3,00000 0
D 4,00000 1
</code></pre>
<p>I started with the following code, which does not filter as I want:</p>
<pre><code>result <- DT1[DT2, on = c(id1='id3', id2='id4')]
</code></pre>
| [
{
"answer_id": 74346939,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 1,
"selected": false,
"text": "%in%"
},
{
"answer_id": 74347123,
"author": "Ronak Shah",
"author_id": 3962914,
"author_profile": "https://Stackoverflow.com/users/3962914",
"pm_score": 1,
"selected": false,
"text": "data.table"
},
{
"answer_id": 74347174,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 3,
"selected": true,
"text": "DT1[ DT2, on = c(id1 = 'id3', id2 = 'id4'), ref := 1 ][ is.na(ref), ref := 0 ]\n\nDT1\n# id1 id2 ref\n# 1: A 1 0\n# 2: B 2 1\n# 3: C 3 0\n# 4: D 4 1\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19123441/"
] |
74,346,897 | <p>I've recently had to debug a cython library for a specific version of python on ubuntu and I needed python, venv, distutils, cython, pip, a compiler, and a text editor. I had to go fishing around the web for instructions on how to do this, so I'm asking this question to answer with what I did.</p>
<p>I googled it and found instructions in one place for pip, another place for venv, another place for compilers.</p>
| [
{
"answer_id": 74346939,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 1,
"selected": false,
"text": "%in%"
},
{
"answer_id": 74347123,
"author": "Ronak Shah",
"author_id": 3962914,
"author_profile": "https://Stackoverflow.com/users/3962914",
"pm_score": 1,
"selected": false,
"text": "data.table"
},
{
"answer_id": 74347174,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 3,
"selected": true,
"text": "DT1[ DT2, on = c(id1 = 'id3', id2 = 'id4'), ref := 1 ][ is.na(ref), ref := 0 ]\n\nDT1\n# id1 id2 ref\n# 1: A 1 0\n# 2: B 2 1\n# 3: C 3 0\n# 4: D 4 1\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4127286/"
] |
74,346,919 | <p>Is it possible that <strong>2 azure functions</strong> can get <strong>triggered by one eventhub</strong>? One azure function will write its data to database1 and the other azure function writes its data to database2</p>
<pre><code>[FunctionName("EventToDB1")]
public async System.Threading.Tasks.Task Run([EventHubTrigger("eventhub", Connection = "Debezium")]
EventData[] events, ILogger log)
{
{
[FunctionName("EventToDB2")]
public async System.Threading.Tasks.Task Run([EventHubTrigger("eventhub", Connection = "Debezium")]
EventData[] events, ILogger log)
{
{
</code></pre>
<p>answer on the possibility of having 2 azure functions get triggered by one eventhub</p>
| [
{
"answer_id": 74348794,
"author": "Peter Bons",
"author_id": 932728,
"author_profile": "https://Stackoverflow.com/users/932728",
"pm_score": 1,
"selected": false,
"text": "ConsumerGroup"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440213/"
] |
74,346,960 | <p>I need to create a UDF in pyspark that converts letter grades ('A', 'B', 'C', 'D', 'F') to numerical grades (4, 3, 2, 1, and 0). I then need to register this function as a spark UDF.
Next, I have a dataframe 'current_gpa'. Current_gpa has a column named 'grade' I need to add a column to the dataframe current_gpa called 'num_grade' where the letter grades in the column 'grade' are converted to the corresponding numbers in the column 'num_grade'.</p>
<p>This is the UDF I created:</p>
<pre><code>def get_num(letter):
letter_class_dict = {"A": 1, "B": 2, "C": 3, "D": 4, "F": 5}
for letter, l in letter_class_dict():
x['letter'] = l
return l
get_num = udf(lambda letter: letter_class_dict.get(letter))
get_num_udf = F.udf(get_num, IntegerType())
</code></pre>
<p>This is the dataframe current_gpa:</p>
<pre><code>+-------+-------+------+----+-----+-------+
| course|term_id| sid| fid|grade|credits|
+-------+-------+------+----+-----+-------+
|BIO 101| 2000B|100001|1007| F| 3|
|BIO 102| 2000B|100001|1007| F| 4|
|CHM 101| 2000B|100001|1002| F| 4|
|BIO 103| 2000B|100001|1007| F| 4|
|GEN 114| 2000B|100001|1006| F| 3|
+-------+-------+------+----+-----+-------+
</code></pre>
<p>I'm trying to use this UDF to add a column 'num_grade' where the values should look like:</p>
<pre><code>+-------+-------+------+----+-----+-------+----------+
| course|term_id| sid| fid|grade|credits|num_grades|
+-------+-------+------+----+-----+-------+----------+
|BIO 101| 2000B|100001|1007| F| 3| 0|
|BIO 102| 2000B|100001|1007| F| 4| 0|
|CHM 101| 2000B|100001|1002| F| 4| 0|
|BIO 103| 2000B|100001|1007| F| 4| 0|
|GEN 114| 2000B|100001|1006| F| 3| 0|
+-------+-------+------+----+-----+-------+----------+
</code></pre>
<pre><code>current_gpa = (
grades
.join(courses, 'course')
.select('course', 'term_id', 'sid', 'fid', 'grade', 'credits')
.withColumn('num_grade', get_num_udf(col('grade')))
)
current_gpa.show()
</code></pre>
<p>This gives me the error:
An exception was thrown from a UDF: 'RuntimeError: SparkContext should only be created and accessed on the driver.'. Full traceback below:</p>
| [
{
"answer_id": 74356398,
"author": "samkart",
"author_id": 8279585,
"author_profile": "https://Stackoverflow.com/users/8279585",
"pm_score": 1,
"selected": false,
"text": "when().otherwise()"
},
{
"answer_id": 74439258,
"author": "Kayleen Carlson",
"author_id": 20438731,
"author_profile": "https://Stackoverflow.com/users/20438731",
"pm_score": 0,
"selected": false,
"text": "def convert_grades(letter):\n letter_grades = {\n 'A':4,\n 'B': 3,\n 'C':2,\n 'D':1,\n 'F':0\n }\n return letter_grades.get(letter)\n \ngrade_points = spark.udf.register('convert_grades', convert_grades)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20438731/"
] |
74,346,961 | <p>I have a future, that returns a Future response.</p>
<pre><code>class FutureInformation extends StatelessWidget {
const FutureInformation({Key? key}) : super(key: key);
Future<List<SliderDetails>> getSliderDetails() async {
try {
var response = await http.get((Uri.parse("/path/to/jsonFile.json")));
if (response.statusCode == 200) {
print(response.statusCode);
var jsonData = json.decode(utf8.decode(response.bodyBytes));
List<SliderDetails> listedFestivals = [];
for (var map in jsonData) {
SliderDetails allFestivals = SliderDetails(
map['urlLink'] ?? "",
map['name'] ?? "",
);
/// add them to the array
listedFestivals.add(allFestivals);
}
return listedFestivals;
}
} catch (e){
print(e);
}
throw Exception('Nothing here, no food');
}
</code></pre>
<p>my Json file only has 2 elements both strings</p>
<pre><code>[{
"image": "https://i.gyazo.com/5d808c6e55a8b2151974bf53b35e21b6.png",
"title": "Yellow Car"
},
{
"image": "https://i.gyazo.com/7f33e4e78a54d1c4795aec5e0d57fab1.png",
"title": "Black Car"
},
{
"image": "https://i.gyazo.com/5e399b0ac1ffca12165f51af8bc3e81a.png",
"title": "Blue Car"
},
{
"image": "https://i.gyazo.com/8c74b2ec4da1ba477afbc67111573c4d.png",
"title": "Vintage Car"
}
]
</code></pre>
<p>From the response I want to create 2 different lists that would look like the example I have below.</p>
<pre><code>final List<String> imgList = [
"https://i.gyazo.com/5d808c6e55a8b2151974bf53b35e21b6.png",
"https://i.gyazo.com/7f33e4e78a54d1c4795aec5e0d57fab1.png",
"https://i.gyazo.com/5e399b0ac1ffca12165f51af8bc3e81a.png",
"https://i.gyazo.com/8c74b2ec4da1ba477afbc67111573c4d.png",
];
final List<String> titlesList = [
"Yellow Car",
"Black Car",
"Blue Car",
"Vintage Car",
];
</code></pre>
<p>The response I get is</p>
<pre><code>Instance of 'Future<List<SliderDetails>>'
</code></pre>
<p>And what I want to know how can I split the future into 2 separate lists, thanks for any help.</p>
<p>This is how I am calling the Future</p>
<pre><code>var datasource = const FutureInformation();
getSliderDetailsEvents() async {
List futureEvents = await datasource.getSliderDetails();
return futureEvents ;
}
@override
Widget build(BuildContext context) {
return Container();
}
}
</code></pre>
| [
{
"answer_id": 74347204,
"author": "BLKKKBVSIK",
"author_id": 11550065,
"author_profile": "https://Stackoverflow.com/users/11550065",
"pm_score": 0,
"selected": false,
"text": "Future<List<SliderDetails>>"
},
{
"answer_id": 74347205,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "SliderDetails"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1348731/"
] |
74,346,964 | <p>I'm trying to change the value in xml.</p>
<p>XML file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<settings>
<setting name="Attach" defaultValue="False" value="" />
<setting name="Connections" defaultValue="" value="CHANGE_THE_VALUE" />
<setting name="Destroy" defaultValue="True" value="" />
</settings>
</code></pre>
<p>I need to change the value in "Connections"</p>
<p>Powershell:</p>
<pre><code>$file = "C:\New folder\UserSettings.xml"
$xmldata = [xml] (Get-Content $file)
$xmldata.settings.ChildNodes
$xmldata.Save((Resolve-Path $file).Path)
</code></pre>
<p>How should I modify the 3rd string in the code above?</p>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8137621/"
] |
74,346,979 | <p>I want to go inside frame name "body", but it isnt work. I can go to first frame and everything works, but problem is when I try to go inside indeed frameset. Selenium cant see it</p>
<p>This is my code:</p>
<pre><code>frame = driver.find_element(By.XPATH, "/html/frameset/frame[2]")
driver.switch_to.frame(frame)
frame= driver.find_element(By.XPATH, '/html/frameset/frame[1]')
driver.switch_to.frame(frame)
</code></pre>
<p>HTML CODE:</p>
<pre><code><html><head>
<title>
Le Moniteur belge.
</title>
</head>
<frameset rows="14%,*">
<frame src="rech_f1.htm" name="frame1_fr" noresize="">
<frame src="rech_f2.htm" name="frame2_fr" cd_frame_id_="f1e39289d55588245ed84ea909665732">
<html>
<frameset>
<frame src="list_body.pl?language=fr&amp;sql=htit+contains++'roche'&amp;fromtab=+moftxt+UNION+montxt+UNION+modtxt&amp;rech=83&amp;trier=promulgation&amp;tri=dd+AS+RANK+&amp;dt=&amp;ddda=&amp;dddm=&amp;dddj=&amp;ddfa=&amp;ddfm=&amp;ddfj=&amp;pdda=&amp;pddm=&amp;pddj=&amp;pdfa=&amp;pdfm=&amp;pdfj=&amp;numac=&amp;bron=&amp;htit=roche&amp;text1=&amp;choix1=ET&amp;text2=&amp;choix2=ET&amp;text3=&amp;exp=&amp;&amp;fr=f&amp;nl=n&amp;du=d&amp;an=" name="Body" scrolling="auto">
</frameset>
</html>
<noframes>
pas de frames
</noframes>
</frameset>
</code></pre>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440282/"
] |
74,346,994 | <div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>LastName</th>
<th>FirstName</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mr.</td>
<td>Bean</td>
</tr>
<tr>
<td>Mr.</td>
<td>Jobe</td>
</tr>
</tbody>
</table>
</div>
<p>How to use like operators when input name is “Obe ”
Wanna match both column for the input name</p>
<p>SQL
Select * from name where
inputname like (‘%’ || (trim(firstname) || ‘%’));</p>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20078523/"
] |
74,346,998 | <p>After converting a Plotly graph to an HTML Page by this code:</p>
<pre><code>import plotly
import plotly.express as px
df = px.data.stocks()
fig = px.line(df, x='date', y="GOOG")
plotly.offline.plot(fig , filename = 'filename.html', auto_open=False)
</code></pre>
<p>How can I store this HTML Page on an S3 bucket?</p>
<p>I tried this code:</p>
<pre><code>fig.write_html('testPage.html', auto_play=False)
</code></pre>
<p>But I'm getting this error:</p>
<pre><code> Read-only file system: 'testPage.html'
</code></pre>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,347,026 | <p>I leave the error. I was working with this module until yesterday. Whn I try to run appear this error. If I create a new project when install it, Appear always the same
`</p>
<pre><code> ^
</code></pre>
<p>F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:70: error: package androidx.core.app
does not exist
import static androidx.core.app.ActivityCompat.requestPermissions;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:70: error: static import only from cl
asses and interfaces
import static androidx.core.app.ActivityCompat.requestPermissions;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:88: error: cannot find symbol<br />
public class RNCallKeepModule extends ReactContextBaseJavaModule {
^
symbol: class ReactContextBaseJavaModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:100: error: cannot find symbol<br />
private static Promise hasPhoneAccountPromise;
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:101: error: cannot find symbol<br />
private ReactApplicationContext reactContext;
^
symbol: class ReactApplicationContext
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:105: error: cannot find symbol<br />
private ReadableMap _settings;
^
symbol: class ReadableMap
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:107: error: cannot find symbol<br />
public RNCallKeepModule(ReactApplicationContext reactContext) {
^
symbol: class ReactApplicationContext
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:119: error: cannot find symbol<br />
public void setup(ReadableMap options) {
^
symbol: class ReadableMap
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:219: error: cannot find symbol<br />
public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promise promise) {
^
symbol: class ReadableArray
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:219: error: cannot find symbol<br />
public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promise promise) {
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:249: error: cannot find symbol<br />
public void checkDefaultPhoneAccount(Promise promise) {
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:348: error: cannot find symbol<br />
public void hasPhoneAccount(Promise promise) {
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:353: error: cannot find symbol<br />
public void hasOutgoingCall(Promise promise) {
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:358: error: cannot find symbol<br />
public void hasPermissions(Promise promise) {
^
symbol: class Promise
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:469: error: cannot find symbol<br />
private void sendEventToJS(String eventName, @Nullable WritableMap params) {
^
symbol: class WritableMap
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:20: error: package com.facebook.reac
t does not exist
import com.facebook.react.ReactPackage;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:21: error: package com.facebook.reac
t.bridge does not exist
import com.facebook.react.bridge.JavaScriptModule;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:22: error: package com.facebook.reac
t.bridge does not exist
import com.facebook.react.bridge.NativeModule;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:23: error: package com.facebook.reac
t.bridge does not exist
import com.facebook.react.bridge.ReactApplicationContext;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:24: error: package com.facebook.reac
t.uimanager does not exist
import com.facebook.react.uimanager.ViewManager;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:29: error: cannot find symbol<br />
public class RNCallKeepPackage implements ReactPackage {
^
symbol: class ReactPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:32: error: cannot find symbol<br />
public List createNativeModules(ReactApplicationContext reactContext) {
^
symbol: class ReactApplicationContext
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:32: error: cannot find symbol<br />
public List createNativeModules(ReactApplicationContext reactContext) {
^
symbol: class NativeModule
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:37: error: cannot find symbol<br />
public List<Class<? extends JavaScriptModule>> createJSModules() {
^
symbol: class JavaScriptModule
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:42: error: cannot find symbol<br />
public List createViewManagers(ReactApplicationContext reactContext) {
^
symbol: class ReactApplicationContext
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:42: error: cannot find symbol<br />
public List createViewManagers(ReactApplicationContext reactContext) {
^
symbol: class ViewManager
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnection.java:26: error: cannot find symbol
import androidx.annotation.Nullable;
^
symbol: class Nullable
location: package androidx.annotation
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnection.java:27: error: package androidx.localbroad
castmanager.content does not exist
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnectionService.java:29: error: cannot find symbol<br />
import androidx.annotation.Nullable;
^
symbol: class Nullable
location: package androidx.annotation
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnectionService.java:30: error: package androidx.loc
albroadcastmanager.content does not exist
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepBackgroundMessagingService.java:37: error: cannot
find symbol
protected @Nullable
^
symbol: class Nullable
location: class RNCallKeepBackgroundMessagingService
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:118: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:132: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:150: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:164: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:186: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:202: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:218: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:248: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:266: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:280: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:293: error: cannot find symbol
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:307: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:326: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:336: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:347: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:352: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:357: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:362: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:367: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:372: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:383: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:402: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:413: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:419: error: cannot find symbol<br />
@ReactMethod
^
symbol: class ReactMethod
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:469: error: cannot find symbol<br />
private void sendEventToJS(String eventName, @Nullable WritableMap params) {
^
symbol: class Nullable
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnection.java:202: error: cannot find symbol<br />
private void sendCallRequestToActivity(final String action, @Nullable final HashMap attributeMap) {
^
symbol: class Nullable
location: class VoiceConnection
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnectionService.java:273: error: cannot find symbol
private void sendCallRequestToActivity(final String action, @Nullable final HashMap attributeMap) {
^
symbol: class Nullable
location: class VoiceConnectionService
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepBackgroundMessagingService.java:36: error: method
does not override or implement a method from a supertype
@Override
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepBackgroundMessagingService.java:41: error: cannot
find symbol
return new HeadlessJsTaskConfig(
^
symbol: class HeadlessJsTaskConfig
location: class RNCallKeepBackgroundMessagingService
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepBackgroundMessagingService.java:43: error: cannot
find symbol
Arguments.fromBundle(extras),
^
symbol: variable Arguments
location: class RNCallKeepBackgroundMessagingService
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:113: error: method does not override
or implement a method from a supertype
@Override
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:220: error: cannot find symbol<br />
Activity currentActivity = this.getCurrentActivity();
^
symbol: method getCurrentActivity()
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:241: error: cannot find symbol<br />
requestPermissions(currentActivity, allPermissions, REQUEST_READ_PHONE_STATE);
^
symbol: method requestPermissions(Activity,String[],int)
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:424: error: cannot find symbol<br />
Activity activity = getCurrentActivity();
^
symbol: method getCurrentActivity()
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:438: error: cannot find symbol<br />
getReactApplicationContext().startActivity(focusIntent);
^
symbol: method getReactApplicationContext()
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:470: error: cannot find symbol<br />
this.reactContext.getJSModule(RCTDeviceEventEmitter.class).emit(eventName, params);
^
symbol: class RCTDeviceEventEmitter
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:481: error: cannot find symbol<br />
Activity currentActivity = this.getCurrentActivity();
^
symbol: method getCurrentActivity()
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:485: error: cannot find symbol<br />
int permissionCheck = ContextCompat.checkSelfPermission(currentActivity, permission);
^
symbol: variable ContextCompat
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:511: error: cannot find symbol<br />
LocalBroadcastManager.getInstance(this.reactContext).registerReceiver(voiceBroadcastReceiver, intentFilter);
^
symbol: variable LocalBroadcastManager
location: class RNCallKeepModule
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:536: error: cannot find symbol<br />
WritableMap args = Arguments.createMap();
^
symbol: class WritableMap
location: class RNCallKeepModule.VoiceBroadcastReceiver
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:536: error: cannot find symbol<br />
WritableMap args = Arguments.createMap();
^
symbol: variable Arguments
location: class RNCallKeepModule.VoiceBroadcastReceiver
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepModule.java:594: error: cannot find symbol<br />
HeadlessJsTaskService.acquireWakeLockNow(reactContext);
^
symbol: variable HeadlessJsTaskService
location: class RNCallKeepModule.VoiceBroadcastReceiver
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:31: error: method does not override
or implement a method from a supertype
@Override
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:33: error: cannot find symbol<br />
return Collections.singletonList(new RNCallKeepModule(reactContext));
^
symbol: class NativeModule
location: class RNCallKeepPackage
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\RNCallKeepPackage.java:41: error: method does not override
or implement a method from a supertype
@Override
^
F:\lantis_new_and_updated\node_modules\react-native-callkeep\android\src\main\java\io\wazo\callkeep\VoiceConnection.java:215: error: cannot find symbol<br />
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
^
symbol: variable LocalBroadcastManager
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors</p>
<p>FAILURE: Build failed with an exception.</p>
<ul>
<li>What went wrong:
Execution failed for task ':react-native-callkeep:compileDebugJavaWithJavac'.</li>
</ul>
<blockquote>
<p>Compilation failed; see the compiler error output for details.</p>
</blockquote>
<ul>
<li><p>Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p>
</li>
<li><p>Get more help at <a href="https://help.gradle.org" rel="noreferrer">https://help.gradle.org</a></p>
</li>
</ul>
<p>BUILD FAILED in 48s</p>
<pre><code>at checkExecSyncError (node:child_process:828:11)
at execFileSync (node:child_process:863:15)
at runOnAllDevices (F:\lantis_new_and_updated\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Command.handleAction (F:\lantis_new_and_updated\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:182:9)
</code></pre>
<pre><code>`
I have tried all this solutions below:
change the implementation 'com.google.android.gms:play-services-ads:+' to 19.8.0
add the onRewardedVideoCompleted() method in RNAdMobRewardedVideoAdModule
update the compileSdkVersion, buildToolsVersion and targetSdkVersion in RNAdMobRewardedVideoAdModule
set the enableJetifier to false
</code></pre>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18666916/"
] |
74,347,062 | <p>I have my Blazor component with some <code>JavaScript</code> code. When there is a click detected by the JavaScript code, I want to call an <code>JSInvokable</code> function in my Blazor component to update the UI.</p>
<p>So, I created a function like this</p>
<pre><code>[JSInvokable]
public static async Task ChangeTab(string val)
{
Console.WriteLine(val);
}
</code></pre>
<p>in the <code>JavaScript</code>, I added the following line:</p>
<pre><code>DotNet.invokeMethodAsync('myComponent', 'ChangeTab', tabText);
</code></pre>
<p>This code is working and the function <code>ChangeTab</code> receives the value I expected. The problem is that this function is <code>static</code>. So, I can't change the variables. I tried to change the code like this (<em>ActivatePage</em> is a function in the component)</p>
<pre><code>[JSInvokable("ChangeTab")]
public async Task ChangeTab(string val)
{
ActivatePage(val);
}
</code></pre>
<p>but in this case I get an error because the function is not static.</p>
<blockquote>
<p>Error: System.ArgumentException: The assembly 'PSC.Blazor.Components.ScrollTabs' does not contain a public invokable method with [JSInvokableAttribute("ChangeTab")]</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/UXvzQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UXvzQ.png" alt="enter image description here" /></a></p>
<p>I checked the <a href="https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-dotnet-from-javascript?view=aspnetcore-6.0" rel="nofollow noreferrer">Microsoft documentation</a> but I don't understand how to change the <code>JSInvokable</code> function to not be <code>static</code>.</p>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5201985/"
] |
74,347,063 | <p>I had previously modelled a ManyToMany relation in JPA but now I had to make it OneToMany and ManyToOne. I had some input from a friend but now I am unable to save the join table correctly.</p>
<p>These are my entities:</p>
<p>Label:</p>
<pre><code>public class Label implements Serializable {
@Id
@GeneratedValue()
@Column(updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
// BEFORE
// @OneToMany
@OneToMany(mappedBy = "technology")
private Set<TechnologyLabel> technology;
//getters setters equal hashcode
}
</code></pre>
<p>Technology:</p>
<pre><code>public class Technology implements Serializable {
@Id
@GeneratedValue
@Column(updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID uuid;
@Column(nullable = false, length = 30)
private String technologyName;
// BEFORE
// @OneToMany
@OneToMany(mappedBy = "label")
private Set<TechnologyLabel> labels;
//getters setters equal hashcode
}
</code></pre>
<p>TechnologyLabel:</p>
<pre><code>public class TechnologyLabel {
@Id
@EqualsAndHashCode.Include
UUID technologyId;
@Id
@EqualsAndHashCode.Include
@Column(name = "label__id")
UUID labelId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(insertable = false, updatable = false)
Technology technology;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(insertable = false, updatable = false)
Label label;
//getters setters equal hashcode
@Data
public static class PK implements Serializable {
UUID technologyId;
UUID labelId;
}
}
</code></pre>
<p>My issues is in how to save <code>TechnologyLabel</code>. What I do is:</p>
<ol>
<li>create <code>label</code> and save it in DB</li>
<li>create <code>technology</code> and save it in DB</li>
<li>create <code>technologyLabel</code> add <code>label</code> and <code>technology</code> and save it in DB</li>
</ol>
<p>an example of step 3 is:</p>
<pre><code>var technologyLabelList = new ArrayList<TechnologyLabel>();
for (var t : technologies) {
for (var l : labels) {
var technologyLabel = new TechnologyLabel();
technologyLabel.setTechnology(t);
technologyLabel.setLabelId(l.getId());
technologyLabel.setTechnologyId(t.getUuid());
technologyLabel.setLabel(l);
technologyLabelList.add(technologyLabel);
}
}
technologyLabelRepository.saveAll(technologyLabelList);
</code></pre>
<p>like this my program runs and the table is created. The issue I have is that I have to manually set the <code>labelId</code> and <code>technologyId</code>. The resulting <code>TechnologyLabel table</code> looks weird to me though as it has the IDs twice and once empty.</p>
<p><a href="https://i.stack.imgur.com/apO8H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/apO8H.png" alt="enter image description here" /></a></p>
<p>I had to set the name of the column for the <code>labelId</code> to <code>label__id</code> or I would get the following error:</p>
<blockquote>
<p>Caused by: org.hibernate.DuplicateMappingException: Table [technology_label] contains physical column name [label_id] referred to by multiple logical column names: [label_id], [labelId]</p>
</blockquote>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11903423/"
] |
74,347,108 | <p>Our app works fine without problems during the OAuth flow, that is, the following URL:
<a href="https://accounts.google.com/o/oauth2/auth" rel="nofollow noreferrer">https://accounts.google.com/o/oauth2/auth</a></p>
<p>However, if the account is under the <a href="https://landing.google.com/advancedprotection/" rel="nofollow noreferrer">Advanced Protected Program</a>, then the OAuth will failed with the following messages: (assume XXX is the name of our app)</p>
<blockquote>
<p>Access blocked: XXX is not approved by Advanced Protection <br><br>
The Advanced Protection Program performs additional security checks to safeguard your account data, and it hasn't approved this app.
If you want to allow XXX access to your data, you can reach out to the app developer and encourage them to submit the app for verification. Learn more about this error
If you are a developer of XXX, see error details.
<br><br>Error 400: policy_enforced</p>
</blockquote>
<p>We have checked the <a href="https://support.google.com/accounts/answer/7539956" rel="nofollow noreferrer">Common questions with Advanced Protection Program</a> article, and there seems to be only 4 kinds of apps are allowed to access:</p>
<ul>
<li>All Google apps and services</li>
<li>Apple Mail, Calendar, and Contacts apps on iOS and macOS</li>
<li>Mozilla Thunderbird</li>
<li>Desktop email clients that access Gmail directly</li>
</ul>
<p>Since the above error messages said that "encourage them to submit the app for verification", we think there maybe some way to submit the verification. However, there's no other information about the app verification submission for Advanced Protection Program in the article.</p>
<p>We found out that for Google Workspace accounts, admin can <a href="https://support.google.com/a/answer/7281227" rel="nofollow noreferrer">configure whitelist</a> to bypass the advanced protection issue, but for Google's account (ex: gmail.com), no such way is available.</p>
<p>By the way, our app already passed the app verification for sensitive/restricted API scope:
<a href="https://i.stack.imgur.com/ImkwZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ImkwZ.png" alt="enter image description here" /></a>
<br>We don't know whether the app verification for Advanced Protection Program is related to the above app verification progress or not. (For example, click the verify again and maybe there will be a new option for Advanced Protection Program during the verification form?)</p>
<p>We would like to know if there's a way to submit the app verification for Advanced Protection Program, or any alternative way to bypass this error (except for temporarily turn off the Advanced Protected Program).</p>
<p>Thank you!</p>
| [
{
"answer_id": 74347122,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 1,
"selected": false,
"text": "$xmldata.settings.ChildNodes | where {$_.name -eq \"Connections\"} | foreach {$_.value = \"new-value\"}\n"
},
{
"answer_id": 74347162,
"author": "Santiago Squarzon",
"author_id": 15339544,
"author_profile": "https://Stackoverflow.com/users/15339544",
"pm_score": 3,
"selected": true,
"text": "SelectSingleNode"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4976038/"
] |
74,347,112 | <p><a href="https://i.stack.imgur.com/KXxj4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KXxj4.png" alt="enter image description here" /></a></p>
<p>I want to call the state method in answer file.
<a href="https://i.stack.imgur.com/Lf0vt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lf0vt.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74347967,
"author": "Duck Programmer",
"author_id": 12858184,
"author_profile": "https://Stackoverflow.com/users/12858184",
"pm_score": 1,
"selected": false,
"text": "final VoidCallback selectHandler"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20019751/"
] |
74,347,114 | <p>I have the following dataset:</p>
<pre><code>my.df <- data.frame(my_function=rep(c("Var1+Var 2","Var 2-Var1","(Var 2-(Var 2-Var1))/Var 2"), 1),
`Var1`=rep(1:1,3),
`Var 2`=rep(5:5,3), check.names = FALSE)
my.df
# my_function Var1 Var 2
# 1 Var1+Var 2 1 5
# 2 Var 2-Var1 1 5
# 3 (Var 2-(Var 2-Var1))/Var 2 1 5
</code></pre>
<p>And I want to use column named <code>my_function</code> to calculate the values for each row into a new column called <code>outcome</code></p>
<p>The <code>outcome</code> would be: <code>1+5=6</code>,<code>5-1=4</code>,<code>(5-(5-1))/5=0.2</code> for each of the rows.</p>
<p><strong>EDIT</strong>
Correct answers also reference the following original dataset:</p>
<pre><code>my.df <- data.frame(my_function=rep(c("1000+2000","2000-1000","(2000-(2000-1000))/2000"), 1), `1000`=rep(1:1,3), `2000`=rep(5:5,3))
</code></pre>
| [
{
"answer_id": 74347247,
"author": "Ric Villalba",
"author_id": 6912817,
"author_profile": "https://Stackoverflow.com/users/6912817",
"pm_score": 0,
"selected": false,
"text": "my.df <- data.frame(my_function=rep(c(\"1000+2000\",\"2000-1000\",\"(2000-(2000-1000))/2000\"), 1), `1000`=rep(1:1,3), `2000`=rep(5:5,3))\n\nmy.df\n#> my_function X1000 X2000\n#> 1 1000+2000 1 5\n#> 2 2000-1000 1 5\n#> 3 (2000-(2000-1000))/2000 1 5\n\nmy.df$my_function = gsub(\"1000\", \"X1000\", my.df$my_function)\nmy.df$my_function = gsub(\"2000\", \"X2000\", my.df$my_function)\n\nmy.df$outcome = sapply(split(my.df, 1:NROW(my.df)), function(x)\n eval(str2lang(x$my_function),x))\n\nmy.df\n#> my_function X1000 X2000 outcome\n#> 1 X1000+X2000 1 5 6.0\n#> 2 X2000-X1000 1 5 4.0\n#> 3 (X2000-(X2000-X1000))/X2000 1 5 0.2\n"
},
{
"answer_id": 74347294,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 0,
"selected": false,
"text": "library(tidyverse)\n\nmy.df <- data.frame(my_function=rep(c(\"1000+2000\",\"2000-1000\",\"(2000-(2000-1000))/2000\"), 1), `1000`=rep(1:1,3), `2000`=rep(5:5,3))\n\nmy.df |>\n mutate(sub_function = pmap_chr(list(my_function, X1000, X2000),\n ~gsub(pattern = \"1000\", \n replacement = ..2,\n x = ..1) |> \n gsub(pattern = \"2000\",\n replacement = ..3)),\n eval = map_chr(sub_function, ~as.character(Ryacas::yac_symbol(.x))))\n#> my_function X1000 X2000 sub_function eval\n#> 1 1000+2000 1 5 1+5 6\n#> 2 2000-1000 1 5 5-1 4\n#> 3 (2000-(2000-1000))/2000 1 5 (5-(5-1))/5 1/5\n"
},
{
"answer_id": 74347456,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 2,
"selected": false,
"text": "vars <- colnames(my.df)[ -1 ]\n\nsapply(seq(nrow(my.df)), function(i){\n res <- my.df[i, 1]\n for(v in vars){\n res <- gsub(v, my.df[i, v], res, fixed = TRUE)\n }\n eval(parse(text = res))\n})\n# [1] 6.0 4.0 0.2\n"
},
{
"answer_id": 74347510,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 0,
"selected": false,
"text": "purrr::pmap_dbl()"
},
{
"answer_id": 74347581,
"author": "TimTeaFan",
"author_id": 9349302,
"author_profile": "https://Stackoverflow.com/users/9349302",
"pm_score": 0,
"selected": false,
"text": "bquote"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6072684/"
] |
74,347,125 | <p>I was looking at this post <a href="https://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as-the-key">C++ unordered_map using a custom class type as the key</a></p>
<ol>
<li>I understand that we need to redefine <code>equality</code> and <code>hash code</code> for a custom type key.</li>
<li>I know how the operator overloading works in general.</li>
</ol>
<p>However, what does <code>operator()</code> have to do with the <code>hash code</code>?<br />
Does <code>unordered_map</code> internally evaluate a key with <code>()</code> operator somewhere?</p>
| [
{
"answer_id": 74347201,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 3,
"selected": true,
"text": "std::unordered_map"
},
{
"answer_id": 74350200,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 0,
"selected": false,
"text": "std::unordered_map"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13316849/"
] |
74,347,128 | <p>I created a confirm sell wherein the seller will be able to click a specific transaction in React JS, and once that transaction is complete, the status will be <code>completed</code> and the button should be disabled permanently.</p>
<p><a href="https://i.stack.imgur.com/QX49N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QX49N.png" alt="enter image description here" /></a></p>
<p>In this latest transaction, I will only confirm the shoe with a status of <code>pending</code></p>
<p><a href="https://i.stack.imgur.com/dKhJ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dKhJ3.png" alt="Result" /></a></p>
<p>This is what happened after clicking the pending button.</p>
<p>Confirm Button</p>
<pre><code>const confirmSell = async (e) => {
try {
await userRequest.put(`/order/${e}`, {status: 'complete'})
setExecuting(true)
} catch (error) {
console.log({error: error.message})
}
}
</code></pre>
<p>Actual Button</p>
<pre><code><Button variant="contained"
onClick={(e) => confirmSell(recent._id)}
disabled={executing}
color="success">Confirm
</Button>
</code></pre>
| [
{
"answer_id": 74347256,
"author": "Jan",
"author_id": 12271495,
"author_profile": "https://Stackoverflow.com/users/12271495",
"pm_score": 1,
"selected": false,
"text": "<Button id=\"submit\" variant=\"contained\" \n onClick={(e) => confirmSell(recent._id)} \n disabled={executing} \n color=\"success\">Confirm \n</Button>\n"
},
{
"answer_id": 74348381,
"author": "Noel Moses Mwadende",
"author_id": 12273877,
"author_profile": "https://Stackoverflow.com/users/12273877",
"pm_score": 3,
"selected": true,
"text": "products = [\n {\n _id: \"1\",\n name: \"Airpods Wireless Bluetooth Headphones\",\n confirmed: \"pending\",\n },\n\n {\n _id: \"2\",\n name: \"iPhone 11 Pro 256GB Memory\",\n confirmed: \"pending\",\n },\n]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20088885/"
] |
74,347,138 | <p>i'm trying to make cartesian coordinate for my coursework and can only get here, I'm grateful if anyone can help me to fix this "0" line</p>
<pre><code><?php
$n=10;
for($i=-10;$i<=$n;$i++){
for($j=-10;$j<=$n;$j++){
if($i==0 || $j==0){
echo " $i ";
} else {
echo " ";
}
}
echo "\n";
}
</code></pre>
<p><a href="https://i.stack.imgur.com/oqYs2.jpg" rel="nofollow noreferrer">Current output</a>
<a href="https://i.stack.imgur.com/607Ns.jpg" rel="nofollow noreferrer">What i expected</a></p>
| [
{
"answer_id": 74347256,
"author": "Jan",
"author_id": 12271495,
"author_profile": "https://Stackoverflow.com/users/12271495",
"pm_score": 1,
"selected": false,
"text": "<Button id=\"submit\" variant=\"contained\" \n onClick={(e) => confirmSell(recent._id)} \n disabled={executing} \n color=\"success\">Confirm \n</Button>\n"
},
{
"answer_id": 74348381,
"author": "Noel Moses Mwadende",
"author_id": 12273877,
"author_profile": "https://Stackoverflow.com/users/12273877",
"pm_score": 3,
"selected": true,
"text": "products = [\n {\n _id: \"1\",\n name: \"Airpods Wireless Bluetooth Headphones\",\n confirmed: \"pending\",\n },\n\n {\n _id: \"2\",\n name: \"iPhone 11 Pro 256GB Memory\",\n confirmed: \"pending\",\n },\n]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16412398/"
] |
74,347,141 | <p><a href="https://i.stack.imgur.com/cJF1O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cJF1O.png" alt="enter image description here" /></a></p>
<p>so, i want to hide "Overtime AC" Value when i choose Balikpapan Office.</p>
<p>This is my code, still not working</p>
<pre><code>var ddlLoc = $("[id$='_ddl_OfficeLocationosf']");
var ddlReqFor = $("[id$='_ddl_RequestForosf']");
ddlLoc.change(function() {
if(ddlLoc.find("option[value='Balikpapan Office']") == true) {
ddlReqFor.find("option[value='Overtime AC']").parent().parent().hide();
} else {
ddlReqFor.find("option[value='Overtime AC']").parent().parent().show();
}
});
</code></pre>
| [
{
"answer_id": 74347256,
"author": "Jan",
"author_id": 12271495,
"author_profile": "https://Stackoverflow.com/users/12271495",
"pm_score": 1,
"selected": false,
"text": "<Button id=\"submit\" variant=\"contained\" \n onClick={(e) => confirmSell(recent._id)} \n disabled={executing} \n color=\"success\">Confirm \n</Button>\n"
},
{
"answer_id": 74348381,
"author": "Noel Moses Mwadende",
"author_id": 12273877,
"author_profile": "https://Stackoverflow.com/users/12273877",
"pm_score": 3,
"selected": true,
"text": "products = [\n {\n _id: \"1\",\n name: \"Airpods Wireless Bluetooth Headphones\",\n confirmed: \"pending\",\n },\n\n {\n _id: \"2\",\n name: \"iPhone 11 Pro 256GB Memory\",\n confirmed: \"pending\",\n },\n]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16564771/"
] |
74,347,142 | <p>I am encountering a issue that is ECU waked up by error frame.
Then, I got report from the testing team for this issue.
I am wondering why error frame can wake up the ECU in sleep mode? how can?</p>
<p>who know this issue or encountered this one, Please help me</p>
<p>I really appreciate your willing to support!</p>
| [
{
"answer_id": 74347256,
"author": "Jan",
"author_id": 12271495,
"author_profile": "https://Stackoverflow.com/users/12271495",
"pm_score": 1,
"selected": false,
"text": "<Button id=\"submit\" variant=\"contained\" \n onClick={(e) => confirmSell(recent._id)} \n disabled={executing} \n color=\"success\">Confirm \n</Button>\n"
},
{
"answer_id": 74348381,
"author": "Noel Moses Mwadende",
"author_id": 12273877,
"author_profile": "https://Stackoverflow.com/users/12273877",
"pm_score": 3,
"selected": true,
"text": "products = [\n {\n _id: \"1\",\n name: \"Airpods Wireless Bluetooth Headphones\",\n confirmed: \"pending\",\n },\n\n {\n _id: \"2\",\n name: \"iPhone 11 Pro 256GB Memory\",\n confirmed: \"pending\",\n },\n]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18519005/"
] |
74,347,147 | <p>i have a form where user can upload pictures with text fields. Image isn't mandatory. But when user don't upload the image, then on result page a broken image icon appears. i am using angular 14.</p>
<p>Here is what i have tried so far but that didn't work</p>
<pre><code><div id="task-description" data-ui-test="task-details-description">
<p class=" kKZuUH"> | {{ selectJobPostData.detail }}
<span style="float: left;">-</span>
<span style="float: left;">Due date: {{
selectJobPostData.time_range.title }}</span>
</p>
<img *ngIf="imageulr + selectJobPostData.id" [src]="imageulr + selectJobPostData.id"
style="width:250px"/>
<div class="bubbles"></div>
</div>
</code></pre>
| [
{
"answer_id": 74347203,
"author": "Matthieu Riegler",
"author_id": 884123,
"author_profile": "https://Stackoverflow.com/users/884123",
"pm_score": 0,
"selected": false,
"text": "onerror"
},
{
"answer_id": 74347314,
"author": "Team Thunder",
"author_id": 14796728,
"author_profile": "https://Stackoverflow.com/users/14796728",
"pm_score": 3,
"selected": true,
"text": "<img src=\"pic_trulli.jpg\" alt=\"\" onerror=\"this.style.display='none'\"/>\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16903358/"
] |
74,347,149 | <p>I have a stringified data from which I'm trying to print a character that occurs before a matching pattern. This matching pattern will occur multiple times so the result can also be a list of characters</p>
<p>E.g</p>
<p>Stringified data is <code>[[1, "[{\"name\": \"john\", \"id\": \"1\"}]", [2, "[{\"name\": \"john\", \"id\": \"1\"}]"]</code></p>
<p>The matching pattern from the data will be <code>, "[</code></p>
<p>The Expected result is <code>1 2</code></p>
<p>As we can see the charecter <code>1</code> and <code>2</code> is printed before each occurance of <code>, "[</code></p>
| [
{
"answer_id": 74347293,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 2,
"selected": true,
"text": "astring = '[[1, \"[{\\\"name\\\": \\\"john\\\", \\\"id\\\": \\\"1\\\"}]\", [2, \"[{\\\"name\\\": \\\"john\\\", \\\"id\\\": \\\"1\\\"}]\"]'\n\npattern = ', \"['\n\noffset = 0\npchars = []\n\nwhile (index := astring[offset:].find(pattern)) >= 0:\n if offset + index > 0:\n pchars.append(astring[offset+index-1])\n offset += index + 1\n\nprint(*pchars)\n"
},
{
"answer_id": 74347302,
"author": "Thomas Weller",
"author_id": 480982,
"author_profile": "https://Stackoverflow.com/users/480982",
"pm_score": 0,
"selected": false,
"text": "import json\ndata = '[[1, \"[{\\\\\"name\\\\\": \\\\\"john\\\\\", \\\\\"id\\\\\": \\\\\"1\\\\\"}]\"], [2, \"[{\\\\\"name\\\\\": \\\\\"john\\\\\", \\\\\"id\\\\\": \\\\\"1\\\\\"}]\"]]'\nparsed = json.loads(data)\nfor arr in parsed:\n print(arr[0], end=\" \")\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11496645/"
] |
74,347,157 | <p>I'm currently trying to understand why this little piece of code doesn't work as expected:</p>
<pre><code>// ContentView.swift (before var body: some View)
let name = "Emma"
// ContentView.swift (inside var body: some View)
Text("hello-name \(name)")
// Localizable.strings
"hello-name %@" = "Hello, my name is %@";
</code></pre>
<p>I have also tried using <code>NSLocalizedString</code> as sometimes it does the trick:</p>
<pre><code>// ContentView.swift (inside var body: some View)
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name))
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name as String))
Text(String(format: NSLocalizedString("hello-name %@", comment: "Name"), name as CVarArg))
</code></pre>
<p>But still I don't get <code>Hello, my name is Emma</code>. Do you know why? Thanks!</p>
| [
{
"answer_id": 74347293,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 2,
"selected": true,
"text": "astring = '[[1, \"[{\\\"name\\\": \\\"john\\\", \\\"id\\\": \\\"1\\\"}]\", [2, \"[{\\\"name\\\": \\\"john\\\", \\\"id\\\": \\\"1\\\"}]\"]'\n\npattern = ', \"['\n\noffset = 0\npchars = []\n\nwhile (index := astring[offset:].find(pattern)) >= 0:\n if offset + index > 0:\n pchars.append(astring[offset+index-1])\n offset += index + 1\n\nprint(*pchars)\n"
},
{
"answer_id": 74347302,
"author": "Thomas Weller",
"author_id": 480982,
"author_profile": "https://Stackoverflow.com/users/480982",
"pm_score": 0,
"selected": false,
"text": "import json\ndata = '[[1, \"[{\\\\\"name\\\\\": \\\\\"john\\\\\", \\\\\"id\\\\\": \\\\\"1\\\\\"}]\"], [2, \"[{\\\\\"name\\\\\": \\\\\"john\\\\\", \\\\\"id\\\\\": \\\\\"1\\\\\"}]\"]]'\nparsed = json.loads(data)\nfor arr in parsed:\n print(arr[0], end=\" \")\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18547664/"
] |
74,347,181 | <p>I have a problem when logging in, <strong>it does not show me the data in the database</strong>, it seems that the problem is in the function that <strong>fetches the data</strong>, but I don't know where the problem is</p>
<p>This is the function that fetches data from the database:</p>
<pre><code>Future<void> fetchProperties() async {
final url = Uri.https(
'aqarlibya-4d39c-default-rtdb.europe-west1.firebasedatabase.app',
'/properties.json?auth=$authToken');
try {
final response = await http.get(url);
final extractedData = json.decode(response.body) as Map<String, dynamic>?;
if (extractedData == null) {
return;
}
final List<Property> loadedProperties = [];
extractedData.forEach((propId, propData) {
loadedProperties.add(Property(
id: propId,
name: propData['name'],
description: propData['description'],
type: propData['type'],
propertySize: propData['propertySize'],
bedrooms: propData['bedrooms'],
price: propData['price'],
cityId: propData['cityId'],
imageUrl: propData['imageUrl'],
isFav: propData['isFav'],
));
});
_items = loadedProperties;
notifyListeners();
} catch (error) {
throw (error);
}
}
</code></pre>
<p>This is part of the code in the main file:</p>
<pre><code>Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(
value: Auth(),
),
ChangeNotifierProxyProvider<Auth, Properties>(
create: (ctx) => Properties('', []),
update: (ctx, auth, previousProperties) => Properties(
auth.token,
previousProperties == null ? [] : previousProperties.items,
),
),
],
</code></pre>
<p>I tried looking for the problem but couldn't find it</p>
<p><a href="https://i.stack.imgur.com/MG1qr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MG1qr.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74347377,
"author": "Remy",
"author_id": 20398469,
"author_profile": "https://Stackoverflow.com/users/20398469",
"pm_score": 0,
"selected": false,
"text": "try {} catch(e) {}"
},
{
"answer_id": 74348160,
"author": "Frank van Puffelen",
"author_id": 209103,
"author_profile": "https://Stackoverflow.com/users/209103",
"pm_score": 2,
"selected": true,
"text": "final url = Uri.https(\n 'aqarlibya-4d39c-default-rtdb.europe-west1.firebasedatabase.app',\n '/properties.json',\n { 'auth': authToken }\n);\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20358871/"
] |
74,347,193 | <p>I have a PHP array like so:</p>
<pre><code>$booleans = array(true, '||', false, '&&', true, '||', false);
</code></pre>
<p>Now I would now like to convert this array to a condition, e.g.:</p>
<pre><code>if(true || false && true || false){
// Do something
}
else{
// Do something else
}
</code></pre>
<p>Preferably, for security reasons, I want to avoid using <code>eval</code>.</p>
<p>Is this possible? If so, what is the most efficient way to do it?</p>
| [
{
"answer_id": 74347511,
"author": "Stranger",
"author_id": 13349935,
"author_profile": "https://Stackoverflow.com/users/13349935",
"pm_score": 0,
"selected": false,
"text": "function validate($params) {\n return true || false && true || false; // Maybe you'd want to use $params in there at some point?\n}\n"
},
{
"answer_id": 74347959,
"author": "Markus Zeller",
"author_id": 2645713,
"author_profile": "https://Stackoverflow.com/users/2645713",
"pm_score": 3,
"selected": true,
"text": "$validateExpression = function (array $expression): bool {\n $allowedOperators = ['&&', '||'];\n $values = [];\n $operators = [];\n foreach ($expression as $expr) {\n if (is_bool($expr)) {\n $values[] = $expr;\n continue;\n }\n if (in_array($expr, $allowedOperators)) {\n $operators[] = $expr;\n continue;\n }\n throw new \\InvalidArgumentException('Invalid expression');\n }\n\n while($operators) {\n $a = array_shift($values);\n $b = array_shift($operators);\n $c = array_shift($values);\n array_unshift($values, match($b) {\n '&&' => $a && $c,\n '||' => $a || $c,\n });\n }\n\n return reset($values);\n};\n\nvar_dump($validateExpression([true, '||', false, '&&', true, '||', false]));\nvar_dump(true || false && true || false);\n"
},
{
"answer_id": 74347998,
"author": "trckster",
"author_id": 8896838,
"author_profile": "https://Stackoverflow.com/users/8896838",
"pm_score": 2,
"selected": false,
"text": "<?php\n\nfunction parseArray(array $booleans): bool\n{\n $result = false;\n\n for ($i = 0; $i < count($booleans); $i += 2) {\n if ($i + 1 === count($booleans) || $booleans[$i + 1] === '||') {\n $result = $result || $booleans[$i];\n\n continue;\n }\n\n $andResult = $booleans[$i];\n while ($booleans[$i + 1] === '&&') {\n $i += 2;\n\n $andResult = $andResult && $booleans[$i];\n\n if ($i + 1 === count($booleans)) {\n break;\n }\n }\n\n $result = $result || $andResult;\n }\n\n return $result;\n}\n\nvar_dump(parseArray([false]));\nvar_dump(parseArray([true]));\nvar_dump(parseArray([true, '&&', false]));\nvar_dump(parseArray([true, '&&', true]));\nvar_dump(parseArray([true, '||', false]));\nvar_dump(parseArray([false, '||', false]));\nvar_dump(parseArray([false, '||', false, '&&', true, '||', false]));\nvar_dump(parseArray([true, '||', false, '&&', true, '||', false]));\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3289949/"
] |
74,347,196 | <p>For example i inputted "ABC"</p>
<p>The output should be:</p>
<pre><code>*** ** ***
* * * * *
*** ** *
* * * * *
* * ** ***
</code></pre>
<p>I only tried the letter A but it results an error.
Can someone help me do it in plain python without any modules</p>
<pre><code>text = input("Enter my text: ").split()
A = [3, [1,0,1], 3, [1,0,1], [1,0,1]]
for i in range(text+1):
if text[i] == 'A':
print("*" * A[i])
</code></pre>
| [
{
"answer_id": 74347267,
"author": "Cory Kramer",
"author_id": 2296458,
"author_profile": "https://Stackoverflow.com/users/2296458",
"pm_score": 1,
"selected": false,
"text": "A = [[1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,0,1]]\n"
},
{
"answer_id": 74347526,
"author": "jvx8ss",
"author_id": 11107859,
"author_profile": "https://Stackoverflow.com/users/11107859",
"pm_score": 1,
"selected": true,
"text": "a = {\n \"a\": [\n \"***\",\n \"* *\",\n \"***\",\n \"* *\",\n \"* *\",\n ],\n \"b\": [\n \"** \",\n \"* *\",\n \"** \",\n \"* *\",\n \"** \",\n ]\n}\n\nstring = \"abab\"\n\ndata = [a[char] for char in string]\n\n# 5 because the \"big letters\" have 5 rows\nfor i in range(5):\n row = \" \".join(d[i] for d in data)\n print(row)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440485/"
] |
74,347,209 | <p>I have created two new python notebooks for databricks in /workspace/Shared/Notebooks.</p>
<p>I would share some functions between the both notebooks. I have created a python file containing a few generic functions.</p>
<p>It exists a way to import my functions into my both notebooks ?</p>
<p>Thanks for your help.</p>
| [
{
"answer_id": 74347267,
"author": "Cory Kramer",
"author_id": 2296458,
"author_profile": "https://Stackoverflow.com/users/2296458",
"pm_score": 1,
"selected": false,
"text": "A = [[1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,0,1]]\n"
},
{
"answer_id": 74347526,
"author": "jvx8ss",
"author_id": 11107859,
"author_profile": "https://Stackoverflow.com/users/11107859",
"pm_score": 1,
"selected": true,
"text": "a = {\n \"a\": [\n \"***\",\n \"* *\",\n \"***\",\n \"* *\",\n \"* *\",\n ],\n \"b\": [\n \"** \",\n \"* *\",\n \"** \",\n \"* *\",\n \"** \",\n ]\n}\n\nstring = \"abab\"\n\ndata = [a[char] for char in string]\n\n# 5 because the \"big letters\" have 5 rows\nfor i in range(5):\n row = \" \".join(d[i] for d in data)\n print(row)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8094916/"
] |
74,347,235 | <p>I'm currently exploring using snakemake as a workflow tool.</p>
<p>In my specific use case I don't start from a list of files but rather from a list of values that should result in the creation of a list of files.</p>
<p>In my example, I create the files with a small python snippet which works fine but when I want to use those files in parallel in a second rule, they are concatenated into one parameter:</p>
<pre><code>
rule all:
input:
expand('{file}.bar', file=data)
rule foo:
output:
expand('{file}.foo', file=data)
run:
for item in data:
with open(f'{item}.foo', 'w') as fout:
fout.write('foo')
rule bar:
input:
file=expand('{file}.foo', file=data)
output:
outfile=expand('{file}.bar', file=data)
shell:
"""echo {output.outfile};echo bar > {output.outfile} """
</code></pre>
<p>the example prints</p>
<p>"one.bar two.bar three.bar"</p>
<p>at once, so the rule is applied only once,</p>
<p>and then raises an error because the expected output files are not created.</p>
| [
{
"answer_id": 74347267,
"author": "Cory Kramer",
"author_id": 2296458,
"author_profile": "https://Stackoverflow.com/users/2296458",
"pm_score": 1,
"selected": false,
"text": "A = [[1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,0,1]]\n"
},
{
"answer_id": 74347526,
"author": "jvx8ss",
"author_id": 11107859,
"author_profile": "https://Stackoverflow.com/users/11107859",
"pm_score": 1,
"selected": true,
"text": "a = {\n \"a\": [\n \"***\",\n \"* *\",\n \"***\",\n \"* *\",\n \"* *\",\n ],\n \"b\": [\n \"** \",\n \"* *\",\n \"** \",\n \"* *\",\n \"** \",\n ]\n}\n\nstring = \"abab\"\n\ndata = [a[char] for char in string]\n\n# 5 because the \"big letters\" have 5 rows\nfor i in range(5):\n row = \" \".join(d[i] for d in data)\n print(row)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680164/"
] |
74,347,246 | <p>I am trying to select the last string after splitting it in Azure Data Factory.</p>
<p>My file name looks like this:</p>
<p><code>s = "cloudboxacademy/covid19/main/ecdc_data/hospital_admissions.csv"</code></p>
<p>With Python I would use <code>s.split('/')[-1]</code> to get the last element, according to <a href="https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#last" rel="nofollow noreferrer">Microsoft documentation</a> I can use <code>last</code> to achieve this, so I've tried this in the sink database Pipeline expression builder:</p>
<p><code>@last(split(dataset().fileName, '/'))</code></p>
<p>Which gives me a red underline stating:</p>
<blockquote>
<p>Cannot fit string list item into the function parameter string</p>
</blockquote>
<p>However, after running the pipeline I get what I desire, the file named <code>hospital_admissions.csv</code> placed in the folder I want it to go, so my question is if I am chaining the functions correctly & why am I having the error with a working code?</p>
| [
{
"answer_id": 74347267,
"author": "Cory Kramer",
"author_id": 2296458,
"author_profile": "https://Stackoverflow.com/users/2296458",
"pm_score": 1,
"selected": false,
"text": "A = [[1,1,1], [1,0,1], [1,1,1], [1,0,1], [1,0,1]]\n"
},
{
"answer_id": 74347526,
"author": "jvx8ss",
"author_id": 11107859,
"author_profile": "https://Stackoverflow.com/users/11107859",
"pm_score": 1,
"selected": true,
"text": "a = {\n \"a\": [\n \"***\",\n \"* *\",\n \"***\",\n \"* *\",\n \"* *\",\n ],\n \"b\": [\n \"** \",\n \"* *\",\n \"** \",\n \"* *\",\n \"** \",\n ]\n}\n\nstring = \"abab\"\n\ndata = [a[char] for char in string]\n\n# 5 because the \"big letters\" have 5 rows\nfor i in range(5):\n row = \" \".join(d[i] for d in data)\n print(row)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8913983/"
] |
74,347,276 | <p>Sometimes we get text like reversed when people scan documents in reverse, which will look like this:</p>
<pre><code>stri = "1234 ᔭƐᘔІ "
</code></pre>
<p>I would like to count occurance of the each number in this cases like.</p>
<pre class="lang-none prettyprint-override"><code>1 - occured 2 times including reversed one.
2 - occured 2 times including reversed one
3 - occured 2 times including reversed one
4 - occured 2 times including reversed one
</code></pre>
<p>I've tried to use normal count like</p>
<pre><code>stri.count('1')
</code></pre>
<p>which gives me 1, but I expected 2 including reversed.</p>
<p>Expected output</p>
<pre class="lang-none prettyprint-override"><code>Number of 2's in str = 2
</code></pre>
| [
{
"answer_id": 74347413,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 1,
"selected": false,
"text": "UNICODE"
},
{
"answer_id": 74347454,
"author": "Bhargav",
"author_id": 15358800,
"author_profile": "https://Stackoverflow.com/users/15358800",
"pm_score": 1,
"selected": true,
"text": "pip install upsidedown\n\n\nimport upsidedown\n\nstrs = \"1234 ᔭƐᘔІ \"\n\nnormal =(strs.count('1'))\n\nflip = (upsidedown.transform('1234 ᔭƐᘔІ'))\nflip = (flip.count('1'))\n\ntotal = flip + normal\nprint(total)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440524/"
] |
74,347,279 | <p>I have a go struct which I'm using for my POST of an entity</p>
<pre><code>type Student struct {
ID string `json:"id" firestore:"id"`
Name string `json:"name" validate:"required" firestore:"name"`
}
</code></pre>
<p>From the POST body request I can send body as</p>
<pre><code>{
"id" : 123,
"name" : "Student Name"
}
</code></pre>
<p>I want to implement a functionality where the request should fail while doing the validation saying "id" field in POST body is not allowed.</p>
<p>As I'm planning to reuse the same struct for GET I'm unable to skip the "id" in json marshalling and unmarshalling.</p>
<p>Is there any struct tag like allowed:true or false ?</p>
<p>I tried to skip the json validation but I want to reuse the same struct i was unable to proceed.</p>
<p>In the code logic i can just every time override it to empty value but it doesn't seem to be good way to add custom logic for updating the fields after converting into object.</p>
<p>Saw various validate struct tag but didn't find any that will match the use case</p>
| [
{
"answer_id": 74347413,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 1,
"selected": false,
"text": "UNICODE"
},
{
"answer_id": 74347454,
"author": "Bhargav",
"author_id": 15358800,
"author_profile": "https://Stackoverflow.com/users/15358800",
"pm_score": 1,
"selected": true,
"text": "pip install upsidedown\n\n\nimport upsidedown\n\nstrs = \"1234 ᔭƐᘔІ \"\n\nnormal =(strs.count('1'))\n\nflip = (upsidedown.transform('1234 ᔭƐᘔІ'))\nflip = (flip.count('1'))\n\ntotal = flip + normal\nprint(total)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20261665/"
] |
74,347,282 | <p>Problem:
I have a ndarray (2000,7) and I want to count the numbers of Nan's per column and save it in an ndarray</p>
<p>Tried:</p>
<pre><code>number_nan_in_arr = np.count_nonzero(np.isnan(arr))
</code></pre>
<p>But this count the total number of nan's over all columns</p>
<p>Solution: ?</p>
| [
{
"answer_id": 74347337,
"author": "Hamzah",
"author_id": 16733101,
"author_profile": "https://Stackoverflow.com/users/16733101",
"pm_score": 2,
"selected": true,
"text": "axis=0"
},
{
"answer_id": 74347342,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": false,
"text": "sum"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19738291/"
] |
74,347,331 | <p>I have one column in MySQL which is return me comma separated value , I want to convert that column in to rows.</p>
<p>Better answer then <a href="https://stackoverflow.com/questions/22732151/how-to-convert-comma-separated-parameters-to-rows-in-mysql">How to convert comma separated parameters to rows in mysql?</a></p>
<p><code>select value from table limit 1</code></p>
<p>response</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>honda,activa,pleasure,car</td>
</tr>
</tbody>
</table>
</div>
<p>I want this value to row like</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>honda</td>
</tr>
<tr>
<td>activa</td>
</tr>
<tr>
<td>pleasure</td>
</tr>
<tr>
<td>car</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74347402,
"author": "Akina",
"author_id": 10138734,
"author_profile": "https://Stackoverflow.com/users/10138734",
"pm_score": 2,
"selected": true,
"text": "CREATE TABLE response (id INT, value TEXT)\nSELECT 1 id, 'honda,activa,pleasure,car' value;\n"
},
{
"answer_id": 74347465,
"author": "Harikrushna Patel",
"author_id": 8823231,
"author_profile": "https://Stackoverflow.com/users/8823231",
"pm_score": 0,
"selected": false,
"text": "CREATE FUNCTION `SPLIT_STR`(\n x VARCHAR(255),\n delim VARCHAR(12),\n pos INT\n) RETURNS varchar(255) CHARSET utf8mb3\nRETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),\n LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),\n delim, '')\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8823231/"
] |
74,347,358 | <p>I want to pass a property getter method reference as one of the function arguments, and have that argument be of my own functional interface type, but ran into an issue.</p>
<p>Here's a stripped down minimal reproducible case, I changed the variable from an argument into a property, but the issue is the same.</p>
<pre class="lang-kotlin prettyprint-override"><code>class Foo {
val bar: Bar? = null
}
class Bar
fun interface FooBarSelector {
fun select(foo: Foo): Bar?
}
class KotlinClass() {
val selector: FooBarSelector = Foo::bar
}
</code></pre>
<p>This doesn't compile, <code>Foo::bar</code> is underlined and the error is</p>
<pre><code>Type mismatch.
Required: FooBarSelector
Found: KProperty1<Foo, Bar?>
</code></pre>
<p>I tried to look this up, found similar questions about SAM conversions, but they were a bit different and I don't think any of them referred specifically to property getters.</p>
<p>I found that the issue can be solved by doing one of the following:</p>
<ol>
<li>Remove the explicit type, or replace it with the suggested <code>KProperty1</code>. Not an option, I want to preserve my type.</li>
<li>Replace the method reference with <code>FooBarSelector { it.bar }</code>. Far from ideal, but better than the first option.</li>
</ol>
<p>Why does this happen and are there any other options? I am new to Kotlin, but not Java.</p>
<p>Kotlin version used is 1.7.20</p>
<p><strong>EDIT:</strong></p>
<p>Here's my original goal: accept a <code>FooBarSelector</code> as an argument, and by default point it at a property getter:</p>
<pre class="lang-kotlin prettyprint-override"><code>fun doSomething(
selector: FooBarSelector = Foo::bar //doesn't compile
) {
}
</code></pre>
| [
{
"answer_id": 74347720,
"author": "Tarmo",
"author_id": 3020903,
"author_profile": "https://Stackoverflow.com/users/3020903",
"pm_score": 0,
"selected": false,
"text": "class Foo(\n val bar: Bar\n)\n\ndata class Bar(\n val value: String\n)\n\ninterface FooBarSelector {\n fun select(foo: Foo): Bar {\n return foo.bar\n }\n}\n\nclass FooBarCustomSelector: FooBarSelector {\n override fun select(foo: Foo): Bar {\n return Bar(\"I don't care about which Foo was passed. I'll return my own Bar\")\n }\n}\n\nclass KotlinClass(val selector: (Foo) -> Bar = Foo::bar)\n\nfun main(args: Array<String>) {\n val kotlinClassWithDefaultSelector = KotlinClass()\n val kotlinClassWithCustomSelector = KotlinClass(FooBarCustomSelector()::select)\n val foo = Foo(Bar(\"Bar1\"))\n println(\"kotlinClassWithDefaultSelector: ${kotlinClassWithDefaultSelector.selector(foo)}\")\n println(\"kotlinClassWithCustomSelector: ${kotlinClassWithCustomSelector.selector(foo)}\")\n}\n\n"
},
{
"answer_id": 74347991,
"author": "Tenfour04",
"author_id": 506796,
"author_profile": "https://Stackoverflow.com/users/506796",
"pm_score": 3,
"selected": true,
"text": "class KotlinClass() {\n val selector = FooBarSelector(Foo::bar)\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5999354/"
] |
74,347,384 | <p>I am trying to find a specific element inside a certain parent element "table_list". However, the webdriver finds all the occurence of my required element on the web page.</p>
<pre><code>def value():
table_list = driver.find_element(By.ID,"table_list")
print(table_list.text)
value_informal = table_list.find_elements(By.XPATH,"//tr[contains(@id,'informal')]")
for i in range(len(value_informal)):
value_td = value_informal[i].find_elements(By.TAG_NAME, "td")
print(value_td[3].text)
</code></pre>
<p>I want to find all the "informal" elements in the parent element "table_list" but my code is returning all the occurences of informal on the webpage. (I cannot use by.id,"informal" directly because I am using Partial Text).</p>
<p>I just want to find all the occurences of "informal" inside my specific "table_list".</p>
| [
{
"answer_id": 74347720,
"author": "Tarmo",
"author_id": 3020903,
"author_profile": "https://Stackoverflow.com/users/3020903",
"pm_score": 0,
"selected": false,
"text": "class Foo(\n val bar: Bar\n)\n\ndata class Bar(\n val value: String\n)\n\ninterface FooBarSelector {\n fun select(foo: Foo): Bar {\n return foo.bar\n }\n}\n\nclass FooBarCustomSelector: FooBarSelector {\n override fun select(foo: Foo): Bar {\n return Bar(\"I don't care about which Foo was passed. I'll return my own Bar\")\n }\n}\n\nclass KotlinClass(val selector: (Foo) -> Bar = Foo::bar)\n\nfun main(args: Array<String>) {\n val kotlinClassWithDefaultSelector = KotlinClass()\n val kotlinClassWithCustomSelector = KotlinClass(FooBarCustomSelector()::select)\n val foo = Foo(Bar(\"Bar1\"))\n println(\"kotlinClassWithDefaultSelector: ${kotlinClassWithDefaultSelector.selector(foo)}\")\n println(\"kotlinClassWithCustomSelector: ${kotlinClassWithCustomSelector.selector(foo)}\")\n}\n\n"
},
{
"answer_id": 74347991,
"author": "Tenfour04",
"author_id": 506796,
"author_profile": "https://Stackoverflow.com/users/506796",
"pm_score": 3,
"selected": true,
"text": "class KotlinClass() {\n val selector = FooBarSelector(Foo::bar)\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18459359/"
] |
74,347,406 | <p>I have 2 lists</p>
<p><code>l1 = [['a',1],['b',2],['c',3]]</code>
<code>l2 = [['b',2,10],['c',3,8]]</code></p>
<p>I want the below code to be replicated using list comprehension in python:</p>
<pre><code>for i in range(len(l1)):
cnt = 0
for j in range(len(l2)):
if (l1[i][0]==l2[j][0]) & (l1[i][1]==l2[j][1]):
cnt = 1
if cnt==1:
isintb.append(1)
else:
isintb.append(0)
</code></pre>
<p>expected output: [0,1,1]</p>
<p>can you guys help??</p>
<p>I tried as below:</p>
<p><code>[[1 if (l1[i][0]==l2[j][0]) & (l1[i][1]==l2[j][1]) else 0 for j in range(len(l2))] for i in range(len(l1))]</code></p>
<p>got output as below:
[[0, 0], [1, 0], [0, 1]]</p>
| [
{
"answer_id": 74347720,
"author": "Tarmo",
"author_id": 3020903,
"author_profile": "https://Stackoverflow.com/users/3020903",
"pm_score": 0,
"selected": false,
"text": "class Foo(\n val bar: Bar\n)\n\ndata class Bar(\n val value: String\n)\n\ninterface FooBarSelector {\n fun select(foo: Foo): Bar {\n return foo.bar\n }\n}\n\nclass FooBarCustomSelector: FooBarSelector {\n override fun select(foo: Foo): Bar {\n return Bar(\"I don't care about which Foo was passed. I'll return my own Bar\")\n }\n}\n\nclass KotlinClass(val selector: (Foo) -> Bar = Foo::bar)\n\nfun main(args: Array<String>) {\n val kotlinClassWithDefaultSelector = KotlinClass()\n val kotlinClassWithCustomSelector = KotlinClass(FooBarCustomSelector()::select)\n val foo = Foo(Bar(\"Bar1\"))\n println(\"kotlinClassWithDefaultSelector: ${kotlinClassWithDefaultSelector.selector(foo)}\")\n println(\"kotlinClassWithCustomSelector: ${kotlinClassWithCustomSelector.selector(foo)}\")\n}\n\n"
},
{
"answer_id": 74347991,
"author": "Tenfour04",
"author_id": 506796,
"author_profile": "https://Stackoverflow.com/users/506796",
"pm_score": 3,
"selected": true,
"text": "class KotlinClass() {\n val selector = FooBarSelector(Foo::bar)\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440489/"
] |
74,347,411 | <pre class="lang-js prettyprint-override"><code>var tablNum = prompt("enter numberr");
var tableCout = (tablNum * 10) + 1 ;
for (let i = tablNum; i < tableCout; i = i + 10) {
console.log(i)
}
</code></pre>
<p>This is my code but when I run my code, the loop works. I am trying to make math table generator this is my code but its not working.</p>
<pre class="lang-js prettyprint-override"><code>var tablNum = prompt("enter number");
var tableCout = (tablNum * 10) + 1 ;
for (let i = tablNum; i < tableCout; i = i + 10) {
console.log(i)
}
</code></pre>
<p>And what I want from my code to do is generate a table which number I type.</p>
| [
{
"answer_id": 74347460,
"author": "Mtdt",
"author_id": 12966265,
"author_profile": "https://Stackoverflow.com/users/12966265",
"pm_score": 2,
"selected": false,
"text": "var tablNum = Number(prompt(\"enter number\"));\n"
},
{
"answer_id": 74347488,
"author": "ncpa0cpl",
"author_id": 8907391,
"author_profile": "https://Stackoverflow.com/users/8907391",
"pm_score": 0,
"selected": false,
"text": "tablNum"
},
{
"answer_id": 74347573,
"author": "Shoaib Amin",
"author_id": 19580087,
"author_profile": "https://Stackoverflow.com/users/19580087",
"pm_score": 0,
"selected": false,
"text": "const number = parseInt(prompt('Enter an integer: '));\n\n//creating a multiplication table\nfor(let i = 1; i <= 10; i++) {\n\n // multiply i with number\n const result = i * number;\n\n // display the result\n console.log(`${number} * ${i} = ${result}`);\n}\n"
},
{
"answer_id": 74349280,
"author": "Andy",
"author_id": 1377002,
"author_profile": "https://Stackoverflow.com/users/1377002",
"pm_score": 1,
"selected": false,
"text": "prompt"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20081031/"
] |
74,347,443 | <p>I am using Spring Boot framework for my backend application and Keycloak for my user and access management system. I have a problem regarding creating a costume exception handler for 403 forbidden error.</p>
<p>I already read <a href="https://stackoverflow.com/questions/48306302/spring-security-creating-403-access-denied-custom-response">this link</a> and <a href="https://stackoverflow.com/questions/71205918/how-to-map-403-error-to-user-friendly-error">this link</a>. These questions are about creating custom message when 403 error is raised. Both of the answers did not help me since I have a general exception handler.</p>
<p><strong>Without any general exception handler</strong>, I get proper 401 and 403 responses regarding unauthorized tokens.
But I want to have a general exception handler for unexpected errors. Following is my general exception handler:</p>
<pre><code>@ExceptionHandler(value = Exception.class)
public ResponseEntity<String> generalExceptionHandler(Exception e) {
log.error(e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("General Error");
}
</code></pre>
<p>Without any other exception handler all situations that result in 401 or 403 response are handled by my <em>generalExceptionHandler</em>, which is not preferred. Since I want to send the proper message to the frontend in case of occurrence of 401 or 403 errors.</p>
<p>Therefore I developed an exception handler for Access denied exception like following:</p>
<pre><code>@ExceptionHandler(value = AccessDeniedException.class)
public ResponseEntity<String> accessDeniedExceptionHandler(Exception e) {
log.error(e.getMessage());
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Access is denied"));
}
</code></pre>
<p>In this step all situations regarding the 401 situation are handled successfully with <em>accessDeniedExceptionHandler</em>.</p>
<p><strong>The problem is that, situations regarding 403 Forbidden now are handled by <em>accessDeniedExceptionHandler</em> too</strong>. Since I want to send the proper message to frontend in case of 403 situation, I want to have a separate handler for this case. The reason relies in importance of distinguishing 401 and 403 errors in my software.</p>
<p>Can somebody please help me to fix this problem?</p>
| [
{
"answer_id": 74347552,
"author": "Mohammad Javad",
"author_id": 16038483,
"author_profile": "https://Stackoverflow.com/users/16038483",
"pm_score": 0,
"selected": false,
"text": "@ControllerAdvice\npublic class AccessDeniedExceptionHandler implements AccessDeniedHandler {\n\n@Override\npublic void handle(\n HttpServletRequest httpServletRequest,\n HttpServletResponse res,\n AccessDeniedException e) throws IOException {\n APIErrorResponse apiErrorResponse = new APIErrorResponse(Collections.singletonList(\"Access Denied!\"));\n res.setHeader(\"Content-Type\", MediaType.APPLICATION_JSON_VALUE);\n String message = new Gson().toJson(apiErrorResponse);\n res.sendError(HttpServletResponse.SC_FORBIDDEN, message);\n }\n}\n"
},
{
"answer_id": 74372011,
"author": "Reza Azad",
"author_id": 19584950,
"author_profile": "https://Stackoverflow.com/users/19584950",
"pm_score": 1,
"selected": false,
"text": "public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint \n\n@Override\npublic void commence(HttpServletRequest req, HttpServletResponse res, AuthenticationException authException) throws IOException, ServletException {\n res.setContentType(\"application/json;charset=UTF-8\");\n res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);\n\n // Create response content\n JSONObject obj=new JSONObject();\n obj.put(\"code\", HttpServletResponse.SC_UNAUTHORIZED);\n obj.put(\"message\", \"Access Denied\");\n\n\n res.getWriter().write(obj.toString());\n\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19584950/"
] |
74,347,458 | <p>Any help in figuring this out would be appreciated. I would like a forumla to calculate the number of times a code number appears more than once AND where type is A.</p>
<p>A sample set of data looks like the following:
<a href="https://i.stack.imgur.com/Y3duI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y3duI.png" alt="enter image description here" /></a></p>
<p>In this case the forumla should return 1 as there is one case of a repeated code number (1) where type is (A) - first row and last row in this case.</p>
<p>Would the forumla be any different if I also had a third column and wanted that to be a certain value as well? Again with the test data below I would want this to return 1 in the case that I wanted to measure the number of times any code number appeared more than once where type=A and subtype=C:
<a href="https://i.stack.imgur.com/dWgkx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dWgkx.png" alt="enter image description here" /></a>.</p>
<p>Ihave started with the following which identifies the number of unique combinations in columns A and B, but I can't seem to add any way to only return where a particular combination appears more than once:</p>
<pre><code>=COUNTUNIQUE(IFERROR(FILTER(A2:A,B2:B="A"),""))
</code></pre>
<p>I have tried the following but it doesn't return correctly:</p>
<pre><code>=COUNTUNIQUE(IFERROR(FILTER(A2:A,B2:B="A",COUNTIF(A2:A,A2:A)>1)))
</code></pre>
<p>Been trying to figure this one out for a while with no success.
Thank you</p>
| [
{
"answer_id": 74347552,
"author": "Mohammad Javad",
"author_id": 16038483,
"author_profile": "https://Stackoverflow.com/users/16038483",
"pm_score": 0,
"selected": false,
"text": "@ControllerAdvice\npublic class AccessDeniedExceptionHandler implements AccessDeniedHandler {\n\n@Override\npublic void handle(\n HttpServletRequest httpServletRequest,\n HttpServletResponse res,\n AccessDeniedException e) throws IOException {\n APIErrorResponse apiErrorResponse = new APIErrorResponse(Collections.singletonList(\"Access Denied!\"));\n res.setHeader(\"Content-Type\", MediaType.APPLICATION_JSON_VALUE);\n String message = new Gson().toJson(apiErrorResponse);\n res.sendError(HttpServletResponse.SC_FORBIDDEN, message);\n }\n}\n"
},
{
"answer_id": 74372011,
"author": "Reza Azad",
"author_id": 19584950,
"author_profile": "https://Stackoverflow.com/users/19584950",
"pm_score": 1,
"selected": false,
"text": "public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint \n\n@Override\npublic void commence(HttpServletRequest req, HttpServletResponse res, AuthenticationException authException) throws IOException, ServletException {\n res.setContentType(\"application/json;charset=UTF-8\");\n res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);\n\n // Create response content\n JSONObject obj=new JSONObject();\n obj.put(\"code\", HttpServletResponse.SC_UNAUTHORIZED);\n obj.put(\"message\", \"Access Denied\");\n\n\n res.getWriter().write(obj.toString());\n\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440588/"
] |
74,347,463 | <p>I'm trying to update the stock field or create it when the model doesn't exists</p>
<p>The eloquent :</p>
<pre><code>\App\Models\MarketingStock::updateOrCreate(
['marketing_id' => $attr['marketing_id']],
['product_id' => $attr['product_id']],
)->increment('stock',$attr['qty']);
</code></pre>
<p>The model :</p>
<pre><code>class MarketingStock extends Model
{
use HasFactory;
protected $fillable = ['marketing_id','product_id','stock'];
}
</code></pre>
<p>The result :</p>
<pre><code>SQLSTATE[HY000]: General error: 1364 Field 'stock' doesn't have a default value (SQL: insert into `marketing_stocks` (`marketing_id`, `product_id`, `updated_at`, `created_at`) values (2, 1, 2022-11-07 20:21:11, 2022-11-07 20:21:11))
</code></pre>
<p>I did research from these refferences :
<a href="https://stackoverflow.com/a/33145252/12355557">Solution 1</a>
<a href="https://stackoverflow.com/a/33183979/12355557">Solution 2</a></p>
<p>But nothing works for me
How to solve this ?</p>
| [
{
"answer_id": 74352138,
"author": "Mahmoud",
"author_id": 10094324,
"author_profile": "https://Stackoverflow.com/users/10094324",
"pm_score": -1,
"selected": false,
"text": "$table->integer('stock')->nullable();\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12355557/"
] |
74,347,474 | <p>I'm struggling with mocking a method when mocking an ES6 class, using <a href="https://jestjs.io/docs/mock-function-api#jestmockedsource" rel="nofollow noreferrer"><code>MockedClass</code></a> of the jest library.</p>
<p>Example:</p>
<pre class="lang-js prettyprint-override"><code>export default class CalculatorService {
constructor() {
// setup stuff
}
public add(num1: number, num2: number): number {
return num1 + num2;
}
}
</code></pre>
<p>The following works as expected:</p>
<pre class="lang-js prettyprint-override"><code>import CalculatorService from 'services/calculatorService';
jest.mock('services/calculatorService');
const MockedCalculatorService = CalculatorService as jest.MockedClass<typeof CalculatorService>;
describe('Tests', () => {
test('Test flow with Calculator service', () => {
// Arrange
// Act
implementation(1,2); // Where CalculatorService is used
// Assert
const mockServiceInstance = MockedService.mock.instances[0];
expect(mockServiceInstance.add).toHaveBeenCalledWith(1,2);
});
}
</code></pre>
<p>But say I wanted to mock <code>add</code> to always return 5, no matter the input.</p>
<p>With <code>jest.Mocked</code> it's done like: <code>MockedService.add.mockReturnValue(5)</code> if I understand it correctly <a href="https://jestjs.io/docs/mock-function-api#jestmockedsource-options" rel="nofollow noreferrer">here</a>. But how do I solve it when I've mocked a class?</p>
<p>EDIT: Ismail gave the option to mock the whole implementation in the
<code>jest.mock()</code> invocation. However, in this case, ideally, I'd like to mock the implementation/return value for each test.</p>
| [
{
"answer_id": 74352138,
"author": "Mahmoud",
"author_id": 10094324,
"author_profile": "https://Stackoverflow.com/users/10094324",
"pm_score": -1,
"selected": false,
"text": "$table->integer('stock')->nullable();\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6094030/"
] |
74,347,486 | <p>I'm writing a fairly large text file (it's actually more like ascii-encoded data), and it's... very slow. And uses a lot of memory.</p>
<p>Here's a minimalistic version of the code I'm using to test how to write files more quickly. <code>writeFileIncrementally</code> writes one line at a time in a for loop, while <code>writeFileFromBigData</code> creates a large string and then dumps it to disk. I was fully expecting <code>writeFileFromBigData</code> to be faster, but it's <em>20 times faster!</em> That's a bit more than I expected. For <code>size=10_000_000</code>, it takes 20-25 seconds to write it incrementally and 1-1.5 seconds to write it one go. Plus, the incremental version actually allocates more and more memory as it goes. By the end of it, it's well into the GiB range. I don't understand what's going on here.</p>
<pre class="lang-swift prettyprint-override"><code>func writeFileIncrementally(toUrl url: URL, size: Int) {
// ensure file exists and is empty
try? "".write(to: url, atomically: true, encoding: .ascii)
guard let handle = try? FileHandle(forWritingTo: url) else {return}
defer {
handle.closeFile()
}
for i in 0..<size {
let s = "\(i)\n"
handle.write(s.data(using: .ascii)!)
}
}
func writeFileFromBigData(toUrl url: URL, size: Int) {
let s = (0..<size).map{String($0)}.joined(separator: "\n")
try? s.write(to: url, atomically: true, encoding: .ascii)
}
</code></pre>
<p>Compare that to the same thing in Python. The create-string-then-write-it is faster in Python as well. That's reasonable, but the difference in Python is it takes about 2.7 seconds to write it incrementally (about 98% user time) and about 1 second to write it in one go (including creating the string). Additionally, the incremental version has constant memory usage. It does not go up as the file is being written.</p>
<pre class="lang-py prettyprint-override"><code>def writeFileIncrementally(path, size):
with open(path, "w+") as f:
for i in range(size):
f.write(f"{i}\n")
def writeFileFromBigData(path, size):
with open(path, "w+") as f:
f.write("\n".join(str(i) for i in range(size)))
</code></pre>
<p>So my question is twofold:</p>
<ol>
<li>Why is my <code>writeFileIncrementally</code> function so slow and why does it use so much memory? I was hoping to be able to write incrementally to reduce memory usage.</li>
<li>Is there some better approach for incrementally writing a large text file in Swift?</li>
</ol>
| [
{
"answer_id": 74348058,
"author": "Duncan C",
"author_id": 205185,
"author_profile": "https://Stackoverflow.com/users/205185",
"pm_score": 2,
"selected": false,
"text": "autoreleasepool()"
},
{
"answer_id": 74349466,
"author": "Rob Napier",
"author_id": 97337,
"author_profile": "https://Stackoverflow.com/users/97337",
"pm_score": 4,
"selected": true,
"text": " handle.write(s.data(using: .ascii)!)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1031253/"
] |
74,347,498 | <p>I had and issue when I Instantiate a game object.
I have a list of targets and when I instantiate my game object, I add this object to a list and set an Id to my object using PlayerPrefs.
my issue is that I have call a method onEnable that use the list and because OnEnable happen before the next line on the script, I get a ArgumentOutOfRangeException.
I can disable my prefab but I dont like the idea that if someone active it by mistake it will give me an error.
someone know how can I add the object to my list before "OnEnable" happen?</p>
<p>this is my script thast Instantiate the game object:</p>
<pre><code> private void CreateTargetOnNetwork(Vector3 position, Quaternion rotation)
{
PlayerPrefs.SetInt("Index", index);
targetsList.Add(Instantiate(Resources.Load("TargetPrefabNetwork") as GameObject, position, rotation, areaTargetManager.GetCurrentArea().transform));
index++;
}
[PunRPC]
private void UpdateTargetOnOffOnNetwork(int id, bool status)
{
targetsList[id].SetActive(status);
}
</code></pre>
<p>and this is my script on the game object:</p>
<pre><code> private void Awake()
{
_targetIndex = PlayerPrefs.GetInt("Index");
PlayerPrefs.DeleteKey("Index");
targetManager = FindObjectOfType<TargetManager>();
targetManagerPhotonView = targetManager.GetComponent<PhotonView>();
}
private void OnEnable()
{
targetManagerPhotonView.RPC("UpdateTargetOnOffOnNetwork", RpcTarget.AllBuffered, _targetIndex, true);
}
</code></pre>
<p>I work with photon but this is not my issue so the RPC is just like calling a method.</p>
| [
{
"answer_id": 74351507,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "OnEnable"
},
{
"answer_id": 74352675,
"author": "Sisus",
"author_id": 12806072,
"author_profile": "https://Stackoverflow.com/users/12806072",
"pm_score": 2,
"selected": false,
"text": "[DefaultExecutionOrder(-1000)]\npublic sealed class OnBefore : MonoBehaviour\n{\n public static event Action<GameObject> Enabled;\n public static event Action<GameObject> Disabled;\n \n private void OnEnable() => Enabled?.Invoke(gameObject);\n private void OnDisable() => Disabled?.Invoke(gameObject);\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9343039/"
] |
74,347,549 | <p>I'm new to Docker and I'm trying to deploy a Discord music bot on a remote Ubuntu Linux server in a Docker container.</p>
<p>The problem is that when the bot is launched in the container, the music does not play, while other parts of the bot that are not related to music playback work fine; at the same time, if the bot is launched outside the Docker container environment, the bot works fine and the music is played.</p>
<p>The bot's behavior when requesting music playback when it is operating in a container is as follows: the bot displays a message that it has found a song and that it starts playing it, and immediately thereafter displays a message that the song has finished playing.</p>
<p>I guess the problem lies in my <code>Dockerfile</code>, or in how I run the image.</p>
<p>My <code>Dockerfile</code>:</p>
<pre><code>FROM node:lts-alpine
ENV WORK_FOLDER='/usr/MyBot'
WORKDIR ${WORK_FOLDER}
COPY ["package.json", "package-lock.json", "tsconfig.json", "./"]
COPY src ./src
RUN npm install
RUN npm install -g typescript
RUN npm run build
COPY . .
CMD ["node", "./dist/index" ]
</code></pre>
<p>I'm building an image with the command:</p>
<pre><code>docker build -t mybot .
</code></pre>
<p>And I launch the container as follows:</p>
<pre><code>docker run -d -p 80:80 --restart=always --name=mybot mybot
</code></pre>
<p>The bot is written in TypeScript using the library <code>discord.js</code>. To play music, the bot uses the library <code>distube.js</code>.</p>
| [
{
"answer_id": 74351507,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "OnEnable"
},
{
"answer_id": 74352675,
"author": "Sisus",
"author_id": 12806072,
"author_profile": "https://Stackoverflow.com/users/12806072",
"pm_score": 2,
"selected": false,
"text": "[DefaultExecutionOrder(-1000)]\npublic sealed class OnBefore : MonoBehaviour\n{\n public static event Action<GameObject> Enabled;\n public static event Action<GameObject> Disabled;\n \n private void OnEnable() => Enabled?.Invoke(gameObject);\n private void OnDisable() => Disabled?.Invoke(gameObject);\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18452428/"
] |
74,347,600 | <p>Here is an example of the csv</p>
<pre><code>17/10/2022 23:00;10
18/10/2022 00:00;10
19/10/2022 19:00;9
</code></pre>
<p>I want to remove specific rows depends on a date.
How would you do that?
Thank you so much.
I would like to do it as you introduce a range of dates, and it deletes everything out of the range.</p>
<p>I havent tried it yet because i,m starting with python and dont know where to start</p>
| [
{
"answer_id": 74351507,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "OnEnable"
},
{
"answer_id": 74352675,
"author": "Sisus",
"author_id": 12806072,
"author_profile": "https://Stackoverflow.com/users/12806072",
"pm_score": 2,
"selected": false,
"text": "[DefaultExecutionOrder(-1000)]\npublic sealed class OnBefore : MonoBehaviour\n{\n public static event Action<GameObject> Enabled;\n public static event Action<GameObject> Disabled;\n \n private void OnEnable() => Enabled?.Invoke(gameObject);\n private void OnDisable() => Disabled?.Invoke(gameObject);\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440754/"
] |
74,347,606 | <p>Sample code:</p>
<pre><code>library(tidyverse)
iris <- iris
test_tidyeval <- function(data, col_name, col_name_2, column1) {
mutate(
data,
{{col_name}} := case_when(Species == "setosa" ~ column1 + Sepal.Width + Petal.Length,
TRUE ~ column1),
{{col_name_2}} := case_when(Species == "setosa" ~ {{col_name}} + 100,
TRUE ~ {{col_name}} + 500))
}
iris %>% test_tidyeval("new_column_test", "new_column_test_2", Sepal.Length)
</code></pre>
<p>I'm sure this is a tidyeval/nse issue which I can never get my head around.</p>
<p>What I basically want is for <code>new_column_test</code> to be created where if the row Species == "setosa" then for this to be the sum of Sepal.Length, which we're passing to <code>column1</code> in the user-defined function, Sepal.Width and Petal.length, else just return the value from Sepal.Length, then for <code>new_column_test_2</code> to add 100 to <code>new_column_test</code> with the same logical condition used previously and 500 to non setosa species.</p>
<p>I can seem to manipulate the LHS of case_when okay but I'm stuck on the RHS statements.</p>
| [
{
"answer_id": 74347878,
"author": "Andy Baxter",
"author_id": 10744082,
"author_profile": "https://Stackoverflow.com/users/10744082",
"pm_score": 1,
"selected": false,
"text": "library(tidyverse)\nlibrary(rlang)\n\n\ntest_tidyeval <- function(data, col_name, col_name_2, column1) {\n \n mutate(\n data,\n {{col_name}} := case_when(Species == \"setosa\" ~ !!enquo(column1) + Sepal.Width + Petal.Length,\n TRUE ~ !!enquo(column1)),\n {{col_name_2}} := case_when(Species == \"setosa\" ~ !!parse_expr(col_name) + 100,\n TRUE ~ !!parse_expr(col_name) + 500)\n )\n \n}\n\niris %>% \n test_tidyeval(\"new_column_test\", \"new_column_test_2\", Sepal.Length) %>%\n head()\n#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species new_column_test\n#> 1 5.1 3.5 1.4 0.2 setosa 10.0\n#> 2 4.9 3.0 1.4 0.2 setosa 9.3\n#> 3 4.7 3.2 1.3 0.2 setosa 9.2\n#> 4 4.6 3.1 1.5 0.2 setosa 9.2\n#> 5 5.0 3.6 1.4 0.2 setosa 10.0\n#> 6 5.4 3.9 1.7 0.4 setosa 11.0\n#> new_column_test_2\n#> 1 110.0\n#> 2 109.3\n#> 3 109.2\n#> 4 109.2\n#> 5 110.0\n#> 6 111.0\n"
},
{
"answer_id": 74348003,
"author": "MrFlick",
"author_id": 2372064,
"author_profile": "https://Stackoverflow.com/users/2372064",
"pm_score": 3,
"selected": true,
"text": "{{ }}"
},
{
"answer_id": 74348150,
"author": "G. Grothendieck",
"author_id": 516548,
"author_profile": "https://Stackoverflow.com/users/516548",
"pm_score": 1,
"selected": false,
"text": "column1"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8487930/"
] |
74,347,646 | <p>I have a vue.js project and am using Vuex for my store. I am trying to process all notifications to users within the store and I am having some issues with async/await.</p>
<p>I am sure its something very simple and trivial but I am stuck. Any help is much appreciated.</p>
<p>Here is my function</p>
<pre><code>async getNotifications() {
console.log('1')
const internalNotifications = await this.$store.getters['AppData/getInternalNotifications']
console.log('2')
if(internalNotifications) {
this.notifications = internalNotifications
this.message = true
console.log('4 ', internalNotifications)
}
}
</code></pre>
<p>Here is my function in the store to get the notifications and dispatch them.</p>
<pre><code>async getInternalNotifications({ dispatch }, { cid, user, roles, isSupperAdmin }) {
console.log('getInternalNotifications')
let internalNotifications = []
// Get all the notifications for this church
let getAllNotifications = await db
.collection('notifications')
.where('cid', '==', cid)
.where('active', '==', true)
.orderBy('created')
.get()
for (const notificationDoc of getAllNotifications.docs) {
let notification = notificationDoc.data()
notification.id = notificationDoc.id
// check to make sure this notification has not already been read
let getAllReadNotifications = await db
.collection('notificationsread')
.where('notificationid', '==', notification.id)
.where('userid', '==', user.uid)
.get()
if (getAllReadNotifications.empty)
internalNotifications.push(notification)
}
if (!isSupperAdmin && internalNotifications.length > 0) {
const hasAudience = internalNotifications.filter((el) => {
return roles.some(r => el.audience.includes(r))
})
hasAudience.sort((a, b) => (a.created < b.created) ? 1 : -1)
internalNotifications = hasAudience[0]
}
console.log('3 ', internalNotifications)
dispatch('addInternalNotification', internalNotifications)
},
</code></pre>
<p>My thinking is when viewing the console log I should see the logs in order 1,3,2,4 but instead I get 1,2,4,3 and as you can see from the screen shot it's an Observer not the actual array/object.</p>
<p>see screen shot of console log
<a href="https://i.stack.imgur.com/y0yBx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y0yBx.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74347878,
"author": "Andy Baxter",
"author_id": 10744082,
"author_profile": "https://Stackoverflow.com/users/10744082",
"pm_score": 1,
"selected": false,
"text": "library(tidyverse)\nlibrary(rlang)\n\n\ntest_tidyeval <- function(data, col_name, col_name_2, column1) {\n \n mutate(\n data,\n {{col_name}} := case_when(Species == \"setosa\" ~ !!enquo(column1) + Sepal.Width + Petal.Length,\n TRUE ~ !!enquo(column1)),\n {{col_name_2}} := case_when(Species == \"setosa\" ~ !!parse_expr(col_name) + 100,\n TRUE ~ !!parse_expr(col_name) + 500)\n )\n \n}\n\niris %>% \n test_tidyeval(\"new_column_test\", \"new_column_test_2\", Sepal.Length) %>%\n head()\n#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species new_column_test\n#> 1 5.1 3.5 1.4 0.2 setosa 10.0\n#> 2 4.9 3.0 1.4 0.2 setosa 9.3\n#> 3 4.7 3.2 1.3 0.2 setosa 9.2\n#> 4 4.6 3.1 1.5 0.2 setosa 9.2\n#> 5 5.0 3.6 1.4 0.2 setosa 10.0\n#> 6 5.4 3.9 1.7 0.4 setosa 11.0\n#> new_column_test_2\n#> 1 110.0\n#> 2 109.3\n#> 3 109.2\n#> 4 109.2\n#> 5 110.0\n#> 6 111.0\n"
},
{
"answer_id": 74348003,
"author": "MrFlick",
"author_id": 2372064,
"author_profile": "https://Stackoverflow.com/users/2372064",
"pm_score": 3,
"selected": true,
"text": "{{ }}"
},
{
"answer_id": 74348150,
"author": "G. Grothendieck",
"author_id": 516548,
"author_profile": "https://Stackoverflow.com/users/516548",
"pm_score": 1,
"selected": false,
"text": "column1"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2646266/"
] |
74,347,679 | <p>I have this dataset and list of dataframe matrixes as follows :</p>
<pre><code>set.seed(222)
df = data.frame(x = trunc(runif(10,0,2)),
y = trunc(runif(10,4,6)),
z = trunc(runif(10,19,21)),
m = trunc(runif(10,28,30)))
df
t1 = table(df$x,df$y)
t2=table(df$z,df$m)
L = list(t1,t2)
L1 <- lapply(L, as.data.frame.matrix)
</code></pre>
<p>The output is</p>
<pre><code>[[1]]
4 5
0 4 2
1 3 1
[[2]]
28 29
19 3 2
20 1 4
</code></pre>
<p>I wish to create proportion tables as for example for the first elements :</p>
<pre><code>[[1]]
4 5
0 4/(4+2) 2/(4+2)
1 3/(3+1) 1/(3+1)
</code></pre>
<p>Thank you</p>
| [
{
"answer_id": 74347782,
"author": "Jilber Urbina",
"author_id": 1315767,
"author_profile": "https://Stackoverflow.com/users/1315767",
"pm_score": 3,
"selected": true,
"text": "sapply"
},
{
"answer_id": 74349705,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 1,
"selected": false,
"text": "proportions"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19720935/"
] |
74,347,701 | <p>I have the dataframe:</p>
<pre><code>df = batch Code
a 100
a 120
a 130
a 120
b 140
b 150
c 100
</code></pre>
<p>I want to add a column 'add_code' that will be the value of the column 'Code' from the next row, per batch.
So the output will be:</p>
<pre><code>df = batch Code next_code
a 100 120
a 120 130
a 130 120
a 120 END
b 140 150
b 150 END
c 100 END
</code></pre>
<p>What is the best way to do it?</p>
| [
{
"answer_id": 74347724,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "DataFrameGroupBy.shift"
},
{
"answer_id": 74348905,
"author": "Jahirul islam",
"author_id": 7386944,
"author_profile": "https://Stackoverflow.com/users/7386944",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\ndef next_code(x):\n return x.shift(-1).fillna('END')\ndf = pd.DataFrame({\n \"batch\" : ['a','a','a','a','b','b','c'],\n \"code\" : [100,120,130,120,140,150,100]\n})\ndf['next_code'] = df.groupby(['batch'])['code'].apply(lambda x: next_code(x))\nprint(df)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6057371/"
] |
74,347,740 | <p>In Power Query, how is the first table transformed into the second? In the second table the categorical values are counted for every column. The set of values for every column is limited to: Strongly agree, Agree, Neutral, Disagree, Strongly disagree.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Question A</th>
<th style="text-align: center;">Question B</th>
<th style="text-align: center;">Question C</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">Strongly disagree</td>
<td style="text-align: center;">Agree</td>
<td style="text-align: center;">Neutral</td>
</tr>
<tr>
<td style="text-align: center;">Disagree</td>
<td style="text-align: center;">Strongly disagree</td>
<td style="text-align: center;">Strongly agree</td>
</tr>
<tr>
<td style="text-align: center;">Agree</td>
<td style="text-align: center;">Agree</td>
<td style="text-align: center;">Neutral</td>
</tr>
<tr>
<td style="text-align: center;">Neutral</td>
<td style="text-align: center;">Strongly agree</td>
<td style="text-align: center;">Neutral</td>
</tr>
<tr>
<td style="text-align: center;">Strongly agree</td>
<td style="text-align: center;">Agree</td>
<td style="text-align: center;">Strongly disagree</td>
</tr>
<tr>
<td style="text-align: center;">Disagree</td>
<td style="text-align: center;">Strongly disagree</td>
<td style="text-align: center;">Strongly agree</td>
</tr>
</tbody>
</table>
</div>
<p>In to this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Agree, Disagree</th>
<th style="text-align: center;">Question A</th>
<th style="text-align: center;">Question B</th>
<th style="text-align: center;">Question C</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">Strongly agree</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">2</td>
</tr>
<tr>
<td style="text-align: center;">Agree</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">3</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">Neutral</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">3</td>
</tr>
<tr>
<td style="text-align: center;">Disagree</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">Strongly disagree</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">1</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74347914,
"author": "horseyride",
"author_id": 9264230,
"author_profile": "https://Stackoverflow.com/users/9264230",
"pm_score": 2,
"selected": true,
"text": "let Source = Excel.CurrentWorkbook(){[Name=\"Table1\"]}[Content],\n#\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n#\"Added Index\" = Table.AddIndexColumn(#\"Changed Type\", \"Index\", 0, 1, Int64.Type),\n#\"Unpivoted Other Columns\" = Table.UnpivotOtherColumns(#\"Added Index\", {\"Index\"}, \"Attribute\", \"Value\"),\n#\"Removed Columns\" = Table.RemoveColumns(#\"Unpivoted Other Columns\",{\"Index\"}),\n#\"Duplicated Column\" = Table.DuplicateColumn(#\"Removed Columns\", \"Value\", \"Value - Copy\"),\n#\"Pivoted Column\" = Table.Pivot(#\"Duplicated Column\", List.Distinct(#\"Duplicated Column\"[Attribute]), \"Attribute\", \"Value - Copy\", List.Count)\nin #\"Pivoted Column\"\n"
},
{
"answer_id": 74348028,
"author": "David Bacci",
"author_id": 18345037,
"author_profile": "https://Stackoverflow.com/users/18345037",
"pm_score": 0,
"selected": false,
"text": "let\n Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(\"i45WCi4pys9Lz6lUSMksTkwvSk1V0lFyhNJ+qaUlRYk5SrE60UouCGlsWuBiEAGQDkc8psHYGBpRlWFIOuJ0AhlujAUA\", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#\"Question A\" = _t, #\"Question B\" = _t, #\"Question C\" = _t]),\n #\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n #\"Unpivoted Columns\" = Table.UnpivotOtherColumns(#\"Changed Type\", {}, \"Attribute\", \"Value\"),\n #\"Grouped Rows\" = Table.Group(#\"Unpivoted Columns\", {\"Attribute\", \"Value\"}, {{\"Count\", each Table.RowCount(_), Int64.Type}}),\n #\"Pivoted Column\" = Table.Pivot(#\"Grouped Rows\", List.Distinct(#\"Grouped Rows\"[Attribute]), \"Attribute\", \"Count\", List.Sum),\n #\"Replaced Value\" = Table.ReplaceValue(#\"Pivoted Column\",null,0,Replacer.ReplaceValue,{\"Question A\", \"Question B\", \"Question C\"})\nin\n #\"Replaced Value\"\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9308858/"
] |
74,347,754 | <p>I read in the Julia doc page <a href="https://docs.julialang.org/en/v1/manual/variables/#:%7E:text=Variable%20names%20must%20begin%20with,Sm%20math%20symbols" rel="nofollow noreferrer">https://docs.julialang.org/en/v1/manual/variables/#:~:text=Variable%20names%20must%20begin%20with,Sm%20math%20symbols</a>)%20are%20allowed. :</p>
<blockquote>
<p>Word separation can be indicated by underscores ('_'), but use of
underscores is discouraged unless the name would be hard to read
otherwise</p>
</blockquote>
<p>My question is if there any reasons to discourage the usage of underscores? Thanks.</p>
| [
{
"answer_id": 74347914,
"author": "horseyride",
"author_id": 9264230,
"author_profile": "https://Stackoverflow.com/users/9264230",
"pm_score": 2,
"selected": true,
"text": "let Source = Excel.CurrentWorkbook(){[Name=\"Table1\"]}[Content],\n#\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n#\"Added Index\" = Table.AddIndexColumn(#\"Changed Type\", \"Index\", 0, 1, Int64.Type),\n#\"Unpivoted Other Columns\" = Table.UnpivotOtherColumns(#\"Added Index\", {\"Index\"}, \"Attribute\", \"Value\"),\n#\"Removed Columns\" = Table.RemoveColumns(#\"Unpivoted Other Columns\",{\"Index\"}),\n#\"Duplicated Column\" = Table.DuplicateColumn(#\"Removed Columns\", \"Value\", \"Value - Copy\"),\n#\"Pivoted Column\" = Table.Pivot(#\"Duplicated Column\", List.Distinct(#\"Duplicated Column\"[Attribute]), \"Attribute\", \"Value - Copy\", List.Count)\nin #\"Pivoted Column\"\n"
},
{
"answer_id": 74348028,
"author": "David Bacci",
"author_id": 18345037,
"author_profile": "https://Stackoverflow.com/users/18345037",
"pm_score": 0,
"selected": false,
"text": "let\n Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(\"i45WCi4pys9Lz6lUSMksTkwvSk1V0lFyhNJ+qaUlRYk5SrE60UouCGlsWuBiEAGQDkc8psHYGBpRlWFIOuJ0AhlujAUA\", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#\"Question A\" = _t, #\"Question B\" = _t, #\"Question C\" = _t]),\n #\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n #\"Unpivoted Columns\" = Table.UnpivotOtherColumns(#\"Changed Type\", {}, \"Attribute\", \"Value\"),\n #\"Grouped Rows\" = Table.Group(#\"Unpivoted Columns\", {\"Attribute\", \"Value\"}, {{\"Count\", each Table.RowCount(_), Int64.Type}}),\n #\"Pivoted Column\" = Table.Pivot(#\"Grouped Rows\", List.Distinct(#\"Grouped Rows\"[Attribute]), \"Attribute\", \"Count\", List.Sum),\n #\"Replaced Value\" = Table.ReplaceValue(#\"Pivoted Column\",null,0,Replacer.ReplaceValue,{\"Question A\", \"Question B\", \"Question C\"})\nin\n #\"Replaced Value\"\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945738/"
] |
74,347,766 | <p>I have data similar to this:</p>
<pre><code>library(data.table)
library(stringr)
dt <- data.table(id=1:20,
month_1=rep(sample(1:12, 20, replace = T)),
month_2=rep(sample(1:12, 20, replace = T)),
month_3=rep(sample(1:12, 20, replace = T)),
month_4=rep(sample(1:12, 20, replace = T)),
year_1=rep(sample(2010:2020, 20, replace = T)),
year_2=rep(sample(2010:2020, 20, replace = T)),
year_3=rep(sample(2010:2020, 20, replace = T)),
year_4=rep(sample(2010:2020, 20, replace = T)))
</code></pre>
<p>and I am trying execute these 4 commands</p>
<pre><code>dt[,date_1:= as.Date(paste0(year_1, "-", str_pad(month_1, 2, pad = "0"), "-", 01))]
dt[,date_2:= as.Date(paste0(year_2, "-", str_pad(month_1, 2, pad = "0"), "-", 01))]
dt[,date_3:= as.Date(paste0(year_3, "-", str_pad(month_1, 2, pad = "0"), "-", 01))]
dt[,date_4:= as.Date(paste0(year_4, "-", str_pad(month_1, 2, pad = "0"), "-", 01))]
</code></pre>
<p>How can I do this using a for loop?</p>
<p>I have tried:</p>
<pre><code>for (i in 1:4){
dt[,date_i:= as.Date(paste0(year_i, "-", str_pad(month_i, 2, pad = "0"), "-", 01))]
}
</code></pre>
<p>But get the error:</p>
<blockquote>
<p>Error in paste0(year_i, "-", str_pad(month_i, 2, pad = "0"), "-", 1) :
object 'year_i' not found</p>
</blockquote>
| [
{
"answer_id": 74347914,
"author": "horseyride",
"author_id": 9264230,
"author_profile": "https://Stackoverflow.com/users/9264230",
"pm_score": 2,
"selected": true,
"text": "let Source = Excel.CurrentWorkbook(){[Name=\"Table1\"]}[Content],\n#\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n#\"Added Index\" = Table.AddIndexColumn(#\"Changed Type\", \"Index\", 0, 1, Int64.Type),\n#\"Unpivoted Other Columns\" = Table.UnpivotOtherColumns(#\"Added Index\", {\"Index\"}, \"Attribute\", \"Value\"),\n#\"Removed Columns\" = Table.RemoveColumns(#\"Unpivoted Other Columns\",{\"Index\"}),\n#\"Duplicated Column\" = Table.DuplicateColumn(#\"Removed Columns\", \"Value\", \"Value - Copy\"),\n#\"Pivoted Column\" = Table.Pivot(#\"Duplicated Column\", List.Distinct(#\"Duplicated Column\"[Attribute]), \"Attribute\", \"Value - Copy\", List.Count)\nin #\"Pivoted Column\"\n"
},
{
"answer_id": 74348028,
"author": "David Bacci",
"author_id": 18345037,
"author_profile": "https://Stackoverflow.com/users/18345037",
"pm_score": 0,
"selected": false,
"text": "let\n Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(\"i45WCi4pys9Lz6lUSMksTkwvSk1V0lFyhNJ+qaUlRYk5SrE60UouCGlsWuBiEAGQDkc8psHYGBpRlWFIOuJ0AhlujAUA\", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#\"Question A\" = _t, #\"Question B\" = _t, #\"Question C\" = _t]),\n #\"Changed Type\" = Table.TransformColumnTypes(Source,{{\"Question A\", type text}, {\"Question B\", type text}, {\"Question C\", type text}}),\n #\"Unpivoted Columns\" = Table.UnpivotOtherColumns(#\"Changed Type\", {}, \"Attribute\", \"Value\"),\n #\"Grouped Rows\" = Table.Group(#\"Unpivoted Columns\", {\"Attribute\", \"Value\"}, {{\"Count\", each Table.RowCount(_), Int64.Type}}),\n #\"Pivoted Column\" = Table.Pivot(#\"Grouped Rows\", List.Distinct(#\"Grouped Rows\"[Attribute]), \"Attribute\", \"Count\", List.Sum),\n #\"Replaced Value\" = Table.ReplaceValue(#\"Pivoted Column\",null,0,Replacer.ReplaceValue,{\"Question A\", \"Question B\", \"Question C\"})\nin\n #\"Replaced Value\"\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10455998/"
] |
74,347,794 | <p>I have an example data set</p>
<pre><code>data test;
input ID 1-4
var1 $ 5-13
;
datalines;
1 Apples
2 Chocolate
3 Milk
3 Cocoa
3 Cake
3 Sugar
4 Marmelade
5 Banana
6 Rice
6 Beef
;
run;
</code></pre>
<p>I want to create a third variable all_names where I group all entries for var1 given that the ID appears multiple times. So for ID = 3, all_names should read "milk, cocoa, cake, sugar" and for ID = 6 it sould say "Rice, Beef".</p>
<p>I have some code that works but only in cases where ID appears twice:</p>
<pre><code> data step1;
set test;
by ID;
prevID=lag(ID);
prevVar1=lag(var1);
if first.ID then prevID = . ;
if ID eq prevID then all_names = cat(var1, ", ", prevVar1);
else all_names = var1;
drop prevID prevVar1;
run;
</code></pre>
<p>How can I make my code work for cases where ID appears several times? I tried playing around with first.ID and last.ID but haven't figured it out yet. Thanks!</p>
| [
{
"answer_id": 74347910,
"author": "PeterClemmensen",
"author_id": 4044936,
"author_profile": "https://Stackoverflow.com/users/4044936",
"pm_score": 3,
"selected": true,
"text": "data test;\ninput ID 1-4\nvar1 $ 5-13\n;\ndatalines;\n1 Apples\n2 Chocolate\n3 Milk\n3 Cocoa\n3 Cake\n3 Sugar\n4 Marmelade\n5 Banana\n6 Rice\n6 Beef\n;\nrun; \n\ndata want(drop = var1);\n\n do until (last.ID);\n set test;\n by ID;\n length all_names $200;\n all_names = catx(', ', all_names, var1);\n end;\n\nrun;\n\ndata want2;\n\n do until (last.ID);\n set test;\n by ID;\n length all_names $200;\n all_names = catx(', ', all_names, var1);\n end;\n\n do until (last.ID);\n set test;\n by ID;\n output;\n end;\n\nrun;\n"
},
{
"answer_id": 74349779,
"author": "fl0r3k",
"author_id": 6695762,
"author_profile": "https://Stackoverflow.com/users/6695762",
"pm_score": 0,
"selected": false,
"text": "/* If needed just to make sure it's sorted by ID for datastep group by processing */\nproc sort data=test;\n by ID;\nrun;\n\ndata temp;\n set test;\n by ID;\n\n length all_names $200;\n retain all_names;\n \n all_names = catx(', ', all_names, var1);\n \n if last.ID then output;\n \n drop var1;\nrun;\n\nproc sql;\n create table results as\n select t1.*, t2.all_names\n from test as t1, temp as t2\n where t1.ID = t2.ID\n ;\nquit;\n"
},
{
"answer_id": 74374862,
"author": "Negdo",
"author_id": 19646183,
"author_profile": "https://Stackoverflow.com/users/19646183",
"pm_score": 1,
"selected": false,
"text": "data have;\ninput ID 1-4\nvar1 $ 5-13\n;\ndatalines;\n1 Apples\n2 Chocolate\n3 Milk\n3 Cocoa\n3 Cake\n3 Sugar\n4 Marmelade\n5 Banana\n6 Rice\n6 Beef\n;\nrun; \n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11820022/"
] |
74,347,814 | <p>I'm new to HTML and CSS and I have a problem. I'm working on responsive design and where I have a <code>media screen</code> of <code>min-width 860px</code>. I want my navigation text to be next to my logo. I managed to do this, but the navigation text is placed on top of my line instead of in the center.</p>
<p>(hope that makes sense)<a href="https://i.stack.imgur.com/R8Soe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R8Soe.png" alt="enter image description here" /></a></p>
<pre class="lang-css prettyprint-override"><code>.netflix-logo {
float:left;
margin-right: 18px;
}
nav a {
display:inline;
vertical-align: middle;
color: white;
margin: 9px 8px 0 0;
text-decoration: none;
}
</code></pre>
<p>I tried working with <code>vertical-align: middle</code> and center but that didn't work either, could you please help me?</p>
| [
{
"answer_id": 74347886,
"author": "Aleksandre Geladze",
"author_id": 17348589,
"author_profile": "https://Stackoverflow.com/users/17348589",
"pm_score": 2,
"selected": false,
"text": ".netflix-logo && nav a"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440859/"
] |
74,347,822 | <p>I can't find a correct solution to this problem and I'm stuck. Let's say I have this method</p>
<pre><code> @GET
@Path("/testingAsync")
public Uni<List<String>> testingMutiny() {
List<String> completeList = new ArrayList<>();
completeList.add("hello");
completeList.add("RestEasy");
List<String> finalList = new ArrayList<>();
completeList.forEach(e -> Uni.createFrom().item(e)
.onItem().delayIt().by(Duration.ofMillis(10000))
.map(value -> finalList.add(value.toUpperCase()))
.subscribe().asCompletionStage());
return Uni.createFrom().item(finalList);
}
</code></pre>
<p>As you see the method is simple it just takes the values from 1 list and adds them to the second one but what's the problem? When you add the waiting <code>.onItem().delayIt().by(Duration.ofMillis(10000))</code> the program will return an empty list and after a while, it will just update the list. I created this method to simulate a request that the response that has some delay in it.</p>
<p>Let's say you hit 2 URLs with 2 different Unis after that you try to combine them and return it as one Uni. The problem is if one of those 2 URLs delay for some reason we will return the list empty but I don't want that to happen I either want the list to be completed 100% or return an error if it takes a while.</p>
<p>What is the best approach to that? I understand that if you add await() you are blocking the main thread and you lose all the value of using the reactive library but still, I can't find a way for this to work</p>
<p><strong>EDIT</strong></p>
<p>I have found out that the external URL I try to call takes about 5 seconds to do the job so I want my code to stop when creating the Uni and continue after I have received an answer from the server. I have seen in their docs (<a href="https://smallrye.io/smallrye-mutiny/1.7.0/guides/reactive-to-imperative/" rel="nofollow noreferrer">here</a>) That I can also call await.indefinitely but I receive <code>The current thread cannot be blocked: vert.x-eventloop-thread-14</code>. How do I wait for a response from the server?</p>
<p><strong>EDIT 2</strong></p>
<p>I understand that with strings it doesn't make sense my question so much so let's say I have the following one</p>
<pre><code> @GET
@Path("/testingAsync")
public Uni<List<Car>> testingMutiny() {
//ALL THIS IS IN A FOR EACH FOR EVERY CAR
//HIT ENDPOINT GET DOORS
Uni<List<JsonObjectCar>> carDoorsUni = getDoors(variable1,
variable2, variable3);
//HIT ENDPOINT GET WHEELS
Uni<List<JsonObjectCar>> carWheelsUni = getWheels(variable1,
variable2, variable3);
//HIT ENDPOINT GET WINDOWS
Uni<List<JsonObjectCar>> carWindowsUni = getWindows(variable1,
variable2, variable3);
Uni.combine()
.all()
.unis(carDoorsUni, carWheelsUni, carWindowsUni)
.combinedWith((carDoors, carWheels, carWindows) -> {
//Check if cardoors is present and set the doors into the car object
Optional.of(carDoors)
.ifPresent(val -> car.setDoors(val.getDoors()));
Optional.of(carWheels)
.ifPresent(val -> car.setWheels(val.getWheels()));
Optional.of(carWindows)
.ifPresent(val -> car.setWindows(val.getWindows()));
return car;
}).subscribe().with(e-> System.out.println("Okay it worked"));
//END OF FOR EACH
//Return car (Should have been returned with new doors / wheels/ windows but instead its empty)
return Uni.createFrom().item(car);
}
</code></pre>
<p>As you see in the above code It should have hit some endpoints for doors / wheels / windows and set them into the variable car but what happens, in reality, is that the car is empty because one of those endpoints has been delayed so i return a car without those values inside it. I want to first update the car object and then actually return it</p>
| [
{
"answer_id": 74347886,
"author": "Aleksandre Geladze",
"author_id": 17348589,
"author_profile": "https://Stackoverflow.com/users/17348589",
"pm_score": 2,
"selected": false,
"text": ".netflix-logo && nav a"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10839527/"
] |
74,347,842 | <p>I need to copy a lot of files and use the same sort of folder structure where the files needs to go.
So for instance if I have the following two documents:</p>
<pre><code>\\Server1\Projects\OldProject\English\Text_EN.docx
\\Server1\Projects\OldProject\English\Danish\Text_DA.docx
</code></pre>
<p>I would need to move them to a new place on the server, but they need to be in the same "language folder". So I need to move them like this:</p>
<pre><code>\\Server1\Projects\OldProject\English\Text_EN.docx -> \\Server1\Projects\NewProject\English\Text_EN.docx
\\Server1\Projects\OldProject\English\Danish\Text_DA.docx -> \\Server1\Projects\NewProject\English\Danish\Text_DA.docx
</code></pre>
<p>The issue here is, that I would need to take names of the "language" folder and create them in the <code>NewProject</code> folder.</p>
<p>How would I be able to take and remove everything before the <code>\</code>, so I end up with only having the "language" folders like <code>English\</code> and <code>English\Danish</code></p>
| [
{
"answer_id": 74347886,
"author": "Aleksandre Geladze",
"author_id": 17348589,
"author_profile": "https://Stackoverflow.com/users/17348589",
"pm_score": 2,
"selected": false,
"text": ".netflix-logo && nav a"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16713387/"
] |
74,347,869 | <p>I'm receiving the below XML response from an API call and am looking to iterate through the "Results" and store all of the data points as a pandas dataframe.</p>
<p>I was successfully able to grab my data points of interest by chaining .find() methods shown below, but don't know how to loop through all of the Results block within the body given the structure of the XML response.</p>
<p>I am using Python 3.7+ in Jupyter on Windows.</p>
<p><strong>What I've Tried:</strong></p>
<pre><code>import pandas as pd
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
soup = BeautifulSoup(soap_response.text, "xml")
# print(soup.prettify())
objectid_field = soup.find('Results').find('ObjectID').text
customerkey_field = soup.find('Results').find('CustomerKey').text
name_field = soup.find('Results').find('Name').text
issendable_field = name_field = soup.find('Results').find('IsSendable').text
sendablesubscribe_field = soup.find('Results').find('SendableSubscriberField').text
# for de in soup:
# de_name = soup.find('Results').find('Name').text
# print(de_name)
# test_df = pd.read_xml(soup,
# xpath="//Results",
# namespaces={""})
</code></pre>
<p><strong>Sample XML Data Structure:</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-201-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-201-wss-security-1.0.xsd">
<env:Header
xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<wsa:Action>RetrieveResponse</wsa:Action>
<wsa:MessageID>urn:uuid:1234</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:1234</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/dressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-1234">
<wsu:Created>2021-11-07T13:10:54Z</wsu:Created>
<wsu:Expires>2021-11-07T13:15:54Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</env:Header>
<soap:Body>
<RetrieveResponseMsg
xmlns="http://partnerAPI">
<OverallStatus>OK</OverallStatus>
<RequestID>f9876</RequestID>
<Results xsi:type="Data">
<PartnerKey xsi:nil="true" />
<ObjectID>Object1</ObjectID>
<CustomerKey>Customer1</CustomerKey>
<Name>Test1</Name>
<IsSendable>true</IsSendable>
<SendableSubscriberField>
<Name>_Something1</Name>
</SendableSubscriberField>
</Results>
<Results xsi:type="Data">
<PartnerKey xsi:nil="true" />
<ObjectID>Object2</ObjectID>
<CustomerKey>Customer2</CustomerKey>
<Name>Name2</Name>
<IsSendable>true</IsSendable>
<SendableSubscriberField>
<Name>_Something2</Name>
</SendableSubscriberField>
</Results>
<Results xsi:type="Data">
<PartnerKey xsi:nil="true" />
<ObjectID>Object3</ObjectID>
<CustomerKey>AnotherKey</CustomerKey>
<Name>Something3</Name>
<IsSendable>false</IsSendable>
</Results>
</RetrieveResponseMsg>
</soap:Body>
</soap:Envelope>'
</code></pre>
| [
{
"answer_id": 74347886,
"author": "Aleksandre Geladze",
"author_id": 17348589,
"author_profile": "https://Stackoverflow.com/users/17348589",
"pm_score": 2,
"selected": false,
"text": ".netflix-logo && nav a"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9982613/"
] |
74,347,888 | <p>I am trying to nest two components by writing their Element selector into each other like this <code><outerElementSelector><innerElementSelector></innerElementSelector></outerElementSelector></code> in the HTML file of another third component. I found that my <code><innerElementSelector></code> was not rendering on the page.</p>
<p>Note: Above mentioned selector names are imaginary and are not part of the code, I just took them for explaining my problem.
Also, there is no error on the Console of the Browser.
And yes I have mentioned by components in the <code>app.module.ts</code> for Angular to know about our components</p>
<p>I am having 3 Components <code>servers, server, successalert</code>.
The <code>servers.component.html</code> file contains the other two selectors named <code>app-server</code> and <code>app-successalert</code> in the nested form where <code><app-successalert></code> tag is nested in <code><app-server></code> tag.</p>
<p><strong>servers.component.html</strong></p>
<pre><code><app-server>
<app-successalert></app-successalert>
</app-server>
</code></pre>
<p><strong>servers.component.ts</strong></p>
<pre><code>import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-servers',
templateUrl: './servers.component.html',
styleUrls: ['./servers.component.css']
})
export class ServersComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
// IGNORE OnInit AND CONSTRUCTOR();
</code></pre>
<p><strong>server.component.html</strong></p>
<pre><code><h3>Server Component</h3>
</code></pre>
<p><strong>server.component.ts</strong></p>
<pre><code>import { Component } from "@angular/core";
@Component({
selector: 'app-server',
templateUrl: './server.component.html',
styles: [`
h3 {
color: orange;
}
`]
})
export class ServerComponent {}
</code></pre>
<p><strong>successalert.component.ts</strong></p>
<pre><code>import { Component } from "@angular/core";
@Component({
selector: 'app-successalert',
template: `<p>You are so successfull, Congratzs</p>`,
styles: [`p{
color: green;
padding: 10px;
background-color: lightgreen;
border: 1px solid green;
font-weight: bold;
}`]
})
export class SuccessAlert {}
</code></pre>
<p><strong>app.module.ts</strong></p>
<pre><code>import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';
import { ServersComponent } from './servers/servers.component';
import { SuccessAlert } from './successalert/successalert.component';
import { WarningalertComponent } from './warningalert/warningalert.component';
@NgModule({
declarations: [
AppComponent,
ServerComponent,
ServersComponent,
SuccessAlert,
WarningalertComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
</code></pre>
<p><strong>app.component.html</strong></p>
<pre><code><h3>Hello, I am Core</h3>
<hr>
<app-servers></app-servers>
</code></pre>
<p><strong>app.component.ts</strong></p>
<pre><code>import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
</code></pre>
<p>Just a Quick Note: Other Componets like my <code><app-root>, <app-servers>, <app-server></code> are Rendering just the Nested components are not rendering(app-successalert).</p>
<p>I tried the above-mentioned code and expected the (When it is nested in ) will result in showing the <code>You are so successful, Congratzs</code> on the screen but the is itself not rendered on the screen.</p>
<p>When i put outside of the component like the below code, basically when I am not nesting them renders on the screen.</p>
<p><strong>servers.component.html</strong></p>
<pre><code><app-server></app-server>
<app-successalert></app-successalert>
</code></pre>
<p>Why is it happening?</p>
| [
{
"answer_id": 74347886,
"author": "Aleksandre Geladze",
"author_id": 17348589,
"author_profile": "https://Stackoverflow.com/users/17348589",
"pm_score": 2,
"selected": false,
"text": ".netflix-logo && nav a"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410750/"
] |
74,347,890 | <p>I have a Datafaame like this:</p>
<pre><code> dt <- tibble(
TRIAL = c("A", "A", "A", "B", "B", "B", "C", "C", "C","D","D","D"),
RL = c(1, NA, 3, 1, 6, 3, 2, 3, 1, 0, 1.5, NA),
SL = c(6, 1.5, 1, 0, 0, 1, 1, 2, 0, 1, 1.5, NA),
HC = c(0, 1, 5, 6,7, 8, 9, 3, 4, 5, 4, 2)
)
# A tibble: 12 x 4
TRIAL RL SL HC
<chr> <dbl> <dbl> <dbl>
1 A 1 6 0
2 A NA 1.5 1
3 A 3 1 5
4 B 1 0 6
5 B 6 0 7
6 B 3 1 8
7 C 2 1 9
8 C 3 2 3
9 C 1 0 4
10 D 0 1 5
11 D 1.5 1.5 4
12 D NA NA 2
</code></pre>
<p>I want to group the data frame by TRIAL and have the values in RL and SL checked by group, if the value in either of the column is greater than 5 then move all values for RL and SL for that particular group to RLCT and SLCT respectively.</p>
<pre><code># A tibble: 12 x 6
TRIAL HC RLCT SLCT SL RL
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A 0 1 6 NA NA
2 A 1 NA 1.5 NA NA
3 A 5 3 1 NA NA
4 B 6 1 0 NA NA
5 B 7 6 0 NA NA
6 B 8 3 1 NA NA
7 C 9 NA NA 1 3
8 C 3 NA NA 3 5
9 C 4 NA NA 1 1
10 D 5 NA NA 1 0
11 D 4 NA NA 1.5 1.5
12 D 2 NA NA NA NA
</code></pre>
<p>When I run the below code, I did not get the expected output</p>
<pre><code>dt0 <- dt %>%
mutate(RLCT = NA,
SLCT = NA) %>%
group_by(TRIAL) %>%
filter(!any(RL > 5.0 | SL > 5.0))
dt1 <- dt %>%
group_by(TRIAL) %>%
filter(any(RL > 5.0 | SL > 5.0)) %>%
mutate(RLCT = RL,
SLCT = SL) %>%
rbind(dt0, .) %>%
mutate(RL = ifelse(!is.na(RLCT), NA, RL),
SL = ifelse(!is.na(SLCT), NA, SL)) %>% arrange(TRIAL)
</code></pre>
<p>This is what I get</p>
<pre><code># A tibble: 9 x 6
# Groups: TRIAL [3]
TRIAL RL SL HC RLCT SLCT
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A NA NA 0 1 6
2 A NA NA 1 NA 1.5
3 A NA NA 5 3 1
4 B NA NA 6 1 0
5 B NA NA 7 6 0
6 B NA NA 8 3 1
7 C 2 1 9 NA NA
8 C 3 2 3 NA NA
9 C 1 0 4 NA NA
</code></pre>
| [
{
"answer_id": 74348295,
"author": "Ricardo Semião e Castro",
"author_id": 13048728,
"author_profile": "https://Stackoverflow.com/users/13048728",
"pm_score": 3,
"selected": true,
"text": "RL"
},
{
"answer_id": 74348800,
"author": "Darren Tsai",
"author_id": 10068985,
"author_profile": "https://Stackoverflow.com/users/10068985",
"pm_score": 1,
"selected": false,
"text": "dplyr"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17445085/"
] |
74,347,952 | <p>I want to separate string from the digits using regex. I don't want to replace anything just add space. I don't want to add space in digit and special character or string and special character.
for example</p>
<pre><code> "A-21PHASE-1,ASHOK VIHARA-21, PHASE-1, - ASHOK VIHAR110052"
</code></pre>
<p>output for above example should look like,</p>
<pre><code>"A-21 PHASE-1,ASHOK VIHARA-21, PHASE-1, - ASHOK VIHAR 110052"
</code></pre>
<p>in this example I want to add space between alphabets and number. there are number attached with '-' or any special character , I don't want to do anything with it.</p>
| [
{
"answer_id": 74348061,
"author": "treuss",
"author_id": 19838568,
"author_profile": "https://Stackoverflow.com/users/19838568",
"pm_score": 2,
"selected": true,
"text": "thestring = re.sub(r'(\\d)([A-Z])', r'\\1 \\2', thestring)\nthestring = re.sub(r'([A-Z])(\\d)', r'\\1 \\2', thestring)\n"
},
{
"answer_id": 74348177,
"author": "ILS",
"author_id": 10017662,
"author_profile": "https://Stackoverflow.com/users/10017662",
"pm_score": 0,
"selected": false,
"text": "(?<=...)"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12362316/"
] |
74,347,954 | <p>Something like:</p>
<pre class="lang-py prettyprint-override"><code>string_one = "hello world one"
string_two = "hello john one"
if string_one = string_two:
do something
</code></pre>
<p>So if it detects 2 words in 2 (or more) strings that are the same do something. But I can't figure out how to do it.</p>
| [
{
"answer_id": 74347988,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 3,
"selected": true,
"text": "split()"
},
{
"answer_id": 74348117,
"author": "Bhargav",
"author_id": 15358800,
"author_profile": "https://Stackoverflow.com/users/15358800",
"pm_score": 0,
"selected": false,
"text": "string_one = \"hello world one\"\nstring_two = \"hello john one\"\n\nmatched = [i for i in string_one.split() if i in string_two.split()]\nprint(matched)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440977/"
] |
74,347,961 | <p>I am struggling to stop my entire List from rerendering. When I select an item it should be underlined. It should suffice if the newly selected and the previously selected elements are rerendered.<br />
In a worst-case scenario, this List can get hundreds of entries long and it's getting really slow. So I tried using <code>React.memo</code> method, but I am probably using it wrong.<br />
These are my custom Functions for List and ListEntry (<em>changeSelected</em> and <em>currentlySelected</em> are the state and setState functions from the parent)</p>
<pre><code>function CustomList(props: any) {
return (
<List
component="div"
>
{props.data.map((entryData: any, index: number) => {
return (
<React.Fragment key={index}>
<CustomListEntry
entryData={entryData}
changeSelected={props.changeSelected}
style={{
borderBottom:
props.currentlySelected == entryData.id ? "dashed" : "",
}}
/>
</React.Fragment>
);
})}
</List>
);
}
</code></pre>
<pre><code>const CustomListEntry = React.memo((props: any) => {
return (
<ListItemButton
style={props.style}
onClick={() => {
props.changeSelected(props.entryData.id);
}}
>
<ListItemText>
{props.entryData.exampledata}
</ListItemText>
</ListItemButton>
);
});
</code></pre>
<p>And the parent Component:</p>
<pre><code>function Root(props:any){
const [selectedId, setSelectedId] = React.useState("");
...
return{
<CustomList
data={data}
changeSelected={setSelectedId}
currentlySelected={selectedId}
></CustomList>
}
}
</code></pre>
<p><strong>Edit:</strong>
Here my full code, if its important for context. (useApiEnpoint just uses Axios to get the initial data for the List. Is just called on first mounting and shouldnt affect the poor performance on selection change)</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>export default function SubSiteDokumentation(props: any) {
const StammdatenContext = React.useContext(ProbandContext);
const [selectedId, setSelectedId] = React.useState("");
const { formData, handleGetDetail, isLoading, isError } = useAPIEndpoint({
endpoint: "KontaktetermineList",
formName: "Termine",
pk: StammdatenContext.currentPnr,
enableSnackbar: true,
initialLoading: true,
});
React.useEffect(() => {
handleGetDetail();
}, []);
if (isError) {
return (
<Typography variant="h4" align="center" color="red">
Termine konnten nicht geladen werden! Versuchen sie es später erneut
oder wenden sie sich an den Administrator
</Typography>
);
}
if (isLoading) {
return <Spinner animation="border"></Spinner>;
}
return (
<Grid container spacing={2}>
<Grid item xs={7}>
<TermineList
data={formData}
changeSelected={setSelectedId}
currentlySelected={selectedId}
></TermineList>
</Grid>
{/* <Grid item xs={5}>
<TerminDetail currentlySelected={selectedId}></TerminDetail>
</Grid> */}
</Grid>
);
}
function TermineList(props: any) {
return (
<Box
pl={"10px"}
sx={{
background: "#b4f5bf",
}}
className="my-sidebarAuftraege my-nice-scrollbarBox"
>
<ListSubheader sx={{ background: "#b4f5bf", zIndex: "1000" }}>
<Typography align="center" variant="h5" color="black">
Dokumentation
</Typography>
</ListSubheader>
<List
component="div"
disablePadding
sx={{ background: "#e3ffe9", borderRadius: "10px" }}
>
{props.data.map((termin: any, index: number) => {
let style = {
backgroundColor: index % 2 === 1 ? "#00000011" : "",
borderColor: "#89ca07",
borderBottom: props.currentlySelected == termin.id ? "dashed" : "",
};
return (
<React.Fragment key={index}>
<TermineListEntry
termin={termin}
changeSelected={props.changeSelected}
style={style}
/>
<Divider
sx={{ borderBottomWidth: 2, backgroundColor: "black" }}
></Divider>
</React.Fragment>
);
})}
<ListItem
sx={{
display: "flex",
justifyContent: "center",
backgroundColor:
(props.data.length % 2 === 1 && "#00000011") || "#00000000",
}}
>
{/* <Box sx={{ display: "flex", justifyContent: "center" }}>
<div>test</div>
</Box> */}
</ListItem>
</List>
</Box>
);
}
const TermineListEntry = React.memo((props: any) => {
return (
<ListItemButton
style={props.style}
onClick={() => {
props.changeSelected(props.termin.id);
}}
>
<ListItemText>
<Grid container>
<Grid item xs={2}>
{Moment(props.termin.datum).format("DD.MM.YYYY")}
</Grid>
<Grid item xs={2}>
{props.termin.uhrzeit}
</Grid>
<Grid item xs={6}>
{props.termin.inhalt}
</Grid>
<Grid item xs={1}>
{props.termin.art}
</Grid>
<Grid item xs={1}>
{props.termin.kv}
</Grid>
</Grid>
</ListItemText>
</ListItemButton>
);
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.my-sidebarAuftraege {
height: calc(
calc(calc(100vh - #{$navbar-height}) - #{$subNavbar-height}) - 24px
);
padding: 0px;
border-style: solid;
border-color: $primary-dark;
background-color: #00000009;
border-radius: 5px;
overflow: scroll;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
//Scrollbar Styling for Edge
.my-nice-scrollbarBox::-webkit-scrollbar {
width: 10px;
height: 6px;
}
.my-nice-scrollbarBox::-webkit-scrollbar-track {
background: transparent;
}
.my-nice-scrollbarBox::-webkit-scrollbar-thumb {
border-radius: 10px;
background: rgba(0, 0, 0, 0.2);
}
.my-nice-scrollbarBox::-webkit-scrollbar-thumb:hover {
background: rgba(0, 0, 0, 0.4);
}
.my-nice-scrollbarBox::-webkit-scrollbar-thumb:active {
background: rgba(0, 0, 0, 0.9);
}
//Scrollbar Styling for Firefox
.my-nice-scrollbarBox {
scrollbar-width: thin;
scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74348236,
"author": "Ji aSH",
"author_id": 6108947,
"author_profile": "https://Stackoverflow.com/users/6108947",
"pm_score": 2,
"selected": false,
"text": "for (let i = 0 ; i < 10000 ; i++) {\n data.push({ id: String(i), exampledata: `Value ${i}`})\n}\n"
},
{
"answer_id": 74348456,
"author": "Nick Vu",
"author_id": 9201587,
"author_profile": "https://Stackoverflow.com/users/9201587",
"pm_score": 1,
"selected": false,
"text": "React.memo"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19633641/"
] |
74,347,966 | <p>I have some statements like this in notepad ++</p>
<pre><code>INSERT INTO ZZZZZZZ (A,B,C,D)
VALUES (1,2,3,4)
;
</code></pre>
<p>I need to put the semicolon after the end of line 2 for all the occurrences.
Desired output :</p>
<pre><code>INSERT INTO ZZZZZZZ (A,B,C,D)
VALUES (1,2,3,4);
</code></pre>
<p>How to do that in notepad++</p>
| [
{
"answer_id": 74347995,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 2,
"selected": true,
"text": "Find: $\\R;\nReplace: ;\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846981/"
] |
74,347,977 | <p><strong>here is my class model</strong></p>
<p>do not pay attention to hivefield and hivetype</p>
<p>I know how to read the data from my Patient list but not from ListNote which is in my Patient list</p>
<pre><code>import 'package:hive_flutter/hive_flutter.dart';
part 'listpatient.g.dart';
@HiveType(typeId: 0)
class Patients {
@HiveField(0)
final String? name;
@HiveField(1)
final String? firstname;
@HiveField(3)
final String? dateofbirth;
@HiveField(4)
final String? email;
@HiveField(5)
final String? numero;
@HiveField(6)
final DateTime? date;
@HiveField(7)
final int? id;
@HiveField(8)
final List<ListNote>? listOfNotes;
const Patients({
this.name,
this.firstname,
this.dateofbirth,
this.email,
this.numero,
this.date,
this.id,
this.listOfNotes,
});
}
@HiveType(typeId: 0)
class ListNote {
@HiveField(1)
final String? title;
@HiveField(2)
final String? note;
@HiveField(3)
final String? conclusion;
ListNote({
this.title,
this.note,
this.conclusion,
});
}
</code></pre>
<p>here is the code where I try to read my information</p>
<pre><code> _body() {
return Column(
children: <Widget>[
Expanded(
child: ListView(children: [
Card(child: Text(widget.patients.listOfNotes.)) <------ Here
]),
),
],
);
}
</code></pre>
<p>patients comes from the parent it patients contains the list</p>
<pre><code>widget.patients.listOfNotes
</code></pre>
<p><strong>thank you for your help</strong></p>
| [
{
"answer_id": 74348174,
"author": "LacticWhale",
"author_id": 11962301,
"author_profile": "https://Stackoverflow.com/users/11962301",
"pm_score": 1,
"selected": false,
"text": "children: [\n ...widget.patients.listOfNotes.map((e) -> Card(child: Text(e.title)))\n]\n"
},
{
"answer_id": 74348228,
"author": "Youhana Sheriff",
"author_id": 20440884,
"author_profile": "https://Stackoverflow.com/users/20440884",
"pm_score": 3,
"selected": true,
"text": "@HiveType(typeId: 0)\nclass Patients {\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74347977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17817878/"
] |
74,348,006 | <p>I've set up this opening hours timetable for my website, but I wanted to get rid of unnecessary javascript and therefore wanted to do with liquid only.</p>
<p>I'm not very familiar with it but could anyone maybe point me in the right direction? Is it possible to do "if certain day between this and that time" conditions?</p>
<p>Thanks a lot for helping out,</p>
<p><a href="https://codepen.io/EliasUUUU/pen/GRyMgyj" rel="nofollow noreferrer">https://codepen.io/EliasUUUU/pen/GRyMgyj</a></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>var currentDate = new Date();
var weekday = [];
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var currentDay = weekday[currentDate.getDay()];
var currentTimeHours = currentDate.getHours();
currentTimeHours = currentTimeHours < 10 ? "0" + currentTimeHours : currentTimeHours;
var currentTimeMinutes = currentDate.getMinutes();
var timeNow = currentTimeHours + "" + currentTimeMinutes;
var currentDayID = "#" + currentDay; //gets todays weekday and turns it into id
$(currentDayID).toggleClass("today"); //this works at hightlighting today
var openTimeSplit = $(currentDayID).children('.opens').text().split(":");
var openTimeHours = openTimeSplit[0];
openTimeHours = openTimeHours < 10 ? "0" + openTimeHours : openTimeHours;
var openTimeMinutes = openTimeSplit[1];
var openTimex = openTimeSplit[0] + openTimeSplit[1];
var closeTimeSplit = $(currentDayID).children('.closes').text().split(":");
var closeTimeHours = closeTimeSplit[0];
closeTimeHours = closeTimeHours < 10 ? "0" + closeTimeHours : closeTimeHours;
var closeTimeMinutes = closeTimeSplit[1];
var closeTimex = closeTimeSplit[0] + closeTimeSplit[1];
if (timeNow >= openTimex && timeNow <= closeTimex) {
$(".openorclosed").toggleClass("open");
} else {
$(".openorclosed").toggleClass("closed");
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.openinghours {
margin:10px;
padding:0 10px 0 10px;
overflow: hidden;
display: inline-block;
}
.openinghourscontent {
float:left;
}
.openinghourscontent h2 {
display:block;
text-align:center;
margin-top:.33em;
}
.today {
color: #8AC007;
}
.opening-hours-table tr td:first-child {
font-weight:bold;
}
#open-status {
display:block;
margin-top:-1em;
text-align:center;
}
.openorclosed:after {
content:" åbent på disse tider:";
}
.open {
color:green;
}
.open:after {
content:" Åbent";
color: #6C0;
}
.closed:after {
content:" Lukket";
color: red;
}
.opening-hours-table tr td {
padding:5px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <section class="openinghours">
<div class="openinghourscontent section">
<div class="header">
<h2></h2>
<span id="open-status"><small class="openorclosed">Vi har </small></span>
</div>
<table class="opening-hours-table">
<tr id="Monday" itemprop="openingHours" title="Open Monday at 9am to 6pm">
<td>Mandag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">19:00</td>
</tr>
<tr id="Tuesday" itemprop="openingHours" title="Open Tuesday at 9am to 6pm">
<td>Tirsdag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">22:00</td>
</tr>
<tr id="Wednesday" itemprop="openingHours" title="Open Wednesday at 9am to 6pm">
<td>Onsdag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">19:00</td>
</tr>
<tr id="Thursday" itemprop="openingHours" title="Open Thursday at 9am to 8pm">
<td>Torsdag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">19:00</td>
</tr>
<tr id="Friday" itemprop="openingHours" title="Open Friday at 9am to 6pm">
<td>Fredag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">19:00</td>
</tr>
<tr id="Saturday" itemprop="openingHours" title="Open Saturday at 10am to 6pm">
<td>Lørdag</td>
<td class="opens">12:00</td>
<td>-</td>
<td class="closes">19:00</td>
</tr>
<tr id="Sunday" itemprop="openingHours" title="Open Sunday at 11am to 4pm">
<td>Søndag</td>
<td class="closed"> </td>
<td></td>
<td class="closes"></td>
</tr>
</table>
<script>
(function(e, t, n, r) {
if (e) return;
t._appt = true;
var i = n.createElement(r),
s = n.getElementsByTagName(r)[0];
i.async = true;
i.src = '//dje0x8zlxc38k.cloudfront.net/loaders/s-min.js';
s.parentNode.insertBefore(i, s)
})(window._appt, window, document, "script")
</script>
</div>
</section></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74349231,
"author": "Fabio Filippi",
"author_id": 343794,
"author_profile": "https://Stackoverflow.com/users/343794",
"pm_score": 1,
"selected": false,
"text": "date"
},
{
"answer_id": 74402502,
"author": "Elias Nielsen",
"author_id": 17621645,
"author_profile": "https://Stackoverflow.com/users/17621645",
"pm_score": 1,
"selected": true,
"text": " .day_open {\n color: black;\n }\n .day_closed {\n color: light-grey;\n }\n\n .now_open:before {\n content:\"⬤ \";\n color: green;\n vertical-align: baseline;\n padding-right: 3px;\n font-size: 12px;\n }\n\n .now_open:after {\n content:\" We're open\";\n }\n \n .now_closed:before {\n content:\"⬤ \";\n color: red;\n vertical-align: baseline;\n padding-right: 3px;\n font-size: 12px;\n }\n\n .now_closed:after {\n content:\" We're closed\";\n } \n \n .openclosed {\n font-size: 12px;\n }\n\n .now_open.openclosed {\n margin-bottom:15px;\n margin-top:10px;\n }\n\n .now_closed.openclosed {\n margin-bottom:15px;\n margin-top:10px;\n }\n\n .opening-hours-table tr td:first-child {\n font-weight:bold;\n }\n .opening-hours-table tr td:nth-child(2) {\n padding-left:20px;\n }\n .opening-hours-table tr td {\n padding:5px 0px;\n border: none;\n }\n .opening-hours-table td {\n border: none !important;\n }\n .opening-hours-table {\n font-size: 14px;\n }"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17621645/"
] |
74,348,035 | <p>With MAP I can easily return single cell values, like in</p>
<pre><code> =MAP(SEQUENCE(5),LAMBDA(x,x*x))
</code></pre>
<p>However, if I try to return compound values 8ranges or arrays) it doesn't seem to work, like in</p>
<pre><code> =MAP(SEQUENCE(5),LAMBDA(x,HSTACK(x,x*x)))
</code></pre>
<p>... and I get a CALC! error.</p>
<p>Is there any workaround that allows me to return ranges/arrays with the MAP function?</p>
| [
{
"answer_id": 74348108,
"author": "JvdV",
"author_id": 9758194,
"author_profile": "https://Stackoverflow.com/users/9758194",
"pm_score": 3,
"selected": true,
"text": "REDUCE()"
},
{
"answer_id": 74348783,
"author": "Tom Sharpe",
"author_id": 3894917,
"author_profile": "https://Stackoverflow.com/users/3894917",
"pm_score": 2,
"selected": false,
"text": "=--LET(lmda,MAP(SEQUENCE(5),LAMBDA(x,x&\"|\"&x*x)),HSTACK(TEXTBEFORE(lmda,\"|\"),TEXTAFTER(lmda,\"|\")))\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6304284/"
] |
74,348,036 | <p>I have a table and I need to get rows which matche a list of values. I've created a <a href="http://sqlfiddle.com/#!4/280d0/15" rel="nofollow noreferrer">SQLFiddle</a> where you can see the result.</p>
<p>This query is used to populate a DropDownList which uses or not autocompletion.
So there are two possible uses for this request: the first is with an empty LIKE ('%') and the second with a populated LIKE ('***%'). Only the first use is problematic because all rows are selected without LIKE condition and I only need those which matches the list of values of PGM column.</p>
<p>My issue is that I can't get the rows which PGM = 'N' and 'L' (according to Fiddle example), not just 'L' or just 'N', nor 'L' and 'N' and 'P': only the pair 'N' and 'L' if this is the values in the list.</p>
<pre><code>SELECT al.* FROM ALPHA al WHERE al.PN IN (
SELECT al2.PN FROM ALPHA al2 WHERE TRIM(al2.PGM) IN ('N','L') AND TRIM(al2.NUM) IN ('2350') AND TRIM(al2.TEAM) = 'R2D2'
AND TRIM(al2.PN) LIKE '%' AND (
SELECT COUNT(*) FROM ALPHA al3 WHERE TRIM(al3.PGM) IN ('N','L') AND TRIM(al3.PN) LIKE '%') = 2
)
AND TRIM(al.PGM) IN ('N','L') ORDER BY al.PN ASC;
/*
The idea, in a nutshell, is as follows:
line 1 - Get all rows from ALPHA
line 2 - Get filtered rows from ALPHA according to PGM, NUM, TEAM
line 3 - Filter PN with LIKE (according to autocompletion or not)
line 4 - Get rows which have a PGM = N and PGM = L ONLY | As there are two values in the list it should returns 2 but it does not because of empty LIKE
line 6 - Filter all rows according to PGM
*/
</code></pre>
<p>I'm aware of this <a href="https://stackoverflow.com/questions/7154611/oracle-get-rows-that-exactly-matches-the-list-of-values">link</a> but I cannot use it in my case, in PROD I'm working on VIEW not joined TABLES.</p>
<p>Thank you !</p>
| [
{
"answer_id": 74348583,
"author": "MT0",
"author_id": 1509264,
"author_profile": "https://Stackoverflow.com/users/1509264",
"pm_score": 3,
"selected": true,
"text": "N"
},
{
"answer_id": 74349467,
"author": "d r",
"author_id": 19023353,
"author_profile": "https://Stackoverflow.com/users/19023353",
"pm_score": 1,
"selected": false,
"text": "WITH\n pgm_filter AS\n (\n Select PN, PGM_LIST\n From (SELECT DISTINCT PN, PGM, LISTAGG(PGM, '') WITHIN GROUP (Order By PGM) OVER(PARTITION BY PN) \"PGM_LIST\"\n FROM ALPHA a)\n Where PGM_LIST = 'LN'\n Group By PN, PGM_LIST \n )\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4191101/"
] |
74,348,037 | <p>I have huge data and I want merge it on a specific column where values from df1 is not available in df2 and vice versa.</p>
<p>Example:</p>
<p>df1:</p>
<pre><code>Domain Sales
google.com 100
facebook.com 200
youtube.com 300
</code></pre>
<p>df2:</p>
<pre><code>Domain Sales
google.com 100
yahoo.com 200
youtube.com 300
</code></pre>
<p>Required output:</p>
<pre><code>Domain Sales
facebook.com 200
yahoo.com 200
</code></pre>
<p>I have tried:</p>
<pre><code>df = pd.merge(df1, df2, on="Domain", how="outer")
</code></pre>
<p>and all the other values for the <code>how</code> parameter, but it does not give me the required output. How can I achieve the required output?</p>
| [
{
"answer_id": 74348087,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 3,
"selected": true,
"text": "pd.concat([df1, df2]).drop_duplicates('Domain', keep=False)\n"
},
{
"answer_id": 74348089,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "concat"
},
{
"answer_id": 74348137,
"author": "BENY",
"author_id": 7964527,
"author_profile": "https://Stackoverflow.com/users/7964527",
"pm_score": 0,
"selected": false,
"text": "merge"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11834577/"
] |
74,348,070 | <p>I have some rows in an SQL table.
I have attributes as: id, name, etc.
Some of the names (in the name column) are built from some name ("xyz") and the id</p>
<pre class="lang-none prettyprint-override"><code>id name
333 regularName
555 somename.555
666 myName.666
</code></pre>
<p>I want to select only rows that don't include the id inside the name.</p>
<p>So my query was:</p>
<pre><code>select *
from MY_TABLE
where name not like '%.id'
</code></pre>
<p>But it refer to id as a string</p>
<p>Is there a way to refer to one of the columns value inside the query?</p>
| [
{
"answer_id": 74348287,
"author": "a_horse_with_no_name",
"author_id": 330315,
"author_profile": "https://Stackoverflow.com/users/330315",
"pm_score": 2,
"selected": true,
"text": "select * \nfrom MY_TABLE \nwhere name not like concat('%.', id::text);\n"
},
{
"answer_id": 74348289,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "select * from table\nwhere \nnot regexp_like(name, '.[0-9]+')\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11492153/"
] |
74,348,073 | <p>assume a table has id and date columns, is there a way to apply different date filter to each id?</p>
<p>one way I can think of is to add a flag column that is populated with an if ladder</p>
<p>if id=A and date>date1 then 1</p>
<p>elseif id=B and date>date2 then 1</p>
<p>elseif id=C and date>date3 then 1</p>
<p>else 0</p>
<p>and then select rows where flag=1</p>
<p>is there a better way?</p>
| [
{
"answer_id": 74348214,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 2,
"selected": true,
"text": "where (id=A and date>date1)\n or (id=B and date>date2)\n or (id=C and date>date3)\n"
},
{
"answer_id": 74348215,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "case when"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18398254/"
] |
74,348,116 | <p>The data in the column does not align with the headers.</p>
<p>I have tried to set the display in the head to</p>
<pre><code> display: table-header-group;
</code></pre>
<p>to no avail.</p>
<p>Thanks</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> table {
border-collapse: collapse;
margin: 25px;
font-size: 0.9em;
border-radius: 5px 5px 0 0;
overflow: hidden;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
background-color: bisque;
table-layout: fixed;
thead {
border: 1px solid black;
display: table-header-group;
tr {
background-color: #009879;
color: white;
font-weight: bold;
text-align: left;
}
}
tbody {
tr:nth-of-type(even) {
background-color: whitesmoke;
}
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
<thead>
<tr>
<th id="monthName">Months</th>
<th class="header" colspan="2">June</th>
<th class="header" colspan="2">July</th>
<th class="header" colspan="2">August</th>
<th class="header" colspan="2">September</th>
<th class="header" colspan="2">October</th>
<th class="header" colspan="2">February</th>
<th class="header" colspan="2">March</th>
<th class="header" colspan="2">April</th>
<th class="header" colspan="2">January</th>
<th class="header" colspan="2">May</th>
</tr>
</thead>
<tbody>
<tr>
<td class="question">x</td>
<td class="answer">95</td>
<td class="answer">73</td>
<td class="answer">73</td>
<td class="answer">56</td>
<td class="answer">63</td>
<td class="answer">68</td>
<td class="answer">80</td>
<td class="answer">86</td>
<td class="answer"></td>
<td class="answer"></td>
</tr>
<tr>
<td class="question">y</td>
<td class="answer">68</td>
<td class="answer">85</td>
<td class="answer">64</td>
<td class="answer">56</td>
<td class="answer">96</td>
<td class="answer">100</td>
<td class="answer"></td>
<td class="answer"></td>
<td class="answer">89</td>
<td class="answer">79</td>
</tr>
<tr>
<td class="question">z</td>
<td class="answer">61</td>
<td class="answer">59</td>
<td class="answer">86</td>
<td class="answer">44</td>
<td class="answer">86</td>
<td class="answer">65</td>
<td class="answer"></td>
<td class="answer">73</td>
<td class="answer">51</td>
<td class="answer">92</td>
</tr>
</tbody>
</table></code></pre>
</div>
</div>
</p>
<p>I tried to align the content of the body to the headers so that it looks like a spreadsheet but the answers get bunched together.</p>
| [
{
"answer_id": 74348214,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 2,
"selected": true,
"text": "where (id=A and date>date1)\n or (id=B and date>date2)\n or (id=C and date>date3)\n"
},
{
"answer_id": 74348215,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "case when"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13811854/"
] |
74,348,124 | <p>I am using React with Typescript.</p>
<p>I am passing <code>id</code> as a prop to my button component. Still getting the mentioned error on <code>e.target.id</code></p>
<pre><code> function handleButtonClick(e: React.MouseEvent<HTMLButtonElement>) {
someOperation(e.target.id)
}
</code></pre>
<p>React: <code>18.0.0</code></p>
<p>Typescript: <code>4.7.4</code></p>
| [
{
"answer_id": 74348214,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 2,
"selected": true,
"text": "where (id=A and date>date1)\n or (id=B and date>date2)\n or (id=C and date>date3)\n"
},
{
"answer_id": 74348215,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "case when"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20002028/"
] |
74,348,134 | <p>I'm aware that the question is awkward. If I could phrase it better I'd probably find the solution in an other thread.</p>
<p>I have this data structure...</p>
<pre class="lang-r prettyprint-override"><code>df <- data.frame(group = c("X", "F", "F", "F", "F", "C", "C"),
subgroup = c(NA, "camel", "horse", "dog", "cat", "orange", "banana"))
</code></pre>
<p>... and would like to turn it into this...</p>
<pre class="lang-r prettyprint-override"><code>data.frame(group = c("X", "F", "camel", "horse", "dog", "cat", "C", "orange", "banana"))
</code></pre>
<p>... which is surprisingly confusing. Also, I would prefer not using a loop.</p>
<p>EDIT: I updated the example to clarify that solutions that depend on sorting unfortunately do not do the trick.</p>
| [
{
"answer_id": 74348214,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 2,
"selected": true,
"text": "where (id=A and date>date1)\n or (id=B and date>date2)\n or (id=C and date>date3)\n"
},
{
"answer_id": 74348215,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "case when"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2996802/"
] |
74,348,189 | <p>I try to show the contents of a dictionary that has to return this output:</p>
<pre><code>'Watermeloenen': 466, 'Appels': 688, 'Sinaasappels': 803
</code></pre>
<p>So I have this method:</p>
<pre><code> def total_fruit_per_sort(self, file_content):
file_contents = self.extractingText.extract_text_from_image(
file_content)
number_found = re.findall(self.total_amount_fruit_regex(), file_contents)
fruit_dict = {}
for n, f in number_found:
fruit_dict[f] = fruit_dict.get(f, 0) + int(n)
return str({value: key for value, key in fruit_dict.items()}).replace("{", "").replace("}", "")
</code></pre>
<p>This is the regex:</p>
<pre><code> def total_amount_fruit_regex(self):
return r"(\d*(?:\.\d+)*)\s*W+({self.fruit_list()})"
</code></pre>
<p>and the input string(file_contents) is this:</p>
<pre><code>"[' \n\na)\n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. : 71201 Koopliedenweg 33\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 10-12-21\nAantal Omschrijving Prijs Bedrag\nOrder number : 77553 Loading date : 09-12-21 Incoterm: : FOT\nYour ref. : SCHOOLFRUIT Delivery date :\nWK50\nD.C. Schoolfruit\n16 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 123,20\n360 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 2.772,00\n6 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,/0 € 46,20\n75 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 577,50\n9 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 69,30\n688 Appels Royal Gala 13kg 60/65 Generica PL I € 5,07 € 3.488,16\n22 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 137,50\n80 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 500,00\n160 Sinaasappels Valencias 15kg 105 FVC ZAI € 6,25 € 1.000,00\n320 Sinaasappels Valencias 15kg 105 Generica ZAI € 6,25 € 2.000,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 1.000,00\n61 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 381,25\nTotaal Colli Totaal Netto Btw Btw Bedrag Totaal Bedrag\n€ 12.095,11 1.088,56\nBetaling binnen 30 dagen\nAchterstand wordt gemeld bij de kredietverzekeringsmaatschappij\nVerDi Import BV ING Bank NV. Rotterdam IBAN number: NL17INGB0006959173 ~~\n\n \n\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 i\nTel, +31 (0}1 80 61 88 11, Fax +31 (0)1 8061 88 25 Chamber of Commerce Rotterdam no. 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nrut ard wegetables\n\x0c']"
</code></pre>
<p>And this is the fruit_list:</p>
<pre><code> self.list_fruit = ['Appels', 'Ananas', 'Peen Waspeen',
'Tomaten Cherry', 'Sinaasappels',
'Watermeloenen', 'Rettich', 'Peren', 'Peen',
'Mandarijnen', 'Meloenen', 'Grapefruit', 'Rettich']
</code></pre>
<p>But if I run the function: total_fruit_per_sort. I get this error:</p>
<pre><code>expected string or bytes-like object
Request Method: POST
Request URL: http://127.0.0.1:8000/
Django Version: 4.1.1
Exception Type: TypeError
Exception Value:
expected string or bytes-like object
Exception Location: C:\Python310\lib\re.py, line 240, in findall
Raised during: main.views.ReadingFile
Python Executable: C:\Python310\python.exe
</code></pre>
<p>But I parse the dictionary already to a string.</p>
<p>So don't know how to tackle this.</p>
<p>This line in the stracktrace it complains:</p>
<pre><code> number_found = re.findall(
self.total_amount_fruit_regex(), file_contents)
</code></pre>
<p>This is the output of print(file_contents):</p>
<pre><code>[' \n\na)\n\n \n\nFactuur\nVerdi Import Schoolfruit\nFactuur nr. : 71201 Koopliedenweg 33\nDeb. nr. : 108636 2991 LN BARENDRECHT\nYour VAT nr. : NL851703884B01 Nederland\nFactuur datum : 10-12-21\nAantal Omschrijving Prijs Bedrag\nOrder number : 77553 Loading date : 09-12-21 Incoterm: : FOT\nYour ref. : SCHOOLFRUIT Delivery date :\nWK50\nD.C. Schoolfruit\n16 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 123,20\n360 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 2.772,00\n6 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,/0 € 46,20\n75 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 577,50\n9 Watermeloenen Quetzali 16kg 4 IMPERIAL BR I € 7,70 € 69,30\n688 Appels Royal Gala
13kg 60/65 Generica PL I € 5,07 € 3.488,16\n22 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 137,50\n80 Sinaasappels Valencias 15kg 105 Elara ZAI € 6,25 € 500,00\n160 Sinaasappels Valencias 15kg 105 FVC ZAI € 6,25 € 1.000,00\n320 Sinaasappels Valencias 15kg 105 Generica ZAI € 6,25 € 2.000,00\n160 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 1.000,00\n61 Sinaasappels Valencias 15kg 105 Noordhoek ZA I € 6,25 € 381,25\nTotaal Colli Totaal Netto Btw Btw Bedrag Totaal Bedrag\n€ 12.095,11 1.088,56\nBetaling binnen 30 dagen\nAchterstand wordt
gemeld bij de kredietverzekeringsmaatschappij\nVerDi Import BV ING Bank NV. Rotterdam IBAN number: NL17INGB0006959173 ~~\n\n \n\nKoopliedenweg 38, 2991 LN Barendrecht, The Netherlands SWIFT/BIC: INGBNL2A, VAT number: NL851703884B01 i\nTel, +31 (0}1 80 61 88 11, Fax +31 (0)1 8061
88 25 Chamber of Commerce Rotterdam no. 55424309 VerDi\n\nE-mail: sales@verdiimport.nl, www.verdiimport.nl Dutch law shall apply. The Rotterdam District Court shall have exclusive jurisdiction.\n\nrut ard wegetables\n\x0c']
</code></pre>
| [
{
"answer_id": 74348214,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 2,
"selected": true,
"text": "where (id=A and date>date1)\n or (id=B and date>date2)\n or (id=C and date>date3)\n"
},
{
"answer_id": 74348215,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 0,
"selected": false,
"text": "case when"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7713770/"
] |
74,348,193 | <p>I want to create a randomized bool array with a given length a given number of True values efficiently in Python. I could not find a single command to do so, the following does what I want (twice). Is there anything more elegant way to do it?</p>
<pre><code>import numpy as np
def randbool(length,numtrue):
index_array=np.random.choice(length,numtrue,replace=False)
bool_array=np.zeros(length,dtype=bool)
bool_array[index_array]=True
return(bool_array)
def randbool2(length,numtrue):
bool_array=np.hstack((np.tile(True,numtrue),np.tile(False,length-numtrue)))
np.random.shuffle(bool_array)
return(bool_array)
print(randbool(5,2))
print(randbool2(5,2))
</code></pre>
| [
{
"answer_id": 74348336,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "def randbool3(length, numtrue):\n return np.random.choice(length, length, replace=False) < numtrue\n"
},
{
"answer_id": 74348971,
"author": "obchardon",
"author_id": 4363864,
"author_profile": "https://Stackoverflow.com/users/4363864",
"pm_score": 3,
"selected": true,
"text": "def randbool(l,n):\n return np.random.permutation(l)<n\n"
},
{
"answer_id": 74349358,
"author": "Sam Mason",
"author_id": 1358308,
"author_profile": "https://Stackoverflow.com/users/1358308",
"pm_score": 1,
"selected": false,
"text": "n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3373796/"
] |
74,348,197 | <p>reading the <a href="https://redux-toolkit.js.org/rtk-query/usage/mutations" rel="nofollow noreferrer">documentation</a> I saw that mutations can share their result using the fixedCacheKey option:</p>
<blockquote>
<p>RTK Query provides an option to share results across mutation hook instances using the fixedCacheKey option. Any useMutation hooks with the same fixedCacheKey string will share results between each other when any of the trigger functions are called. This should be a unique string shared between each mutation hook instance you wish to share results.</p>
</blockquote>
<p>I have a GET api call that I need to invoke using the <code>trigger</code> method of the <code>useLazyQuery</code> hook, but I need to exploit its booleans (isSuccess, isError, etc...) in many places. Is it possible to have the same behaviour for the <code>useLazyQuery</code> hooks ?</p>
| [
{
"answer_id": 74617860,
"author": "lucataglia",
"author_id": 9099269,
"author_profile": "https://Stackoverflow.com/users/9099269",
"pm_score": 1,
"selected": true,
"text": "// This is the custom hook that wrap the useLazy logic\nconst useCustomHook = () => {\n const [trigger] = useLazyGetItemQuery();\n const result = apiSlice.endpoints.getItem.useQueryState(/* argument if any */);\n\n const handleOnClick = async () => { \n // The second argument for the trigger is the preferCacheValue boolean\n const { data, error } = await trigger(/* argument if any */, true);\n\n // Here where I will implement the success/error logic ...\n }\n\n return { onClick: handleOnClick, result} \n}\n\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9099269/"
] |
74,348,219 | <p>I was wondering if there is a way to set a default function for a getter or a setter.
For example, let's say I have this:</p>
<pre><code>public class MyClass
{
public bool IsDirty {get; private set; } = false;
private string _property;
public string Property1
{
get
{
return _property1;
}
set
{
if (value != _property1)
{
_property1 = value;
IsDirty = true;
}
}
}
}
</code></pre>
<p>I was wondering if there was a way to do something like this:</p>
<pre><code>public class MyClass
{
public bool IsDirty {get; private set;} = false;
MyClass.defaultSet = { if (value != !_property1) { _property1 = value; IsDirty = true; } };
private string _property1;
public string Property1 { get; set; }
public string Property2 {get; set;}
public string Property3 {get; set;}
//...
}
</code></pre>
<p>So that I don't have to do it the first way on this big class I have (~100 properties).</p>
| [
{
"answer_id": 74348555,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "get"
},
{
"answer_id": 74348773,
"author": "Klaus Gütter",
"author_id": 2142950,
"author_profile": "https://Stackoverflow.com/users/2142950",
"pm_score": 2,
"selected": false,
"text": "private void Set<T>(ref T field, T value)\n{\n if (!Equals(value, field))\n {\n field = value;\n IsDirty = true;\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16009197/"
] |
74,348,245 | <p>I have an object named <code>responses</code> that consists of arrays as keys like this</p>
<pre class="lang-js prettyprint-override"><code>responses = {
'Day': [1,2,3,4,5,6,7,8,9,10],
'Score': [9,10,9,8,8,9,10,9,8,7],
'Grade': ['A','O','A','B','B','A','O','A','B','C']
}
</code></pre>
<p>I want to loop through the object and only print the <code>Score</code> and <code>Grade</code> values, like this:</p>
<pre><code>9 'A'
10 'O'
9 'A'
. .
. .
. .
7 'C'
</code></pre>
<p>How do print this?</p>
| [
{
"answer_id": 74348555,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "get"
},
{
"answer_id": 74348773,
"author": "Klaus Gütter",
"author_id": 2142950,
"author_profile": "https://Stackoverflow.com/users/2142950",
"pm_score": 2,
"selected": false,
"text": "private void Set<T>(ref T field, T value)\n{\n if (!Equals(value, field))\n {\n field = value;\n IsDirty = true;\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13333430/"
] |
74,348,276 | <p>The Button receives the onClose method as a prop, which is used in the handleKeyDown.
The handleKeyDown itself is added as a dependency for the useEffect, therefore I wrapped it with a useCallback so in case I want to add a state change in the future in the useEffect, this won't cause an infinite rerender.
However, I have to add the onClose in the dependency of the useCallback wrapped around the handleKeyDown. As the onClose comes from props, this will change at every re-render, causing the handleKeyDown to be created at every re-render.
Of course, a solution would be to wrap the onClose in a useCallback before passing it to the CloseButton and use React.memo on the component. However, I want to handle this from inside the component instead of outsourcing it.
Could you please confirm if there is a way to solve this issue?
Thank you.</p>
<pre><code> const Button: React.FC<ButtonProps> = ({ onClose ...props }) => {
const onKeyDown = (event: KeyboardEvent) => {
if (event.keyCode === 65) {
onClose(event);
}
};
useEffect(() => {
window.addEventListener('keydown', onKeyDown);
return () => {
window.removeEventListener('keydown', onKeyDown);
};
}, [onKeyDown]); `
...
}
</code></pre>
| [
{
"answer_id": 74348555,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "get"
},
{
"answer_id": 74348773,
"author": "Klaus Gütter",
"author_id": 2142950,
"author_profile": "https://Stackoverflow.com/users/2142950",
"pm_score": 2,
"selected": false,
"text": "private void Set<T>(ref T field, T value)\n{\n if (!Equals(value, field))\n {\n field = value;\n IsDirty = true;\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11494348/"
] |
74,348,301 | <p>New Common Lisper here. I have seen <a href="https://github.com/zkat/cl-ffmpeg/blob/master/ffmpeg.lisp#L1" rel="noreferrer">packages being declared with the pound colon syntax</a>, as in <code>(defpackage #:foo)</code>, but I have also seen them <a href="https://github.com/fukamachi/quri/blob/master/src/quri.lisp#L1" rel="noreferrer">defined as plain keywords</a>, as <code>(defpackage :foo)</code>.</p>
<p>Which is considered "better"? What is the difference between these two? I read somewhere that pound colon simply means the keyword isn't interned. Is that true? If so, what are the advantages to defining a package with an uninterned keyword?</p>
| [
{
"answer_id": 74349240,
"author": "coredump",
"author_id": 124319,
"author_profile": "https://Stackoverflow.com/users/124319",
"pm_score": 3,
"selected": false,
"text": "1. (defpackage foo ...)\n2. (defpackage \"FOO\" ...)\n3. (defpackage :foo ...)\n4. (defpackage #:foo ...)\n"
},
{
"answer_id": 74360994,
"author": "ignis volens",
"author_id": 17026934,
"author_profile": "https://Stackoverflow.com/users/17026934",
"pm_score": 3,
"selected": true,
"text": "(symbol-name 'foo)"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/850326/"
] |
74,348,311 | <p>Please have a look at the reprex at the end of the post.
I need to read a column as a string, perform several manipulations and then save convert it to a numerical column.
The blanks ("") in the string column give me a headache because arrow does not convert them to numerical missing values NA.</p>
<p>Does anybody know how to achieve that?
Many thanks</p>
<pre class="lang-r prettyprint-override"><code>library(tidyverse)
library(arrow)
#> Some features are not enabled in this build of Arrow. Run `arrow_info()` for more information.
#>
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#>
#> timestamp
df <- tibble(x=rep(c("4000 -", "6000 -", "", "8000 - "), 10),
y=seq(1,10, length=40))
write_csv(df, "test_string.csv")
data <- open_dataset("test_string.csv",
format="csv",
skip=1,
schema=schema(x=string(), y=double()))
data2 <- data |>
mutate(x= sub(" -.*", "", x) ) |>
mutate(x2=as.numeric(x)) |>
collect() ## how to convert the blank to a numeric NA ?
#> Error in `collect()`:
#> ! Invalid: Failed to parse string: '' as a scalar of type double
#> Backtrace:
#> ▆
#> 1. ├─dplyr::collect(mutate(mutate(data, x = sub(" -.*", "", x)), x2 = as.numeric(x)))
#> 2. └─arrow:::collect.arrow_dplyr_query(mutate(mutate(data, x = sub(" -.*", "", x)), x2 = as.numeric(x)))
#> 3. └─base::tryCatch(...)
#> 4. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 5. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 6. └─value[[3L]](cond)
#> 7. └─arrow:::augment_io_error_msg(e, call, schema = x$.data$schema)
#> 8. └─rlang::abort(msg, call = call)
sessionInfo()
#> R version 4.2.2 (2022-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 11 (bullseye)
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so
#>
#> locale:
#> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
#> [5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
#> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] arrow_10.0.0 forcats_0.5.2 stringr_1.4.1 dplyr_1.0.10
#> [5] purrr_0.3.5 readr_2.1.3 tidyr_1.2.1 tibble_3.1.8
#> [9] ggplot2_3.4.0 tidyverse_1.3.2
#>
#> loaded via a namespace (and not attached):
#> [1] lubridate_1.9.0 assertthat_0.2.1 digest_0.6.30
#> [4] utf8_1.2.2 R6_2.5.1 cellranger_1.1.0
#> [7] backports_1.4.1 reprex_2.0.2 evaluate_0.17
#> [10] httr_1.4.4 highr_0.9 pillar_1.8.1
#> [13] rlang_1.0.6 googlesheets4_1.0.1 readxl_1.4.1
#> [16] R.utils_2.12.1 R.oo_1.25.0 rmarkdown_2.17
#> [19] styler_1.8.0 googledrive_2.0.0 bit_4.0.4
#> [22] munsell_0.5.0 broom_1.0.1 compiler_4.2.2
#> [25] modelr_0.1.9 xfun_0.34 pkgconfig_2.0.3
#> [28] htmltools_0.5.3 tidyselect_1.2.0 fansi_1.0.3
#> [31] crayon_1.5.2 tzdb_0.3.0 dbplyr_2.2.1
#> [34] withr_2.5.0 R.methodsS3_1.8.2 grid_4.2.2
#> [37] jsonlite_1.8.3 gtable_0.3.1 lifecycle_1.0.3
#> [40] DBI_1.1.3 magrittr_2.0.3 scales_1.2.1
#> [43] vroom_1.6.0 cli_3.4.1 stringi_1.7.8
#> [46] fs_1.5.2 xml2_1.3.3 ellipsis_0.3.2
#> [49] generics_0.1.3 vctrs_0.5.0 tools_4.2.2
#> [52] bit64_4.0.5 R.cache_0.16.0 glue_1.6.2
#> [55] hms_1.1.2 parallel_4.2.2 fastmap_1.1.0
#> [58] yaml_2.3.6 timechange_0.1.1 colorspace_2.0-3
#> [61] gargle_1.2.1 rvest_1.0.3 knitr_1.40
#> [64] haven_2.5.1
</code></pre>
<p><sup>Created on 2022-11-07 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
| [
{
"answer_id": 74348585,
"author": "Ruam Pimentel",
"author_id": 13015865,
"author_profile": "https://Stackoverflow.com/users/13015865",
"pm_score": 0,
"selected": false,
"text": "read_csv"
},
{
"answer_id": 74348677,
"author": "r2evans - GO NAVY BEAT ARMY",
"author_id": 3358272,
"author_profile": "https://Stackoverflow.com/users/3358272",
"pm_score": 2,
"selected": true,
"text": "ifelse"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2952838/"
] |
74,348,335 | <p>(New to Julia)</p>
<p>I'm trying to run this operation. Here's a minimal working example:</p>
<pre><code>df = DataFrame(A = 1:4)
Row A
Int64
1 1
2 2
3 3
4 4
</code></pre>
<p>Just a dataframe with four values, 1-4. I want to add a new column where each value is equal to the element, plus the previous elements. In other words, I want:</p>
<pre><code>Row A Row B
Int64 Int64
1 1 1
2 2 3
3 3 6
4 4 10
</code></pre>
<p>How can I do this?</p>
<p>I can write a function that calculates the desired number:</p>
<pre><code>function first(j)
val = 0
while j != 0
val += df.A[j]
j -= 1
end
return val
end
</code></pre>
<p>Here <code>j</code> is the index of the element. <a href="https://stackoverflow.com/questions/67261725/julia-how-to-create-a-new-column-in-dataframes-jl-by-adding-two-columns-using">This question</a> also gives how to add a column after it's been calculated. However, I can't figure out how to turn these values into a new column. I suspect there should be an easier way than calculating the numbers, forming a column with it and then adding it to the dataframe, as well.</p>
| [
{
"answer_id": 74348525,
"author": "Przemyslaw Szufel",
"author_id": 9957710,
"author_profile": "https://Stackoverflow.com/users/9957710",
"pm_score": 2,
"selected": false,
"text": "julia> df.B = cumsum(df.A);\n\njulia> df\n4×2 DataFrame\n Row │ A B\n │ Int64 Int64\n─────┼──────────────\n 1 │ 1 1\n 2 │ 2 3\n 3 │ 3 6\n 4 │ 4 10\n"
},
{
"answer_id": 74348759,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 2,
"selected": true,
"text": "using DataFrames\n\njulia> df.B = [first(i) for i in 1:4]\n4-element Vector{Int64}:\n 1\n 3\n 6\n 10\n\njulia> df\n4×2 DataFrame\n Row │ A B\n │ Int64 Int64\n─────┼──────────────\n 1 │ 1 1\n 2 │ 2 3\n 3 │ 3 6\n 4 │ 4 10\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3727079/"
] |
74,348,348 | <p>I have a table of users that are owned by various Owners. One person left and the list of users needs to be split up between two owners. How would you use SQL to randomly assign the users between two ownerIds . For example, a function that theoretically behaves like below</p>
<pre><code>UPDATE Users
set OwnerId = RAND(64,72)
Where OwnerId = 37
</code></pre>
<p>We are utilizing SQL Server 2012. Tried looking at a random function between two users but is unable to find anything specific. Thank you,</p>
| [
{
"answer_id": 74348535,
"author": "Stuck at 1337",
"author_id": 20091109,
"author_profile": "https://Stackoverflow.com/users/20091109",
"pm_score": 3,
"selected": true,
"text": "CHECKSUM(NEWID())"
},
{
"answer_id": 74348678,
"author": "Patrick Hurst",
"author_id": 18522514,
"author_profile": "https://Stackoverflow.com/users/18522514",
"pm_score": 1,
"selected": false,
"text": "DECLARE @users TABLE (UserID INT, OwnerID INT)\nINSERT INTO @users (UserID, OwnerID) VALUES\n(1, 100),(2, 100),(3, 100),(4, 100),(5, 100),(6, 100),(7, 100),(8, 100),(9, 100),(10, 100)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1441143/"
] |
74,348,360 | <p>I have a form that using ajax for update data client. In that form there is an input file. Everything is going fine except for updating the file. File is sent, it changed on storage too, but it gives error on validation and didn't change data on database.
Here is the code on the controller :</p>
<pre><code>public function update(Request $request, Client $client)
{
$validatedData = Validator::make($request->all(), [
'name' => 'required|max:255',
'logo'=> 'image|file|max:100',
'level' => 'required|max:1'
]);
$validatedData['user_id'] = auth()->user()->id;
if ($validatedData->fails()){
return response()->json($validatedData->errors());
} else {
if($request->file('logo')){
if($request->oldLogo){
Storage::delete($request->oldLogo);
}
$validatedData['logo'] = $request->file('logo')->store('logo-clients');
}
$validateFix = $validatedData->validate();
Client::where('id', $client->id)->update($validateFix);
return response()->json([
'success' => 'Success!'
]);
}
}
</code></pre>
<p>It gives error on line :</p>
<pre><code>$validatedData['logo'] = $request->file('logo')->store('logo-clients');
</code></pre>
<p>With message :
"Cannot use object of type Illuminate\Validation\Validator as array"</p>
<p>I use the same code that works on another case, the difference is the other not using ajax or I didn't use Validator::make on file input. I guess it's just wrong syntax but I don't really know where and what it is.</p>
| [
{
"answer_id": 74348477,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 1,
"selected": false,
"text": "Validator"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19625260/"
] |
74,348,362 | <p>I have two classes. One class(Person) has a vector collection composed of pointers of the other class(Student). At run time, the Person class will call a method which will store a pointer to a Student class in the vector. I have been trying to do this with smart pointers to avoid Memory leak issues that can arise but I am struggling to do so. How would I go about it?</p>
<p>My goal is for the Person class to have handles to objects that exist somewhere else in the code</p>
<pre><code>Class Student
{
public:
string studentName
Student(string name){
studentName = name;
}
}
Class Person
{
public:
vector <Student*> collection;
getStudent()
{
cout << "input student name";
collection.push_back(new Student(name));
}
}
</code></pre>
| [
{
"answer_id": 74348420,
"author": "Ayxan Haqverdili",
"author_id": 10147399,
"author_profile": "https://Stackoverflow.com/users/10147399",
"pm_score": 4,
"selected": true,
"text": "std::vector<Student> collection;\n\ncollection.emplace_back(name);\n"
},
{
"answer_id": 74348764,
"author": "John",
"author_id": 4380147,
"author_profile": "https://Stackoverflow.com/users/4380147",
"pm_score": 0,
"selected": false,
"text": "std::vector<std::shared_ptr<Student>> students; \n // an array of smart pointers\n\nstd::vector<Student*> students; // array of pointers\n\nstd::vector<Student> students; // array of objects stored by value.\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16879173/"
] |
74,348,387 | <p>I am using the Azure DevOps REST API to create a serviceendpoint/serviceconnection which works fine. I am using the following endpoint: <a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-6.0&tabs=HTTP" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-6.0&tabs=HTTP</a></p>
<p>However we would like to specify a group of approvers as you can do via the Azure DevOps portal like shown in the attached image</p>
<p><a href="https://i.stack.imgur.com/yev0d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yev0d.png" alt="enter image description here" /></a></p>
<p>Project Settings->Serviceconnections-> Approvals and check</p>
<p>Can this be done via the Azure DevOps REST API?</p>
<p>I reviewed the Microsoft docs with regard to Azure DevOps REST API.</p>
| [
{
"answer_id": 74348420,
"author": "Ayxan Haqverdili",
"author_id": 10147399,
"author_profile": "https://Stackoverflow.com/users/10147399",
"pm_score": 4,
"selected": true,
"text": "std::vector<Student> collection;\n\ncollection.emplace_back(name);\n"
},
{
"answer_id": 74348764,
"author": "John",
"author_id": 4380147,
"author_profile": "https://Stackoverflow.com/users/4380147",
"pm_score": 0,
"selected": false,
"text": "std::vector<std::shared_ptr<Student>> students; \n // an array of smart pointers\n\nstd::vector<Student*> students; // array of pointers\n\nstd::vector<Student> students; // array of objects stored by value.\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16896703/"
] |
74,348,393 | <p>I am new to data.table, but I need to speed up a dplyr code and so far I divided the processing time by 20, so needless to say I'd like to master that library. Understand by that introduction that processing time is the essence.</p>
<p>I have to modify rows using a loop because some columns are inter-connected. The use of a loop is not a matter addressed here: I will use a loop and there is no workaround, for other reasons not shown.
I already know what I'll use in my code to get the results needed because it's obviously the fastest, BUT I know there's a .SD way to do it, which would allow me a deeper understanding of that library, hence I seek your advices.</p>
<p>So, just to be clear: consider this post as an exercise that will help me understanding a subtlety in the use of .SD. I will present a simple table and a simple function (mean) but these are far from being the actual data (I use a self-made windowed mean). But if anyone can get the same results by using "mean" and .SD, then the problem is solved and I will learn something I don't know yet.
Sorry for the authoritative tone I use here, I just mean to be clear: I want to know what went wrong in my approach.</p>
<p>The very simplified table and goals are:</p>
<pre><code>temp <- data.table(a=c(0,10), b=c(15,25))
#initialize 1rst row
temp[1, `:=`(worksA=a, worksB=b)]
#in the (not shown) loop, starting row 2, worksA & worksB update a mean with fresh data:
temp[2, `:=`(worksA=mean(temp$a[1:2]), worksB=mean(temp$b[1:2]))]
</code></pre>
<p>Thus you get what I want (but note that I will use a self-made "mean" function with a rolling window, so actually using cummean will not do):</p>
<pre><code> a b worksA worksB
1: 0 15 0 15
2: 10 25 5 20
</code></pre>
<p>My 1rst failure was:</p>
<pre><code>temp[2, `:=`(tryA=mean(a[1:2]),tryB=mean(b[1:2]))]
</code></pre>
<p>creates NA's. I guessed that I could not use row selection to create a column by reference, so I dealt with it using "$" (working solution); still I suspected .SD would do the trick, so trial "number" 2:</p>
<pre><code>temp[2, c("tryA", "tryB"):=lapply(.SD[1:2], mean), .SDcols=c("a", "b")]
</code></pre>
<p>same. Funny fact, if you use na.rm:</p>
<pre><code>temp[2, `:=`(tryA=mean(a[1:2], na.rm=TRUE),tryB=mean(b[1:2], na.rm=TRUE))]
</code></pre>
<p>or:</p>
<pre><code>temp[2, c("tryA", "tryB"):=lapply(.SD[1:2], mean, na.rm=TRUE), .SDcols=c("a", "b")]
</code></pre>
<p>you get tryA & tryB row 2 updated with values a & b from the same row, as if it calculated the mean only with row 2 values.
Regarding to that matter, I try not to use the row selection on 1rst parameter (without "2" after 1rst braquet):</p>
<pre><code>temp[, c("tryA", "tryB"):=lapply(.SD[1:2], mean), .SDcols=c("a", "b")]
</code></pre>
<p>which of course gives:</p>
<pre><code> a b worksA worksB tryA tryB
1: 0 15 0 15 5 20
2: 10 25 5 20 5 20
</code></pre>
<p>i.e. the values I wanted printed on all rows. Better, but not what I want.</p>
<p>Microbenchmark tells me that my working solution is close to 20x faster than the lapply function anyway, so I give up on that.
But can anyone explain why my attempts (except for the last one, this one is crystal clear) were wrongly coded and how I could have edited 1 row at a time with a user-defined function and .SD ?</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74348420,
"author": "Ayxan Haqverdili",
"author_id": 10147399,
"author_profile": "https://Stackoverflow.com/users/10147399",
"pm_score": 4,
"selected": true,
"text": "std::vector<Student> collection;\n\ncollection.emplace_back(name);\n"
},
{
"answer_id": 74348764,
"author": "John",
"author_id": 4380147,
"author_profile": "https://Stackoverflow.com/users/4380147",
"pm_score": 0,
"selected": false,
"text": "std::vector<std::shared_ptr<Student>> students; \n // an array of smart pointers\n\nstd::vector<Student*> students; // array of pointers\n\nstd::vector<Student> students; // array of objects stored by value.\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19143801/"
] |
74,348,398 | <p>I have a simple makefile with a variable for the compiler flags, it also contains some targets that modify that variable and append some flags.</p>
<p>My point with it is to be able to run, for example:</p>
<pre><code>make debug perf
</code></pre>
<p>that would in turn add to the variable the flags required to build under that configuration. The problem is that if I run it, it does compile the executable with the debug info, and then tries to compile with the performance tools, and obviously does nothing. Can make only execute the compilation step after both targets run?</p>
<p>Makefile:</p>
<pre><code>CFLAGS = -std=c11 -Wall -pedantic -D_GNU_SOURCE
executable: gcc $(CFLAGS) main.c -o exe
debug: CFLAGS += -g
debug: executable
perf: CFLAGS += -D__PERF__
perf: executable
</code></pre>
<p>Make version 4.2.1</p>
| [
{
"answer_id": 74348717,
"author": "MadScientist",
"author_id": 939557,
"author_profile": "https://Stackoverflow.com/users/939557",
"pm_score": 0,
"selected": false,
"text": "executable"
},
{
"answer_id": 74349366,
"author": "Useless",
"author_id": 212858,
"author_profile": "https://Stackoverflow.com/users/212858",
"pm_score": 3,
"selected": true,
"text": "executable # default to release build\nexecutable.dbg # with -g\nexecutable.perf # with -D__PERF__\nexecutable.dbgperf # with both\n"
},
{
"answer_id": 74350259,
"author": "Klaus",
"author_id": 878532,
"author_profile": "https://Stackoverflow.com/users/878532",
"pm_score": 1,
"selected": false,
"text": "debug"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15999533/"
] |
74,348,472 | <p>I have this program which takes two lists as input from the user and then combines the two while alternating the items of each list. The thing is if one list is larger in length than the other i want it to print the rest of the items at the end of the result. I apologize for the bad writing of this i am new to the site</p>
<pre><code>input1= input("Enter numbers of the first list with spaces in between: ")
a=input1.split()
input2=input("Enter numbers of the second list with spaces in between: ")
b = input2.split()
c = []
for x, y in zip(a, b):
c += [x, y]
print(c)
</code></pre>
<p>i tried using extend or append but it is not working</p>
| [
{
"answer_id": 74348717,
"author": "MadScientist",
"author_id": 939557,
"author_profile": "https://Stackoverflow.com/users/939557",
"pm_score": 0,
"selected": false,
"text": "executable"
},
{
"answer_id": 74349366,
"author": "Useless",
"author_id": 212858,
"author_profile": "https://Stackoverflow.com/users/212858",
"pm_score": 3,
"selected": true,
"text": "executable # default to release build\nexecutable.dbg # with -g\nexecutable.perf # with -D__PERF__\nexecutable.dbgperf # with both\n"
},
{
"answer_id": 74350259,
"author": "Klaus",
"author_id": 878532,
"author_profile": "https://Stackoverflow.com/users/878532",
"pm_score": 1,
"selected": false,
"text": "debug"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20441255/"
] |
74,348,474 | <p>Using an image-generation AI I'm getting centered objects on a dark background. My goal is to convert all pixels outside this object to transparent. I figured a good-enough approach would be to flood-fill from all 4 corners using a fuzzy threshold, so that similar colors are erased too. But using e.g. the following recursive approach causes a StackOverflow:</p>
<pre><code>static void FillPixels(Color[][] pixels, int x, int y, Color originColor, Color fillColor, float threshold)
{
int width = pixels.Length;
int height = pixels[0].Length;
bool isInLimits = x >= 0 && x < width && y >= 0 && y < height;
if (isInLimits && ColorDistance(pixels[x][y], originColor) <= threshold)
{
pixels[x][y] = fillColor;
FillPixels(pixels, x - 1, y, originColor, fillColor, threshold);
FillPixels(pixels, x + 1, y, originColor, fillColor, threshold);
FillPixels(pixels, x, y - 1, originColor, fillColor, threshold);
FillPixels(pixels, x, y + 1, originColor, fillColor, threshold);
}
}
</code></pre>
<p>The images are up to 1024x1024 pixels in size. The specific background color is unknown -- I can instruct the image AI to make it black, but it will usually not be a precise rgb(0,0,0) -- so I'm initially color-picking dynamically on each corner. What can be done to flood fill with a threshold, or otherwise find a good mask for the object to erase its background? Thanks!</p>
| [
{
"answer_id": 74349684,
"author": "JonasH",
"author_id": 12342238,
"author_profile": "https://Stackoverflow.com/users/12342238",
"pm_score": 2,
"selected": true,
"text": "fillColor"
},
{
"answer_id": 74351246,
"author": "Philipp Lenssen",
"author_id": 34170,
"author_profile": "https://Stackoverflow.com/users/34170",
"pm_score": 0,
"selected": false,
"text": "using System.Collections.Generic;\nusing UnityEngine;\n\npublic static class ImageFloodFill\n{\n public static void FillFromPoint(Texture2D texture, Color color, Vector2Int point, float threshold = 0f)\n {\n var points = new Vector2Int[] { point };\n FillFromPoints(texture, color, points, threshold);\n }\n\n public static void FillFromCorners(Texture2D texture, Color color, float threshold = 0f)\n {\n var points = new Vector2Int[]\n {\n new Vector2Int(0, 0),\n new Vector2Int(texture.width - 1, 0),\n new Vector2Int(0, texture.height - 1),\n new Vector2Int(texture.width - 1, texture.height - 1)\n };\n FillFromPoints(texture, color, points, threshold);\n }\n\n public static void FillFromPoints(Texture2D texture, Color color, Vector2Int[] points, float threshold = 0f)\n {\n Color[,] pixelsGrid = GetPixelsGrid(texture);\n \n foreach (Vector2Int point in points)\n {\n FillPixels(pixelsGrid, point, color, threshold);\n }\n\n texture.SetPixels(GetPixelsLinearFromGrid(pixelsGrid));\n texture.Apply();\n }\n\n static void FillPixels(Color[,] pixels, Vector2Int startPoint, Color color, float threshold)\n {\n int width = pixels.GetLength(0);\n int height = pixels.GetLength(1);\n bool[,] pixelsHandled = new bool[width, height];\n Color originColor = pixels[startPoint.x, startPoint.y];\n var size = new RectInt(0, 0, width, height);\n\n var stack = new Stack<Vector2Int>();\n stack.Push(startPoint);\n\n while (stack.Count > 0)\n {\n Vector2Int point = stack.Pop();\n if (size.Contains(point) && !pixelsHandled[point.x, point.y])\n {\n pixelsHandled[point.x, point.y] = true;\n if (ColorDistance(pixels[point.x, point.y], originColor) <= threshold)\n {\n pixels[point.x, point.y] = color;\n\n stack.Push(new Vector2Int(point.x - 1, point.y));\n stack.Push(new Vector2Int(point.x + 1, point.y));\n stack.Push(new Vector2Int(point.x, point.y - 1));\n stack.Push(new Vector2Int(point.x, point.y + 1));\n }\n }\n }\n }\n\n static Color[,] GetPixelsGrid(Texture2D texture)\n {\n int width = texture.width;\n int height = texture.height;\n Color[] pixelsLinear = texture.GetPixels();\n Color[,] pixels = new Color[width, height];\n \n for (int x = 0; x < width; x++)\n {\n for (int y = 0; y < height; y++)\n {\n pixels[x, y] = pixelsLinear[y * height + x];\n }\n }\n\n return pixels;\n }\n\n static Color[] GetPixelsLinearFromGrid(Color[,] pixelsGrid)\n {\n int width = pixelsGrid.GetLength(0);\n int height = pixelsGrid.GetLength(1);\n Color[] pixelsLinear = new Color[width * height];\n\n for (int x = 0; x < width; x++)\n {\n for (int y = 0; y < height; y++)\n {\n pixelsLinear[y * height + x] = pixelsGrid[x, y];\n }\n }\n\n return pixelsLinear;\n }\n\n static float ColorDistance(Color color1, Color color2)\n {\n return Mathf.Sqrt(\n Mathf.Pow(color1.r - color2.r, 2) +\n Mathf.Pow(color1.g - color2.g, 2) +\n Mathf.Pow(color1.b - color2.b, 2)\n );\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34170/"
] |
74,348,509 | <p>I just to display No Reviews message for the user who don't have any reviews. Currently when the Review button is pressed, it shows the reviews for the user who have the reviews, but if any user who don't have any review, Review Button pressing show nothing.</p>
<p>Here is the code</p>
<pre><code><div class="checkbox-item mt-2" (click)="getReviews(item.offer_by.id)">
<button type="button" class="btn btn-outline-secondary" >Reviews</button>
</div>
<div class="çontainer" *ngFor="let items of reviews" >
<div class="row" *ngIf="items.tasker_id == item.offer_by.id">
<h6>{{items.name}}</h6>
<div class="emVaRl">
<div class="lnfldP">
<svg width="16" height="16" class="elJCm" viewBox="0 0 24 24" *ngFor='let in of
counter(items.review_rating) ;let i = index'>
<path d="M16.2 8.16l4.74.73a1.23 1.23 0 01.67 2.11l-3.46 3.28a1.23 1.23 0 00-.37 1.1l.77 4.68a1.24 1.24 0 01-1.82 1.29L12.5 19.1a1.28 1.28 0 00-1.16 0l-4.27 2.17A1.25 1.25 0 015.27 20l.85-4.68a1.19 1.19 0 00-.34-1.09l-3.41-3.4a1.23 1.23 0 01.71-2.1l4.75-.64a1.26 1.26 0 00.95-.67l2.16-4.24a1.25 1.25 0 012.24 0l2.09 4.28a1.22 1.22 0 00.93.7z">
</path>
</svg>
</div>
</div>
<p>({{items.review}})</p>
<hr>
</div>
</div>
</code></pre>
<p>.ts code</p>
<pre><code>review(data: any): boolean {
data['job_id'] = this.jobOffer.id;
data['tasker_id'] = this.jobOffer.assign_to_id;
this.ds.addReview(data).subscribe((resp: any) => {
if (resp.status == true) {
this.makeReview = false;
window.location.reload();
this.ts.success(resp.msg);
return true;
} else {
this.ts.error(resp.msg);
return false;
}
});
return true;
}
getReviews(data: any) {
this.ds.getReviews(data).subscribe((resp: any) => {
if (resp.status == true) {
this.reviews = [];
this.rating = '';
this.total_rating = '';
this.reviews = resp.data;
this.rating = resp.rating;
this.total_rating = resp.total_rating;
return true;
}
}, );
}
</code></pre>
| [
{
"answer_id": 74348632,
"author": "Eudz",
"author_id": 11549319,
"author_profile": "https://Stackoverflow.com/users/11549319",
"pm_score": 1,
"selected": false,
"text": "<ng-container *ngIf=\"reviews?.length > 0; else noReview\">\n <div class=\"container\" *ngFor=\"let items of reviews\">\n [...]\n </div>\n</ng-container>\n\n<ng-template #noReview>\n <p>Sorry there is no review yet...</p>\n</ng-template>\n"
},
{
"answer_id": 74348669,
"author": "Ruan Molinari",
"author_id": 8534073,
"author_profile": "https://Stackoverflow.com/users/8534073",
"pm_score": 0,
"selected": false,
"text": "<div class=\"container\" *ngIf=\"reviews.length > 0\">\n <ng-container *ngFor=\"let items of reviews\">\n ...\n </ng-container>\n</div>\n"
},
{
"answer_id": 74352099,
"author": "Team Thunder",
"author_id": 14796728,
"author_profile": "https://Stackoverflow.com/users/14796728",
"pm_score": 2,
"selected": true,
"text": "<div *ngIf=\"reviews\">\n <div *ngIf=\"reviews.length > 0\">\n <div class=\"çontainer\" *ngFor=\"let items of reviews\">\n <div class=\"row\" *ngIf=\"items.tasker_id == item.offer_by.id\">\n <h6>{{items.name}}</h6>\n <div class=\"emVaRl\">\n <div class=\"lnfldP\">\n <svg width=\"16\" height=\"16\" class=\"elJCm\" viewBox=\"0 0 24 24\"\n *ngFor='let in of counter(items.review_rating) ;let i =index'>\n <path\n d=\"M16.2 8.16l4.74.73a1.23 1.23 0 01.67 2.11l-3.46 3.28a1.23 1.23 0 00-.37 1.1l.77 4.68a1.24 1.24 0 01-1.82 1.29L12.5 19.1a1.28 1.28 0 00-1.16 0l-4.27 2.17A1.25 1.25 0 015.27 20l.85-4.68a1.19 1.19 0 00-.34-1.09l-3.41-3.4a1.23 1.23 0 01.71-2.1l4.75-.64a1.26 1.26 0 00.95-.67l2.16-4.24a1.25 1.25 0 012.24 0l2.09 4.28a1.22 1.22 0 00.93.7z\">\n </path>\n </svg>\n </div>\n </div>\n <p>({{items.review}})</p>\n <hr>\n </div>\n </div>\n </div>\n <div *ngIf=\"reviews.length == 0\">\n <h3 style=\"text-align: center;\">No Reviews</h3>\n </div>\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16903358/"
] |
74,348,538 | <p>trying to making scrollbar out of the layout as pic 2</p>
<p>is there any way with custom scrollbar or with any plugin?</p>
<pre><code>.notification-container>div{
scrollbar-color: #CFD8DC #FFFFFF;
scrollbar-width: thin;}
.notification-container>div::-webkit-scrollbar-track
{
background-color: #FFFFFF;
}
.notification-container>div::-webkit-scrollbar
{
width: 4px;
background-color: #FFFFFF;
}
.notification-container>div::-webkit-scrollbar-thumb
{
background-color: #CFD8DC;
}
</code></pre>
<p><a href="https://i.stack.imgur.com/dVv9j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dVv9j.png" alt="current" /></a></p>
<p><a href="https://i.stack.imgur.com/3Fa1T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Fa1T.png" alt="pic 2. i want like that " /></a></p>
| [
{
"answer_id": 74348621,
"author": "Jonas Grumann",
"author_id": 1254917,
"author_profile": "https://Stackoverflow.com/users/1254917",
"pm_score": 3,
"selected": true,
"text": ".container {\nwidth: 400px;\nheight: 400px;\nborder: 2px solid black;\n}\n\n.scroller {\nheight: 100%;\nwidth: calc(100% + 20px);\noverflow: auto;\n}\n\n.content {\n height: 800px;\n width: 400px;\n}\n::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 7px;\n}\n::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0, 0, 0, .5);\n -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n}"
},
{
"answer_id": 74349236,
"author": "idiltugba",
"author_id": 15160448,
"author_profile": "https://Stackoverflow.com/users/15160448",
"pm_score": 0,
"selected": false,
"text": ".notification-container{\nposition: relative;\nmargin-bottom: 25px;\noverflow-y: hidden;\npadding-right: 15px;\nmargin-right: -15px;}\n\n.notification-container>div{\nscrollbar-color: #CFD8DC #FFFFFF;\nscrollbar-width: thin;\npadding-right: 15px;\nmargin-right: -15px;}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15160448/"
] |
74,348,547 | <p>I want achieve the following result using the MudBlazor library.</p>
<ol>
<li>The (A) element i want to be a MudToolBar with secondary color pinned in the top of the Container</li>
<li>The (C) element i want it to be a MudToolBar again stuck in the bottom of the Container</li>
<li>The (B) element i want it to be a Scrollable container with whatever i put inside. When i scroll it, the elements A && C MUST not scroll along with the content.</li>
</ol>
<p>All of that is diplayed inside a Drawer's main content</p>
<pre><code><MudMainContent>
<MudPaper Class="d-flex flex-grow-1 gap-4" Elevation="0">
<MudLayout>
// Here i will write the whole component
</MudLayout>
</MudPaper>
</MudMainContent>
</code></pre>
<p>Up to now i have done the following</p>
<pre><code><div class="d-flex flex-grow-1 flex-row">
<MudPaper Elevation="25" Class="flex-grow-1">
<MudToolBar>
A-Element
</MudToolBar>
<div class="d-flex flex-column" style="max-height:100vh;min-height:100vh; overflow:scroll;">
// Here there will be a ForEach loop creating elements B-Element
</div>
<MudPaper Elevation="25" Class="d-flex flex-row px-2 mx-4" Style="">
C-Element
</MudPaper>
</MudPaper>
</div>
</code></pre>
<p>How can i do that??</p>
<p><a href="https://i.stack.imgur.com/qfvkk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qfvkk.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74348621,
"author": "Jonas Grumann",
"author_id": 1254917,
"author_profile": "https://Stackoverflow.com/users/1254917",
"pm_score": 3,
"selected": true,
"text": ".container {\nwidth: 400px;\nheight: 400px;\nborder: 2px solid black;\n}\n\n.scroller {\nheight: 100%;\nwidth: calc(100% + 20px);\noverflow: auto;\n}\n\n.content {\n height: 800px;\n width: 400px;\n}\n::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 7px;\n}\n::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0, 0, 0, .5);\n -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n}"
},
{
"answer_id": 74349236,
"author": "idiltugba",
"author_id": 15160448,
"author_profile": "https://Stackoverflow.com/users/15160448",
"pm_score": 0,
"selected": false,
"text": ".notification-container{\nposition: relative;\nmargin-bottom: 25px;\noverflow-y: hidden;\npadding-right: 15px;\nmargin-right: -15px;}\n\n.notification-container>div{\nscrollbar-color: #CFD8DC #FFFFFF;\nscrollbar-width: thin;\npadding-right: 15px;\nmargin-right: -15px;}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5371749/"
] |
74,348,572 | <p>within a data frame, I need to count and sum conescutive row values in column A into a new column, column B.</p>
<p>Starting with column A, the script would count the consecutive runs in 1s but when a 0 appears it prints the total count in column B, it then resets the count and continues through the remaining data.</p>
<p>Desired outcome:</p>
<pre><code>A | B
0 0
1 0
1 0
1 0
1 0
0 4
0 0
1 0
1 0
0 2
</code></pre>
<p>I've tried using .shift() along with various if statements but have been unsuccessful.</p>
| [
{
"answer_id": 74348621,
"author": "Jonas Grumann",
"author_id": 1254917,
"author_profile": "https://Stackoverflow.com/users/1254917",
"pm_score": 3,
"selected": true,
"text": ".container {\nwidth: 400px;\nheight: 400px;\nborder: 2px solid black;\n}\n\n.scroller {\nheight: 100%;\nwidth: calc(100% + 20px);\noverflow: auto;\n}\n\n.content {\n height: 800px;\n width: 400px;\n}\n::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 7px;\n}\n::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0, 0, 0, .5);\n -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n}"
},
{
"answer_id": 74349236,
"author": "idiltugba",
"author_id": 15160448,
"author_profile": "https://Stackoverflow.com/users/15160448",
"pm_score": 0,
"selected": false,
"text": ".notification-container{\nposition: relative;\nmargin-bottom: 25px;\noverflow-y: hidden;\npadding-right: 15px;\nmargin-right: -15px;}\n\n.notification-container>div{\nscrollbar-color: #CFD8DC #FFFFFF;\nscrollbar-width: thin;\npadding-right: 15px;\nmargin-right: -15px;}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19238175/"
] |
74,348,584 | <p>So I'm reading every line with this code:</p>
<pre class="lang-py prettyprint-override"><code>with open ('file.txt') as f:
for line in f:
</code></pre>
<p>but I want to save every line as a global accessible string. Any way I can do that?</p>
| [
{
"answer_id": 74349391,
"author": "Achxy_",
"author_id": 17242950,
"author_profile": "https://Stackoverflow.com/users/17242950",
"pm_score": 1,
"selected": false,
"text": "foo.txt"
},
{
"answer_id": 74351039,
"author": "BokiX",
"author_id": 16843389,
"author_profile": "https://Stackoverflow.com/users/16843389",
"pm_score": 0,
"selected": false,
"text": "with open(\"your_file.txt\", \"r\") as file\n content = file.read()\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440977/"
] |
74,348,598 | <p>I already have a Macro in Excel that pulls through data from specific tables, rows and columns in a specified Word doc and returns it to cells in my Excel s/sheet. I need to make 2 alterations to the code but my knowledge is not advanced enough.</p>
<ol>
<li><p>I need to run this code on multiple Word docs in a specified folder, whether it is .doc or a .docx</p>
</li>
<li><p>I need to establish why on some Word docs, the code fails to pull through the data from the Word doc and I get RUN TIME ERROR CODE '4605' 'The method or property is not available because no text is selected'. I tried putting, 'on error resume next', at the start of the module so it keeps on running to the end, in the hope that some text would get pulled through, but still none of the cells in my Excel s/sheet get populated.</p>
</li>
</ol>
<pre><code>Sub ImportFromWord()
On Error Resume Next
'Activate Word Object Library
Dim WordDoc As Word.Document
Set WordApp = CreateObject("word.application") ' Open Word session
WordApp.Visible = False 'keep word invisible
Set WordDoc = WordApp.Documents.Open("C:\Users\brendan.ramsey\OneDrive - Ofcom\Objectives\Brendan's Objectives 2022-23\Licence calls\test 2.docx") ' open Word file
'copy third row of first Word table
WordDoc.Tables(1).Cell(Row:=1, Column:=3).Range.Copy
'paste in Excel
Range("A3").PasteSpecial xlPasteValues
WordDoc.Tables(4).Cell(Row:=3, Column:=6).Range.Copy
Range("B3").PasteSpecial xlPasteValues
WordDoc.Tables(4).Cell(Row:=3, Column:=3).Range.Copy
Range("C3").PasteSpecial xlPasteValues
WordDoc.Tables(5).Cell(Row:=2, Column:=5).Range.Copy
Range("D3").PasteSpecial xlPasteValues
WordDoc.Tables(5).Cell(Row:=2, Column:=7).Range.Copy
Range("E3").PasteSpecial xlPasteValues
WordDoc.Tables(5).Cell(Row:=2, Column:=2).Range.Copy
Range("F3").PasteSpecial xlPasteValues
WordDoc.Close 'close Word doc
WordApp.Quit ' close Word
End Sub
</code></pre>
| [
{
"answer_id": 74349391,
"author": "Achxy_",
"author_id": 17242950,
"author_profile": "https://Stackoverflow.com/users/17242950",
"pm_score": 1,
"selected": false,
"text": "foo.txt"
},
{
"answer_id": 74351039,
"author": "BokiX",
"author_id": 16843389,
"author_profile": "https://Stackoverflow.com/users/16843389",
"pm_score": 0,
"selected": false,
"text": "with open(\"your_file.txt\", \"r\") as file\n content = file.read()\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19562745/"
] |
74,348,619 | <p>My team is currently facing an issue distributing a mass of reports from OBIEE. I was just wondering what tools any oracle developers have used to distribute OBIEE reports to a LOT of users at once. Also, the users are not permissioned to OBIEE. Therefore, the reports have to be exported then distributed.</p>
<p>I'm very new to Oracle (about two months experience) so any information would be helpful.</p>
| [
{
"answer_id": 74349391,
"author": "Achxy_",
"author_id": 17242950,
"author_profile": "https://Stackoverflow.com/users/17242950",
"pm_score": 1,
"selected": false,
"text": "foo.txt"
},
{
"answer_id": 74351039,
"author": "BokiX",
"author_id": 16843389,
"author_profile": "https://Stackoverflow.com/users/16843389",
"pm_score": 0,
"selected": false,
"text": "with open(\"your_file.txt\", \"r\") as file\n content = file.read()\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20441409/"
] |
74,348,634 | <p>I want help in creating a Input box with only a submit button which redirect user to another site.</p>
<p>when user typed a url in the input box and clicked submit button</p>
| [
{
"answer_id": 74349391,
"author": "Achxy_",
"author_id": 17242950,
"author_profile": "https://Stackoverflow.com/users/17242950",
"pm_score": 1,
"selected": false,
"text": "foo.txt"
},
{
"answer_id": 74351039,
"author": "BokiX",
"author_id": 16843389,
"author_profile": "https://Stackoverflow.com/users/16843389",
"pm_score": 0,
"selected": false,
"text": "with open(\"your_file.txt\", \"r\") as file\n content = file.read()\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74348634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20441389/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.