instruction
stringlengths 0
30k
⌀ |
---|
Unable to import Snowflake Connector python library after install in Azure Devops YAML Pipeline |
|python-3.x|azure-devops|azure-pipelines|snowflake-cloud-data-platform|azure-pipelines-yaml| |
null |
We have to compute percentiles for 100 columns in an R dataframe. In the example below, the column names that need percentiles are `pctile_columns`. The criteria for receiving percentiles is (1) the column is not NA, and (1) the `min_pg` column is >= 12. We are struggling to obtain the correct set of percentiles:
**reproducible example**
```
# 1 group, 1 stat for example purposes
pctile_columns <- c('stat1')
temp_df <- rbind(
data.frame(group_var = 1, min_pg = 11, stat1 = 0.35),
data.frame(group_var = 1, min_pg = 15, stat1 = 0.32),
data.frame(group_var = 1, min_pg = 19, stat1 = 0.27),
data.frame(group_var = 1, min_pg = 7, stat1 = NA),
data.frame(group_var = 1, min_pg = 5, stat1 = NA),
data.frame(group_var = 1, min_pg = 34, stat1 = 0.42),
data.frame(group_var = 1, min_pg = 32, stat1 = 0.45),
data.frame(group_var = 1, min_pg = 27, stat1 = 0.47),
data.frame(group_var = 1, min_pg = 24, stat1 = 0.33),
data.frame(group_var = 1, min_pg = 18, stat1 = NA),
data.frame(group_var = 1, min_pg = 13, stat1 = 0.24),
data.frame(group_var = 1, min_pg = 10, stat1 = 0.39)
)
temp_output <- temp_df %>%
dplyr::group_by(group_var) %>%
dplyr::mutate(dplyr::across(.cols = all_of(pctile_columns),
.fns = ~ if_else(is.na(.) | min_pg < 12,
as.numeric(NA),
rank(., ties.method = "max")),
.names = "{.col}__rank")) %>%
dplyr::mutate(dplyr::across(.cols = all_of(pctile_columns),
.fns = ~ if_else(is.na(.) | min_pg < 12,
as.numeric(NA),
round((rank(., ties.method = "max") - 1) / (n() - 1) * 100, 0)),
.names = "{.col}__pctile"))
```
**output**
```
# Groups: group_var [1]
group_var min_pg stat1 stat1__rank stat1__pctile
<dbl> <dbl> <dbl> <dbl> <dbl>
1 1 11 0.35 NA NA
2 1 15 0.32 3 18
3 1 19 0.27 2 9
4 1 7 NA NA NA
5 1 5 NA NA NA
6 1 34 0.42 7 55
7 1 32 0.45 8 64
8 1 27 0.47 9 73
9 1 24 0.33 4 27
10 1 18 NA NA NA
11 1 13 0.24 1 0
12 1 10 0.39 NA NA
```
The problem with this output is that the ranks go from 1 - 9, whereas they should go from 1 - 7. Even though the stat1 values with `min_pg < 12` are correctly being assigned an `NA` value, these stat1 values are still being factored into the `rank()` equation when computing the ranks for all of the other rows. The correct set of ranks should be 1 - 7 in this instance, as there are 7 metrics that meet the criteria for `stat1` to receive a rank/percentile.
How can we revise our code to compute ranks/percentiles properly per our criteria? |
from pyspark.sql.functions import lit,sum,max
from pyspark.sql.window import Window
window_spec = Window.orderBy("timestamp").rowsBetween(-4, 0)
dataframe_2 = dataframe_2.withColumn("counter_1", lit(0)).withColumn("max_1", lit(0))
union_df = dataframe_1.union(dataframe_2)
# Calculate the running sum and max over the window
result_df = union_df \
.withColumn("counter_1", sum("target").over(window_spec)) \
.withColumn("max_1", max("target").over(window_spec))
results.show(truncate=False)
+----------------------------+------+---------+-----+
|timestamp |target|counter_1|max_1|
+----------------------------+------+---------+-----+
|2023-08-18T00:00:00.000+0000|0 |0 |0 |
|2023-08-18T00:10:00.000+0000|1 |1 |1 |
|2023-08-18T00:20:00.000+0000|1 |2 |1 |
|2023-08-18T00:30:00.000+0000|0 |2 |1 |
|2023-08-18T00:40:00.000+0000|1 |3 |1 |
|2023-08-18T00:50:00.000+0000|0 |3 |1 |
|2023-08-18T01:00:00.000+0000|1 |3 |1 |
|2023-08-18T01:10:00.000+0000|1 |3 |1 |
|2023-08-18T01:20:00.000+0000|1 |4 |1 |
|2023-08-18T01:30:00.000+0000|1 |4 |1 |
|2023-08-18T01:40:00.000+0000|0 |4 |1 |
|2023-08-18T01:50:00.000+0000|1 |4 |1 |
|2023-08-18T02:00:00.000+0000|0 |3 |1 |
+----------------------------+------+---------+-----+
|
I'm dealing with an older application that we recently updated from Java 8 to Java 11. In one part of the application, I have several XML files (XSDs) that are converted into Java classes using the Jaxb2 Maven plugin. It worked fine with Java 8, but after switching to Java 11, I encountered an error: 'code too large'.
I know that in Java, a method or function can't exceed 65536 bytes in size. But it's puzzling why it worked with Java 8 and not with Java 11. I've spent two weeks on this issue, and I still don't understand why it worked before.
The problem is, I can't split the code into smaller parts because of some limitations. I tried using another plugin called Castor, hoping it would solve the issue, but it also ran into the same problem.
I experimented with different versions of both plugins, but none of them worked with Java 11. The rest of the application runs smoothly with Java 11. It's only when I change the Java version in the Maven plugin that I encounter this compilation error.
Please help to get me out of this issue as I already have spent time alot.
Thanks in advance.
```
<configuration>
<release>8</release> <!-- working fine -->
<release>11</release> <!-- problem -->
<!--<compilerArgs><arg>-J-Xmx512m</arg></compilerArgs>-->
</configuration>
```
This is the code for plugin Jaxb2 (Dependencies I added and plugin)
# **pom.xml**
```
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
<scope>runtime</scope>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<!--<compilerArgs><arg>-J-Xmx512m</arg></compilerArgs>-->
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The schema directory or xsd files. -->
<!--<arguments>
<arg>-XautoNameResolution</arg>
</arguments>-->
<sources>
<source>src/main/resources/xsds</source>
</sources>
<xjbSources>
<xjbSource>src/main/resources/xsds/bindings.xjb</xjbSource>
</xjbSources>
<!-- The package in which the source files will be generated. -->
<packageName>com.example.java</packageName>
<!-- The working directory to create the generated java source files. -->
<outputDirectory>${project.build.directory}/generated-sources/jaxb/</outputDirectory>
</configuration>
</plugin>
```
**bindings.jxb**
```
<?xml version="1.0"?>
<jaxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jaxb:extensionBindingPrefixes="xjc"
version="3.0">
<jaxb:bindings schemaLocation="../xml/afd/code.xsd" node="/xs:schema">
<jaxb:globalBindings typesafeEnumMemberName="generateName" typesafeEnumMaxMembers="4300">
<jaxb:serializable uid="1"/>
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
```
This is the configuration, I did for **Castor** plugin
```
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>castor-maven-plugin</artifactId>
<version>2.1</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!--<version>3.8.1</version>-->
<configuration>
<release>11</release>
<!--<compilerArgs><arg>-J-Xmx512m</arg></compilerArgs>-->
</configuration>
</plugin>
<!-- JAXB xjc plugin that invokes the xjc compiler to compile XML schema into Java classes.-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>castor-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>generate-main-java-classes</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/xsds</schemaDirectory>
<!--<bindingfile>src/main/resources/xsds/binding.xml</bindingfile>-->
<packaging>com.example</packaging>
<generateImportedSchemas>true</generateImportedSchemas>
<descriptors>false</descriptors>
<generateMappings>true</generateMappings>
<dest>${project.build.directory}/generated-sources/jaxb/</dest>
</configuration>
</execution>
</executions>
</plugin>
```
|
'Code too large' XML to Java using Jaxb2 and Castor maven plugins |
|java|jaxb|maven-jaxb2-plugin|castor| |
null |
You can let htmx send csrf token value with every request by attaching it to the body element with [hx-headers][1] attribute:
<body hx-headers='{"X-CSRF-TOKEN": "{{ csrf_token() }}"}'>
This approach is explained [here in more details][2] (django-htmx docs). It should work same way with laravel, by using the above snippet.
[1]: https://htmx.org/attributes/hx-headers/
[2]: https://django-htmx.readthedocs.io/en/latest/tips.html#make-htmx-pass-the-csrf-token |
**You try this code and it will be solved**
<a href="{% url 'download_wav' filename='your_wav_filename.wav' %}">Download .wav File</a>
|
**I have 2 Questions**:
[![enter image description here][1]][1]
For EMI we have:
Excel Formula: `=PMT(rate, number_of_periods, present_value)`
Maths Fromula: `= P*r*(1+r)^n/((1+r)^n-1)`
**QUESTION 1:** Keeping the principal amount & interest tenure as same, **I want to calculate the interest rate if we change the EMI to 9000.**
For Interest Rate:
Excel Formula: `?`
Maths Fromula: `?`
(Till now, I have used the GOAL SEEK of What If Analysis to achieve the Interest Rate)
**QUESTION 2:**
Recently, I learned about EMI calucations so wanted to tally it with real applications.
So I came across the Apple's website where there are multiple EMI options, so I wanted to get the numbers by myself.The iphone costs **₹1,99,900** and they are giving **₹6000** discount in all credit card payments (whether EMI or one-off both) so in all cases of credit card payments there is at least ₹6000 savings so principal amount gets **1,93,900**.
**For 9 Months:**
[![enter image description here][2]][2]
**EMI:** ₹22,913
**Total Amount:** ₹2,06,219
**Savings**: ₹6000
**Our calculations EXACTLY match it:**
[![enter image description here][3]][3]
**For 6 Months (NO COST EMI):**
[![enter image description here][4]][4]
**EMI:** ₹32,317
**Total Amount:** 1,93,899
**Savings**: ₹6000 + ₹8209
**Our calculations EXACTLY match it:**
[![enter image description here][5]][5]
But what doesn't match is the savings they have mentioned, obviously considering the total EMI interest as savings we get ₹8,571 but according to them it is ₹8209. **Can you please explain how did they come up with ₹8209 ?** (using goal seek for ₹8209 interest the principal is ₹1,85,691)
Google Sheet Link: https://docs.google.com/spreadsheets/d/1bQFYfOE7O16lp-sW2DWCibwedszkshuTmOhX2BAqj5Q/edit?usp=sharing
[1]: https://i.stack.imgur.com/7RE5a.jpg
[2]: https://i.stack.imgur.com/ohsts.jpg
[3]: https://i.stack.imgur.com/Qijyo.jpg
[4]: https://i.stack.imgur.com/rB6is.jpg
[5]: https://i.stack.imgur.com/qEPl0.jpg |
I have two xaml files:
- one (present in solution1) I can see in the design view.
- the other one (present in solution2) I can't see in the design view.
There's nothing wrong with the second xaml: I can see it when I run the application. But I would like to see it in design view (if ever I need to perform a modification, I'll see what I'm doing).
In order to learn, I decided to open the one in solution1 in design view and see in the "Output" window how everything should behave, and based on that, I'd learn what to do.
That failed, because, when opening a xaml file in design view, nothing is added to Visual Studio's "Output" window (nothing in the "Debug" chapter, nothing either in "Build", "Build order" or the other chapters).
For your information, my xaml-related settings look as follows:
[![enter image description here][1]][1]
Where can I see what happens in the design view of Visual Studio (2022) while opening a xaml file?
[1]: https://i.stack.imgur.com/i1hmL.png |
In the following program:
```
#include <stdio.h>
int main() {
int c;
c = getchar();
putchar(c);
}
```
Even if If write many characters in the input and press `enter`, it only prints the first character.
However in the following program:
```
#include <stdio.h>
int main() {
int c;
c = getchar();
while (c != EOF) {
putchar(c);
c = getchar();
}
}
```
When I write multiple characters, it prints all of them.
My question is the following: Why, when I press enter, doesn't it print only the first character in my input as in the first program and how come the condition in while is evaluated before `putchar(c)` is called?
|
I had problems with **auth.global.ts** been render on server side.
So I put a **client side validation** and a trick (**{ external: true }**) on navigateTo redirect (because redirect to page with diferent layout cause style bugs):
``` lang-js
export default defineNuxtRouteMiddleware((to, from) => {
if (process.client) {
const user = UtilsUser.user //Get from localStorage.getItem('user')
if (!user && to.meta.layout === 'profile') {
//Prevent Loop:
if (to.path !== '/auth/login') {
return navigateTo('/auth/login', { external: true })
}
}
}
}) |
Classic mul
[1 qbyte * 1 qbyte] it's 1 ops;
[2 qbyte * 2 qbyte] it's 4 ops;
[4 qbyte * 4 qbyte] it's 20 ops;
Imul
imul probably 1 ops
mul probably 11 ops
then use long arithmetic, 2nd is optimal, else 1st variant; |
I want to do a post api call, but it never reaches the do catch block because guard let exits me out of the function. I've debugged it and I have values inside the postCompleteCall, but stil returns me out of the function. I will pass the code below:
```
@MainActor
func completeChangeEmail(id: String, email: String) async throws {
networkMonitor.checkInternetConnection()
guard let completePost = postCompleteCall(email: email) else { return }
isLoading = true
do {
isLoading = false
changeEmailModel.getChangeEmailData = try await changeEmailUseCase.completeChangeEmail(id: id, completeChangeEmailPost: completePost)
presentingUnknownError = false
} catch {
presentingUnknownError = true
isLoading = false
RCHLog.log("Failed to get change email")
}
}
private func postCompleteCall(email: String) -> CompleteChangeEmailPost? {
changeEmailModel.completeChangeEmailPost?.variables.form.value.email = email
return changeEmailModel.completeChangeEmailPost
}
``` |
In R, compute ranks/percentiles for many columns in dataframe, while filtering each column for criteria |
|r|dataframe|ranking| |
As **smr** already commented, you can use `Layout.preferredWidth` in order to achieve a static width for the button. The shared documentation also mentions that `implicitWidth` can also be used which I commented out in the snippet below.
> If the preferred width is -1 it will be ignored, and the layout will
> use implicitWidth instead.
```
Rectangle {
id: rectangle
height: 50
anchors.left: parent.left
anchors.right: parent.right
color: "#555"
RowLayout {
id: chatInputLayout
anchors.fill: parent
anchors.margins: 5
spacing: 5
TextField {
id: chatInputField
placeholderText: qsTr("Write something ...")
Layout.fillWidth: true
}
Button {
id: chatSendButton
width: 200
//implicitWidth: chatSendButton.width
Layout.preferredWidth: chatSendButton.width
text: qsTr("Send")
Connections {
function onClicked() {
console.log("Send.onClicked", chatInputField.text)
}
}
}
}
}
``` |
I've got a wordpress backup to restore a website in a new hosting. I have zero experience in wordpress and I only know is a php application that uses myqsl database. My questions are.. can I restore the database if it has different database data (database name, user and password) than the original one? or do I need to delete the default database created in the wordpress installation? If the website used themes or plugins or something else.. do they need to be installed before the restore process, in order to the website to work? (I unzipped the backup file and noticed an 'Avada' folder in the themes zip, and many subfolders in the plugins zip.. one of them the updraftplus that I guessed was used to create the backup file)
Thanks |
wordpress restore in new hosting |
|wordpress|restore| |
cucumber.api.cli.Main run
WARNING: You are using deprecated Main
class. Please use
io.cucumber.core.cli.Main
0 Scenarios
0 Steps
0m0.014s
I'm not getting snippets for my steps.
Exception in thread "main"
io.cucumber.core.exception.CompositeCucumbe
rException: There were 2 exceptions. The details are in the stacktrace below.
at
io.cucumber.core.runtime.RethrowingThrowabl
eCollector.getThrowable(RethrowingThrowableCollector.java:57)
and my login feature file
Feature: Login
Scenario: Successful Login with valid credentials
Given User Launch Chrome browser
When User Opens URL "http://admin-demo.nopcommerce.com/login"
And User enters email as "admin@yourstore.com" and Password as "admin"
And Click on Login
Then Page Title Should be "Dashboard / nopcommerce administration"
When User Click on Log out Link
Then Page Title should be "Your store. Login"
And Close browser
I have added all necessary dependencies in pom.xml
like
cucumber-core
cucumber-html
cobertura
cucumber-java
cucumber-junit
cucumber-jvm-deps
cucumber-reporting
hamcrest-core
gherkin
selenium-Java
Junit |
Math's & Excel formula to calculate the interest rate from the EMI and principal amount? |
|excel|math|excel-formula|google-sheets-formula| |
Pretty much what it says on the tin.
I have a JS script that isn't staying within the div element it is designated to on my page, it "sits" in the footer section instead.
[Page design with the JS script result "sitting" in the footer](https://i.stack.imgur.com/0Dpil.png)
```
<header>
<div>icon</div>
<div>header</div>
<div style="padding:5px;">
script is supposed to go here
<script src="JS/SpinningBaton.js"></script>
</div>
</header>
```
That's how I currently have the HTML block written in an attempt to resolve the issue. Unfortunately, nothing has changed. What am I doing to wrong?
For context, the div element is 165px in size while the JS script is 155px, so it should fit without overflow.
I have tried putting the script within different elements within the div and resizing the div element. But the script defiantly stays in the footer area regardless of what I have tried so far.
SpinningBaton code, as requested - I'd include the code that makes the script actually work, but it exceeds the limit:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
angleMode = "radians";
var angle = 0;
var aVelocity = 0;
var aAcceleration = 0.0001;
// var TargetSpeed = ((Math.random() * 2)-1)/2;
function RandNum(){
a = Math.floor(Math.random() * 256);
return a;
}
Num1 = RandNum();
Num2 = RandNum();
Num3 = RandNum();
Num4 = RandNum();
Num5 = RandNum();
Num6 = RandNum();
Num7 = RandNum();
Num8 = RandNum();
Num9 = RandNum();
Num10 = RandNum();
Num11 = RandNum();
Num12 = RandNum();
draw = function() {
createCanvas(155,155);
resetMatrix();
translate(width/2, height/2);
rotate(angle);
stroke(0, 0, 0,0);
fill(Num1, Num2, Num3);
ellipse(60, 0, 32, 32);
fill(Num4, Num5, Num6);
ellipse(-60, 0, 32, 32);
fill(Num7, Num8, Num9);
ellipse(0, 60, 32, 32);
fill(Num10, Num11, Num12);
ellipse(-0, -60, 32, 32);
if (aVelocity < TargetSpeed)
{
aVelocity += aAcceleration;
}
else
{
aVelocity -= aAcceleration;
}
angle += aVelocity;
};
<!-- end snippet -->
|
You asked:
>i dont understand it so if it could be provided with proper explanation
## Arrays
As shown in [The Java Tutorials][1] by Oracle Corp, a `for` loop has three parts:
```java
for ( initialization ; termination ; increment )
{
statement(s)
}
```
Take for example an array `{ "alpha" , "beta" , "gamma" }`:
```java
for ( int index = 0 ; index < myArray.length ; index ++ )
{
System.out.println( "Index: " + index + ", value: " + myArray[ index ] );
}
```
See this [code run at Ideone.com][2].
```none
------| Ascending |----------
Index: 0, Value: alpha
Index: 1, Value: beta
Index: 2, Value: gamma
```
To reverse the direction:
- The first part, *initialization*, can start at the *last* index of the array rather than at the *first* index. Ex: `int index = ( myArray.length - 1 )`. (Parentheses optional there.)
- The second part, *termination*, can test for going past the first index, into negative numbers: `index > -1` (or `index >= 0`).
- The third part, *increment*, can go downwards (negative) rather than upwards (positive):
```java
for ( int index = ( myArray.length - 1 ) ; index > -1 ; index -- )
{
System.out.println( "Index: " + index + ", value: " + myArray[ index ] );
}
```
See this [code run at Ideone.com][2].
```none
------| Descending |----------
Index: 2, value: gamma
Index: 1, value: beta
Index: 0, value: alpha
```
## Collections
The code above certainly works. And, on the upside, arrays tend to use less memory while executing faster. But, on the downside, working with arrays is limiting, cumbersome, and somewhat error-prone.
More commonly in Java, we use the [*Java Collections Framework*][3].
In collections, the appropriate replacement for an array is a [`SequencedCollection`][4] such as [`ArrayList`][5] (a [`List`][6]) or [`TreeSet`][7] (a [`NavigableSet`][8]).
We can easily make an [unmodifiable][9] `List` of our array by calling [`List.of`][10]. (The concrete actually used under-the-covers is unspecified.) The `List.of` method performs a *shallow copy*. This means the content of the elements is *not* duplicated — the same three `String` object are in both the original array *and* in the new `List`.
Every `List` is also a `SequencedCollection`. This means we can call the [`reversed`][11] method. This method is quite efficient in that it does *not* really create another collection. Instead the `reversed` method creates a *view* upon the original collection that presents its elements in a reversed encounter order.
```java
String[] myArray = { "alpha" , "beta" , "gamma" };
SequencedCollection < String > strings = List.of( myArray );
System.out.println( "strings.toString() = " + strings );
System.out.println( "strings.reversed().toString() = " + strings.reversed().toString() );
```
When run:
```none
strings.toString() = [alpha, beta, gamma]
strings.reversed().toString() = [gamma, beta, alpha]
```
[1]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html
[2]: https://ideone.com/EsDnUk
[3]: https://en.wikipedia.org/wiki/Java_collections_framework
[4]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/SequencedCollection.html
[5]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/ArrayList.html
[6]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/List.html
[7]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/TreeSet.html
[8]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/NavigableSet.html
[9]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/List.html#unmodifiable
[10]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/List.html#of(java.lang.Object[])
[11]: https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/util/SequencedCollection.html#reversed() |
I had a problem, then I authenticated my account using Microsoft. I want to upload files. But I can not do that.
Here is my source code (my English sorry is not good, please help me if you have a solution); I have tried all options, but had no success.
Thank you.
```
var folderName = "YourFolderName";
var fileName = file.FileName;
var url = $"https://api.onedrive.com/v1.0/drive/me/root:/{folderName}/{fileName}:/upload.createSession";
var request = WebRequest.Create(url);
request.Method = "POST";
request.Headers.Add("Authorization", "Bearer " + accessToken);
request.ContentType = "application/octet-stream";
```
|
How to upload file to Onedrive using ASP.NET MVC? |
Guard let returns me out of the function |
|swift|swiftui| |
Alternative, as a run-length encoding problem:
```r
df |>
mutate(grp = consecutive_id(Class)) |>
mutate(.by = grp, Class = c(Class[1], rep("", n() - 1))) |>
select(-grp)
# # A tibble: 10 × 3
# ID Class Score
# <dbl> <chr> <dbl>
# 1 1 "A" 45
# 2 2 "" 67
# 3 3 "" 87
# 4 4 "C" 33
# 5 5 "" 25
# 6 6 "A" NA
# 7 7 "B" 67
# 8 8 "" 88
# 9 9 "D" 21
# 10 10 "" NA
```
The use of `.by=` requires `dplyr_1.1.0` or newer; if you have an older version, change from `mutate(.by=c(..), stuff)` to `group_by(..) |> mutate(stuff) |> ungroup()`. |
null |
I have implemented notification system in SpringBoot using WebFlux, below is my sse endpoint
@GetMapping(path = "/backoffice/sse/notifications")
public Flux<ServerSentEvent<NotificationData>> sse()
{
return this.sseNotificationService.subscribe();
}
And here is the implementation of SSENotificationService
@Component
public class SSENotificationService
{
private static final Logger LOGGER = LoggerFactory.getLogger(SSENotificationService.class);
private final Flux<ServerSentEvent<NotificationData>> notificationFlux;
private final NotificationRepository notificationRepository;
private final UserService userService;
public SSENotificationService(
NotificationRepository notificationRepository,
UserService userService
)
{
this.notificationRepository = notificationRepository;
this.userService = userService;
notificationFlux = Flux.push(this::generateNotifications);
}
@Nonnull
private Flux<ServerSentEvent<NotificationData>> keepAlive(
@Nonnull Duration duration,
@Nonnull Flux<ServerSentEvent<NotificationData>> data,
@Nonnull String id
)
{
Flux<ServerSentEvent<NotificationData>> heartBeat = Flux.interval(duration)
.map(_ -> ServerSentEvent.<NotificationData>builder()
.event("comment")
.comment(STR."keep alive for: \{id}")
.build())
.doFinally(_ -> LOGGER.info("Heartbeat closed for id: {}", id));
return Flux.merge(heartBeat, data);
}
@Nonnull
public Flux<ServerSentEvent<NotificationData>> subscribe()
{
var userIdOrSystem = userService.userIdOrSystem();
return keepAlive(Duration.ofSeconds(7), notificationFlux, userIdOrSystem);
}
private void generateNotifications(@Nonnull FluxSink<ServerSentEvent<NotificationData>> sink)
{
var userIdOrSystem = userService.userIdOrSystem();
Flux.interval(Duration.ofSeconds(5))
.flatMap(_ -> {
var pendingNotifications = this.notificationRepository.pendingNotifications(userIdOrSystem);
return Flux.fromIterable(pendingNotifications)
.map(notificationData -> {
this.notificationRepository.updateNotificationStatus(notificationData.id());
return ServerSentEvent.<NotificationData>builder()
.id(notificationData.id())
.data(notificationData)
.event("message")
.build();
});
})
.doOnNext(sink::next)
.onErrorResume(throwable -> {
LOGGER.error("An error occurred while processing notifications: {}", throwable.getMessage());
return Flux.empty();
})
.doFinally(signalType -> LOGGER.debug(signalType.toString()))
.takeWhile(_ -> !sink.isCancelled())
.subscribe();
}
}
This imlementation works fine when I test with postman,
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/jwEV7.png
But I'm having trouble handling notifications on client side with React.js, I have tried everything, but cannot receive events, sse.onopen function gets called when i call the endpoint, but onmessage won't work for some reason, any ideas why ? |
Hello I am new in stackoverflow. I am currently finding a solution to solve the data importing issue. When I imported the records over 2000 with excel file, the web going down. Then I searched error log in the server found out the following. Web servers using nginx and database is mysql. The web is with python. Could any one suggest what I am missing?
Log: 2024/03/10 13:47:34 [error] 431467#431467: *5870 upstream prematurely closed connection while reading response header from upstream, client: 172.70.116.166, server: xxxxxx.com, request: "POST /upload_excelData/ HTTP/1.1", upstream: "http://unix:/xxxxx.sock:/upload_excelData/", host: "www.xxxxx.com", referrer: "https://www.xxxxxx.com/doe_upload/"
I tried to edit the Nginx proxy connection timeout setting but not work.I am expecting to import large excel data which may be 10,000 or more. |
I'm currently working on a school project where I need to apply multiple border images to an element using border-image-source. However, I'm encountering issues where only one of the border images is displayed, while the other is not being applied. It would show up as a grey border instead if both of the borders are applied, as shown below (left). When I alternate between both borders, it appears as shown in the middle and right images. However, when I try to enable both in the inspect element, it doesn't work (right). [helpme](https://i.stack.imgur.com/rYcE7.png)
here's the full clas code
````.calendar {
height: 300px;
width: 400px;
margin: 0 auto;
margin-top: 50px;
background-image: url(calendarbg.png);
background-size: auto;
background-position: center;
/* ^^ not relevant, i guess ^^ */
border-style: solid;
border-image-source: url(border1.png);
/* border-image-source: url(border.png); */
border-image-slice: 30 fill;
border-width: 20px;
}````
I tried simplifying the code, tried different images, issue still persists. I can't seem to have both two image sources running for some reason... |
Having trouble applying border images |
|html|css|image|calendar|border| |
null |
def word_find(word, string):
# Using str.find() method
# It returns -1 if the word is not found, else returns the index of the first occurrence
if string.find(word) != -1:
return 'success'
else:
return 'word not found in string'
print(word_find('lo', 'Hello world')) ## success |
Dart's anonymous functions are defined with parentheses and curly braces: `(s) { print(s); }`, but if it consists of a single statement, you can use right arrow (`(s) => print(s);`, and then you **must** omit the curly braces or things will break, or worse, be interpreted as a Set. D'oh.
Removing them (or the arrow) was all that was needed:
```dart
destinations:
appPages.map((e) =>
NavigationRailDestination(
icon: e['icon'] as Widget, label: Text(e['name'] as String))
).toList() as List<NavigationRailDestination>
```
Working sandbox: https://flutlab.io/editor/2041e217-a3b9-482f-bc3e-45c0a36895fd |
|asp.net-mvc| |
I want to ask that when calculating MSE loss about time-sequence data shaped like (minibatch, feature, sequence length) in pytorch by using `nn.MSELoss()` with `reduction="mean"`, average just targets on minibatch? or also implicitly about time sequence?
To confirm the calculation result to check what I have questioned above, I printed out below code
```
nn.MSELoss() #reduction='mean' is default
x_t = torch.randn((32, 4, 100)) # [minibatch size, feature size, time sequence length]
x_est = torch.randn((32, 4, 100)) * 2
loss_result = loss(x_t, x_est)
print(loss_result)
```
```
>>> tensor(1.)
``` |
Ask nn.MSELoss() calculation mechnism in pytorch framework |
|pytorch|recurrent-neural-network| |
null |
Ошибка Required Param value not set
Сам код:
SELECT id_vst,
CASE
WHEN id_sys = 155 THEN CAST('Вид' AS varchar(80))
ELSE CAST(' ' AS varchar(80))
END AS result
FROM DOC_ACC_CNT
Пробовал видоизменять код, используемые функции и т.д., но так как только начал работать в FastReport не знаю всех тонкостей и спросить некого, почему ошибка выходит? может дело не в коде ? |
Работая в FastReport пишу SQL код и выдаёт ошибку Required Param value not set |
|sql|parameters|fastreport| |
null |
I am running a SPARK job and for the most it goes fast but at the last task it gets stuck in one of the stages. I can see there is a lot more shuffle read / rows happening for that task, and tried a bunch of re-partitioning strategies to make sure an even distribution. But still can't get through it. Could you please help? Attaching images for the same too.
The join that I am doing is trying to look-up for some private data which is in a delta lake table (all of this is being done on Databricks).
**Table 1** with all desired event logs / rows is: `sizeInBytes=218.2 TiB`; BUT, filtered on a partition key `date` for just the `last 4 days`. Still huge enough I assume, as there are a lot of events.
**Table 2** the look up table for the personal fields which are hashed in the above table is: `sizeInBytes=1793.9 GiB`. This table just has 4 columns. Key, hash, timestamp and type. This is just a simple look up table.
[enter image description here](https://i.stack.imgur.com/LvMKY.png)
[enter image description here](https://i.stack.imgur.com/vx3cL.png)
Essentially, there are 4 hashed out field that I need to reverse look up and that needs 4 separate joins with this look up table. This is quite expensive, but at this point there is no way out for this. The join is happening on that `hashed_key`, which I tried to use in `reparitioning` scheme for the Dataframes. I thought doing this will bring the same `hash_keys` in the same partition and then they could be picked up by the same executor. This is the hypothesis, but still I see one task running for a long time as it is doing exorbitant amount of `shuffle reads` and going through a lot more rows.
What could I be doing wrong? Is `repartitioning` not a good approach here? I read somewhere that I could try `ITERATIVE` broadcasting. That involved breaking the smaller table (which seems the lookup table here) in to smaller chunks (I think lesser than 8 GB) and then broadcast it multiple times to eventually merge all data later.
Any help would be appreciated as I am getting stuck at the same place with these strategies.
Thank you!
Doing a union on a few types to create first Dataframe. Then joining it with the lookup.
```scala
allIncrementalEvents.as("e")
.filter(col("e.type") === "authentication")
.filter(lower(col("e.payload.type")).isin(eventConf.eventTypes:_*))
.filter(lower(col("e.payload.os.name")).isin(eventConf.osNames:_*))
.filter(lower(col("e.payload.device.manufacturer")).isin(eventConf.manufacturers:_*))
.repartition(partitions)
UNION
allIncrementalEvents.as("e")
.filter(col("e.type") === "session")
.filter(lower(col("e.payload.type")).isin(eventConf.eventTypes:_*))
.filter(lower(col("e.payload.os.name")).isin(eventConf.osNames:_*))
.filter(lower(col("e.payload.device.manufacturer")).isin(eventConf.manufacturers:_*))
.repartition(partitions)
UNION
allIncrementalEvents.as("e")
.filter(col("e.type") === "other")
.filter(lower(col("e.payload.type")).isin(eventConf.eventTypes:_*))
.filter(lower(col("e.payload.os.name")).isin(eventConf.osNames:_*))
.filter(lower(col("e.payload.device.manufacturer")).isin(eventConf.manufacturers:_*))
.repartition(partitions)
```
Join
```scala
extractAuthEvents
.union(extractSubEvents)
.union(extractOpenEvents)
.union(extractSessionEvents)
.join(reverseLookupTableDf.as("adId"),
col("adId") === col("adId.hashed"),
"leftouter"
)
.join(reverseLookupTableDf.as("ip"),
col("ae.ip") === col("ip.hashed"),
"leftouter"
)
.join(reverseLookupTableDf.as("ua"),
col("ae.ua") === col("ua.hashed"),
"leftouter"
)
.join(reverseLookupTableDf.as("uid"),
col("ae.uuid") === col("uid.hashed"),
"leftouter"
)
``` |
Last SPARK Task taking forever to complete |
|scala|apache-spark|databricks|apache-spark-sql-repartition| |
null |
````
def newValue(value):
if value == "":
return 1
if value is None:
return 1
return value + 1
out_df['# of Days'] = newValue(out_df['# of Days'])
```` |
I am using `spring cloud stream kafka binding` and `resilience4j circuit breaker`. In cloud stream when `enableDlq: true` all messages with exception in processing goes to the `dlq` topic.
Now, lets suppose we have an `exponential backoff retry` configured to retry messages 5 times. But there is still a chance that due to some transient issue (dependent service going down), good messages fail even after all retries and goes in dlq.
Considering that situation, is there any proper way as how to retry the messages from the dlq topic.
Also please note that the consumer kafka broker might be an external service not in our control to produce back to the main topic as stated [here](https://docs.spring.io/spring-cloud-stream/reference/4.1-SNAPSHOT/kafka/kafka-binder/dlq.html#_enabling_dlq)
|
Handle kafka messages due to transient error in DLQ |
|apache-kafka|spring-cloud-stream|dlq| |
I want to ask that when calculating MSE loss about time-sequence data shaped like (minibatch, feature, sequence length) in pytorch by using `nn.MSELoss()` with `reduction="mean"`, average just targets on minibatch? or also implicitly about time sequence?
To confirm the calculation result to check what I have questioned above, I printed out below code
```
nn.MSELoss() #reduction='mean' is default
x_t = torch.ones((32, 4, 100)) # [minibatch size, feature size, time sequence length]
x_est = torch.ones((32, 4, 100)) * 2
loss_result = loss(x_t, x_est)
print(loss_result)
```
```
>>> tensor(1.)
``` |
Use `text-shadow` to make it look bolder.
<!-- language: lang-css -->
.really-bold {
text-shadow: -1px 0, 0 1px, 1px 0, 0 -1px, -1px -1px, 1px 1px, -1px 1px, 1px -1px;
}
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-css -->
body {
font-family: Arial;
font-weight: 900;
font-size: 40px;
}
.really-bold {
text-shadow: -1px 0, 0 1px, 1px 0, 0 -1px, -1px -1px, 1px 1px, -1px 1px, 1px -1px;
}
<!-- language: lang-html -->
<div class="normal">SAMPLE TEXT</div>
<div class="really-bold">SAMPLE TEXT</div>
<!-- end snippet --> |
What you want is called the "Windows SDK", which contains everything you need to build applications on Windows, except the IDE (Visual Studio).
It comes with all necessary libraries, header files, a compiler, nmake et cetera, and a handy shortcut for a preconfigured `cmd.exe` that puts all of these tools in your `PATH`. If you know what you are doing, this is what you want to use.
What version of the SDK you want depends on the system you are compiling on, but you will find all of them on the Microsoft website. For Windows 10 for example, the SDK can be found here: https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk
Be aware, though, that the windows' compiler `cl.exe` can be a bit tricky at times, and nmake is not what you expect when you only learned GNUmake. If all you want is to compile on Windows, without having to drag 20+ Gigabytes of IDE around, then the SDK is an option to consider.
(We are using virtual machines with a preinstalled Windows SDK quite successfully in lectures and exercises.)
---
As of Windows 8 the SDK no longer contains the build tools for C++ based applications. These are now only contained in a Visual Studio installation. |
My advice is - build it as if there wasn't any NestJS at play. Think of it as of a standalone SDK. As agnostic as possible.
It'll get supereasy to implement it into NestJS (or any other) architecture later on.
---
Breaking code into logical parts is always an implementation decision. Sometimes it's pointless to break code into multiple classes/files, sometimes - quite the opposite. That's your decision :)
---
Generally speaking, testing integration with API is not quite the matter of unit tests, but it all depends on the naming as I've seen hundreds of own definitions where unit tests end, and where features tests start.
But - again. It all depends on the API. If you'd end up writing 100 unit tests for 100 different methods, all of them having `axios.get` or `axios.post`, it's pointless. It can be done with a single feature test mocking axios instance on the fly.
---
Hope that helps anyhow :) |
"I'm considering pursuing a career path in software development, particularly in areas like ServiceNow and OutSystems development. However, I'm curious about how these roles might evolve in comparison to more traditional coding jobs, especially with the advancements in artificial intelligence (AI).
Specifically, I'd like to understand:
1. How the demand for ServiceNow and OutSystems developers might change in the coming years compared to roles focused on general programming languages and frameworks.
2. Whether AI technologies are expected to significantly impact the tasks performed by ServiceNow and OutSystems developers, potentially altering the nature of these roles.
3. Any emerging trends or shifts in the job market that could influence the career prospects for professionals specializing in these platforms.
|
Notification system using SpringBoot/WebFlux with React.js |
|reactjs|spring-boot|spring-webflux|sse|server-sent-events| |
I have a dataframe which has columns as per the screen shot below. I want to add an additional column "all_data" which will hold all the data of the columns in it.
[enter image description here](https://i.stack.imgur.com/PJPeO.png)
here is what i tried
```
from pyspark.sql.functions import collect_list, udf
from pyspark.sql.types import ArrayType, StringType
def read_file_content(file_path):
content = spark.read.json(file_path).rdd.map(lambda x: x[0]).collect()
return content
read_file_content_udf = udf(read_file_content, ArrayType(StringType()))
file_with_all_data = daftrame.withColumn("all_data", read_file_content_udf("file_name_input"))
```
how ever with the above approach i get error as
```
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 63.0 failed 4 times, most recent failure: Lost task 0.3 in stage 63.0 (TID 5275) (10.99.0.10 executor driver): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File "/root/.ipykernel/2377/command-3710246798592077-2084292290", line 12, in read_and_collect_data
File "/databricks/python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 284, in _modified_open
return io_open(file, *args, **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: 'abfss://soruce@storage_abs.dfs.core.windows.net/xbyte/keyword_search/2024/03/asdaf-adase2-47217e-31-0150bda34e47_20240308_09-19-35.json'
```
whereas the file is available and i can read in a separate dataframe
so the final data frame would look like all the columns along with that the additional column "all_data" holding the data from each file individually in the rows.
The column name "file_name_input" has the file location basically something like "abfss://soruce@storage_abs.dfs.core.windows.net/bite/searc/2024/03/asdaf-adase2-47217e-31-0150bda34e47_20240308_09-19-35.json"
and likewise there are 196 other files name and location in the column "file_name_input".
can it be possible to read all the files individually and store the data in the additional column "all_data" respectively |
null |
null |
Reading bytes from a stream does not guarantee that it will read _all_ the bytes you request. try `readNBytes()` instead. |
> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named '<name>.storyboard' in bundle NSBundle <path>
- check/recheck that storyboard file is in `Target Membership`[<sup>\[About\]</sup>][1]
- recheck(remove/add) storyboard UIViewController `Custom Class`
<img src="https://i.stack.imgur.com/Lelch.png" height="150" />
[1]: https://stackoverflow.com/a/59217378/4770877
|
null |
**By using net module (not WebSockets), I want to create a real-time chat application with a simple TCP server. So far, I have been able to implement the text-based chatting system with net module. However, for instance, I cannot write a code that sends image in real-time. By using net module, I want to write a TCP server for real-time image sending. How can I achieve this in Node.js? Can you give me some code to do this task or is there any documentation link for this task? Thanks...**
With my TCP server, I have implemented the real-time text-based chat system; however, I also want to learn how I can send image in real-time with net module in Node.js. |
What is the future of serviceNow developer and outSystems developer jobs as compared to actual coding jobs considering AI? |
|servicenow|outsystems|xenocode| |
null |
|azure|powershell|charts|azure-active-directory| |
I'd re-ask this as a question as I don't think there's much value in this being a PHP discussion. If you do ask it as a question you will also need to provide more details like e.g. which .dll you downloaded and if it's listed as compatible with your php version, where you placed the .dll etc |
null |
null |
{"Voters":[{"Id":3558960,"DisplayName":"Robby Cornelissen"},{"Id":635608,"DisplayName":"Mat"},{"Id":243373,"DisplayName":"TT."}],"SiteSpecificCloseReasonIds":[19]} |
In my case the error was `exception emyxerror in module mysqlquerybrowser.exe at 00103cd2 error while loading stored connections.error number 11.`
I have searched how to uncheck "Beta: Use Unicode UTF-8 for worldwide language support" as the user @alexandr-denschikov suggested.
-Windows will ask you to restart your computer after this.-
To fix:
Control Panel > Clock and Region > Region > Administrative > Change system locale > Uncheck option "Beta: Use Unicode UTF-8 for worldwide language support"
-Windows will ask you to restart your computer after this.-
[If you struggle with a faded out checkbox][1]
[1]: https://stackoverflow.com/questions/67240773/how-to-uncheck-beta-use-unicode-utf-8-for-worldwide-language-support-box-in-w |
This happened to me and after much research, i solved it by enabling Early Access Preview and downloading the latest kotlin version, go to file -> Settings -> then search eap or early access,
Move out of stable and download the eap build |
I Have a "For **Loop**" In ASP.NET Core Like This :
`<button type="submit" Form="FormActive" name="id" value="@item.I"></button>`
<!--It Will Create SomeThing Like This:-->
<button type="submit" Form="FormActive" name="id" value="1"></button>
<button type="submit" Form="FormActive" name="id" value="2"></button>
<button type="submit" Form="FormActive" name="id" value="3"></button>
... ... ... ... 4
... ... ... ... 99
<!--And This Is My Single Form : -->
<form id="FormActive" action="/action_page">
</form>
Whats The Problem?
why This Form Just Send A **httpRequest POST** **Without"ID"** And Value?(infact It Will Send A Post Request With **Empty Body**)
What I Should To do for **send ID**
Edit: I cant **Remove Form** - And I Cant Use **+99 Form** too
maybe i need jquery ... or something?
|
|html|jquery|forms|asp.net-core|post| |
I'm trying to created an ASP.NET Core 8 Web API using only CLI and have the `program.cs` as shown below.
When I run this from VS 2022, no compiler or runtime errors are appearing.
But when this is run from a "docker-compose up" I dot get specific error:
> 2024-03-28 17:54:11 Unhandled exception. System.InvalidOperationException: Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddAuthorization' in the application startup code.
>
> 2024-03-28 17:54:11 at Microsoft.AspNetCore.Builder.AuthorizationAppBuilderExtensions.VerifyServicesRegistered(IApplicationBuilder app)
> 2024-03-28 17:54:11 at Microsoft.AspNetCore.Builder.AuthorizationAppBuilderExtensions.UseAuthorization(IApplicationBuilder app)
> 2024-03-28 17:54:11 at WebApi.Program.Main(String[] args) in /app/Program.cs:line 41
Code:
``` csharp
using Microsoft.EntityFrameworkCore;
namespace WebApi
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
services.AddControllers();
/*
Console.WriteLine("Preparing DbContext");
services.AddDbContext<ParkingDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
*/
services.AddAuthorization(); // Move AddAuthorization here
services.AddHealthChecks();
var app = builder.Build();
app.UseAuthorization();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI();
}
// Configure the HTTP request pipeline.
app.UseRouting();
app.MapControllers();
app.Run();
}
}
}
```
As you notice I do have the `.AddAuthorization` method above but when run and opening a browser localhost is not running.
I'm probably missing something very obvious here, have spent some hours searching here without any luck. |
I'm automating my login process to my servers using an inline bash script, I'm using expect to automate this, but upon logging into server I also want to print a message, I didn't had any luck with echo because I read in a stackoverflow post that it's not reliable cause I want to use color coding, now I'm using printf to do this, printf works in the server perfectl but when passing it in this little script of mine I'm getting an error, I suspect that there is something wrong with the way I'm using curly braces instead of double quotes, I will be glad if someone can point out what is wrong with the way I'm putting the printf command in curly braces.
`expect -c 'spawn ssh -t MYHOST@MYSERVER {printf [\33[01;32m A MESSAGE TO BE SHOWN \33[01;37m]\n; bash}; expect "Password:"; send "MY PASSWORD"; interact'`
I'm getting these errors, there is absolutely something wrong with the I'm putting printf command inside curly braces:
`bash: {printf: command not found
bash: 32m: command not found
bash: 37m]n}}: command not found
`
I tried using double quotes and many ways of using curly braces but didn't have any luck.
Thank you everyone. |
How can I pass commands to SSH when using expect while it doesn't support using doube quotes? |
|bash|ssh|formatting|expect|curly-braces| |
null |
With anything that involves sending messages, always try looking at the actual messages: for IP networking, tcpdump; for D-Bus, use `busctl monitor` or `dbus-monitor`.
For basic types, sd_bus_set_property() doesn't want pointers to the value – it wants the value directly, so your pointer-to-bool is always interpreted as "true" which you could see in the message being sent. Changing the `&powered` to `powered` should make the call work.
See the manual for [_sd_bus_message_append(3)_][1], which has a table with "Expected C type" for each type specifier. It's more like printf() than ioctl().)
(The second example with sd_bus_message_append_basic() _does_ want a pointer, and it seems to generate an identical message to `busctl set-property` – of course, only after you uncomment the `bool powered = false`.)
[1]: https://www.freedesktop.org/software/systemd/man/latest/sd_bus_message_append.html |
{"Voters":[{"Id":49849,"DisplayName":"user1686"}],"DeleteType":1} |
Try to go from the opposite, using Python, create a test.csv
next to your file.
If you manage to create a file, read test.csv
This is how you check if the path is available for the user you are working under. |
If you have your csv data imported into database table or you can have it as a dataset like:
~~~sql
/*
FID A_DATE ORIGINAL_AIRPORT AIRLINE_NAME AIRCRAFT_TYPE IS_HEAVY
--- ---------- ------------------ -------------- -------------- ---------
1 2024-02-25 101 Ryanair A-320 no
2 2024-02-25 102 AirFrance A-380 yes
3 2024-02-25 103 Vueling A-319 no */
~~~
... you could use it to insert data into flights table using case expression converting 'yes' to 1 (or TRUE with no quotes) and 'no' to 0 (or FALSE with no quotes)
~~~sql
INSERT INTO flights
( Select FID, A_DATE, ORIGINAL_AIRPORT, AIRLINE_NAME, AIRCRAFT_TYPE,
Case When IS_HEAVY = 'yes' Then 1 -- or TRUE instead of 1
Else 0 -- or FALSE instead of 0
End as IS_HEAVY
From csv_flights
);
~~~
~~~sql
-- test it
Select * From flights;
/* R e s u l t :
FID A_DATE ORIGINAL_AIRPORT AIRLINE_NAME AIRCRAFT_TYPE IS_HEAVY
--- ---------- ------------------ -------------- -------------- ---------
1 2024-02-25 101 Ryanair A-320 0
2 2024-02-25 102 AirFrance A-380 1
3 2024-02-25 103 Vueling A-319 0 */
~~~
If you are doing it while reading csv out of db and passing commands to a database - do the same - convert 'yes' to 1 (TRUE) and 'no' to 0 (FALSE) while creating a command to be executed in db. |
Node.js Broadcasting Image In Real-time |
|javascript|node.js|tcp|chat|real-time| |
null |
I've asked a few questions here in the past and everyone has been very gracious about answering me. I am about as 'beginner' as it gets. Thank you in advance.
So I am using the premium version of the Rank Math SEO plugin for wordpress. Regarding the SCHEMA creation feature: The issue is that the plugin pulls the author image from the gravatar profile (and I don't use gravatar to sign into my wordpress website). I want to hardcode the image URL for the author in the Rank Math php files (I'm the only author on my website so it's okay). Website is https://mbastory [dot] builders
Here is the snippet of php that fetches the image URL
```
private function add_image( &$entity, $author_id, $jsonld ) {
$entity['image'] = [
'@type' => 'ImageObject',
'@id' => get_avatar_url( $author_id ),
'url' => get_avatar_url( $author_id ),
'caption' => get_the_author(),
];
$jsonld->add_prop( 'language', $entity['image'] );
}
```
And here is what I am thinking might work. I want to print the url and attach the #author at the end of it for the @id and then I want to display the image for the URL.
```
private function add_image( &$entity, $author_id, $jsonld ) {
$entity['image'] = [
'@type' => 'ImageObject',
'@id' => echo 'https//mbastory.builders/wp-content/uploads/Leah-Derus-Circular-Light-Grey-500px.png#author',
'url' => $filepath= '\wp-content\uploads\Leah-Derus-Circular-Light-Grey-500px.png'; echo '<img src="'.$filepath.'">',
'caption' => get_the_author(),
];
$jsonld->add_prop( 'language', $entity['image'] );
}
```
**
Does this seem right?**
No surprise (to me at least)...my code through a huge critical error... |
Beginner | Hardcode an image URL path in php | Modify Rank Math Wordpress Plugin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.