each

$().each vs $.each vs for loop in jQuery?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I Can't understand why it is happening. I read here that : The first $.each constitutes a single function call to start the iterator. The second $(foo.vals).each makes three function calls to start the iterator. The first is to the $() which produces a new jQuery wrapper set (Not sure how many other function calls are made during this process). Then the call to $().each. And finally it makes the internal call to jQuery.each to start the iterator. In your example, the difference would be negligible to say the least. However, in a nested use

Get HWND of each Window?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am developing a python application and I want to get the HWND of each open windows. I need the name of the windows and the HWND to filter the list to manage some specifics windows, moving and resizing them. I have tried to do it myself looking information around but I did not get the correct piece of code. I tried with this code but I only get the title of each windows (that is great), but I need the HWND too. import ctypes import win32gui EnumWindows = ctypes.windll.user32.EnumWindows EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool,

How do I fetch the content for each tab using AJAX? Rails4, Bootstrap3

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have 4 tab sections in an Event page view. I have it working where ALL the content for each tab is fetched and rendered when an Event page is requested. This doesn't seem like a good solution for scalability... How do I fetch the content for each tab using AJAX when a tab is clicked on? (First time doing it... looks simple in theory but failing to get it working) I tried adding remote: true to the tab links but that doesn't play well with the in-page references - it makes the same get request Events#Show for all the tabs which makes it

jquery: reverse an order

≯℡__Kan透↙ 提交于 2019-12-03 02:25:28
How can I reverse an order with jquery? I tried with the suggestion like this but it won't work! $($(".block-item").get().reverse()).each(function() { /* ... */ }); Have a look here . I want the boxed to be rearranged like this, 18 17 16 etc Thanks. If you have a container around the list, it's a little easier: $("#container").append($(".block-item").get().reverse()); http://jsfiddle.net/BhTEN/12/ You can use this: $($(".block-item").get().reverse()).each(function (i) { $(this).text(++i); }); Demo here . Second demo here (changing the DOM elements positioning). Another way, using also jQuery

Enumerate each row for each group in a DataFrame

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: In pandas, how can I add a new column which enumerates rows based on a given grouping? For instance, assume the following DataFrame: import pandas as pd import numpy as np a_list = [ 'A' , 'B' , 'C' , 'A' , 'A' , 'C' , 'B' , 'B' , 'A' , 'C' ] df = pd . DataFrame ({ 'col_a' : a_list , 'col_b' : range ( 10 )}) df col_a col_b 0 A 0 1 B 1 2 C 2 3 A 3 4 A 4 5 C 5 6 B 6 7 B 7 8 A 8 9 C 9 I'd like to add a col_c that gives me the Nth row of the "group" based on a grouping of col_a and sorting of col_b . Desired output: col_a col_b col_c 0

Get the first element of each tuple in a list in Python

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: An SQL query gives me a list of tuples, like this: [(elt1, elt2), (elt1, elt2), (elt1, elt2), (elt1, elt2), (elt1, elt2), ...] I'd like to have all the first elements of each tuple. Right now I use this: rows = cur.fetchall() res_list = [] for row in rows: res_list += [row[0]] But I think there might be a better syntax to do it. Do you know a better way? 回答1: Use a list comprehension : res_list = [x[0] for x in rows] Below is a demonstration: >>> rows = [(1, 2), (3, 4), (5, 6)] >>> [x[0] for x in rows] [1, 3, 5] >>> Alternately, you could

How to use eigenvectors obtained through PCA to reproject my data?

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using PCA on 100 images. My training data is 442368x100 double matrix. 442368 are features and 100 is number of images. Here is my code for finding the eigenvector. [ rows, cols] = size(training); maxVec=rows; maxVec=min(maxVec,rows); train_mean=mean(training,2); A=training-train_mean*ones(1,cols); A=A'*A; [evec,eval]=eig(A); [eval ind] = sort(-1*diag(eval)); evec= evec(:, ind(1:100)); Now evec is an eigenvector matrix of order of 100x100 double and now I have got 100 eigenvectors sorted. Questions: Now, if I want to transform my

ggplot: arranging boxplots of multiple y-variables for each group of a continuous x

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to create boxplots of multiple variables for groups of a continuous x-variable. The boxplots should be arranged next to each other for each group of x. The data looks like this: require (ggplot2) require (plyr) library(reshape2) set.seed(1234) x <- rnorm(100) y.1 <- rnorm(100) y.2 <- rnorm(100) y.3 <- rnorm(100) y.4 <- rnorm(100) df <- as.data.frame(cbind(x,y.1,y.2,y.3,y.4)) which I then melted dfmelt <- melt(df, measure.vars=2:5) The facet_wrap as shown in this solution ( Multiple plots by factor in ggplot (facets) ) gives me

用漂亮的图表展示爬取到的数据

家住魔仙堡 提交于 2019-12-03 02:13:59
经过了前面的努力,我们成功获取到了数据,并且学会了保存,但是只是用网页展示出来,是不是有一些不够美观呢? 所以本节的内容是:数据的可视化。拿到了数据却不能使其简单易懂并且足够突出,那就是不是好的数据工程师。 效果图: 部分效果图 本节需要做的准备: 安装pyecharts这个Python的图表库,在之前我们安装了requests、lxml、bs4。所以只需要再在cmd里面 pip3 install pyecharts 就OK啦,如果失败,请仔细阅读教程: 爬虫入门教程⑥—安装爬虫常用工具包 pyecharts简介 这是百度echarts图表库,使用Python接口进行生成图表的一个库,非常炫酷。在之前绘图基本上是用的【Matplotlib】这个库,这个库功能非常强大,但是缺点也比较明显,api调用比较复杂,新手上手很慢也很难。于是在去年, 陈键冬 大佬推出了一个简单易用的绘图库 pyecharts 。 我当时怀着试一试的心情使用了一下,哇,超好用的,对新手超友好的,代码和图都写出来了,非常详细,同时配置项也非常清晰。 一口气画5个图都超快超简单的~! 确定可视化的目标 这是很重要的一步,先确认哪些数据值得拿来可视化,然后再去编写代码。一部电影的信息有:名字、上映日期、地区、类型、关注者数量。最明显的当然是 关注者数量排行榜(柱状图) ,除此之外我还想了几个: 上映电影类型占比(饼图

How to get each device's IP address in Wi-Fi Direct scenario?

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Starting from ICS, Wi-Fi Direct is introduced. Normally, we use the WifiP2pManager class to operate on Wi-Fi Direct, but it seems that it can only retrieve the GroupOwner IP address after connected. But, actually, any device all came negotiate to become the GroupOwner. In Upper Application, we need to get the peer's IP address, or each peer's IP address in a group so that we can send/communicate with them. How to get each IP address in Wi-Fi Direct? Include own IP address and each peer in the group? 回答1: I encountered the same