箜明

文章 评论 浏览 28

箜明 2025-02-20 10:52:37

我解决了这个问题。只需在卷中添加docker -compose.yml,例如 - '/app/node_modules'。确保目录在容器中可用。

I solved this problem. Just add in docker-compose.yml in volumes a code like - '/app/node_modules'.For ensure that the directory is available within the container.

Docker失败-BCRYPT_LIB.NODE:EXEC格式错误

箜明 2025-02-20 07:01:28

如果您想将单个元素作为普通perl标量提取,请在上使用 slice :

pdl> $pdl = random(4,4)
pdl> p $pdl->at(0,0) + $pdl->at(1,0)
0.288796754210711
pdl> p ref \($pdl->at(0,0) + $pdl->at(1,0))
SCALAR

将整个ndarray对象转换为嵌套的perl数组,请使用umpdl

pdl> $aoa = random(4,4)->unpdl;
pdl> p ref $aoa
ARRAY
pdl> p ref $aoa->[0]
ARRAY

请注意,perl数组中元素的索引是在ndarray对象中完成的横向。例如,

pdl> p $pdl->at(1,0)
0.111869023064209

pdl> p $aoa->[1][0] # wrong
0.954887281829823

pdl> p $aoa->[0][1] # correct
0.111869023064209

If you're looking to extract individual elements as normal Perl scalars, use at instead of slice:

pdl> $pdl = random(4,4)
pdl> p $pdl->at(0,0) + $pdl->at(1,0)
0.288796754210711
pdl> p ref \($pdl->at(0,0) + $pdl->at(1,0))
SCALAR

To convert the entire ndarray object into nested Perl arrays, use unpdl

pdl> $aoa = random(4,4)->unpdl;
pdl> p ref $aoa
ARRAY
pdl> p ref $aoa->[0]
ARRAY

Note that the indexing of elements in the Perl arrays is the transverse of that done in the ndarray objects. For example,

pdl> p $pdl->at(1,0)
0.111869023064209

pdl> p $aoa->[1][0] # wrong
0.954887281829823

pdl> p $aoa->[0][1] # correct
0.111869023064209

访问PDL对象中数据的最佳实践

箜明 2025-02-20 06:55:53

好吧,您没有对购物车类做任何事情。

cartIcon.onclick = () => {
    cart.classList.remove("cart");
    cart.classList.add("cart-active");
};
cartClose.onclick = () => {
    cart.classList.remove("cart-active");
    cart.classList.add("cart");
}

如果要替换CART类,用cart-Active替换。

Well, you aren't doing anything to the cart class.

cartIcon.onclick = () => {
    cart.classList.remove("cart");
    cart.classList.add("cart-active");
};
cartClose.onclick = () => {
    cart.classList.remove("cart-active");
    cart.classList.add("cart");
}

if you want to replace the cart class with cart-active.

如何覆盖带有连字符的JavaScript的className( - )

箜明 2025-02-20 04:57:29

您可以简单地将注意力图的内容串联到字符串中,然后使用“”“ +注意向量 +”“”将其粘贴到位:

attention_vector = """[{
  'word': 'Lorem',
  'attention': 0.39
}, {
  'word': 'ipsum',
  'attention': 0.76
}, {
  'word': 'dolor',
  'attention': 0.2
}, {
  'word': 'sit',
  'attention': 0.43
}, {
  'word': 'amet,',
  'attention': 0.54
}, {
  'word': 'consectetur',
  'attention': 0.29
}, {
  'word': 'adipiscing',
  'attention': 0.98
}]"""

js_getResults =""" <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">


<script
    type="text/javascript"
    src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"
    
></script>

    <link rel="stylesheet" type="text/css" href="/css/result-light.css">


<style id="compiled-css" type="text/css">
    

    /* EOS */
</style>

<script id="insert"></script>

</head>
<body>
    <div id="text">text goes here</div>


    <script type="text/javascript">//<![CDATA[


var words = """ + attention_vector + """;

$('#text').html($.map(words, function(w) {
return '<span style="background-color:hsl(360,100%,' + (w.attention * 50 + 50) + '%)">' + w.word + ' </span>'
}))



//]]></script>

<script>
    // tell the embed parent frame the height of the content
    if (window.parent && window.parent.parent){
    window.parent.parent.postMessage(["resultsFrame", {
        height: document.body.getBoundingClientRect().height,
        slug: "ohLs4ae0"
    }], "*")
    }

    // always overwrite window.name, in case users try to set it manually
    window.name = "result"
</script>


</body>
</html> """

