problem
stringlengths
26
131k
labels
class label
2 classes
javax.management.InstanceNotFoundException: org.springframework.boot:type=Admin,name=SpringApplication : <p>I developed a Spring boot application and the functionality of the application is working fine. However, at the time of startup, I see the below exception multiple times. </p> <p>When I ran the same application a couple of weeks back I did not see any such exception. The code base has not changed after that. I am wondering if it has to do something with the environment. </p> <p>The reason for my post is I would like to understand more about the cause of the exception and how to fix it. I could not find much help when I googled. This <a href="https://stackoverflow.com/questions/26901991/spring-boot-actuator-with-multiple-web-applications-in-a-tomcat-container-throws">here</a> did not work.</p> <p>The Spring batch process extracts data from Oracle DB and writes it into a JSON file after some processing. I have posted the pom.xml.</p> <pre><code>javax.management.InstanceNotFoundException: org.springframework.boot:type=Admin,name=SpringApplication at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095) ~[na:1.8.0_161] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoaderFor(DefaultMBeanServerInterceptor.java:1444) ~[na:1.8.0_161] at com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoaderFor(JmxMBeanServer.java:1324) ~[na:1.8.0_161] at javax.management.remote.rmi.RMIConnectionImpl$6.run(RMIConnectionImpl.java:1365) ~[na:1.8.0_161] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_161] at javax.management.remote.rmi.RMIConnectionImpl.getClassLoaderFor(RMIConnectionImpl.java:1362) ~[na:1.8.0_161] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:813) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:361) ~[na:1.8.0_161] at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_161] at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_161] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_161] at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_161] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) [na:1.8.0_161] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) [na:1.8.0_161] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) [na:1.8.0_161] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_161] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) [na:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_161] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_161] </code></pre> <p><strong>POM.xml</strong></p> <p> http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0</p> <pre><code>&lt;groupId&gt;com.mySample&lt;/groupId&gt; &lt;artifactId&gt;db-extraction&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.5.10.RELEASE&lt;/version&gt; &lt;/parent&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-batch&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.oracle&lt;/groupId&gt; &lt;artifactId&gt;ojdbc7&lt;/artifactId&gt; &lt;version&gt;12.1.0.1&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.commons&lt;/groupId&gt; &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt; &lt;version&gt;3.0&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/commons-dbutils/commons-dbutils --&gt; &lt;dependency&gt; &lt;groupId&gt;commons-dbutils&lt;/groupId&gt; &lt;artifactId&gt;commons-dbutils&lt;/artifactId&gt; &lt;version&gt;1.6&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/commons-dbutils/commons-dbutils --&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.commons&lt;/groupId&gt; &lt;artifactId&gt;commons-collections4&lt;/artifactId&gt; &lt;version&gt;4.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt; &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.h2database&lt;/groupId&gt; &lt;artifactId&gt;h2&lt;/artifactId&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;downloadSources&gt;true&lt;/downloadSources&gt; &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre> <p></p>
0debug
how to concat multiple columns in sql : > SELECT EMP_HOUSE_NO,EMP_STREET_NAME,EMP_AREA,EMP_PIN_CODE > > FROM EMPLOYEE_DETAILS > > WHERE EMP_ID=1; i need to concat these columns as address
0debug
Set Shadow on Bottom UIView only : <p>I want to create bottom only shadow on UIView. Right now with this function, will create shadow in top, bottom, left, and right.</p> <pre><code>func setCardView(view : UIView){ view.layer.masksToBounds = false view.layer.shadowOffset = CGSize(width: 0, height: 0) view.layer.shadowRadius = 2 view.layer.shadowOpacity = 0.5 } </code></pre> <p>Is there anyway to only create shadow in the bottom? Any help would be appreciated. Thank you!</p>
0debug
static void qemu_event_increment(void) { static const uint64_t val = 1; ssize_t ret; if (io_thread_fd == -1) return; do { ret = write(io_thread_fd, &val, sizeof(val)); } while (ret < 0 && errno == EINTR); if (ret < 0 && errno != EAGAIN) { fprintf(stderr, "qemu_event_increment: write() filed: %s\n", strerror(errno)); exit (1); } }
1threat
Error ITMS-90206 Invalid bundle contains disallowed file 'Frameworks' : <p>I have a problem uploading my application into the Store via Xcode, this one in particular.</p> <p><a href="https://i.stack.imgur.com/g1hln.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g1hln.png" alt="Invalid Bundle contains disallowed file frameworks"></a></p> <p>I saw a lot of post about this error, but all are talking about <code>Extension App</code>, that I do not use.</p> <p>I'm using a <code>Custom framework</code> and <code>Cocoapods</code>.</p> <p>You can see here my tree :</p> <p><a href="https://i.stack.imgur.com/mXagh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mXagh.png" alt="Tree Xcode Project Custom Framework"></a></p> <ul> <li><strong>XXX</strong> is my project app name</li> <li><strong>SharedXXX</strong> is my <code>custom framework</code></li> <li><strong>Pods</strong> is the project created by <code>cocoa pods</code></li> </ul> <p>Here is my cocoa <code>podFile</code> :</p> <pre><code>use_frameworks! link_with 'XXX', 'SharedXXX' source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.1' workspace 'XXX' xcodeproj 'XXX/XXX.xcodeproj' xcodeproj 'Shared/SharedXXX.xcodeproj' def default_pods pod 'Reveal-iOS-SDK', :configurations =&gt; ['Debug'] pod "SnapKit", '~&gt; 0.17.0' pod "DKChainableAnimationKit", '~&gt; 1.6.0' pod "AsyncSwift" end def shared_pods pod "Alamofire", '~&gt; 3.0' pod 'SwiftyJSON', :git =&gt; 'https://github.com/SwiftyJSON/SwiftyJSON.git' pod 'ReachabilitySwift', :git =&gt; 'https://github.com/ashleymills/Reachability.swift' end target :XXX do xcodeproj 'XXX/XXX.xcodeproj' default_pods shared_pods end target :XXXDev do xcodeproj 'XXX/XXX.xcodeproj' default_pods shared_pods end target :SharedXXX do xcodeproj 'Shared/SharedXXXX.xcodeproj' shared_pods end </code></pre> <p>Build settings for <code>custom framework</code> (<strong>SharedXXX</strong>) :</p> <p><a href="https://i.stack.imgur.com/XE6Wl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XE6Wl.png" alt="Custom Framework build settings"></a></p> <p>I set the Embedded property to <code>Yes</code></p> <p>General Settings for <code>custom framework</code> (<strong>SharedXXX</strong>) :</p> <p><a href="https://i.stack.imgur.com/Yk639.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Yk639.png" alt="Custom Framework General Settings"></a></p> <p>The framework provided by Cocoapods is linked.</p> <p>And to finish,</p> <p>The General Settings to the main project (App Project : called <strong>XXX</strong> on the tree)</p> <p><a href="https://i.stack.imgur.com/J7oGg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J7oGg.png" alt="Main project"></a>:</p> <p>Any idea ?</p>
0debug
How can I control my website's inputs when they are entered by users? : <p>I have a question and answer website like SO. I have some limitations on some of facilities. For example an user cannot vote who has less than 20 reputation. Or an user cannot close a question until earning at least 200 reputation.</p> <p>Ok well, there is also somethings which don't have any limitation, like writing an answer for questions. In this case, <strong>a bad user</strong> can write multiple irrelevant answers for multiple questions and makes my database huge with useless information.</p> <p>So I guess I need to check something before inserting a new answer, Am I right? Or anyway, how can I manage my website's inputs? As I mentioned, in my current algorithm, a bad user <em>(like a spammer or hacker)</em> can simply enter lots of useless data in my database, and then maybe I understand it after 1 day <em>(which is too late)</em> which in this case, it takes some times to block him and remove all his data.</p> <p>In conclusion, I like to know, <em>(for example)</em>, how a website like SO handle that? Do I need a separated query before inserting a new answer for checking? Or what? </p> <p><strong>Note:</strong> I use PHP <em>(for server-side codes)</em> and MySQL <em>(for database codes)</em>.</p>
0debug
void ff_xface_generate_face(uint8_t *dst, uint8_t * const src) { int h, i, j, k, l, m; for (j = 0; j < XFACE_HEIGHT; j++) { for (i = 0; i < XFACE_WIDTH; i++) { h = i + j * XFACE_WIDTH; k = 0; for (l = i - 2; l <= i + 2; l++) { for (m = j - 2; m <= j; m++) { if (l >= i && m == j) continue; if (l > 0 && l <= XFACE_WIDTH && m > 0) k = 2*k + src[l + m * XFACE_WIDTH]; } } #define GEN(table) dst[h] ^= (table[k>>3]>>(7-(k&7)))&1 switch (i) { case 1: switch (j) { case 1: GEN(g_22); break; case 2: GEN(g_21); break; default: GEN(g_20); break; } break; case 2: switch (j) { case 1: GEN(g_12); break; case 2: GEN(g_11); break; default: GEN(g_10); break; } break; case XFACE_WIDTH - 1: switch (j) { case 1: GEN(g_42); break; case 2: GEN(g_41); break; default: GEN(g_40); break; } break; case XFACE_WIDTH: switch (j) { case 1: GEN(g_32); break; case 2: GEN(g_31); break; default: GEN(g_30); break; } break; default: switch (j) { case 1: GEN(g_02); break; case 2: GEN(g_01); break; default: GEN(g_00); break; } break; } } } }
1threat
static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx) { HEVCParserContext *ctx = s->priv_data; HEVCContext *h = &ctx->h; GetBitContext *gb; SliceHeader *sh = &h->sh; HEVCParamSets *ps = &h->ps; HEVCPacket *pkt = &ctx->pkt; const uint8_t *buf_end = buf + buf_size; int state = -1, i; HEVCNAL *nal; int is_global = buf == avctx->extradata; if (!h->HEVClc) h->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); if (!h->HEVClc) return AVERROR(ENOMEM); gb = &h->HEVClc->gb; s->pict_type = AV_PICTURE_TYPE_I; s->key_frame = 0; s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; h->avctx = avctx; if (!buf_size) return 0; if (pkt->nals_allocated < 1) { HEVCNAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp)); if (!tmp) return AVERROR(ENOMEM); pkt->nals = tmp; memset(pkt->nals, 0, sizeof(*tmp)); pkt->nals_allocated = 1; } nal = &pkt->nals[0]; for (;;) { int src_length, consumed; buf = avpriv_find_start_code(buf, buf_end, &state); if (--buf + 2 >= buf_end) break; src_length = buf_end - buf; h->nal_unit_type = (*buf >> 1) & 0x3f; h->temporal_id = (*(buf + 1) & 0x07) - 1; if (h->nal_unit_type <= NAL_CRA_NUT) { if (src_length > 20) src_length = 20; } consumed = ff_hevc_extract_rbsp(NULL, buf, src_length, nal); if (consumed < 0) return consumed; init_get_bits8(gb, nal->data + 2, nal->size); switch (h->nal_unit_type) { case NAL_VPS: ff_hevc_decode_nal_vps(gb, avctx, ps); break; case NAL_SPS: ff_hevc_decode_nal_sps(gb, avctx, ps, 1); break; case NAL_PPS: ff_hevc_decode_nal_pps(gb, avctx, ps); break; case NAL_SEI_PREFIX: case NAL_SEI_SUFFIX: ff_hevc_decode_nal_sei(h); break; case NAL_TRAIL_N: case NAL_TRAIL_R: case NAL_TSA_N: case NAL_TSA_R: case NAL_STSA_N: case NAL_STSA_R: case NAL_RADL_N: case NAL_RADL_R: case NAL_RASL_N: case NAL_RASL_R: case NAL_BLA_W_LP: case NAL_BLA_W_RADL: case NAL_BLA_N_LP: case NAL_IDR_W_RADL: case NAL_IDR_N_LP: case NAL_CRA_NUT: if (is_global) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type); return AVERROR_INVALIDDATA; } sh->first_slice_in_pic_flag = get_bits1(gb); s->picture_structure = h->picture_struct; s->field_order = h->picture_struct; if (IS_IRAP(h)) { s->key_frame = 1; sh->no_output_of_prior_pics_flag = get_bits1(gb); } sh->pps_id = get_ue_golomb(gb); if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); return AVERROR_INVALIDDATA; } if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) { ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data; ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data; } if (!sh->first_slice_in_pic_flag) { int slice_address_length; if (ps->pps->dependent_slice_segments_enabled_flag) sh->dependent_slice_segment_flag = get_bits1(gb); else sh->dependent_slice_segment_flag = 0; slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * ps->sps->ctb_height); sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0; if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", sh->slice_segment_addr); return AVERROR_INVALIDDATA; } } else sh->dependent_slice_segment_flag = 0; if (sh->dependent_slice_segment_flag) break; for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) skip_bits(gb, 1); sh->slice_type = get_ue_golomb(gb); if (!(sh->slice_type == I_SLICE || sh->slice_type == P_SLICE || sh->slice_type == B_SLICE)) { av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", sh->slice_type); return AVERROR_INVALIDDATA; } s->pict_type = sh->slice_type == B_SLICE ? AV_PICTURE_TYPE_B : sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (ps->pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); if (ps->sps->separate_colour_plane_flag) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(h)) { sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); s->output_picture_number = h->poc = ff_hevc_compute_poc(h, sh->pic_order_cnt_lsb); } else s->output_picture_number = h->poc = 0; if (h->temporal_id == 0 && h->nal_unit_type != NAL_TRAIL_N && h->nal_unit_type != NAL_TSA_N && h->nal_unit_type != NAL_STSA_N && h->nal_unit_type != NAL_RADL_N && h->nal_unit_type != NAL_RASL_N && h->nal_unit_type != NAL_RADL_R && h->nal_unit_type != NAL_RASL_R) h->pocTid0 = h->poc; return 0; } buf += consumed; } if (!is_global) av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n"); return -1; }
1threat
I cannot get NSUserdefaults to work, tried all i know, anyone had same issue? : I cant get nsuserdefaults to save a bool value, its really simple and people do it but it just simply will not save, tried everything i know, most recent attempt being this: if (_EndHide == YES) { NSDictionary *aProperties=[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]forKey:@"EndHide"]; BOOL boolValue; if([aProperties valueForKey:@"EndHide"]) boolValue =[[aProperties valueForKey:@"EndHide"] boolValue]; } else if (_EndHide == NO) { NSDictionary *aProperties=[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]forKey:@"EndHide"]; BOOL boolValue; if([aProperties valueForKey:@"EndHide"]) boolValue =[[aProperties valueForKey:@"EndHide"] boolValue]; } what happens is, i am making ios app a game for iphone, and when you dodged these well objects for period of time, you end the game and unlock a button on the start menu named endless, after the story, now i need this button to be constantly unlocked, i managed to unlock it through a scene its all working but it just wont stay unlocked, does any one have any advice to help me with this? here is the endless button configuration and bool configuration: @property(nonatomic, getter=isActive) bool EndHide; @property(nonatomic) IBOutlet UIButton *endless; thats all the code for the buttons and bools, anyway to keep it unlocked? i know its simple but it wont work maybe a deep bug i tried it on another more updated version of xcode but still to no avail, the issue is persistent and a real problem, i even tried switch saving that didnt work aswell..
0debug
Delete all character in string by sequence solve with javascript : There is a string = "WORLD" now check to maintain the sequence W,O,R,L,D first delete W , then delete O, then delete R, then delete L, last delete D. You can use a delete button and a new word generator button. solve with javascript.
0debug
remove all clasees which contain following style : how do i remove all classes which contain the following style... **HTML** <div class="viewed" style="background:#F9F0D5"> <div class="left"> <span class="title">My </span> <p>MPA </p> </div> <div class="right"> <span>5</span> </div> </div> **code sample** document.getElementsByClassName('viewed')[0].style.background:#F9F0D5)[0].remove();
0debug
GDB kind of doesn't work on macOS Sierra : <p>It is a problem that appeared when I first updated to macOS Sierra yesterday.</p> <p>GDB itself is running OK. However, somehow, it cannot run my program. When I type 'run' and 'enter', it immediately crashes with the information: <code>During startup program terminated with signal SIG113, Real-time event 113.</code></p> <p>My GDB is based on homebrew. So today, I uninstalled the whole homebrew package and reinstalled it. After the codesign step, I still faced the same error.</p> <p>I tried 'sudo' and a few other things. Google had no idea what happened. So I was wondering if you guys might have some magical solution.</p>
0debug
Client connect to server problem using winsock TCP c++ : I try to make a application that client send a message and the server respond on the same machine using winsock TCP c++. The problem is that after the server waited for client to connect, I ran the client code and it stopped at the accept and exit. This is my code. Server: #include <stdio.h> #include <tchar.h> #include <winsock2.h> #include <iostream> #define MY_PORT 8888 using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //Init Winsock WSADATA SData; if (WSAStartup(0x0202, &SData) != 0) { cout << "KHONG THE KHOI DONG WINSOCK"; return 1; } //Init Socket int listeningSocket; if ((listeningSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { perror("socket failed"); WSACleanup(); exit(EXIT_FAILURE); } //Set IP and PORT sockaddr_in server_addr; server_addr.sin_family = AF_INET; server_addr.sin_port = htons(MY_PORT); server_addr.sin_addr.s_addr = INADDR_ANY; //Bind if (bind(listeningSocket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { perror("bind failed"); closesocket(listeningSocket); WSACleanup(); exit(EXIT_FAILURE); } //Listen if (listen(listeningSocket, 5) < 0) { perror("listen failed"); closesocket(listeningSocket); WSACleanup(); exit(EXIT_FAILURE); } //Accept int new_socket; sockaddr_in client_addr; int nSizeAddr = sizeof(sockaddr); if (new_socket = accept(listeningSocket, (struct sockaddr *)&client_addr, &nSizeAddr) < 0) { perror("accept failed"); closesocket(listeningSocket); WSACleanup(); exit(EXIT_FAILURE); } while (1) { //recv char buff[100]; if (recv(new_socket, buff, 100, 0) < 0) { perror("recv failed"); closesocket(listeningSocket); WSACleanup(); exit(EXIT_FAILURE); } cout << buff << endl; //send string sndStr = "Da nhan"; if (send(new_socket, sndStr.c_str(), sndStr.size(), 0) < 0) { perror("send failed"); closesocket(listeningSocket); WSACleanup(); exit(EXIT_FAILURE); } } //close socket closesocket(new_socket); //Cleanup winsock WSACleanup(); return 0; } Client: #include <stdio.h> #include <tchar.h> #include <winsock2.h> #include <iostream> #include <string> #define MY_PORT 8888 using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //Init winsock WSADATA SData; if (WSAStartup(0x0202, &SData) != 0) { cout << "KHONG THE KHOI DONG WINSOCK"; return 1; } //Init socket int clientSocket; if (clientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) < 0) { perror("socket failed"); WSACleanup(); exit(EXIT_FAILURE); } //Set IP and PORT sockaddr_in server_addr; server_addr.sin_family = AF_INET; server_addr.sin_port = htons(MY_PORT); server_addr.sin_addr.s_addr = INADDR_ANY; //Vi Client-Server chung 1 may //Connect if (connect(clientSocket, (SOCKADDR*)&server_addr, sizeof(server_addr)) < 0) { perror("connect failed"); closesocket(clientSocket); WSACleanup(); exit(EXIT_FAILURE); } while (1) { //Send string sndStr; getline(cin, sndStr); if (send(clientSocket, sndStr.c_str(), sndStr.size(), 0) < 0) { perror("send failed"); closesocket(clientSocket); WSACleanup(); exit(EXIT_FAILURE); } //Recv char buff[100]; if (recv(clientSocket, buff, 100, 0) < 0) { perror("recv failed"); closesocket(clientSocket); WSACleanup(); exit(EXIT_FAILURE); } cout << buff << endl; } //Close socket closesocket(clientSocket); //Cleanup Winsock WSACleanup(); } It had an error at the accept step but I don't know what was the error name. How can I fix it. Thanks for all your help
0debug
I need a way to get the names of all the plugins and theme from any WordPress site : I need a way to get the names of all the plugins and theme from any WordPress site Example I will enter http://name-wordpress.com and result plugins and theme
0debug
Why am I getting a run time error(SIGSEGV) for the following code? : <p>This is the solution of the Prime Generator problem on SPOJ(Sphere online judge), I have checked and no array is out of bound, and still it is showing run time error.</p> <pre><code>#include &lt;stdio.h&gt; int main(){ int n; int i,j,a,b; scanf("%d", &amp;n); while(n){ scanf("%d %d", &amp;a, &amp;b); int arr[b]; // Filling the array for(i=2;i&lt;=b;i++){ arr[i-2]=i; } int p,c; for(p=0;p&lt;b-1;p++){ if(arr[p]){ if(arr[p]&gt;=a){ printf("\n%d", arr[p]); } for(c=p+arr[p];c&lt;b-2;c+= arr[p]){ arr[c]=0; } } } n--; } </code></pre>
0debug
static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr, unsigned int *num_sg, unsigned int max_size, int is_write) { unsigned int i; hwaddr len; #ifdef NDEBUG #error building with NDEBUG is not supported #endif assert(*num_sg <= max_size); for (i = 0; i < *num_sg; i++) { len = sg[i].iov_len; sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); exit(1); } if (len != sg[i].iov_len) { error_report("virtio: unexpected memory split"); exit(1); } } }
1threat
How Can i result this C++ code. float type or double problem? : #include <stdio.h> int main() { int i; const int N = 4; double a=0, b=0, c=0, d=0; for (i = 1 ; i <= N ; i++) { a += i; b += i * i; } c = a / N; d = b / N - c * c; printf("%.0f\n", d); return 0; } It`s result is 1 But I don`t know exactly why result is 1. I think c is 3; and N-c*c is -2.25 so d is -13 . so I think print d`s result is -13 but result is 1 why this result comes from? please help me~!!
0debug
static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode, const char *name, V9fsSynthNodeAttr *attr, int inode) { V9fsSynthNode *node; mode = ((mode & 0777) | S_IFDIR) & ~(S_IWUSR | S_IWGRP | S_IWOTH); node = g_malloc0(sizeof(V9fsSynthNode)); if (attr) { node->attr = attr; node->attr->nlink++; } else { node->attr = &node->actual_attr; node->attr->inode = inode; node->attr->nlink = 1; node->attr->mode = mode; node->attr->write = NULL; node->attr->read = NULL; } node->private = node; pstrcpy(node->name, sizeof(node->name), name); QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling); return node; }
1threat
Haven´t been able to solve this: : Can't solve this and just haven´t been able to wonder whats going wrong: SELECT CODE , NAME , BRANCH , SALESP , CASE WHEN SUM(S1) = 0 THEN NULL ELSE SUM(S1) END as S1 , CASE WHEN SUM(V1) = 0 THEN NULL ELSE SUM(V1) END as V1 , CASE WHEN SUM(CHANGE) = 0 THEN NULL ELSE SUM(CHANGE) END as CHANGE FROM SAESQL7_E03.[dbo].[p1] WHERE S1 <> 0 OR CHANGE <> 0 GROUP BY CODE , NAME , BRANCH , SALESP Resulting in: code name branch salesp s1 v1 change 1 Max A S 20 10 -5 2 Ben A 10 3 5 2 Ben B 20 5 10 The problem is in the 3rd column which is always wrong if a customer is in more than one branch. (Max´s example when customer only in one branch, always right; Ben´s example case with two or more branches, first branch always right, following branches always wrong) The table of origin has the correct data being: code name branch salesp V1 V2 change 1 Max A S 5 10 -5 2 Ben A 8 3 5 2 Ben B 10 5 10 CHANGE field comes from: SUM (V1-V2) AS CHANGE Help will be greatly appreciated!!!
0debug
int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f) { char buf[4096], *q; int c; AVFormatContext *ic = NULL; c = url_fgetc(f); while (c != URL_EOF) { for(;;) { if (!redir_isspace(c)) break; c = url_fgetc(f); } if (c == URL_EOF) break; q = buf; for(;;) { if (c == URL_EOF || redir_isspace(c)) break; if ((q - buf) < sizeof(buf) - 1) *q++ = c; c = url_fgetc(f); } *q = '\0'; if (av_open_input_file(&ic, buf, NULL, 0, NULL) == 0) break; } *ic_ptr = ic; if (!ic) return AVERROR(EIO); else return 0; }
1threat
How I Catch What Event While Action of Dynamic Child inside Dynamic Parent vice-versa : I am still not statisfy regarding Dynamic Child Inside Dynamic Parent where a lot of confusing for me and more worst how to know which once and how I can manipulate them to what I want. For yours informations I am very very new on Javascript and Jquery, but I can catch up if someone give a right directions and a rights syntax. I love clean code where from that code I can learn more and understand. Let say I have this structure html where it's same on firebugs:- <div name="div0" class="div0"> <input name="txt0" class="txt0"> <div name="div1[]" class="divL1"> 'index 0 <button class="btn1"> <button class="btn2"> <input name="txtL1_a[]" class="cLtxt1"> <input name="txtL1_b[]" class="cLtxt1"> < div name="div2[]" class="divL2"> <div id="ui-widget"> <input name="txtL2_a[]" class="cLtxt2 autosuggest"> </div> <input name="txtL2_b[]" class="cLtxt2"> </div> </div> <div name="div1[]" class="divL1"> 'index 1 <button class="btn1"> <button class="btn2"> <input name="txtL1_a[]" class="cLtxt1"> <input name="txtL1_b[]" class="cLtxt1"> < div name="div2[]" class="divL2"> <div id="ui-widget"> <input name="txtL2_a[]" class="cLtxt2 autosuggest"> </div> <input name="txtL2_b[]" class="cLtxt2"> </div> </div> Actually on my head have a lot of question but let me ask a few question first. **1.** I want to run .autosuggest where it's complicated for me because on normal form before this I can manage run it, but when .autosuggest inside dynamic parent div and located on dynamic input I cannot get a value and show a autocomplete. By given id "txtL2_a[]" function SearchText cannot performance autocomplete and don't know which index are doing that. function SearchText() { $(".autosuggest").autocomplete({ source: function (request, response) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "frmsetuptrip.aspx/GetAutoCompleteData", minLength: 3, data: "{'presearch':'" + document.getElementById('txtL2_a[]').value + "'}", dataType: "json", success: function (data) { if ((data.d).length == 0) { //$('#button9').show(); var result = [ { label: 'No matches found', value: response.term } ]; response(result); } else { response(data.d); } }, error: function (result) { alert("Error"); } }); } }); } **2.** Let say on <div name="div1[]" class="divL1"> //index 1 I need some auto fill up - let say when I fill up <input name="txtL2_a[]" class="cLtxt2 autosuggest"> //index :1 automatically value inside <input name="txtL2_b[]" class="cLtxt2"> 'Index 1 will change only based parents index. **3.** There is anyway a one function where I can catch all event and elaborate that by IF before go specific sub function or task like this pseudo code below:- $("div.div0").each(function (event) { if (event=="keyup" on child=="divL1"+index[0]){ //detect more spesific which object are doing that if (whoisdoing=="txtL1_a[]"+index[0] { //then do action etc: fill up parent input $("div0.txt0").val($(txtL1_a.index[0]).val()); } if (whoisdoing=="txtL1_b[]"+index[0] { //then do action etc: fill up childs input $("div2[index[0]].txtL2_b[index[0]].val( $(txtL1_b[index[0]]).val() ); } } //event - keypress //event - click //and many more }); I cannot find on internet regarding all this matter I mention above. If anybody have a solution or already develop that function please sharing and I believe this is not easy to handle. Anyway thanks on advance to you for reading and replying my question. Best Regards.
0debug
Folder in 32bit OS for 64bit application : <p>This may seems as a silly question but i remember once that a had an application of 64bit and installed it on 32bit windows 7. Then there was something like a virtual folder created and had all the files there. It was named VirtualStore or sth like this</p> <p>Anyone know this? </p> <p>Thanks!</p>
0debug
static inline void log_input_change(void *ctx, AVFilterLink *link, AVFilterBufferRef *ref) { char old_layout_str[16], new_layout_str[16]; av_get_channel_layout_string(old_layout_str, sizeof(old_layout_str), -1, link->channel_layout); av_get_channel_layout_string(new_layout_str, sizeof(new_layout_str), -1, ref->audio->channel_layout); av_log(ctx, AV_LOG_INFO, "Audio input format changed: " "%s:%s:%"PRId64" -> %s:%s:%u, normalizing\n", av_get_sample_fmt_name(link->format), old_layout_str, link->sample_rate, av_get_sample_fmt_name(ref->format), new_layout_str, ref->audio->sample_rate); }
1threat
String quicksort in c++ : <p>I'm trying to implement alphabet sorting using quick sort in c++ but I'm not able to do so :( </p> <p>Below is my code :</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int partition(string &amp;str, int start, int end){ int pivot = str[end-1]; int i = start; for(int j=start; j&lt;end-1 ; j++){ if(str[j]&lt;=pivot){ swap(str[j], str[i]); i++; } } swap(str[i], str[end]); return i; } void quicksort(string &amp;str, int start, int end){ if(start&lt;end){ int pIndex = partition(str, start, end); quicksort(str, start, pIndex-1); quicksort(str, pIndex+1, end); } } int main() { int t,k, end, start; string str; cin&gt;&gt;t; for(k=0;k&lt;t;k++){ cin&gt;&gt;str; end = str.size(); quicksort(str, 0, end); for(int l=0; l&lt;end; l++){ cout&lt;&lt;str[l]; } cout&lt;&lt; "\n"; } return 0; } </code></pre> <p>Please take a look at it and help me where I'm doing it wrong? :(</p> <p>Thanks in advance.</p>
0debug
void avfilter_unref_buffer(AVFilterBufferRef *ref) { if (!ref) return; av_assert0(ref->buf->refcount > 0); if (!(--ref->buf->refcount)) { if (!ref->buf->free) { store_in_pool(ref); return; } ref->buf->free(ref->buf); } if (ref->extended_data != ref->data) av_freep(&ref->extended_data); if (ref->video) av_freep(&ref->video->qp_table); av_freep(&ref->video); av_freep(&ref->audio); av_free(ref); }
1threat
AjaxContent cannot be loaded in any browsers. : <p>Why is it my ajaxContent not loaded? It was working before I created the text files and the ajax function. Now it cannot be loaded in Chrome or Firefox. What am I doing wrong?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;My website&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"&gt; function ajax(url) { $("#ajaxContent").load(url); } $(document).ready(function() { ajax('Aboutus.txt'); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="wrapper"&gt; &lt;header&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href onClick="ajax('Aboutus.txt')"&gt;About us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Menu&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Events&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Gallery&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Booking&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Shop&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Contacts&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/header&gt; &lt;article id="ajaxContent"&gt;&lt;/article&gt; &lt;footer&gt; &amp;copy; 2016 &lt;/footer&gt; &lt;/div&gt;&lt;!-- .wrapper --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
EditorConfig vs. Eslint vs. Prettier: Is it worthwhile to use them all? : <p>I am trying to set up some tools to help maintain consistency in a codebase used by multiple developers. Is it necessary to use EditorConfig, ESlint and Prettier all together? As far as I understand, EditorConfig is used to set coding styles/rules, ESlint is used to ensure code is formatted consistently by throwing warnings if code does not follow rules, and prettier is used to automatically format code based on the rules. However, I believe you can customize rules in prettier, which in turns does the job of EditorConfig. Is this true? What is the best combination of tools to use to maintain consistent code?</p>
0debug
My bash script is getting an argument but I didn't put any argument : ###My objective is to make a bash script service that creates a file when the runlevel is 5 and delete that file when the runlevel is 3. ###The problem that I got is when i got to runlevel 3 . I get : > The current lvl is : 3 and number of arguments is : 1 I am at line 10 > . The command is start ####Why it's getting start argument and I didn't pass any argument. ####I can make the script work fine if I remove the test condition on the number of arguments and let the script just delete the file when it's at lvl 3 but the thing that it tells me that the number of argument is 1 and it starts doesn't enter my mind. I have already done much research and I didn't find any solution. #! /bin/bash # chkconfig: 35 99 01 # description : some startup script #### Constants FILE="/home/ayadi/Desktop/inittp" TEMPORARY="~" CURRENT_LVL="$(runlevel | awk '{print $2}')" echo "The current lvl is : $CURRENT_LVL and number of arguments is : $# " echo "I am at line 10 . The command is $1" #### Functions start(){ if ! [[ -f "$FILE" ]]; then touch "$FILE" echo "File Created..." else echo "File Does Exist..." fi } stop(){ if [[ -f "$FILE" ]]; then rm "$FILE" echo "File Deleted..." else echo "File Does Not Exist..." fi } #### Main if [ $# -eq 0 ] then echo "Entred the arguments -eq 0" if [ "$CURRENT_LVL" == "5" ] then echo "Entred the if current lvl 5 statement" start fi if [ "$CURRENT_LVL" == "3" ] then echo "Entred the if current lvl 3 statement" stop fi else case "$1" in [sS][tT][aA][rR][tT]) if ! ([ -e "$FILE" ]) then echo "I am the case statement.the command is $1" start fi ;; [sS][tT][oO][pP]) if [ -e "$FILE" ] then stop fi ;; *) echo "Please enter start or stop" ;; esac fi
0debug
Embedding SSRS 2016 reports into another webpage without iFrame? : <p>Reporting-services 2016 (currently only available as a technical preview) comes with big-upgrades including HTML5 rendering and compliance. See: <a href="https://msdn.microsoft.com/en-us/library/ms170438.aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/ms170438.aspx</a></p> <p>My desire is to embed SSRS 2016 reports into another webpage using native mode (no Sharepoint or aspx, just pure HTML5). The traditional fashion to do this is to use an iFrame. This is an half-way okay method as it's possible to remove the toolbar, hide parameters etc but still you end up losing a lot of control over the document. This is a cross-site implementation from a different domain so I can't manipulate the contained iFrame document as I please.</p> <p><strong>Does there exist an official way to embed the report element 'natively'?</strong> I could envision a URL parameter option like <code>rs:Format=REPORTDIV</code> which serves me a html element.</p> <p>I also tried fetching the report as an image (<code>rs:Format=IMAGE&amp;rc:OutputFormat=PNG</code>) but the resulting PNG has a huge white frame (even when setting background to transparent in Report Builder) around the report element which is a no-go.</p>
0debug
static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) { int i; for(i=0; i<width; i++) { int r= src[i*3+0]; int g= src[i*3+1]; int b= src[i*3+2]; dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } }
1threat
static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); assert(in_range_b(disp)); return disp & 0x3fffffc; }
1threat
import re def replace(string, char): pattern = char + '{2,}' string = re.sub(pattern, char, string) return string
0debug
static int mp3_read_header(AVFormatContext *s) { MP3DecContext *mp3 = s->priv_data; AVStream *st; int64_t off; int ret; int i; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_MP3; st->need_parsing = AVSTREAM_PARSE_FULL_RAW; st->start_time = 0; avpriv_set_pts_info(st, 64, 1, 14112000); s->pb->maxsize = -1; off = avio_tell(s->pb); if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) ff_id3v1_read(s); if(s->pb->seekable) mp3->filesize = avio_size(s->pb); if (mp3_parse_vbr_tags(s, st, off) < 0) avio_seek(s->pb, off, SEEK_SET); ret = ff_replaygain_export(st, s->metadata); if (ret < 0) return ret; off = avio_tell(s->pb); for (i = 0; i < 64 * 1024; i++) { uint32_t header, header2; int frame_size; if (!(i&1023)) ffio_ensure_seekback(s->pb, i + 1024 + 4); frame_size = check(s->pb, off + i, &header); if (frame_size > 0) { avio_seek(s->pb, off, SEEK_SET); ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4); if (check(s->pb, off + i + frame_size, &header2) >= 0 && (header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK)) { av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %"PRId64".\n", i, off); avio_seek(s->pb, off + i, SEEK_SET); break; } } avio_seek(s->pb, off, SEEK_SET); } for (i = 0; i < st->nb_index_entries; i++) st->index_entries[i].pos += avio_tell(s->pb); return 0; }
1threat
Android Studio Image Color Filter Application : I want to make a color effect application for android. How to apply a color effect to image by code on Android Studio ? Example Images; [![enter image description here][1]][1] [![enter image description here][2]][2] I have no idea about how to implement color effects to image by code. For example if I want to implement this effects from Photoshop, what can I do ? [![enter image description here][3]][3] Final result that I want for captured photos; [![enter image description here][4]][4] [1]: https://i.stack.imgur.com/oEPhB.jpg [2]: https://i.stack.imgur.com/xMdIl.jpg [3]: https://i.stack.imgur.com/4aWtu.png [4]: https://i.stack.imgur.com/ozoMT.jpg
0debug
How to style react-select options : <p>What's the best way to style a <code>react-select</code> component's (<a href="https://github.com/JedWatson/react-select" rel="noreferrer">https://github.com/JedWatson/react-select</a>) options?</p> <p>I can target the select itself just fine, with something like:</p> <pre><code>... import Select from 'react-select' ... const styles = { fontSize: 14, color: 'blue', } &lt;Select options={[1,2,3,4]} placeholder={'Select something'} clearable={false} style={styles.select} /&gt; </code></pre> <p>The problem is, the actual options when the select is expanded remain styled as the default. How can I target these options for styling?</p> <p>Here is an example of what I'm talking about. I can style the placeholder, but not the options: <a href="https://i.stack.imgur.com/4Hgp7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Hgp7.png" alt="enter image description here"></a></p>
0debug
How to ignore a whole line of text that starts with // using a scanner class and delimiters : I am trying to read data from a .txt file, i need to be ignoring any line that starts with a // or a blank line but i can't seem to get the delimiter to work correctly. public void readVehicleData() throws FileNotFoundException { FileDialog fileBox = new FileDialog(myFrame, "Open", FileDialog.LOAD); fileBox.setVisible(true); String filename = fileBox.getFile(); File vehicleData = new File(filename); Scanner scanner = new Scanner(vehicleData).useDelimiter("\"(,\")?"); while( scanner.hasNext() ) { String lineOfText = scanner.nextLine(); System.out.println(lineOfText); } scanner.close(); } // this is a comment, any lines that start with // // (and blank lines) should be ignored AA, TF-63403, MJ09TFE, Fiat A, TF-61273, MJ09TFD, Fiat A, TF-64810, NR59GHD, Ford B , TF-68670,MA59DCS, Vauxhall B, TF-61854, MJ09TFG, Fiat B, TF-69215, PT09TAW, Peugeot C, TF-67358, NR59GHM, Ford This is the .txt file i am trying to read
0debug
static int mp_decode_layer3(MPADecodeContext *s) { int nb_granules, main_data_begin; int gr, ch, blocksplit_flag, i, j, k, n, bits_pos; GranuleDef *g; int16_t exponents[576]; if (s->lsf) { main_data_begin = get_bits(&s->gb, 8); skip_bits(&s->gb, s->nb_channels); nb_granules = 1; } else { main_data_begin = get_bits(&s->gb, 9); if (s->nb_channels == 2) skip_bits(&s->gb, 3); else skip_bits(&s->gb, 5); nb_granules = 2; for (ch = 0; ch < s->nb_channels; ch++) { s->granules[ch][0].scfsi = 0; s->granules[ch][1].scfsi = get_bits(&s->gb, 4); } } for (gr = 0; gr < nb_granules; gr++) { for (ch = 0; ch < s->nb_channels; ch++) { av_dlog(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); g = &s->granules[ch][gr]; g->part2_3_length = get_bits(&s->gb, 12); g->big_values = get_bits(&s->gb, 9); if (g->big_values > 288) { av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n"); return AVERROR_INVALIDDATA; } g->global_gain = get_bits(&s->gb, 8); if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == MODE_EXT_MS_STEREO) g->global_gain -= 2; if (s->lsf) g->scalefac_compress = get_bits(&s->gb, 9); else g->scalefac_compress = get_bits(&s->gb, 4); blocksplit_flag = get_bits1(&s->gb); if (blocksplit_flag) { g->block_type = get_bits(&s->gb, 2); if (g->block_type == 0) { av_log(s->avctx, AV_LOG_ERROR, "invalid block type\n"); return AVERROR_INVALIDDATA; } g->switch_point = get_bits1(&s->gb); for (i = 0; i < 2; i++) g->table_select[i] = get_bits(&s->gb, 5); for (i = 0; i < 3; i++) g->subblock_gain[i] = get_bits(&s->gb, 3); ff_init_short_region(s, g); } else { int region_address1, region_address2; g->block_type = 0; g->switch_point = 0; for (i = 0; i < 3; i++) g->table_select[i] = get_bits(&s->gb, 5); region_address1 = get_bits(&s->gb, 4); region_address2 = get_bits(&s->gb, 3); av_dlog(s->avctx, "region1=%d region2=%d\n", region_address1, region_address2); ff_init_long_region(s, g, region_address1, region_address2); } ff_region_offset2size(g); ff_compute_band_indexes(s, g); g->preflag = 0; if (!s->lsf) g->preflag = get_bits1(&s->gb); g->scalefac_scale = get_bits1(&s->gb); g->count1table_select = get_bits1(&s->gb); av_dlog(s->avctx, "block_type=%d switch_point=%d\n", g->block_type, g->switch_point); } } if (!s->adu_mode) { const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); assert((get_bits_count(&s->gb) & 7) == 0); av_dlog(s->avctx, "seekback: %d\n", main_data_begin); memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); s->in_gb = s->gb; init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8); #if !UNCHECKED_BITSTREAM_READER s->gb.size_in_bits_plus8 += EXTRABYTES * 8; #endif s->last_buf_size <<= 3; for (gr = 0, ch = 0; gr < nb_granules && (s->last_buf_size >> 3) < main_data_begin; gr++, ch = 0) { for (; ch < s->nb_channels && (s->last_buf_size >> 3) < main_data_begin; ch++) { g = &s->granules[ch][gr]; s->last_buf_size += g->part2_3_length; memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid)); } } skip_bits_long(&s->gb, s->last_buf_size - 8 * main_data_begin); if (get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer) { skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits); s->gb = s->in_gb; s->in_gb.buffer = NULL; } } else { gr = ch = 0; } for (; gr < nb_granules; gr++, ch = 0) { for (; ch < s->nb_channels; ch++) { g = &s->granules[ch][gr]; bits_pos = get_bits_count(&s->gb); if (!s->lsf) { uint8_t *sc; int slen, slen1, slen2; slen1 = slen_table[0][g->scalefac_compress]; slen2 = slen_table[1][g->scalefac_compress]; av_dlog(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2); if (g->block_type == 2) { n = g->switch_point ? 17 : 18; j = 0; if (slen1) { for (i = 0; i < n; i++) g->scale_factors[j++] = get_bits(&s->gb, slen1); } else { for (i = 0; i < n; i++) g->scale_factors[j++] = 0; } if (slen2) { for (i = 0; i < 18; i++) g->scale_factors[j++] = get_bits(&s->gb, slen2); for (i = 0; i < 3; i++) g->scale_factors[j++] = 0; } else { for (i = 0; i < 21; i++) g->scale_factors[j++] = 0; } } else { sc = s->granules[ch][0].scale_factors; j = 0; for (k = 0; k < 4; k++) { n = k == 0 ? 6 : 5; if ((g->scfsi & (0x8 >> k)) == 0) { slen = (k < 2) ? slen1 : slen2; if (slen) { for (i = 0; i < n; i++) g->scale_factors[j++] = get_bits(&s->gb, slen); } else { for (i = 0; i < n; i++) g->scale_factors[j++] = 0; } } else { for (i = 0; i < n; i++) { g->scale_factors[j] = sc[j]; j++; } } } g->scale_factors[j++] = 0; } } else { int tindex, tindex2, slen[4], sl, sf; if (g->block_type == 2) tindex = g->switch_point ? 2 : 1; else tindex = 0; sf = g->scalefac_compress; if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) { sf >>= 1; if (sf < 180) { lsf_sf_expand(slen, sf, 6, 6, 0); tindex2 = 3; } else if (sf < 244) { lsf_sf_expand(slen, sf - 180, 4, 4, 0); tindex2 = 4; } else { lsf_sf_expand(slen, sf - 244, 3, 0, 0); tindex2 = 5; } } else { if (sf < 400) { lsf_sf_expand(slen, sf, 5, 4, 4); tindex2 = 0; } else if (sf < 500) { lsf_sf_expand(slen, sf - 400, 5, 4, 0); tindex2 = 1; } else { lsf_sf_expand(slen, sf - 500, 3, 0, 0); tindex2 = 2; g->preflag = 1; } } j = 0; for (k = 0; k < 4; k++) { n = lsf_nsf_table[tindex2][tindex][k]; sl = slen[k]; if (sl) { for (i = 0; i < n; i++) g->scale_factors[j++] = get_bits(&s->gb, sl); } else { for (i = 0; i < n; i++) g->scale_factors[j++] = 0; } } for (; j < 40; j++) g->scale_factors[j] = 0; } exponents_from_scale_factors(s, g, exponents); huffman_decode(s, g, exponents, bits_pos + g->part2_3_length); } if (s->nb_channels == 2) compute_stereo(s, &s->granules[0][gr], &s->granules[1][gr]); for (ch = 0; ch < s->nb_channels; ch++) { g = &s->granules[ch][gr]; reorder_block(s, g); compute_antialias(s, g); compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); } } if (get_bits_count(&s->gb) < 0) skip_bits_long(&s->gb, -get_bits_count(&s->gb)); return nb_granules * 18; }
1threat
static void ahci_idp_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { AHCIState *s = opaque; if (addr == s->idp_offset) { s->idp_index = (uint32_t)val & ((AHCI_MEM_BAR_SIZE - 1) & ~3); } else if (addr == s->idp_offset + 4) { ahci_mem_write(opaque, s->idp_index, val, size); } }
1threat
static void s390_virtio_blk_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass); k->init = s390_virtio_blk_init; dc->props = s390_virtio_blk_properties; dc->alias = "virtio-blk"; }
1threat
SQL Update returning error message : <p>Still new to this and i have come to a point where i am stuck as i cannot see what is going wrong. </p> <p>I have a users page, when i click a user it opens a different page which shows user details. If i enter data in the input boxes and click update it runs update_user_data.php which should taken the new data and update the table. This however is not working. </p> <p>It is returning "Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE username= 'jRogers'' at line 1"</p> <p>Code is below. Please can anyone see where i am going wrong?</p> <pre><code>&lt;?php require '../php/config.php'; $usernameold = $_POST["username"]; $emailold = $_POST["email"]; $passwordold = $_POST["password"]; $sql = "UPDATE users SET username='$usernameold', email='$emailold', password='$passwordold', WHERE username= '" .$usernameold."'"; if ($con-&gt;query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $con-&gt;error; } ?&gt; </code></pre>
0debug
spacy Can't find model 'en_core_web_sm' on windows 10 and Python 3.5.3 :: Anaconda custom (64-bit) : <p>what is difference between <code>spacy.load('en_core_web_sm')</code> and <code>spacy.load('en')</code>? <a href="https://stackoverflow.com/questions/50487495/what-is-difference-between-en-core-web-sm-en-core-web-mdand-en-core-web-lg-mod">This link</a> explains different model sizes. But i am still not clear how <code>spacy.load('en_core_web_sm')</code> and <code>spacy.load('en')</code> differ</p> <p><code>spacy.load('en')</code> runs fine for me. But the <code>spacy.load('en_core_web_sm')</code> throws error</p> <p>i have installed <code>spacy</code>as below. when i go to jupyter notebook and run command <code>nlp = spacy.load('en_core_web_sm')</code> I get the below error </p> <pre><code>--------------------------------------------------------------------------- OSError Traceback (most recent call last) &lt;ipython-input-4-b472bef03043&gt; in &lt;module&gt;() 1 # Import spaCy and load the language library 2 import spacy ----&gt; 3 nlp = spacy.load('en_core_web_sm') 4 5 # Create a Doc object C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\spacy\__init__.py in load(name, **overrides) 13 if depr_path not in (True, False, None): 14 deprecation_warning(Warnings.W001.format(path=depr_path)) ---&gt; 15 return util.load_model(name, **overrides) 16 17 C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\spacy\util.py in load_model(name, **overrides) 117 elif hasattr(name, 'exists'): # Path or Path-like to model data 118 return load_model_from_path(name, **overrides) --&gt; 119 raise IOError(Errors.E050.format(name=name)) 120 121 OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory. </code></pre> <p>how I installed Spacy ---</p> <pre><code>(C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder) C:\Users\nikhizzz&gt;conda install -c conda-forge spacy Fetching package metadata ............. Solving package specifications: . Package plan for installation in environment C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder: The following NEW packages will be INSTALLED: blas: 1.0-mkl cymem: 1.31.2-py35h6538335_0 conda-forge dill: 0.2.8.2-py35_0 conda-forge msgpack-numpy: 0.4.4.2-py_0 conda-forge murmurhash: 0.28.0-py35h6538335_1000 conda-forge plac: 0.9.6-py_1 conda-forge preshed: 1.0.0-py35h6538335_0 conda-forge pyreadline: 2.1-py35_1000 conda-forge regex: 2017.11.09-py35_0 conda-forge spacy: 2.0.12-py35h830ac7b_0 conda-forge termcolor: 1.1.0-py_2 conda-forge thinc: 6.10.3-py35h830ac7b_2 conda-forge tqdm: 4.29.1-py_0 conda-forge ujson: 1.35-py35hfa6e2cd_1001 conda-forge The following packages will be UPDATED: msgpack-python: 0.4.8-py35_0 --&gt; 0.5.6-py35he980bc4_3 conda-forge The following packages will be DOWNGRADED: freetype: 2.7-vc14_2 conda-forge --&gt; 2.5.5-vc14_2 Proceed ([y]/n)? y blas-1.0-mkl.t 100% |###############################| Time: 0:00:00 0.00 B/s cymem-1.31.2-p 100% |###############################| Time: 0:00:00 1.65 MB/s msgpack-python 100% |###############################| Time: 0:00:00 5.37 MB/s murmurhash-0.2 100% |###############################| Time: 0:00:00 1.49 MB/s plac-0.9.6-py_ 100% |###############################| Time: 0:00:00 0.00 B/s pyreadline-2.1 100% |###############################| Time: 0:00:00 4.62 MB/s regex-2017.11. 100% |###############################| Time: 0:00:00 3.31 MB/s termcolor-1.1. 100% |###############################| Time: 0:00:00 187.81 kB/s tqdm-4.29.1-py 100% |###############################| Time: 0:00:00 2.51 MB/s ujson-1.35-py3 100% |###############################| Time: 0:00:00 1.66 MB/s dill-0.2.8.2-p 100% |###############################| Time: 0:00:00 4.34 MB/s msgpack-numpy- 100% |###############################| Time: 0:00:00 0.00 B/s preshed-1.0.0- 100% |###############################| Time: 0:00:00 0.00 B/s thinc-6.10.3-p 100% |###############################| Time: 0:00:00 5.49 MB/s spacy-2.0.12-p 100% |###############################| Time: 0:00:10 7.42 MB/s (C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder) C:\Users\nikhizzz&gt;python -V Python 3.5.3 :: Anaconda custom (64-bit) (C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder) C:\Users\nikhizzz&gt;python -m spacy download en Collecting en_core_web_sm==2.0.0 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm==2.0.0 Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB) 100% |################################| 37.4MB ... Installing collected packages: en-core-web-sm Running setup.py install for en-core-web-sm ... done Successfully installed en-core-web-sm-2.0.0 Linking successful C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\en_core_web_sm --&gt; C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder\lib\site-packages\spacy\data\en You can now load the model via spacy.load('en') (C:\Users\nikhizzz\AppData\Local\conda\conda\envs\tensorflowspyder) C:\Users\nikhizzz&gt; </code></pre>
0debug
static int vga_load(QEMUFile *f, void *opaque, int version_id) { VGAState *s = opaque; int is_vbe, i, ret; if (version_id > 2) return -EINVAL; if (s->pci_dev && version_id >= 2) { ret = pci_device_load(s->pci_dev, f); if (ret < 0) return ret; } qemu_get_be32s(f, &s->latch); qemu_get_8s(f, &s->sr_index); qemu_get_buffer(f, s->sr, 8); qemu_get_8s(f, &s->gr_index); qemu_get_buffer(f, s->gr, 16); qemu_get_8s(f, &s->ar_index); qemu_get_buffer(f, s->ar, 21); s->ar_flip_flop=qemu_get_be32(f); qemu_get_8s(f, &s->cr_index); qemu_get_buffer(f, s->cr, 256); qemu_get_8s(f, &s->msr); qemu_get_8s(f, &s->fcr); qemu_get_8s(f, &s->st00); qemu_get_8s(f, &s->st01); qemu_get_8s(f, &s->dac_state); qemu_get_8s(f, &s->dac_sub_index); qemu_get_8s(f, &s->dac_read_index); qemu_get_8s(f, &s->dac_write_index); qemu_get_buffer(f, s->dac_cache, 3); qemu_get_buffer(f, s->palette, 768); s->bank_offset=qemu_get_be32(f); is_vbe = qemu_get_byte(f); #ifdef CONFIG_BOCHS_VBE if (!is_vbe) return -EINVAL; qemu_get_be16s(f, &s->vbe_index); for(i = 0; i < VBE_DISPI_INDEX_NB; i++) qemu_get_be16s(f, &s->vbe_regs[i]); qemu_get_be32s(f, &s->vbe_start_addr); qemu_get_be32s(f, &s->vbe_line_offset); qemu_get_be32s(f, &s->vbe_bank_mask); #else if (is_vbe) return -EINVAL; #endif s->graphic_mode = -1; return 0; }
1threat
static void as_memory_range_add(AddressSpace *as, FlatRange *fr) { ram_addr_t phys_offset, region_offset; memory_region_prepare_ram_addr(fr->mr); phys_offset = fr->mr->ram_addr; region_offset = fr->offset_in_region; if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM) { phys_offset += region_offset; region_offset = 0; } if (!fr->readable) { phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD; } if (fr->readonly) { phys_offset |= IO_MEM_ROM; } cpu_register_physical_memory_log(int128_get64(fr->addr.start), int128_get64(fr->addr.size), phys_offset, region_offset, fr->dirty_log_mask); }
1threat
Reducing the running time of R code : <p>I have two tables: 1. A 140,000 X 2 data frame consists of 2 columns and 140,000 rows of text (several words long for each row). See attached file for example:</p> <p><a href="https://ufile.io/tao5g" rel="nofollow noreferrer">Table1</a></p> <ol start="2"> <li>A similar table but smaller, with only 1 column: 3,500 X 1 data frame consists of 1 column and 3,500 rows of text (one to several words long for each row). See attached file for example: </li> </ol> <p><a href="https://ufile.io/b32wl" rel="nofollow noreferrer">Table2</a></p> <p>I've written a code that runs through each one of the 140,000 rows of "Table1" and searches for the presence of any one of the words in "Table2", and the presence of the word "complex", regardless of upper/lower characters. If the code finds a match - it's written in a new data frame that I've made upfront (let's call it "Table3").</p> <p>The code is:</p> <pre><code>Table3 &lt;- data.frame(matrix(nrow = length(Table1$PDB), ncol = 3), stringsAsFactors=FALSE) names(Table3) &lt;- c("PDB", "Description", "Ligand") for (i in 1:length(Table1$Description)) { for (j in 1:length(Table2$Drug)) { if (any(tolower(unlist(strsplit(Table1$Description[i], " "))) %in% tolower(Tabe2$Drug[j])) &amp; any(tolower(unlist(strsplit(Table1$Description[i], " "))) %in% "complex")) { Table3$PDB[i] &lt;- Tabe1$PDB[i] Table3$Description[i] &lt;- Table1$Description[i] Table3$Ligand[i] &lt;- Table2$Drug[j] } print(i) print(j) } } </code></pre> <p>The code works fine but it's terribly slow. According to my calculations, it would take it around 20 days to run to finish.</p> <p>Any suggestions on how to make it faster?</p>
0debug
How can I dynamically resize a select2 input to be the same width as the selected option? : <p>I'm building a 'natural language' search form using a series of inline select inputs, using jQuery Select2 for styling. The widths of the Select2 inputs appear to be set to the width of the selected option on initialisation, which is great. I just can't work out how to get the width to update when the selected option is changed. Any ideas?</p> <p>Many thanks!</p>
0debug
Javascript - Uncaught SyntaxError: Unexpected token const : I have created an empty `div` with the id of `warning_messages` and storing that div inside a `const` using javascript but it is throwing an error: `Uncaught SyntaxError: Unexpected token const` Here is the div code: <div id="warning_messages"></div> and the javascript: const warningMessages = document.getElementById('warning_messages');
0debug
Need additional VBA code for PDF export from excel : I'm fairly new to VBA for excel and I have a macro for exporting a single sheet to PDF but need additional code to add criteria for my export. I want to only include rows that have any value in column "A" in my export. Where do I add this code? Sub RentalEquipmentList() Dim wsA As Worksheet Dim wbA As Workbook Dim strTime As String Dim strName As String Dim strPath As String Dim strFile As String Dim strPathFile As String Dim myFile As Variant On Error GoTo errHandler Set wbA = ActiveWorkbook Set wsA = Sheets("RENTALS") strTime = Format(Now(), "yyyymmdd\_hhmm") 'get active workbook folder, if saved strPath = wbA.Path If strPath = "" Then strPath = Application.DefaultFilePath End If strPath = Left(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, "\")) & "23-Portal Traveler\" 'replace spaces and periods in sheet name strName = Replace(wsA.Name, " ", "") strName = Replace(strName, ".", "_") 'create default name for savng file strName = ThisWorkbook.Sheets("General Info").Range("B8").Value _ & " Rental Equipment List " 'create default name for savng file strFile = strName & ".pdf" strPathFile = strPath & strFile 'use can enter name and ' select folder for file myFile = Application.GetSaveAsFilename _ (InitialFileName:=strPathFile, _ FileFilter:="PDF Files (*.pdf), *.pdf", _ Title:="Select Folder and FileName to save") 'export to PDF if a folder was selected If myFile <> "False" Then wsA.ExportAsFixedFormat _ Type:=xlTypePDF, _ filename:=myFile, _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=True 'confirmation message with file info MsgBox "PDF file has been created: " _ & vbCrLf _ & myFile End If exitHandler: Exit Sub errHandler: MsgBox "Could not create PDF file" Resume exitHandler End Sub I get the full sheet exported now which is fine, I just need to filter out rows based on Column "A" value. Thank you in advance for your help.
0debug
Php get parameter from SEO URL : <p>I have my seo url such as</p> <blockquote> <p><a href="http://domain.com/product/export-grade-large-size-3-tier-organizer-shelf-and-non-woven-storage-box-with-cover-21665223" rel="nofollow">http://domain.com/product/export-grade-large-size-3-tier-organizer-shelf-and-non-woven-storage-box-with-cover-21665223</a></p> </blockquote> <p>at the tail of string there is a number represented an id, which I need it for DB processing, how can I separate and get the last id? I cannot use explode because it may have long string parameter with 'dash'.</p> <p>thanks. </p>
0debug
static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds, uint8_t *buffer, uint32_t count) { uint32_t type, i; int ret; size_t new_size; uint32_t chunk_count; int64_t offset = 0; uint64_t data_offset; uint64_t in_offset = ds->data_fork_offset; uint64_t out_offset; type = buff_read_uint32(buffer, offset); if (type != 0x6d697368 || count < 244) { return 0; } out_offset = buff_read_uint64(buffer, offset + 8); data_offset = buff_read_uint64(buffer, offset + 0x18); in_offset += data_offset; offset += 204; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { s->types[i] = buff_read_uint32(buffer, offset); offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { chunk_count--; i--; offset += 36; continue; } offset += 4; s->sectors[i] = buff_read_uint64(buffer, offset); s->sectors[i] += out_offset; offset += 8; s->sectorcounts[i] = buff_read_uint64(buffer, offset); offset += 8; if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); ret = -EINVAL; goto fail; } s->offsets[i] = buff_read_uint64(buffer, offset); s->offsets[i] += in_offset; offset += 8; s->lengths[i] = buff_read_uint64(buffer, offset); offset += 8; if (s->lengths[i] > DMG_LENGTHS_MAX) { error_report("length %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->lengths[i], i, DMG_LENGTHS_MAX); ret = -EINVAL; goto fail; } update_max_chunk_size(s, i, &ds->max_compressed_size, &ds->max_sectors_per_chunk); } s->n_chunks += chunk_count; return 0; fail: return ret; }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
static void *thread_function(void *data) { GMainLoop *loop; loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); return NULL; }
1threat
ViewHolder views must not be attached when created : <p>I'm trying to create a simple RV that will show a TextView. This is my adapter:</p> <pre><code>public class MyRvAdapter extends RecyclerView.Adapter&lt;MyRvAdapter.ViewHolder&gt; { private String[] mDataset; public static class ViewHolder extends RecyclerView.ViewHolder { // each data item is just a string in this case public TextView mTextView; public ViewHolder(TextView v) { super(v); mTextView = v; } } public MyRvAdapter(String[] myDataset) { mDataset = myDataset; } @NonNull @Override public MyRvAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.text_row_item, parent, false); TextView userNameInList= v.findViewById(R.id.display_name); ViewHolder vh = new ViewHolder(userNameInList); return vh; } @Override public void onBindViewHolder(@NonNull MyRvAdapter.ViewHolder holder, int position) { holder.mTextView.setText(mDataset[position]); } @Override public int getItemCount() { return mDataset.length; } </code></pre> <p>}</p> <p>text_row_item is just a FrameLayout with a TextView inside it("display_name"). This is the eror:</p> <pre><code>java.lang.IllegalStateException: ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6687) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869) </code></pre> <p>Thank you very much!</p>
0debug
Generate md5 hash of JSON and compare in Python and JavaScript : <p>I have a use case where i have to generate <code>md5</code> hash of a <code>JSON</code> object and compare the hashes in the server and the browser.</p> <p>The browser client generates hash and then asks the server for the hash of the same resource[ which happens to be a JSON object], and compares both the hashes to decide what to do next.</p> <p>For server i am using <code>Python</code> and browser client is in <code>Javascript</code>.</p> <p>For me the hashes generated in both cases do not match. Here's my code:</p> <p><strong>Python</strong>:</p> <pre><code>&gt;&gt;&gt; import hashlib &gt;&gt;&gt; import json &gt;&gt;&gt; a = {"candidate" : 5, "data": 1} &gt;&gt;&gt; a = json.dumps(a, sort_keys = True).encode("utf-8") &gt;&gt;&gt; hashlib.md5(a).hexdigest() &gt;&gt;&gt; 12db79ee4a76db2f4fc48624140adc7e </code></pre> <p><strong>JS</strong>: I am using <a href="https://www.npmjs.com/package/md5" rel="noreferrer">md5</a> for hashing in browser</p> <pre><code>&gt; var hash = require("md5") &gt; var data = {"candidate":5, "data":1} &gt; data = JSON.stringify(data) &gt; md5(data) &gt; 92e99f0a99ad2a3b5e02f717a2fb83c2 </code></pre> <p>What is it that i am doing wrong?</p>
0debug
How to display element count in an Array? : <p>I'm trying to display the number of elements in an Array that I have made. It is a regular Array with a string as the data type. If it is possible to display the total number of elements in an Array, will the code be similar to an ArrayList's? </p> <pre><code> String[] list = new String[14]; list = new String[] {"Bob", "Sal", "Jimmy" ,"John"}; list = insert(list, "Joe", 0); list = insert(list, "Manny", list.length); list = insert(list, "Joey", list.length/2); System.out.println(Arrays.toString(list)); } public static String[] insert(String[] original, String value, int k) { String[] copy = new String[original.length + 1]; for(int i=0; i&lt;k; i++) { copy[i] = original[i]; } copy[k] = value; for(int i=k; i&lt;original.length; i++) { copy[i+1] = original[i]; } return copy; } </code></pre>
0debug
static av_cold int init_subtitles(AVFilterContext *ctx, const char *args) { int ret, sid; AVFormatContext *fmt = NULL; AVCodecContext *dec_ctx = NULL; AVCodec *dec = NULL; AVStream *st; AVPacket pkt; AssContext *ass = ctx->priv; ret = init(ctx, args, &subtitles_class); if (ret < 0) return ret; ass->track = ass_new_track(ass->library); if (!ass->track) { av_log(ctx, AV_LOG_ERROR, "Could not create a libass track\n"); return AVERROR(EINVAL); } ret = avformat_open_input(&fmt, ass->filename, NULL, NULL); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Unable to open %s\n", ass->filename); goto end; } ret = avformat_find_stream_info(fmt, NULL); if (ret < 0) goto end; ret = av_find_best_stream(fmt, AVMEDIA_TYPE_SUBTITLE, -1, -1, NULL, 0); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Unable to locate subtitle stream in %s\n", ass->filename); goto end; } sid = ret; st = fmt->streams[sid]; dec_ctx = st->codec; dec = avcodec_find_decoder(dec_ctx->codec_id); if (!dec) { av_log(ctx, AV_LOG_ERROR, "Failed to find subtitle codec %s\n", avcodec_get_name(dec_ctx->codec_id)); return AVERROR(EINVAL); } ret = avcodec_open2(dec_ctx, dec, NULL); if (ret < 0) goto end; if (dec_ctx->subtitle_header) ass_process_codec_private(ass->track, dec_ctx->subtitle_header, dec_ctx->subtitle_header_size); av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; while (av_read_frame(fmt, &pkt) >= 0) { int i, got_subtitle; AVSubtitle sub; if (pkt.stream_index == sid) { ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_subtitle, &pkt); if (ret < 0 || !got_subtitle) break; for (i = 0; i < sub.num_rects; i++) { char *ass_line = sub.rects[i]->ass; if (!ass_line) break; ass_process_data(ass->track, ass_line, strlen(ass_line)); } } av_free_packet(&pkt); avsubtitle_free(&sub); } end: if (fmt) avformat_close_input(&fmt); if (dec_ctx) avcodec_close(dec_ctx); return ret; }
1threat
PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn) { PCNetState *d; uint8_t *pci_conf; #if 0 printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n", sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD)); #endif d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState), devfn, NULL, NULL); pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE); *(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007); *(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280); pci_conf[0x08] = 0x10; pci_conf[0x09] = 0x00; pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; *(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001); *(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000); pci_conf[0x3d] = 1; pci_conf[0x3e] = 0x06; pci_conf[0x3f] = 0xff; d->mmio_index = cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d); pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE, PCI_ADDRESS_SPACE_IO, pcnet_ioport_map); pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map); d->irq = d->dev.irq[0]; d->phys_mem_read = pci_physical_memory_read; d->phys_mem_write = pci_physical_memory_write; d->pci_dev = &d->dev; pcnet_common_init(d, nd); return (PCIDevice *)d; }
1threat
Does Visual Studio 2017 support a _references.js file? : <p>my JavaScript Intellisense is broken in Visual Studio 2017. I know my _references.js file is correct as JS Intellisense works fine in VS2015.</p> <p>Any help is greatly appreciated!</p>
0debug
static void dct_error(const struct algo *dct, int test, int is_idct, int speed) { int it, i, scale; int err_inf, v; int64_t err2, ti, ti1, it1; int64_t sysErr[64], sysErrMax = 0; int maxout = 0; int blockSumErrMax = 0, blockSumErr; AVLFG prng; av_lfg_init(&prng, 1); err_inf = 0; err2 = 0; for (i = 0; i < 64; i++) sysErr[i] = 0; for (it = 0; it < NB_ITS; it++) { for (i = 0; i < 64; i++) block1[i] = 0; switch (test) { case 0: for (i = 0; i < 64; i++) block1[i] = (av_lfg_get(&prng) % 512) - 256; if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; } break; case 1: { int num = av_lfg_get(&prng) % 10 + 1; for (i = 0; i < num; i++) block1[av_lfg_get(&prng) % 64] = av_lfg_get(&prng) % 512 - 256; } break; case 2: block1[0] = av_lfg_get(&prng) % 4096 - 2048; block1[63] = (block1[0] & 1) ^ 1; break; } for (i = 0; i < 64; i++) block_org[i] = block1[i]; if (dct->format == MMX_PERM) { for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; } else if (dct->format == MMX_SIMPLE_PERM) { for (i = 0; i < 64; i++) block[idct_simple_mmx_perm[i]] = block1[i]; } else if (dct->format == SSE2_PERM) { for (i = 0; i < 64; i++) block[(i & 0x38) | idct_sse2_row_perm[i & 7]] = block1[i]; } else if (dct->format == PARTTRANS_PERM) { for (i = 0; i < 64; i++) block[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = block1[i]; } else { for (i = 0; i < 64; i++) block[i] = block1[i]; } dct->func(block); mmx_emms(); if (dct->format == SCALE_PERM) { for (i = 0; i < 64; i++) { scale = 8 * (1 << (AANSCALE_BITS + 11)) / ff_aanscales[i]; block[i] = (block[i] * scale) >> AANSCALE_BITS; } } dct->ref(block1); blockSumErr = 0; for (i = 0; i < 64; i++) { v = abs(block[i] - block1[i]); if (v > err_inf) err_inf = v; err2 += v * v; sysErr[i] += block[i] - block1[i]; blockSumErr += v; if (abs(block[i]) > maxout) maxout = abs(block[i]); } if (blockSumErrMax < blockSumErr) blockSumErrMax = blockSumErr; } for (i = 0; i < 64; i++) sysErrMax = FFMAX(sysErrMax, FFABS(sysErr[i])); for (i = 0; i < 64; i++) { if (i % 8 == 0) printf("\n"); printf("%7d ", (int) sysErr[i]); } printf("\n"); printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", is_idct ? "IDCT" : "DCT", dct->name, err_inf, (double) err2 / NB_ITS / 64.0, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); if (!speed) return; for (i = 0; i < 64; i++) block1[i] = 0; switch (test) { case 0: for (i = 0; i < 64; i++) block1[i] = av_lfg_get(&prng) % 512 - 256; if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) block1[i] >>= 3; } break; case 1: case 2: block1[0] = av_lfg_get(&prng) % 512 - 256; block1[1] = av_lfg_get(&prng) % 512 - 256; block1[2] = av_lfg_get(&prng) % 512 - 256; block1[3] = av_lfg_get(&prng) % 512 - 256; break; } if (dct->format == MMX_PERM) { for (i = 0; i < 64; i++) block[idct_mmx_perm[i]] = block1[i]; } else if (dct->format == MMX_SIMPLE_PERM) { for (i = 0; i < 64; i++) block[idct_simple_mmx_perm[i]] = block1[i]; } else { for (i = 0; i < 64; i++) block[i] = block1[i]; } ti = gettime(); it1 = 0; do { for (it = 0; it < NB_ITS_SPEED; it++) { for (i = 0; i < 64; i++) block[i] = block1[i]; dct->func(block); } it1 += NB_ITS_SPEED; ti1 = gettime() - ti; } while (ti1 < 1000000); mmx_emms(); printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name, (double) it1 * 1000.0 / (double) ti1); }
1threat
reloading visible uicollectionviewcell when nested in uitableviewcell : <p>I have a UICollection that shows a padlock on cells that locked to users who aren't logged in. The user can view the collection and then login in a modal. When the modal dismisses, I am trying to reload the cells of the table and the nested collection to remove the padlocks from the cells. </p> <p>The visible cells are not refreshing to remove the padlock. When the collection is scrolled, the cells offscreen are correct and show with padlock. I am calling reloaddata() on both the tableview and each nested collectionview.</p> <p>The code I have is separated to:</p> <h2>UIViewController</h2> <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("SectionWorkouts", forIndexPath: indexPath) as! SectionTableViewCell cell.delegate = self // Return the workouts count from the section let intIndex = indexPath.row let index = workoutSections.startIndex.advancedBy(intIndex) let currentWorkoutSectionKey = workoutSections.keys[index] if let currentWorkoutSection = workoutSections[currentWorkoutSectionKey] { cell.workoutsCollection.dataSource = sectionWorkoutsCell cell.workoutsCollection.delegate = sectionWorkoutsCell cell.updateCellWithWorkouts(currentWorkoutSectionKey, workouts: currentWorkoutSection) } } return cell } </code></pre> <h2>UITableViewCell</h2> <pre><code>class SectionTableViewCell: UITableViewCell,UICollectionViewDelegate, UICollectionViewDataSource { var workouts = [Workout]() var delegate: WorkoutCellDelegate? @IBOutlet weak var sectionTitle: UILabel! @IBOutlet weak var workoutsCollection: UICollectionView! func updateCellWithWorkouts(title: String, workouts: [Workout]){ self.sectionTitle.text = title self.workouts = workouts dispatch_async(dispatch_get_main_queue(),{ self.workoutsCollection.reloadData() }) } func numberOfSectionsInCollectionView(collectionView: UICollectionView) -&gt; Int { return 1 } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("SectionWorkoutCell", forIndexPath: indexPath) as! SectionCollectionViewCell let row = indexPath.row let workout = workouts[row] cell.configCell(workout) return cell } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int { return workouts.count } func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { let row = indexPath.row let feature = workouts[row] if let delegate = self.delegate{ delegate.didSelectWorkoutCell(feature) } } } </code></pre> <h2>UICollectionViewCell</h2> <pre><code>class SectionCollectionViewCell: UICollectionViewCell { @IBOutlet weak var imageContainer: UIView! @IBOutlet weak var image: UIImageView! @IBOutlet weak var tintOverlay: UIView! @IBOutlet weak var padlock: UIImageView! @IBOutlet weak var workoutTitle: UILabel! @IBOutlet weak var duration: UILabel! var locked = true required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } func configCell(workout: Workout){ self.workoutTitle.text = workout.name if workout.type == "Free" || AccountManager.userIsLoggedInMember() { self.setToUnLocked() }else{ self.setToLocked() } self.layoutIfNeeded() } func setToUnLocked(){ locked = false tintOverlay.alpha = 0 padlock.alpha = 0 } func setToLocked(){ locked = true tintOverlay.alpha = 0.6 padlock.alpha = 1 } } </code></pre>
0debug
How do i input 5 nummbers and check if they are odd or even ( In C language) : I am able to check if one nummber is odd or even but how do i do it iwth 5 nummbers? not exactly shure how i should do that. I tried to do it with 5 but it didn't work. [enter image description here][1] (picture where i try to do five ones) [enter image description here][1] (the picture with one integer) [1]: https://i.stack.imgur.com/jQw4f.png
0debug
How to delete files older than 5 days using only regular expression : <p>How to delete files older than 5 days based on current date.</p> <p>My File names are like that:</p> <pre><code>2016-01-01 Normal.csv 2016-01-02 Normal.csv 2016-01-03 Normal.csv 2016-01-04 Normal.csv 2016-01-05 Normal.csv 2016-01-06 Normal.csv 2016-01-07 Normal.csv </code></pre> <p>Every day one new file in coming into that folder. I want to delete older than 5 days file.</p>
0debug
static inline int GetCode(GifState * s) { int c, sizbuf; uint8_t *ptr; while (s->bbits < s->cursize) { ptr = s->pbuf; if (ptr >= s->ebuf) { if (!s->eob_reached) { sizbuf = get_byte(s->f); s->ebuf = s->buf + sizbuf; s->pbuf = s->buf; if (sizbuf > 0) { get_buffer(s->f, s->buf, sizbuf); } else { s->eob_reached = 1; } } ptr = s->pbuf; } s->bbuf |= ptr[0] << s->bbits; ptr++; s->pbuf = ptr; s->bbits += 8; } c = s->bbuf & s->curmask; s->bbuf >>= s->cursize; s->bbits -= s->cursize; return c; }
1threat
static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { H264Context *h = dst->priv_data, *h1 = src->priv_data; int inited = h->context_initialized, err = 0; int context_reinitialized = 0; int i, ret; if (dst == src) return 0; if (inited && (h->width != h1->width || h->height != h1->height || h->mb_width != h1->mb_width || h->mb_height != h1->mb_height || h->sps.bit_depth_luma != h1->sps.bit_depth_luma || h->sps.chroma_format_idc != h1->sps.chroma_format_idc || h->sps.colorspace != h1->sps.colorspace)) { h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma; av_freep(&h->bipred_scratchpad); h->width = h1->width; h->height = h1->height; h->mb_height = h1->mb_height; h->mb_width = h1->mb_width; h->mb_num = h1->mb_num; h->mb_stride = h1->mb_stride; h->b_stride = h1->b_stride; copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS)); h->sps = h1->sps; copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS)); h->pps = h1->pps; if ((err = h264_slice_header_init(h, 1)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed"); return err; } context_reinitialized = 1; #if 0 h264_set_parameter_from_sps(h); h->cur_chroma_format_idc = h1->cur_chroma_format_idc; #endif } h->linesize = h1->linesize; h->uvlinesize = h1->uvlinesize; memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); if (!inited) { for (i = 0; i < MAX_SPS_COUNT; i++) av_freep(h->sps_buffers + i); for (i = 0; i < MAX_PPS_COUNT; i++) av_freep(h->pps_buffers + i); memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr)); memcpy(&h->cabac, &h1->cabac, sizeof(H264Context) - offsetof(H264Context, cabac)); av_assert0((void*)&h->cabac == &h->mb_padding + 1); memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); memset(&h->er, 0, sizeof(h->er)); memset(&h->me, 0, sizeof(h->me)); memset(&h->mb, 0, sizeof(h->mb)); memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc)); memset(&h->mb_padding, 0, sizeof(h->mb_padding)); h->avctx = dst; h->DPB = NULL; h->qscale_table_pool = NULL; h->mb_type_pool = NULL; h->ref_index_pool = NULL; h->motion_val_pool = NULL; if (h1->context_initialized) { h->context_initialized = 0; memset(&h->cur_pic, 0, sizeof(h->cur_pic)); avcodec_get_frame_defaults(&h->cur_pic.f); h->cur_pic.tf.f = &h->cur_pic.f; ret = ff_h264_alloc_tables(h); if (ret < 0) { av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n"); return ret; } ret = context_init(h); if (ret < 0) { av_log(dst, AV_LOG_ERROR, "context_init() failed.\n"); return ret; } } for (i = 0; i < 2; i++) { h->rbsp_buffer[i] = NULL; h->rbsp_buffer_size[i] = 0; } h->bipred_scratchpad = NULL; h->edge_emu_buffer = NULL; h->thread_context[0] = h; h->context_initialized = h1->context_initialized; } h->avctx->coded_height = h1->avctx->coded_height; h->avctx->coded_width = h1->avctx->coded_width; h->avctx->width = h1->avctx->width; h->avctx->height = h1->avctx->height; h->coded_picture_number = h1->coded_picture_number; h->first_field = h1->first_field; h->picture_structure = h1->picture_structure; h->qscale = h1->qscale; h->droppable = h1->droppable; h->data_partitioning = h1->data_partitioning; h->low_delay = h1->low_delay; for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) { unref_picture(h, &h->DPB[i]); if (h1->DPB[i].f.data[0] && (ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0) return ret; } h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1); unref_picture(h, &h->cur_pic); if (h1->cur_pic.f.buf[0] && (ret = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0) return ret; h->workaround_bugs = h1->workaround_bugs; h->low_delay = h1->low_delay; h->droppable = h1->droppable; h->is_avc = h1->is_avc; copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS)); h->sps = h1->sps; copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS)); h->pps = h1->pps; copy_fields(h, h1, dequant4_buffer, dequant4_coeff); for (i = 0; i < 6; i++) h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]); for (i = 0; i < 6; i++) h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]); h->dequant_coeff_pps = h1->dequant_coeff_pps; copy_fields(h, h1, poc_lsb, redundant_pic_count); copy_fields(h, h1, short_ref, cabac_init_idc); copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1); copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1); copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT + 2, h, h1); h->sync = h1->sync; if (context_reinitialized) h264_set_parameter_from_sps(h); if (!h->cur_pic_ptr) return 0; if (!h->droppable) { err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb = h->poc_msb; h->prev_poc_lsb = h->poc_lsb; } h->prev_frame_num_offset = h->frame_num_offset; h->prev_frame_num = h->frame_num; h->outputed_poc = h->next_outputed_poc; return err; }
1threat
Why would people Cast Objects : <p>While studying the oracle docs I ran into Casting objects and I don't understand the purpose of why people would use it. </p> <p>so lets say in main you have </p> <pre><code>Person p2 = new Student(); Person p3 = new GraduateStudent(); </code></pre> <p>and then you have separate classes </p> <pre><code>class Person { } class Student extends Person { } class GraduateStudent extends Student { } </code></pre> <p>I understand that a student is person and that a graduate student is a person but why would a person write </p> <pre><code>Person s1 = new Student() </code></pre> <p>instead of </p> <pre><code>Student s1 = new Student() </code></pre>
0debug
TPMVersion tpm_backend_get_tpm_version(TPMBackend *s) { TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s); assert(k->get_tpm_version); return k->get_tpm_version(s); }
1threat
static inline int gen_iwmmxt_address(DisasContext *s, uint32_t insn, TCGv dest) { int rd; uint32_t offset; TCGv tmp; rd = (insn >> 16) & 0xf; tmp = load_reg(s, rd); offset = (insn & 0xff) << ((insn >> 7) & 2); if (insn & (1 << 24)) { if (insn & (1 << 23)) tcg_gen_addi_i32(tmp, tmp, offset); else tcg_gen_addi_i32(tmp, tmp, -offset); tcg_gen_mov_i32(dest, tmp); if (insn & (1 << 21)) store_reg(s, rd, tmp); else dead_tmp(tmp); } else if (insn & (1 << 21)) { tcg_gen_mov_i32(dest, tmp); if (insn & (1 << 23)) tcg_gen_addi_i32(tmp, tmp, offset); else tcg_gen_addi_i32(tmp, tmp, -offset); store_reg(s, rd, tmp); } else if (!(insn & (1 << 23))) return 1; return 0; }
1threat
Powershell Calculate number of lines using xml attributes values : I have one xml file say like below, <data> <fields> <artifacts> <artifact AL="68" CL="4" DL="0"> </artifact> <artifact AL="86" CL="2" DL="1"> </artifact> <artifact AL="34" CL="7" DL="0"> </artifact> <artifact AL="18" CL="1" DL="3"> </artifact> </artifacts> <dart> <bug> <fields part="Major">Yes</fields> <fields part="Major">Yes</fields> <fields part="Major">No</fields> </bug> </dart> </fields> </data> i want powershell read xml files and gives total lines (TL = AL + DL + CL) calculating each xml atrifact tags and list defects only it is Major equals Yes Thanks, sundarm
0debug
Stupid type checking in Swift : func cal(X: [Int], Y: [Int64]) -> Double { let total = Double(Y.reduce(0, +)) var z = zip(X, Y).map { pow(Double($0), 2) * Double($1) }.reduce(0, +) / Double(total) return z } I am getting this error Cannot capture 'Double' before it is declared Use of local variable 'Double' before its declaration Who the hell designed this stupid typing system!? How to fix it? Thanks!
0debug
android studio beginner level : [I get this warning everytime I get the "android" attribute into place. I am a beginner in android studio. Kindly help.][1] [1]: https://i.stack.imgur.com/1br36.png
0debug
Custom Cell Reorder Behavior in CollectionView : <p>I am able to reorder my collectionView like so:</p> <p><a href="https://i.stack.imgur.com/BbqAL.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/BbqAL.gif" alt="enter image description here"></a></p> <p>However, instead of all cells shifting horizontally, I would just like to swap with the following behavior (i.e. with less shuffling of cells):</p> <p><a href="https://i.stack.imgur.com/HLhAO.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/HLhAO.gif" alt="enter image description here"></a></p> <p>I have been playing with the following delegate method:</p> <pre><code>func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -&gt; IndexPath </code></pre> <p>however, I am unsure how I can achieve custom reordering behavior. </p>
0debug
char *object_property_print(Object *obj, const char *name, bool human, Error **errp) { StringOutputVisitor *mo; char *string; mo = string_output_visitor_new(human); object_property_get(obj, string_output_get_visitor(mo), name, errp); string = string_output_get_string(mo); string_output_visitor_cleanup(mo); return string; }
1threat
Group By and Sum for this query in SQL SERVER : I want to group by OrderNumber, Product, ConveyanceID and Trip for this below query and sum(Volume). How can I do that SELECT OD.[Customer] ,OD.[OrderNumber] 'Order#' ,OD.[Shipper] ,OD.[Product] ,OD.[Dock] 'Dock/Track' ,OD.[Lines] 'Berth/Position' ,[TAMS].[fnc_GetDelayCountByOrderNumber](OD.OrderNumber) 'Delays' ,OD.[ScheduledArrival] 'Sched .Arrival' ,OD.ActiveCheckPointStatus 'Active CheckPoint' ,OD.[CheckPointStatus] 'CheckPoint Status' ,OD.[ContractNumber] ,OD.[Direction] ,OD.[Volume] ,OD.[PreviousCheckPointStatus] ,OD.[CheckPointType] ,OD.[SourceContainer] ,OD.[DestinationContainer] ,OD.[UnitsOfMeasure] ,OD.ConveyanceID ,OD.TripId ,OD.NumberOfConveyance FROM TAMS.OrderDetail OD WHERE OrderNumber= 8394 [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/9w0kc.png
0debug
DataFrame and Dataset : <p>In spark,there always be operation like this:</p> <pre><code> hiveContext.sql("select * from demoTable").show() </code></pre> <p>When I look up the <strong><em>show()</em></strong> method in Spark Official API,the result is like this: <a href="https://i.stack.imgur.com/wyzV2.png" rel="nofollow noreferrer">enter image description here</a> And when I change the key word to 'Dataset',I Find that the method used on DataFrame belongs to Dataset. How does it happen? Is there any implication? </p>
0debug
static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth, unsigned size) { unsigned i, j; CodeBook cb = { 0 }; if (!can_safely_read(gb, size * 34)) return cb; if (size >= INT_MAX / sizeof(MacroBlock)) return cb; cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1); if (!cb.blocks) return cb; cb.depth = depth; cb.size = size; for (i = 0; i < size; i++) { unsigned mask_bits = get_bits(gb, 4); unsigned color0 = get_bits(gb, 15); unsigned color1 = get_bits(gb, 15); for (j = 0; j < 4; j++) { if (mask_bits & (1 << j)) cb.blocks[i].pixels[j] = color1; else cb.blocks[i].pixels[j] = color0; } } return cb; }
1threat
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBlock *s = opaque; if (version_id != 2) return -EINVAL; virtio_load(&s->vdev, f); while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); req->next = s->rq; s->rq = req; virtqueue_map_sg(req->elem.in_sg, req->elem.in_addr, req->elem.in_num, 1); virtqueue_map_sg(req->elem.out_sg, req->elem.out_addr, req->elem.out_num, 0); } return 0; }
1threat
Looping JSON Array : > I'm trying to make a program that will display multiple titles with > pictures under them. I looked over stackoverflow, and can't get > any of the suggestions to work for me. All my errors are within private > void ShowJSON > > package br.exemplozxingintegration; > > import android.annotation.SuppressLint; > import android.app.ProgressDialog; > import android.content.ClipData; > import android.content.ClipboardManager; > import android.content.Intent; > import android.os.Bundle; > import android.support.v7.app.AppCompatActivity; > import android.view.View; > import android.widget.Button; > import android.widget.EditText; > import android.widget.ImageView; > import android.widget.TextView; > import android.widget.Toast; > > import com.android.volley.RequestQueue; > import com.android.volley.Response; > import com.android.volley.VolleyError; > import com.android.volley.toolbox.StringRequest; > import com.android.volley.toolbox.Volley; > import com.squareup.picasso.Picasso; > > import org.json.JSONArray; > import org.json.JSONException; > import org.json.JSONObject; > > > > public class ForthActivty extends AppCompatActivity implements View.OnClickListener { > > private EditText pastetext; > private ClipboardManager myClipboard; > private ClipData myClip; > private Button btn; > private Button btn2; > private EditText textView1; > private Button buttonGet; > private TextView textViewResult; > private ImageView ImageView1; > > private ProgressDialog loading; > > > @Override > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > setContentView(R.layout.activity_forth_activty); > myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); > pastetext = (EditText) findViewById(R.id.textView1); > > btn = (Button)findViewById(R.id.buttonPaste); > btn.performClick(); > > > textView1 = (EditText) findViewById(R.id.textView1); > buttonGet = (Button) findViewById(R.id.buttonGet); > textViewResult = (TextView) findViewById(R.id.textViewResult); > ImageView1= (ImageView) findViewById(R.id.imageView1); > > buttonGet.setOnClickListener(this); > > btn2 = (Button)findViewById(R.id.buttonGet); > btn2.performClick(); > > > } > > @SuppressLint("NewApi") > public void paste(View view) { > ClipData cp = myClipboard.getPrimaryClip(); > ClipData.Item item = cp.getItemAt(0); > String text = item.getText().toString(); > pastetext.setText(text); > Toast.makeText(getApplicationContext(), "", > Toast.LENGTH_SHORT).show();} > > > private void getData() { > String qrcode = textView1.getText().toString().trim(); > if (qrcode.equals("")) { > Toast.makeText(this, "", Toast.LENGTH_LONG).show(); > return; > } > loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false); > > String url = ConfigRec.DATA_URL+textView1.getText().toString().trim(); > > StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() { > @Override > public void onResponse(String response) { > loading.dismiss(); > showJSON(response); > } > }, > new Response.ErrorListener() { > @Override > public void onErrorResponse(VolleyError error) { > Toast.makeText(ForthActivty.this,error.getMessage().toString(),Toast.LENGTH_LONG).show(); > } > }); > > RequestQueue requestQueue = Volley.newRequestQueue(this); > requestQueue.add(stringRequest); > } > > private void showJSON(String response){ > String title=""; > String image = ""; > try { > for(int response=0;response<JSONArray.length();response++) > JSONObject jsonObject = new JSONObject(response); > JSONArray result = jsonObject.getJSONArray(ConfigRec.JSON_ARRAY); > JSONObject androidData = result.getJSONObject(0); > title = androidData.getString(ConfigRec.KEY_TITLE); > image = androidData.getString(ConfigRec.KEY_IMAGE); > } catch (JSONException e) { > e.printStackTrace(); > } > textViewResult.setText(title);//+"\nImagine :\t"+ image); > //int id = >getResources().getIdentifier("http://192.168.1.254/2015/380panel/uploads/images>/sm/"+ image, null, null); > //ImageView1.setImageURI(id); > >Picasso.with(this).load("http://192.168.1.254/2015/380panel/uploads/images/sm/+ image).into(ImageView1); > > } > > > > And my errors are: Variable response is already defined in the scope Non-static method length cannot be referenced from a static context Cannot resolve constructor JSONobject(int) Cannot resolve symbol JSONobject
0debug
void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid) { KVMDevice *kd; if (!kvm_irqchip_in_kernel()) { return; } if (QSLIST_EMPTY(&kvm_devices_head)) { memory_listener_register(&devlistener, NULL); qemu_add_machine_init_done_notifier(&notify); } kd = g_new0(KVMDevice, 1); kd->mr = mr; kd->kda.id = devid; kd->kda.addr = -1; QSLIST_INSERT_HEAD(&kvm_devices_head, kd, entries); memory_region_ref(kd->mr); }
1threat
static coroutine_fn int cow_co_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { int ret; BDRVCowState *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = cow_write(bs, sector_num, buf, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
How to enable view of rulers in Chrome DevTools? : <p>Chrome DevTools previously offered a setting to show rulers when inspecting elements. It had a pixel ruler at the sides of the view, and boundary lines for each element extending the full view of the page. </p> <p>It used to be found (as I recall) in "DevTools Settings / General". There no longer is a General section, and I don't see it in "DevTools Settings / Appearance". Has this been moved, or removed? I'm not finding documentation or discussion of it. </p>
0debug
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) { int l; while (size > 0) { l = IO_BUF_SIZE - f->buf_index; if (l > size) l = size; memcpy(f->buf + f->buf_index, buf, l); f->buf_index += l; buf += l; size -= l; if (f->buf_index >= IO_BUF_SIZE) qemu_fflush(f); } }
1threat
How to print only the last result in this array? ruby : I only want to print the last result of this operation, that would be 10. How I can do that? result = 0 numbers = [1,2,3,4] numbers.map do |x| result + = x puts result end
0debug
int bdrv_set_key(BlockDriverState *bs, const char *key) { int ret; if (bs->backing_hd && bs->backing_hd->encrypted) { ret = bdrv_set_key(bs->backing_hd, key); if (ret < 0) return ret; if (!bs->encrypted) return 0; } if (!bs->encrypted) { return -EINVAL; } else if (!bs->drv || !bs->drv->bdrv_set_key) { return -ENOMEDIUM; } ret = bs->drv->bdrv_set_key(bs, key); if (ret < 0) { bs->valid_key = 0; } else if (!bs->valid_key) { bs->valid_key = 1; if (bs->blk) { blk_dev_change_media_cb(bs->blk, true); } } return ret; }
1threat
void av_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den) { unsigned int gcd= av_gcd(pts_num, pts_den); s->pts_wrap_bits = pts_wrap_bits; s->time_base.num = pts_num/gcd; s->time_base.den = pts_den/gcd; if(gcd>1) av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, gcd); }
1threat
Android Studio "Unfortunately 'the program' has stopped" : public void onClick(View v) { if (v == buttonOne) { TextView output = (TextView)findViewById(R.id.output); output.append("1"); } else if (v == buttonTwo) { TextView output = (TextView)findViewById(R.id.output); output.append("2"); } else if (v == buttonThree) { TextView output = (TextView)findViewById(R.id.output); output.append("3"); } else if (v == buttonFour) { TextView output = (TextView)findViewById(R.id.output); output.append("4"); } else if (v == buttonFive) { TextView output = (TextView)findViewById(R.id.output); output.append("5"); } else if (v == buttonSix) { TextView output = (TextView)findViewById(R.id.output); output.append("6"); } else if (v == buttonSeven) { TextView output = (TextView)findViewById(R.id.output); output.append("7"); } else if (v == buttonEight) { TextView output = (TextView)findViewById(R.id.output); output.append("8"); } else if (v == buttonNine) { TextView output = (TextView)findViewById(R.id.output); output.append("9"); } else if (v == buttonZero) { TextView output = (TextView)findViewById(R.id.output); output.append("0"); } else if(v == buttonEnter) { TextView output = (TextView)findViewById(R.id.output); temp = Integer.parseInt(output.getText().toString()); compareNumber(temp); output.setText(""); } } Hi, I am trying to compare number using button. For example, if I press buttonOne it append 1 to stack. if buttonTwo is pressed, it append 2 to stack. and For example if I press buttonOne and buttonTwo, it should store number 12(twelve). I tried this using parseInt as you can see in buttonEnter statement but when I run it the application stops. Please help!
0debug
Fragment in java error : <p>Help me to resolve this bug. This is the logcat and fragment java code. I want to make tab layout. In the tab layout, i want to fill a different java logic. But, i dont know must place the code. Please help me</p> <pre><code>04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: FATAL EXCEPTION: main 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: Process: com.prakosoft.physhics.calculator, PID: 27113 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at info.androidhive.materialtabs.fragments.OneFragment.onCreateView(OneFragment.java:39) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.view.ViewPager.populate(ViewPager.java:1177) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.view.ViewPager.populate(ViewPager.java:1025) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1545) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:664) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:731) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2618) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.View.measure(View.java:17637) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2019) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1177) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1383) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1065) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5901) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:550) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.os.Looper.loop(Looper.java:211) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5389) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 04-03 12:17:10.478 27113-27113/com.prakosoft.physhics.calculator E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) </code></pre> <p>This is fragment java code</p> <pre><code>public OneFragment() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_one, container, false); b = (EditText) getView().findViewById(R.id.b); i = (EditText) getView().findViewById(R.id.i); l = (EditText) getView().findViewById(R.id.l); hasil = (TextView) getView().findViewById(R.id.hasil); hitung = (Button) getView().findViewById(R.id.hitung); spinner = (Spinner) getView().findViewById(R.id.spinner); List&lt;String&gt; list = new ArrayList&lt;String&gt;(); list.add(""); list.add("0"); list.add("1/2"); list.add("1/2√2"); list.add("1/2√3"); list.add("1"); hitung.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String be = b.getText().toString().trim(); String ii = i.getText().toString().trim(); String el = l.getText().toString().trim(); String text = spinner.getSelectedItem().toString(); if (spinner.getSelectedItem().toString().equals("1")) { if (b.getText().toString().equals("") || i.getText().toString().equals("") || l.getText().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Isi terlebih dahulu", Toast.LENGTH_SHORT).show(); } else { Integer bee = Integer.parseInt(be); Integer iii = Integer.parseInt(ii); Integer eel = Integer.parseInt(el); Integer tekss = Integer.parseInt(text); Integer gaya = (bee * iii * eel) * tekss; hasil.setText("Gaya Lorentz = " + gaya); } } else if (spinner.getSelectedItem().toString().equals("1/2")) { if (b.getText().toString().equals("") || i.getText().toString().equals("") || l.getText().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Isi terlebih dahulu", Toast.LENGTH_SHORT).show(); } else { Integer bee = Integer.parseInt(be); Integer iii = Integer.parseInt(ii); Integer eel = Integer.parseInt(el); Integer gaya = (bee * iii * eel) / 2; hasil.setText("Gaya Lorentz = " + gaya); } } else if (spinner.getSelectedItem().toString().equals("1/2√2")) { if (b.getText().toString().equals("") || i.getText().toString().equals("") || l.getText().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Isi terlebih dahulu", Toast.LENGTH_SHORT).show(); } else { Integer bee = Integer.parseInt(be); Integer iii = Integer.parseInt(ii); Integer eel = Integer.parseInt(el); double akar = Math.sqrt(2); Integer gaya = (bee * iii * eel) / 2; double hasilakar = gaya * akar; hasil.setText("Gaya Lorentz = " + hasilakar); } } else if (spinner.getSelectedItem().toString().equals("1/2√3")) { if (b.getText().toString().equals("") || i.getText().toString().equals("") || l.getText().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Isi terlebih dahulu", Toast.LENGTH_SHORT).show(); } else { Integer bee = Integer.parseInt(be); Integer iii = Integer.parseInt(ii); Integer eel = Integer.parseInt(el); double akar = Math.sqrt(3); Integer gaya = (bee * iii * eel) / 2; double hasilakar = gaya * akar; hasil.setText("Gaya Lorentz = " + hasilakar); } } else if (spinner.getSelectedItem().toString().equals("0")) { if (b.getText().toString().equals("") || i.getText().toString().equals("") || l.getText().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Isi terlebih dahulu", Toast.LENGTH_SHORT).show(); } else { hasil.setText("Gaya Lorentz = 0"); } } else if (spinner.getSelectedItem().toString().equals("")) { Toast.makeText(getActivity().getApplicationContext(), "Pilih sin θ", Toast.LENGTH_SHORT).show(); } } }); ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); return view; } </code></pre>
0debug
how can we display long length integer values in UILabels in ios : Hi i am very new for Ios and in my app i am integrating services and after getting response from service i am storing that values in Array-list when i load that array list values in tableList showing exception like _Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x7d7ca000' McoIdArray:-( 106314100491, 106314100492, 106314100493, 106314100494, 106314100495 ) -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *simpleTableIdentifier = @"MyCell"; Cell = (CoridersCell *)[tableList dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (Cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CoridersCell" owner:self options:nil]; Cell = [nib objectAtIndex:0]; } Cell.mcoId.text = [McoIdArray objectAtIndex:indexPath.row]; return Cell; }
0debug
Redirect to index.html for S3 subfolder : <p>I have a domain <code>example.com</code>. I have a S3 bucket named <code>example.com</code> setup with an <code>index.html</code> file that works. Now I like to create two subfolders called <code>old</code> and <code>new</code>, each containing a separate version of a single page application. Requesting <code>https://example.com/old</code> (I like to omit the <code>index.html</code> when entering the request in address bar for browser) would open the <code>index.html</code> file in the <code>old</code> subfolder and requesting <code>https://example.com/new</code> would open the <code>index.html</code>. What is the best way of doing these redirects? Should I set something up in Route 53 <code>example.com/old</code> -> <code>example.com/old/index.html</code> or is there a better way of doing it?</p>
0debug
Firebase Cloud Firestore Many to Many Relationships : <p>How to structure and query data from Firebase Cloud Firestore in a many to many relationship?</p> <p>I have Companies and Contractors. A Contractor can work for more than one Company and a Company can have multiple Contractors. This is a straightforward many to many relationship. I want to be able to answer the questions about Companies and Contractors:</p> <p>Given a Company, who are the current Contractors. Given a Contractor what Companies are they working for. What is the right way for structuring the data within Cloud Firestore?</p>
0debug
Convert an async method to non-async : <p>I currently have code that looks like this:</p> <pre><code>private async Task&lt;ListFolderResult&gt; ListFolder(DropboxClient client, string path) { Console.WriteLine("--- Files ---"); var list = await client.Files.ListFolderAsync(path); return list; } </code></pre> <p>And is called like this:</p> <pre><code>var list = await ListFolder(client, path); </code></pre> <p>I would like to change that code so the call looks like this:</p> <pre><code>var list = ListFolder(client, path); </code></pre> <p>And the waiting moves to inside of the <code>ListFolder</code> method.</p>
0debug
how to Get date from input form within Mysql in PHP : how to Get date from input form within Mysql in PHP <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <tr> <td> <div class="field-row"> <label class="form-label" for="dateOfBirth">Date of birth</label> <input type="date" id="dob" class="field date-field dob-field" min="1900-01-01" max="2016-12-31" required> <span class="message"></span> </div> </td> </tr> <!-- end snippet -->
0debug
static void xen_io_del(MemoryListener *listener, MemoryRegionSection *section) { XenIOState *state = container_of(listener, XenIOState, io_listener); xen_unmap_io_section(xen_xc, xen_domid, state->ioservid, section); memory_region_unref(section->mr); }
1threat
struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem, hwaddr base, qemu_irq irq, struct omap_dma_lcd_channel_s *dma, omap_clk clk) { struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) g_malloc0(sizeof(struct omap_lcd_panel_s)); s->irq = irq; s->dma = dma; s->sysmem = sysmem; omap_lcdc_reset(s); memory_region_init_io(&s->iomem, &omap_lcdc_ops, s, "omap.lcdc", 0x100); memory_region_add_subregion(sysmem, base, &s->iomem); s->con = graphic_console_init(omap_update_display, omap_invalidate_display, omap_screen_dump, NULL, s); return s; }
1threat
Here is a link . How is the random string f6909.... Generated? : <p>I got an email for verification . <a href="http://xyz.pythonanywhere.com/record/upload/f690928d034d27ebb943b3f9bc9e3ae9/12" rel="nofollow noreferrer">http://xyz.pythonanywhere.com/record/upload/f690928d034d27ebb943b3f9bc9e3ae9/12</a>. How is the string f6909..... Generated and is there a way to find out the pattern ? Is there any function which is generating the random string for different email addresses ? </p>
0debug
static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst) { int *lendst = (int *)(dst + 1); uint8_t *bin, *ptr; int len = strlen(val); av_freep(dst); *lendst = 0; if (len & 1) return AVERROR(EINVAL); len /= 2; ptr = bin = av_malloc(len); while (*val) { int a = hexchar2int(*val++); int b = hexchar2int(*val++); if (a < 0 || b < 0) { av_free(bin); return AVERROR(EINVAL); } *ptr++ = (a << 4) | b; } *dst = bin; *lendst = len; return 0; }
1threat
Android ListView load more data from Server : <p>I have used the ListView to load the plenty of data from external server using Arrayadapter. But the problem is loading take more time . Is there any way to scroll down and load data from server . Kindly advice me . </p> <p>Thank you . </p>
0debug
I need help obj-C : - (NSString *)_stringToFloat:(NSNumber *)number { if (number && number > 0) { return [NSString stringWithFormat:@"%.2f",[number floatValue]]; } return @"0.0"; } using _lblAppointmentFee.text = [[NSString alloc]initWithFormat:@"%@",[self_stringToFloat:[_dicObject objectForKeyNotNull:@"rate"]]]; how do I can return 5.21 = 5.21 but 5.00 = 5
0debug
document.write('<script src="evil.js"></script>');
1threat
Using ':' in ID atribute : I know it's a weird question bu If I had to use the **id= cu:w** , how could I select it with jquery? <script type="text/javaScript"> $(function() { $('#cu:w').on('change', function() { $(this).hide(); }); }); </script> <fieldset> <legend>Check Here<input id='cu:w' type="checkbox"></legend> <span class="myClass"> <p>This is the text.</p> </span> </fieldset> Demo: http://jsfiddle.net/cEAnM/227/
0debug
How to check if two numbers are equal in javascript : <p>Let's say we have an array: <code>let arr = [10,10,5,11,5]</code></p> <p>How could I check for all the numbers that are equal? ( basically duplicates )</p> <p>What i thought of is a forEach and compare every number but that's not very optimal. A filter ? Maybe. Anyone has any good ideea that would be optimal?</p>
0debug
How to get the print as PDF result using jquery : <p>I would like to get the HTML page in the PDF.</p> <p>After some studies I found the pdfJS plugin, it has some problem with bootstrap , the layout will be messy</p> <p><a href="http://jsfiddle.net/5ud8jkvf/" rel="noreferrer">http://jsfiddle.net/5ud8jkvf/</a></p> <p>here is the fiddle</p> <p>I found the default print as PDF result is great </p> <p><a href="https://i.stack.imgur.com/4rl3r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4rl3r.png" alt="enter image description here"></a></p> <pre><code>var doc = new jsPDF(); var specialElementHandlers = { '#editor': function (element, renderer) { return true; } }; $('#cmd').click(function () { doc.fromHTML($('#content').html(), 15, 15, { 'width': 170, 'elementHandlers': specialElementHandlers }); doc.save('sample-file.pdf'); }); </code></pre> <p>So , instead of fixing the problem for pdfJS, I wonder are there html / jquery way to get the pdf from the print as pdf.</p> <p>The HTML need to convert to PDF is one page application form only, thanks a lot</p>
0debug