offset

Taking offset of a reference member (non PODs)

霸气de小男生 提交于 2020-01-14 22:54:37
问题 Here is the code snippet #include <iostream> struct Z { Z():x(0),y(0),z(x){} ~Z(){} int x; int y; int &z; // Reference member }; template <typename Type, typename C, typename M> size_t Offsetof (M C::* ptr_to_member) { Type type; return reinterpret_cast<char*> (&(type.*ptr_to_member)) - reinterpret_cast<char*> (&type); } int main() { std::cout << Offsetof<Z>(&Z::x); // works std::cout << Offsetof<Z>(&Z::y); // works std::cout << Offsetof<Z>(&Z::z); // doesn't work } We cannot create pointer

Measuring the window offset

心已入冬 提交于 2020-01-14 22:53:47
问题 Is there a way to measure the offset of the window in jQuery, in order than I might compare the positions of a 'fixed' element and a relatively positioned one? I need to be able to tell how far the window is scrolled so I can use the figure to calculate the difference between the height of the fixed element (which is relative to the viewport top) and the relative object (which is relative to the top of the document) 回答1: $(window).scrollTop() and $(window).scrollLeft() can be used to find

How to sum every nth (200) observation in a data frame using R [duplicate]

别来无恙 提交于 2020-01-14 06:24:10
问题 This question already has answers here : calculating mean for every n values from a vector (3 answers) Closed 2 years ago . I am new to R so any help is greatly appreciated! I have a data frame of 278800 observations for each of my 10 variables, I am trying to create an 11th variable that sums every 200 observations (or rows) of a specific variable/column (sum(1:200, 201:399, 400:599 etc.) Similar to the offset function in excel. I have tried subsetting my data to just the variable of

angularJS 自定义指令 分页

十年热恋 提交于 2020-01-13 04:29:19
原理和使用说明 1、插件源码主要基于angular directive来实现。 2、调用时关键地方是后台请求处理函数,也就是从后台取数据。 3、插件有两个关键参数currentPage、itemsPerPage,当前页码和每页的记录数。 4、实现方法调用后我们需要根据每次点击分页插件页码时重新提交后台来获取相应页码数据。 在调用的页码中我使用了$watch来监控。 我初次使用时是把调用函数放在了插件的onchange中,结果发现每次都会触发两次后台。这个地方需要注意。 5、我把请求后台封装成了Service层,然后在Controller里调用,也符合MVC思想。 效果图 调用代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 <div ng-app= "DemoApp" ng-controller= "DemoController" > <table class = "table table-striped" > <thead> <tr>

Unable to get offset lags for kafka. Reason: java.lang.NullPointerException at org.apache.storm.kafk

一个人想着一个人 提交于 2020-01-13 02:23:01
问题信息 Unable to get offset lags for kafka. Reason: java.lang.NullPointerException at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil.getOffsetLags (KafkaOffsetLagUtil.java:272) at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil.main (KafkaOffsetLagUtil.java:124) 我的情况 当数据量慢慢上来的时候,这个问题就会自动解决,不知道原因,网上有如下的解决方案,请参考 问题描述: storm 起动 topology 的在 stormui 中可以看到类似错误 storm 的 KafkaSpout 接收 kafka 消息时报错,错误如下 Unable to get offset lags ``for` `kafka. Reason: java.lang.IllegalArgumentException: zk-node``'/kafka_storm/webTraceId'``dose not exists. at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil

5 郭晓阳

瘦欲@ 提交于 2020-01-12 03:54:38
第五周 第一天 数组 declare -a title = ( [ 0 ] = "ceo" [ 1 ] = "coo" [ 2 ] = "cto" ) echo ${title[1]} coo echo ${title} ceo echo ${title[2]} cto echo ${title[3]} echo ${title[@]} ceo coo cto echo ${title[*]} ceo coo cto echo ${#title[*]} (数组长度) 3 echo ${title[*]} ceo coo cto unset title [ 1 ] ( 删除数组) echo ${title[*]} ceo cto unset title echo ${title[*]} 数据处理 [ root@centos8 ~ ] #num=({0..10}) [ root@centos8 ~ ] #echo ${num[*]:2:3} (跳过两个取三个) 2 3 4 [ root@centos8 ~ ] #echo ${num[*]:6} (跳过6个) 6 7 8 9 10 [ root@centos8 ~ ] #num[${#num[@]}]=11 (追加元素) [ root@centos8 ~ ] #echo ${#num[@]} 12 [ root@centos8 ~ ]

CUDA ---- Memory Access

与世无争的帅哥 提交于 2020-01-11 21:02:42
Memory Access Patterns 大部分device一开始从global Memory获取数据,而且,大部分GPU应用表现会被带宽限制。因此最大化应用对global Memory带宽的使用时获取高性能的第一步。也就是说,global Memory的使用就没调节好,其它的优化方案也获取不到什么大效果,下面的内容会涉及到不少L1的知识,这部分了解下就好,L1在Maxwell之后就不用了,但是cache的知识点是不变的。 Aligned and Coalesced Access 如下图所示,global Memory的load/store要经由cache,所有的数据会初始化在DRAM,也就是物理的device Memory上,而kernel能够获取的global Memory实际上是一块逻辑内存空间。Kernel对Memory的请求都是由DRAM和SM的片上内存以128-byte和32-byte传输解决的。 所有获取global Memory都要经过L2 cache,也有许多还要经过L1 cache,主要由GPU的架构和获取模式决定的。如果L1和L2都被使用,那么Memory的获取是以128-byte为单位传输的,如果只使用L2,则以32-byte为单位传输,在允许使用L1的GPU中(Maxwell已经彻底不使用L1,原本走L1都换成走texture cache)

kafka--- consumer 消费消息

ぐ巨炮叔叔 提交于 2020-01-11 01:26:14
1、 consumer API kafka 提供了两套 consumer API: 1. The high-level Consumer API 2. The SimpleConsumer API 其中 high-level consumer API 提供了一个从 kafka 消费数据的高层抽象,而 SimpleConsumer API 则需要开发人员更多地关注细节。 1.1 The high-level consumer API high-level consumer API 提供了 consumer group 的语义,一个消息只能被 group 内的一个 consumer 所消费,且 consumer 消费消息时不关注 offset,最后一个 offset 由 zookeeper 保存。 使用 high-level consumer API 可以是多线程的应用,应当注意: 1. 如果消费线程大于 patition 数量,则有些线程将收不到消息 2. 如果 patition 数量大于线程数,则有些线程多收到多个 patition 的消息 3. 如果一个线程消费多个 patition,则无法保证你收到的消息的顺序,而一个 patition 内的消息是有序的 1.2 The SimpleConsumer API 如果你想要对 patition 有更多的控制权,那就应该使用

用汇编编写病毒

允我心安 提交于 2020-01-11 00:14:59
用汇编编写一个病毒 在github上看到大神用汇编编写的linux病毒,学习一下 github地址: https://github.com/cranklin/cranky-data-virus/blob/master/cranky_data_virus.asm 源码分析: ;; nasm -f elf -F dwarf -g cranky_data_virus.asm ;; ld -m elf_i386 -e v_start -o cranky_data_virus cranky_data_virus.o section .text global v_start ;代码开始处 v_start: ; virus body start ; make space in the stack for some uninitialized variables to avoid a .bss section mov ecx, 2328 ; set counter to 2328 (x4 = 9312 bytes). filename (esp), buffer (esp+32), targets (esp+1056), targetfile (esp+2080) ;不断向栈上push 0,用作全局未初始化变量空间,依次push是4个字节loop_bss: push 0x00 ; reserve

java8 AbstractStringBuilder源码

回眸只為那壹抹淺笑 提交于 2020-01-10 08:12:55
更新中... 欢迎大佬指出错误 abstract class AbstractStringBuilder implements Appendable, CharSequence { char[] value;//可变字符数组 int count; //value中非null字符数量 AbstractStringBuilder() { } AbstractStringBuilder(int capacity) {//指定初始容量的构造方法 value = new char[capacity]; } @Override public int length() {//返回长度 return count; } public int capacity() {//返回容量 return value.length; } public void ensureCapacity(int minimumCapacity) { if (minimumCapacity > 0) ensureCapacityInternal(minimumCapacity); } private void ensureCapacityInternal(int minimumCapacity) {//setLength的参数newLength if (minimumCapacity - value.length > 0) {/