print(js_getResults)

You could simply concatenate the contents of your attention_vector to a string and then use """ + attention vector + """ to paste it into place:

attention_vector = """[{
  'word': 'Lorem',
  'attention': 0.39
}, {
  'word': 'ipsum',
  'attention': 0.76
}, {
  'word': 'dolor',
  'attention': 0.2
}, {
  'word': 'sit',
  'attention': 0.43
}, {
  'word': 'amet,',
  'attention': 0.54
}, {
  'word': 'consectetur',
  'attention': 0.29
}, {
  'word': 'adipiscing',
  'attention': 0.98
}]"""

js_getResults =""" <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">


<script
    type="text/javascript"
    src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"
    
></script>

    <link rel="stylesheet" type="text/css" href="/css/result-light.css">


<style id="compiled-css" type="text/css">
    

    /* EOS */
</style>

<script id="insert"></script>

</head>
<body>
    <div id="text">text goes here</div>


    <script type="text/javascript">//<![CDATA[


var words = """ + attention_vector + """;

$('#text').html($.map(words, function(w) {
return '<span style="background-color:hsl(360,100%,' + (w.attention * 50 + 50) + '%)">' + w.word + ' </span>'
}))



//]]></script>

<script>
    // tell the embed parent frame the height of the content
    if (window.parent && window.parent.parent){
    window.parent.parent.postMessage(["resultsFrame", {
        height: document.body.getBoundingClientRect().height,
        slug: "ohLs4ae0"
    }], "*")
    }

    // always overwrite window.name, in case users try to set it manually
    window.name = "result"
</script>


</body>
</html> """

print(js_getResults)

如何在Python中使用三重引用的原始文本中使用变量?

箜明 2025-02-19 15:33:54

您可以使用 date function 和date_format

select date_format(date_parse('2022-06-15 10:21:05.698000000', '%Y-%m-%d %H:%i:%s.%f'), '%Y-%m-%d %H:%i:%s')

输出:

_COL0
2022-06-15 10:21:05

我也建议在操作之前使用cocce,即原始尝试cocece(substr(a.hive_date,1,19,1,19),substr(a.hive_date2,1,19) ) - &gt; substr(cocce(a.hive_date,a.hive_date2),1,19)

也可能只需在数据上使用trim,例如:

substr(trim(coalesce(A.hive_date, A.hive_date2)), 1, 19)

或:

select date_format(
        date_parse(
            trim(coalesce(A.hive_date, A.hive_date2)),
            '%Y-%m-%d %H:%i:%s.%f'
        ),
        '%Y-%m-%d %H:%i:%s'
    )

You can use date functions - date_parse and date_format:

select date_format(date_parse('2022-06-15 10:21:05.698000000', '%Y-%m-%d %H:%i:%s.%f'), '%Y-%m-%d %H:%i:%s')

Output:

_col0
2022-06-15 10:21:05

Also I would suggest using coalesce before manipulations i.e. in original attempt coalesce(substr(A.hive_date, 1,19),substr(A.hive_date2,1,19)) -> substr(coalesce(A.hive_date, A.hive_date2), 1, 19)

Also possibly you need to just use trim on the data, like:

substr(trim(coalesce(A.hive_date, A.hive_date2)), 1, 19)

Or:

select date_format(
        date_parse(
            trim(coalesce(A.hive_date, A.hive_date2)),
            '%Y-%m-%d %H:%i:%s.%f'
        ),
        '%Y-%m-%d %H:%i:%s'
    )

将日期时间戳转换为Presto

