你如我软肋

文章 评论 浏览 30

你如我软肋 2025-02-17 15:35:22

正如弗兰克·范·普菲伦(Frank Van Puffelen)所提到的那样,两个片段应该做得完全相同(如您所说,在订购之外)。您可以在repo there

有关更多信息,您可以参考文档href =“ https://firebase.google.com/docs/database/flutter/lists/lists-of-data” rel =“ nofollow noreferrer”> documentation (在Flutter Firebase中使用数据列表。)

  index.js

const查询= db.Collection('cities')。其中('状态','==','ca');

cont observer = query.onsnapshot(querySnapShot => {
  console.log(`接收到的查询快照尺寸$ {querySnapShot.size}`);
  // ...
},err => {
  console.log(`遇到错误:$ {err}`);
});
 

As mentioned by Frank van Puffelen, two snippets should do exactly the same (outside of ordering as you said). You can fill a bug on the repo here :

For more information you can refer to the Documentation (listen a document with onsnapshot() method )and Documentation(working with list of data in flutter firebase.)

index.js

const query = db.collection('cities').where('state', '==', 'CA');

const observer = query.onSnapshot(querySnapshot => {
  console.log(`Received query snapshot of size ${querySnapshot.size}`);
  // ...
}, err => {
  console.log(`Encountered error: ${err}`);
});

Cloud_firestore软件包:不同的行为,等效查询

你如我软肋 2025-02-17 07:24:28

我通过完全事故弄清楚了!我正在测试另一个滑块,并注意到它可以适用于一个,而不是另一个,所以我注意到唯一不同的是包装纸。

我将包装器的宽度设置为比滑块更宽(940px是我的滑块,所以我将包装器设置为1480)。我还设置了父容器上的溢出。在我为移动设备设置它之前,它仅在桌面上创建一个带有额外空间的滚动栏,因此我将桌面上的桌面修改为940px包装器,iPad将iPad和iPad仅用于移动设备,仅为1480-删除了滚动不良和额外的空间,同时非常适合移动。 yayyyyy!

I figured it out by complete accident! I was testing a different slider and noticed it would work for one but not the other, so I noticed the only different was the wrapper.

I had set the wrapper width to wider than my slider (940px is my slider so I set wrapper to 1480). I also set overflow on the parent container. Before I set it for mobile devices only it was creating a scroll bar with extra space on desktop so I modified desktop to 940px wrapper and ipad to mobile devices only to 1480 - this removed scroll bad and extra space on desktop while being perfect for mobile. YAYYYYY!

光滑滑块在手机上显示3个图像I/O

你如我软肋 2025-02-17 04:00:44
letter_rank = {letter:rank for rank, letter in enumerate(string.ascii_lowercase, 1)}

def rank(name):
    return sum(letter_rank.get(c, 0) for c in name.lower())
letter_rank = {letter:rank for rank, letter in enumerate(string.ascii_lowercase, 1)}

def rank(name):
    return sum(letter_rank.get(c, 0) for c in name.lower())

我正在尝试创建一个输入名称并输出等级的函数。创建该功能的最佳方法是什么?

你如我软肋 2025-02-16 18:31:49

来自WP Admin>模板

您可以管理所有Elementor模板,还可以使用可以按名称搜索的Finder搜索栏。

而且没有其他方法可以过滤Elementor模板。

enter image description here

From wp admin > templates

you can manage all your elementor templates and also you get a finder search bar using which you can search by name.

And there's no other way to filter elementor templates.

Elementor模板过滤器

你如我软肋 2025-02-16 15:13:48

使用 numpy.select.select

df=pd.DataFrame({"Column1": [0, 1000, 1023, 1024, 65535, 65536]})


m1 = df.Column1.between(0, 1023)
m2 = df.Column1.between(1024, 49151)
m3 = df.Column1.between(49152, 65535)

df['new'] = np.select([m1, m2, m3], [0,1,2], default=None)

代码> 使用 include_lowest = true 参数:

df['new1']=pd.cut(df.Column1,bins=[0,1023,49151,65535],labels=[0,1,2], include_lowest=True)
print (df)
   Column1   new new1
