Posts

c - Exclude terminator when writing to file -

i'm receiving message through socket in c written buffer. message has terminator ( @@ ) added end know when stop writing buffer, however, buffer larger message. there way write , not including terminator, throwing away rest of buffer? maybe position pointer? char *pos; file* fp = fopen("tempfile", "w+"); pos = strstr(buffer, "@@"); pos = '\0'; // maybe stop writing null? fwrite(buffer, 1, buf_size /*too big*/, fp); fclose(fp); i need size of portion of buffer contains message, or maybe write file character. either way work. statement fwrite(buffer, 1, buf_size, fp) write buf_size bytes, regardless of actual content of buffer , regardless if contains '\0' considered "string termination". way tell fwrite correct number of elements write; , can calculated through pointer arithmetics: fwrite(buffer, 1, pos-buffer, fp) of course, you'll have check if pos != null , on; think straight forward. ...

android - How to Alias XML Arrays or Reference Them in Other Arrays? -

i have integer array set in values xml so: <integer-array name="nums"> <item>1</item> <item>2</item> <item>3</item> </integer-array> i want able reference/alias other arrays in values so: <integer-array name="@string/alias1">@integer-array/nums</integer-array> basically building hashmap inside xml. not programmatically within code itself. possible?

visual studio - C++ Using a single class in multiple other classes - Multiple definition error when compiling -

i downloaded library arduino communicate mcp23017 chip via i2c. goal use 1 class in various files have different functions, library of things chip. after building code run 7-segment multiplexed display, compiled fine , able load onto arduino. after writing class use second chip inputs only, started getting compile errors due multiple definitions of base class. i'm used coding in vb, not c++, having define classes pretty confusing, , not sure fix it. here error: (this snippet of error, since gist of section enough think. every routine in adafruit_mcp23017.cpp file has error.) adafruit_mcp23017.cpp.o (symbol plugin)*: in function adafruit_mcp23017::bitforpin(unsigned char) (.text+0x0)*: multiple definition of adafruit_mcp23017::readgpio(unsigned char) adafruit_mcp23017.cpp.o (symbol plugin)*: (.text+0x0): first defined here mainfile header: #include <arduino.h> #include <wire.h> #include <unistd.h> #include "sevensegmentdisplay_mcp23017.h" #...

css - Accessibility of Hamburger Menu? -

i working on making responsive website accessible , wonder whether blind person opens page on smartphone able open hidden menu somehow, or if he/she "sees" anyway - read screen reader? my "hamburger menu" has structure this: <div class="menu-icon">click here open or close menu</div> <nav id="navigation" role="navigation" tabindex="0" > <ul> <li><a href="...">...</a></li> <li><a href="...">...</a></li> <li><a href="...">...</a></li> <li><a href="...">...</a></li> <li><a href="...">...</a></li> </ul> </nav> the related css follows (first general rules, media queries mobile): .menu-icon { display: none; } nav { display: block; } @media screen , (max-width: 850px) { .m...

amazon web services - AWS with Fortigate - How to access two web servers in a DMZ? -

i'm trying configure fortigate-firewall in aws 2 web servers in dmz. according the below link, 1 can create port forwarding rule access dmz server (rdp in case). http://docs.fortinet.com/uploaded/files/2082/fortigate-aws-deployment.pdf but understand, if have 2 web servers need external ip external port same. i have tried configure 2 private ips & 2 elastic ips the network interface of firewall , add secondary ip external leg without success. what missing?

SQL query to exclude rows within same table with duplicate field values -

i'll try brief. i have single table need data from, contacts. there company field , can in either company or company b. all contacts in company b have duplicate in company a, can matched column legacyid . what i'm trying company rows not have in company b same legacyid . i've tried and legacyid not in (select legacyid contacts company = 'b') and not exists (select legacyid contacts company = 'b') . neither of above work because there 260,000 company contacts , 96,000 company b. not in , not exists worked when there less 50,000 rows total, data migration, query timing out or running forever. thanks if understand correctly, not exists should want: select c.* contacts c companyid = 'a' , not exists (select 1 contacts c2 c2.legacyid = c.legacyid , c2.companyid = 'b' ); for performance, want index on contacts(legacyid, companyid) .

Capabilities error after using selenium grid and Webdriver manager -

i have been using [webdriver manager][1] local executions, has been outstanding, right i'm trying use selenium grid , use same approach i'm getting errors related capabilities. the hub , node localhost, these details of implementation: i'm starting hub line: start cmd /k java -jar selenium-server-standalone-3.5.0.jar -role hub -port 4443 i'm starting node line start cmd /k java -jar selenium-server-standalone-3.5.0.jar -port 5556 -role node -hub http://localhost:4443/grid/register this configuration i'm using browsers, problem chrome, haven't tested other ones yet. public webdriver cbt(string browser, string methodname) throws exception{ webdriver driver; desiredcapabilities caps; //check if parameter passed testng 'firefox' if(browser.equalsignorecase("firefox")) { caps = desiredcapabilities.firefox(); caps.setcapability("platform", "win...