箜明 2025-02-19 02:03:53
db.customers.aggregate([{
    $match: {
        "CDF.UTILITYTYPE.D1.G1" : "12387835"
    }   
},  {
        $project: {
         _id:0, 
         "CDF.UTILITYTYPE.D1.G22.NAME":1, 
         "CDF.UTILITYTYPE.D1.G1":1,
         "CDF.UTILITYTYPE.D5.EVENT": {
            $filter: {
               input: "$CDF.UTILITYTYPE.D5.EVENT",
               as: "item",
               cond: { $regexMatch: { input:"$item.TIME", regex: "05-2022"}}
            }
         }
      }
    }
]).pretty();
db.customers.aggregate([{
    $match: {
        "CDF.UTILITYTYPE.D1.G1" : "12387835"
    }   
},  {
        $project: {
         _id:0, 
         "CDF.UTILITYTYPE.D1.G22.NAME":1, 
         "CDF.UTILITYTYPE.D1.G1":1,
         "CDF.UTILITYTYPE.D5.EVENT": {
            $filter: {
               input: "$CDF.UTILITYTYPE.D5.EVENT",
               as: "item",
               cond: { $regexMatch: { input:"$item.TIME", regex: "05-2022"}}
            }
         }
      }
    }
]).pretty();

如何使用子字符串在Mongo DB中进行比较

箜明 2025-02-18 23:05:07

没有完整的错误消息,我无法确定。但这是我的猜测:

return view('admin.docreviews')->with('doctor_reviews', $reviews);

这将为表格添加了评论列表,当您foreach时,您将循环浏览列表。

return view('admin.docreviews')->with('doctor_reviews', $review);

这将为表格添加单个评论,当您foreach时,您将循环浏览其属性。

return view('admin.docreviews')->with('doctor_reviews', [$review]);

可能会解决您的问题。但是我建议将刀片页面分配到列表查看页面和详细查看页面。

Without the full error message I can't really know for sure. But this is my guess:

return view('admin.docreviews')->with('doctor_reviews', $reviews);

This adds a list of reviews to the form, and when you foreach, you will loop through the list.

return view('admin.docreviews')->with('doctor_reviews', $review);

This will add a single review to the form, and when you foreach, you will loop through its properties.

return view('admin.docreviews')->with('doctor_reviews', [$review]);

Might fix your issue. But I'd suggest splitting the blade page into a list view page and a detail view page.

尝试阅读属性和“用户”在布尔

箜明 2025-02-18 00:51:29

确实,您无法使用CSS为选择选项设计。您可以做的是创建自己的选择组件。为了获得所有内容,例如可访问性,运行良好可能很棘手。

您可以将 headless ui listbox 作为起点。这是一个未风格的自定义选择,可以用尾风CSS创建样式。

希望这会有所帮助。

Indeed, you cannot style the select options with CSS. What you can do is create your own select component. To get everything, like accessibility, working well can be tricky though.

You could take the Headless UI listbox as a starting point. This is an unstyled custom select, created to style with Tailwind CSS.

Hope this helps.

我试图更改选定型式杆的选项的各个样式,并使角落四舍五入,但可以吗?

箜明 2025-02-18 00:37:02
df = df.astype({"columnname": str})

#EG-用于将列类型更改为字符串
#DF是您的数据框

df = df.astype({"columnname": str})

#e.g - for changing the column type to string
#df is your dataframe

更改Pandas中的列类型

箜明 2025-02-17 07:47:38

您可以分开键并构建一个新对象。

const
    data = [{ strIngredient1: 'Light rum', strIngredient2: 'Lime', strIngredient3: 'Sugar', strIngredient4: 'Mint', strIngredient5: 'Soda water' }, { strMeasure1: '2-3 oz ', strMeasure2: 'Juice of 1 ', strMeasure3: '2 tsp ', strMeasure4: '2-4 ' }],
    keys = { strIngredient: 'ingredient', strMeasure: 'measure' },
    result = data.reduce((r, o, i) => {
        Object.entries(o).forEach(([key, value]) => {
            const [, k, i] = key.match(/^(.*?)(\d+)$/);
            (r[i - 1] ??= { ingredient: '', measure: '' })[keys[k]] = value;
        });
        return r;        
    }, []);

console.log(result);

You could separate the keys and build a new object.