0        0     0    0
1     1000     0    0
2     1023     0    0
3     1024     1    1
4    65535     2    2
5    65536  None  NaN

Use numpy.select with Series.between:

df=pd.DataFrame({"Column1": [0, 1000, 1023, 1024, 65535, 65536]})


m1 = df.Column1.between(0, 1023)
m2 = df.Column1.between(1024, 49151)
m3 = df.Column1.between(49152, 65535)

df['new'] = np.select([m1, m2, m3], [0,1,2], default=None)

Or cut with include_lowest=True parameter:

df['new1']=pd.cut(df.Column1,bins=[0,1023,49151,65535],labels=[0,1,2], include_lowest=True)
print (df)
   Column1   new new1
0        0     0    0
1     1000     0    0
2     1023     0    0
3     1024     1    1
4    65535     2    2
5    65536  None  NaN

熊猫替换一个范围之间的值

你如我软肋 2025-02-16 01:00:01

我已经看到此代码是错误的 - 您不会更改 num ,因此此循环将永远运行。但是使用 您将在不递归的情况下创建正常功能。在递归中,您宁愿仅需要,如果/elif/else

在递归中,您必须使用 retun sum_factor(num/base,base)才能返回到先前执行的 sum_factor(),该将其返回到先前执行的 sum_factor ()等。


类似的东西:

def sum_factor(num, base):
  
    if num == base:
        return "Yes"
    if num < base:
        return "Nope"
    
    #if num > base:
    #    return sum_factor(num/base, base)

    return sum_factor(num/base, base)

# --- main ---

print(12, 2, sum_factor(12, 2))
print(16, 2, sum_factor(16, 2))
print(9, 2, sum_factor(9, 2))

I already see that this code is wrong - inside while you don't change num so this loop will run forever. But using while you will create normal function without recursion. In recursion you rather need only if/elif/else.

And in recursion you have to use retun sum_factor(num/base, base) to return value to previous executed sum_factor() which will return it to previous executed sum_factor(), etc.


Something like this:

def sum_factor(num, base):
  
    if num == base:
        return "Yes"
    if num < base:
        return "Nope"
    
    #if num > base:
    #    return sum_factor(num/base, base)

    return sum_factor(num/base, base)

# --- main ---

print(12, 2, sum_factor(12, 2))
print(16, 2, sum_factor(16, 2))
print(9, 2, sum_factor(9, 2))

递归功能:此递归函数是否正确找到数字是否是基数的力量?

你如我软肋 2025-02-15 19:46:30
let productionState = false

const checkbox = document.getElementById("flexCheckDefault");

checkbox.addEventListener("change", (event) => {
productionState = checkbox.checked;
});
let productionState = false

const checkbox = document.getElementById("flexCheckDefault");

checkbox.addEventListener("change", (event) => {
productionState = checkbox.checked;
});

JavaScript复选框活动处理程序

你如我软肋 2025-02-15 15:58:46

打开C:\ Windows \ System32 \ drivers \ etc \ etc \ hosts in Notepad作为管理员,进行输入:

10.27.233.121 OnePlan.dev.ad.ad.trw.com

进入命令窗口(WindowsKey+r tor WindowsKey+r tor Ophan Run Box并输入CMD )和键入ipconfig /flushdns

恭喜,您刚刚覆盖了该域地址的DNS,并且您的计算机专门将始终指向您在主机文件中定义的新IP。请记住,一旦您的域完成了一旦繁殖(您的DNS Guy都应该在处理服务器的DNS中记录记录),请清除它。

open c:\windows\system32\drivers\etc\hosts in notepad as administrator, make an entry:

10.27.233.121 oneplan.dev.ad.trw.com

go into a command window (windowskey+R to open run box and enter cmd) and type ipconfig /flushdns

Congrats, you've just overridden the DNS for that domain address and your computer specifically will always point to the new IP that you defined in the hosts file. Remember to clear it out once your domain is done propagating (your dns guy should have put an A record in the DNS handling the server)

使用DNS时配置IIS主机名