const
    data = [{ strIngredient1: 'Light rum', strIngredient2: 'Lime', strIngredient3: 'Sugar', strIngredient4: 'Mint', strIngredient5: 'Soda water' }, { strMeasure1: '2-3 oz ', strMeasure2: 'Juice of 1 ', strMeasure3: '2 tsp ', strMeasure4: '2-4 ' }],
    keys = { strIngredient: 'ingredient', strMeasure: 'measure' },
    result = data.reduce((r, o, i) => {
        Object.entries(o).forEach(([key, value]) => {
            const [, k, i] = key.match(/^(.*?)(\d+)$/);
            (r[i - 1] ??= { ingredient: '', measure: '' })[keys[k]] = value;
        });
        return r;        
    }, []);

console.log(result);

根据不同的密钥将值分组为一个对象数组

箜明 2025-02-17 04:42:09

经过一些反复试验和查看渲染的html代码,我使用gt :: html

tbl <- tibble::tibble(values = c("test<sup>2</sup>", 2:4), groups = c("x<sup>2</sup>", "x<sup>2</sup>", "y", "y"))

unescape_html <- function(str){
  xml2::xml_text(xml2::read_html(paste0("<x>", str, "</x>")))
}

tbl |> 
  gt::gt(groupname_col = "groups") |> 
  gt::text_transform(
    locations = gt::cells_row_groups(),
    fn = function(x) {
      purrr::map(x, ~ gt::html(paste("<span style=color:blue;>", .x, "</span>")))
    }
  ) |> 
  gt::text_transform(
    locations = gt::cells_body(columns = 1),
    fn = function(x){
      x <- purrr::map_chr(x, unescape_html)
      paste("<span style=color:red;>", x, "</span>")
    }
  )

“

After some trial and error and a look at the rendered html code I figured out a solution using gt::html:

tbl <- tibble::tibble(values = c("test<sup>2</sup>", 2:4), groups = c("x<sup>2</sup>", "x<sup>2</sup>", "y", "y"))

unescape_html <- function(str){
  xml2::xml_text(xml2::read_html(paste0("<x>", str, "</x>")))
}

tbl |> 
  gt::gt(groupname_col = "groups") |> 
  gt::text_transform(
    locations = gt::cells_row_groups(),
    fn = function(x) {
      purrr::map(x, ~ gt::html(paste("<span style=color:blue;>", .x, "</span>")))
    }
  ) |> 
  gt::text_transform(
    locations = gt::cells_body(columns = 1),
    fn = function(x){
      x <- purrr::map_chr(x, unescape_html)
      paste("<span style=color:red;>", x, "</span>")
    }
  )

enter image description here

将text_transform()应用于R GT中的行组

箜明 2025-02-17 03:59:25

您的.spec.ingressclassname字段正确吗?我看到您部署了NGINX Ingress Controller。

Is your .spec.ingressClassName field correct? I see you deployed nginx ingress controller.

无法访问kubernetes入口

箜明 2025-02-17 01:11:48

您应该考虑使用此...

<link rel="stylesheet" href="./assets/index.76858414.css">

而不是这个...

<link rel="stylesheet" href="/assets/index.76858414.css">

您可以阅读有关 html文件路径的更多信息


You should consider using this...

<link rel="stylesheet" href="./assets/index.76858414.css">

Instead of this...

<link rel="stylesheet" href="/assets/index.76858414.css">

You can read more about HTML file paths here.

我已经在GitHub上部署了我的尾风CSS项目,它突然停止在页面部署上工作

箜明 2025-02-16 12:08:21

假设json_object的每个值dict,您也可以使用以下方法:

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': 'james','age':55, 'hobby':'pubg'}, {'name': 'tarzan','status':'single'}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i]] for i in x])
df = df.explode(column="json_object")
df.json_object = df.json_object.str[0].astype(str) + ": " + df.json_object.str[1].astype(str) 
df

------------------------------------------
    customer_id  date        json_object
0   A101         2022-06-21  name: james
0   A101         2022-06-21  age: 55
0   A101         2022-06-21  hobby: pubg
1   A102         2022-06-22  name: tarzan
1   A102         2022-06-22  status: single
------------------------------------------

编辑,

因为您将数据框架更改为

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':['single']}]
    }
)

我的代码,必须按以下方式调整:

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':['single']}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i][0]] for i in x])
df = df.explode(column="json_object")
df.json_object = df.json_object.str[0].astype(str) + ": " + df.json_object.str[1].astype(str) 
df

如果空列表随附,然后只需在lambda函数中添加if-else条件即可。请注意,我还将下一个代码提取中的列重命名。

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':[]}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i][0]] if x[i] else [i, ""] for i in x])
df = df.rename(columns={"json_object": "attribute"}).explode(column="attribute")
df.attribute = df.attribute.str[0].astype(str) + ": " + df.attribute.str[1].astype(str) 

Assuming each value of json_object is a dict, you could also use the following approach:

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': 'james','age':55, 'hobby':'pubg'}, {'name': 'tarzan','status':'single'}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i]] for i in x])
df = df.explode(column="json_object")
df.json_object = df.json_object.str[0].astype(str) + ": " + df.json_object.str[1].astype(str) 
df

------------------------------------------
    customer_id  date        json_object
0   A101         2022-06-21  name: james
0   A101         2022-06-21  age: 55
0   A101         2022-06-21  hobby: pubg
1   A102         2022-06-22  name: tarzan
1   A102         2022-06-22  status: single
------------------------------------------

EDIT

Since you changed your data frame to

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':['single']}]
    }
)

my code must be adjusted as follows:

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':['single']}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i][0]] for i in x])
df = df.explode(column="json_object")
df.json_object = df.json_object.str[0].astype(str) + ": " + df.json_object.str[1].astype(str) 
df

If empty lists are included then simply add an if-else condition inside the lambda function. Note, I have also renamed the columns in the next code extraction.

df = pd.DataFrame(
    data = {
        "customer_id": ["A101", "A102"],
        "date": ["2022-06-21", "2022-06-22"],
        "json_object": [{'name': ['james'],'age':[55], 'hobby':['pubg']}, {'name': ['tarzan'],'status':[]}]
    }
)
df["json_object"] = df["json_object"].map(lambda x: [[i, x[i][0]] if x[i] else [i, ""] for i in x])
df = df.rename(columns={"json_object": "attribute"}).explode(column="attribute")
df.attribute = df.attribute.str[0].astype(str) + ": " + df.attribute.str[1].astype(str) 

如何在python中弄平数据框,其中一列包含一个JSON对象?

箜明 2025-02-16 09:48:30

您的继承想法似乎是一个很好的方法。

我建议让登录类从会话中继承,这样您就可以使用它来创建会话并通过所需的登录功能自定义它:

class Client:

    def __init__(self):
        self.session = LoginSession()

    def login(self, url, headers, username, password):
        self.session.login(url, headers, username, password)


class LoginSession(requests.Session):

    def login(self, url, headers, username, password):
        self.login_func1(url, headers)
        # [...]
        self.login_func10(url, headers)
        resp = self.get(
            url, payload={"user": username, "password": password}, headers=headers
        )
        if resp.status_code == 200:
            print("Successfully logged in!")
            
    def login_func1(self, url, headers):
        resp = self.get(url, headers=headers)

    # [...]
    def login_func10(self, url, headers):
        resp = self.get(url, headers=headers)

Your idea of inheritance seems to be a good approach.

I would propose to let the LogIn class inherit from Session, this way you can use it to create the Session and customize it via your desired login functionality:

class Client:

    def __init__(self):
        self.session = LoginSession()

    def login(self, url, headers, username, password):
        self.session.login(url, headers, username, password)


class LoginSession(requests.Session):

    def login(self, url, headers, username, password):
        self.login_func1(url, headers)
        # [...]
        self.login_func10(url, headers)
        resp = self.get(
            url, payload={"user": username, "password": password}, headers=headers
        )
        if resp.status_code == 200:
            print("Successfully logged in!")
            
    def login_func1(self, url, headers):
        resp = self.get(url, headers=headers)

    # [...]
    def login_func10(self, url, headers):
        resp = self.get(url, headers=headers)

python oop分离一堂课

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文