你如我软肋 2025-02-15 09:46:29
window.fetch = new Proxy(window.fetch, {
  apply(fetch, that, args) {
    let fetchApi = [
      fetch(args.shift())
    ];
    let fetchToken = [
      fetch("https://idaas.provider/get/new/token", {
        method: "POST",
        body: new URLSearchParams({
          grant_type: "refresh_token",
          refresh_token: getRefreshToken(),
          client_id: client_id_str,
        })
      }).then(token => send_new_token_to_service_worker(token)),
    ];
    return Promise.allSettled(fetchApi).then(results => {
      let rejected = results
        .map(result => result.status)
        .includes("rejected");
      if (rejected) {
        return Promise.all([...fetchToken, ...fetchApi]).then(results => results.at(1));
      } else {
        return results.at(0).value;
      }
    });
  },
});

用法fetch(“ https:// your-api”)。

window.fetch = new Proxy(window.fetch, {
  apply(fetch, that, args) {
    let fetchApi = [
      fetch(args.shift())
    ];
    let fetchToken = [
      fetch("https://idaas.provider/get/new/token", {
        method: "POST",
        body: new URLSearchParams({
          grant_type: "refresh_token",
          refresh_token: getRefreshToken(),
          client_id: client_id_str,
        })
      }).then(token => send_new_token_to_service_worker(token)),
    ];
    return Promise.allSettled(fetchApi).then(results => {
      let rejected = results
        .map(result => result.status)
        .includes("rejected");
      if (rejected) {
        return Promise.all([...fetchToken, ...fetchApi]).then(results => results.at(1));
      } else {
        return results.at(0).value;
      }
    });
  },
});

Usage fetch("https://your-api").then(resp => resp);

通用获取重播以处理令牌刷新

你如我软肋 2025-02-15 08:31:52

使用 何时()

这里的方法是 定义

public function when($value, callable $callback = null, callable $default = null)

我对您的代码进行了一些重构的

$items = DB::table('transactions_tbl')->select([fields_array])
    ->leftJoin('tbl_1 as table1', 'table1.id', '=', 'transactions_tbl.tbl1_f_key')
    ->leftJoin('tbl_2 as table2', 'table2.id', '=', 'transactions_tbl.tbl2_f_key')
    ->when(filled($input1), function ($query) use ($input1) {
        $query->where('transactions_tbl.input1', $input1);
    })->when($request->isNotFilled('process'), function ($query) use ($process) {
        $query->whereIn('transactions_tbl.process', $process);

    }, function ($query) use ($process) {
        $query->where('transactions_tbl.process', $process);
    })->paginate($request->input('per_page'), 20);

use when() method

Here is the definition

public function when($value, callable $callback = null, callable $default = null)

I refactored your code a little

$items = DB::table('transactions_tbl')->select([fields_array])
    ->leftJoin('tbl_1 as table1', 'table1.id', '=', 'transactions_tbl.tbl1_f_key')
    ->leftJoin('tbl_2 as table2', 'table2.id', '=', 'transactions_tbl.tbl2_f_key')
    ->when(filled($input1), function ($query) use ($input1) {
        $query->where('transactions_tbl.input1', $input1);
    })->when($request->isNotFilled('process'), function ($query) use ($process) {
        $query->whereIn('transactions_tbl.process', $process);

    }, function ($query) use ($process) {
        $query->where('transactions_tbl.process', $process);
    })->paginate($request->input('per_page'), 20);

添加“哪里” &quot&quot仅当过滤器值不为null时条款

你如我软肋 2025-02-14 13:35:25

只需杠杆 ors ::

{m,g}awk 1 ORS=' AABBCCDD\n'

01_AA_00 11 AABBCCDD
02_BB_00 11 AABBCCDD
03_CC_01 22 AABBCCDD
04_BB_01 22 AABBCCDD
05_CC_02 33 AABBCCDD
06_CC_02 33 AABBCCDD

另一种方法就是使用 ofs 而不是::

 {m,g}awk ++NF FS='^
 OFS=' AABBCCDD' 

just leverage ORS ::

{m,g}awk 1 ORS=' AABBCCDD\n'

01_AA_00 11 AABBCCDD
02_BB_00 11 AABBCCDD
03_CC_01 22 AABBCCDD
04_BB_01 22 AABBCCDD
05_CC_02 33 AABBCCDD
06_CC_02 33 AABBCCDD

another way is to use OFS instead ::

 {m,g}awk ++NF FS='^
 OFS=' AABBCCDD' 

我如何使用循环使其一次读取每行的bash?

你如我软肋 2025-02-14 09:40:42

IPERF是一个纯粹的散装转移操作。就像netperf tcp_stream一样。虽然它似乎是在应用程序层向您“流”的,但在“流式传输”数据时,POCO软件可能并没有进行连续的请求/响应对。

从理论上讲,您可以在数据包捕获中看到这一点。当您查看IPERF测试的数据包捕获时,您将看到大量的TCP数据段从发送者到接收器,并且只有从接收器到发件人的TCP确认。如果HTTP“流”有一些请求/响应,您将至少看到一些数据段(HTTP请求)从接收器回到发件人。根据该软件一次出色的要求,您可能会看到与IPER相比的性能截然不同。

iperf is a pure, bulk-transfer operation. Just like netperf TCP_STREAM. While it may appear to be "streaming" to you at the application layer, likely as not this POCO software is doing successive request/response pairs when "streaming" the data.

In theory you can see that in a packet capture. When you look at the packet capture of the iperf test, you will see large TCP data segments going from the sender to the receiver and only TCP ACKnowledgements going from the receiver to the sender. If there is some request/response going on with the HTTP "streaming" you will see at least some data segments (HTTP requests) going from the receiver back to the sender. And depending on how many requests this software will have outstanding at one time, you may see very different performance compared to iperf.

如何基于POCO C&#x2B;&#x2B;如何提高HTTP服务器的性能。图书馆

你如我软肋 2025-02-14 07:34:46

启动对控制平面API的代理:

kubectl proxy

在单独的外壳中运行请求(set namepace ,并根据需要限制值):

curl -s http://localhost:8001/apis/batch/v1/namespaces/{{namespace}}/jobs?limit=3 \
  | jq '.items | length'

使用JQ,以便您可以轻松地计算返回的作业数量。

Start a proxy to your control plane api:

kubectl proxy

Run the request in a separate shell (set namespace and limit value as needed):

curl -s http://localhost:8001/apis/batch/v1/namespaces/{{namespace}}/jobs?limit=3 \
  | jq '.items | length'

Using jq so you can easily count the number of jobs returned.

如何设置响应限制以返回kubernetes作业列表呼叫?

你如我软肋 2025-02-13 22:37:41

苹果公司的Foodtruck示例应用程序有一个示例,说明了如何在导航截止日期中处理绑定。看看

        .navigationDestination(for: Donut.ID.self) { donutID in
            DonutEditor(donut: model.donutBinding(id: donutID))
        }

他们使用甜甜圈模型ID进行导航。 To pass on the binding, they 在Foodtruck模型上添加了一个Getter/Setter ,其中包含甜甜圈列表,以生成Donut.ID的绑定。

    public func donutBinding(id: Donut.ID) -> Binding<Donut> {
        Binding<Donut> {
            self.donuts[id]
        } set: { newValue in
            self.donuts[id] = newValue
        }
    }

The Foodtruck sample app from Apple has an example on how to tackle bindings in a navigationDestination. Have a look at the following line in their github repo

        .navigationDestination(for: Donut.ID.self) { donutID in
            DonutEditor(donut: model.donutBinding(id: donutID))
        }

They use the Donut model ID for navigation. To pass on the binding, they added a getter/setter on the FoodTruck model that contains a list of donuts to generate a binding by Donut.ID.

    public func donutBinding(id: Donut.ID) -> Binding<Donut> {
        Binding<Donut> {
            self.donuts[id]
        } set: { newValue in
            self.donuts[id] = newValue
        }
    }

如何在新的NavigationStack中传递与儿童视图的约束。

你如我软肋 2025-02-13 20:10:41

让我们定义两个函数,然后用 dis 进行检查:

from dis import dis
from pandas import Series

x = Series([1,2,3,4,5], index=["A","B","C","D","E"])

def a():
   a, b, c, d, e = x.tolist()

def b():
   a, b, c, d, e = x

dis(a)
dis(b)

执行上述功能将产生:

# dis(a)
  7           0 LOAD_GLOBAL              0 (x)
              2 LOAD_METHOD              1 (tolist)
              4 CALL_METHOD              0
              6 UNPACK_SEQUENCE          5
              8 STORE_FAST               0 (a)
             10 STORE_FAST               1 (b)
             12 STORE_FAST               2 (c)
             14 STORE_FAST               3 (d)
             16 STORE_FAST               4 (e)
             18 LOAD_CONST               0 (None)
             20 RETURN_VALUE

# dis(b)
 10           0 LOAD_GLOBAL              0 (x)
              2 UNPACK_SEQUENCE          5
              4 STORE_FAST               0 (a)
              6 STORE_FAST               1 (b)
              8 STORE_FAST               2 (c)
             10 STORE_FAST               3 (d)
             12 STORE_FAST               4 (e)
             14 LOAD_CONST               0 (None)
             16 RETURN_VALUE

从上面看来,(如果有的话)功能(a)具有更多的说明。那为什么更快呢?

此答案,查看 unpack_sequence ,人们可以看到有一些特别案例,例如左侧侧面变量的数量是什么时候等于右侧对象的长度。

因此, x.tolist()在hood下使用 numpy 方法从数组数据创建列表,该列表允许使用此特殊情况的优化(您可以通过更改左侧的参数数量来检查性能的恶化,例如 a, *b = range(3)将起作用,但比 a,b要慢。 ,C =范围(3))。

当右侧对象不是python元组或列表时,则在对象的内容上进行python迭代,这似乎不太效率。

出于实际原因,如果您确实想要最佳性能(使用模块的当前版本),则可以与 x.tolist() x._values.tolist() 交换,这应该给出大约10-15%的性能(您只需删除一层熊猫来拨打numpy调用,然后在此处直接这样做)。需要注意的是,这些类型的优化对低级代码中发生的事情很敏感,因此不能保证将来的Python/library组合中的性能提高。

Let's define two functions and inspect them with dis:

from dis import dis
from pandas import Series

x = Series([1,2,3,4,5], index=["A","B","C","D","E"])

def a():
   a, b, c, d, e = x.tolist()

def b():
   a, b, c, d, e = x

dis(a)
dis(b)

Executing the above will yield:

# dis(a)
  7           0 LOAD_GLOBAL              0 (x)
              2 LOAD_METHOD              1 (tolist)
              4 CALL_METHOD              0
              6 UNPACK_SEQUENCE          5
              8 STORE_FAST               0 (a)
             10 STORE_FAST               1 (b)
             12 STORE_FAST               2 (c)
             14 STORE_FAST               3 (d)
             16 STORE_FAST               4 (e)
             18 LOAD_CONST               0 (None)
             20 RETURN_VALUE

# dis(b)
 10           0 LOAD_GLOBAL              0 (x)
              2 UNPACK_SEQUENCE          5
              4 STORE_FAST               0 (a)
              6 STORE_FAST               1 (b)
              8 STORE_FAST               2 (c)
             10 STORE_FAST               3 (d)
             12 STORE_FAST               4 (e)
             14 LOAD_CONST               0 (None)
             16 RETURN_VALUE

From the above, it seems that, if anything, function (a) has more instructions. So why is it faster?

As explained in this answer, looking at the contents of UNPACK_SEQUENCE, one can see that there are some special-cases, such as when the number of left-hand side variables is equal to the length of the right-hand side object.

So, x.tolist() under the hood uses numpy method to create a list from the array data, which allows making use of the optimization for this special case (you can check the deterioration in performance by changing the number of arguments on the left-hand side, e.g. a, *b = range(3), will work, but will be slower than a, b, c = range(3)).

When the right-hand side object is not a Python tuple or a list, then Python iterates over the contents of the object, which appears to be less efficient.

For practical reasons, if you really want best performance (with the current versions of the modules), you can swap x.tolist() with x._values.tolist(), which should give about 10-15% boost in performance (you're just removing one layer of pandas to numpy call, and doing it directly here). The caveat is that these types of optimizations are sensitive to what's happening in lower-level code, so there is no guarantee that performance gains will be there in future Python/library combinations.

为什么使用“ Tolist”访问元素比直接通过PANDAS系列访问元素?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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