Posts

c++ - Performance difference of iostream console output between Windows and OSX? -

given following simple loop: int main (void) { (int = 0 ; < 1000000; i++) { std::cout<<i<<std::endl; } } running code on clean windows 8 professional using microsoft visual studio 2012 takes 15 secs every 100k prints. on mac os x , using same computer , takes barely 3 secs xcode output 1 mill lines. i'm 100% sure has nothing performance , related output mechanics or something. can confirm this..? know windows & visual studio fine. std::endl flush line. quite expensive this. try : std::cout << << '\n'; in other usual interactive i/o scenarios, std::endl redundant when used std::cout because input std::cin, output std::cerr, or program termination forces call std::cout.flush(). use of std::endl in place of '\n' , encouraged sources, may degrade output performance. source edit : output operation costly , depend on external factors. why slow here. example, terminal applicatio...

android - What are arguments in favor of fragments vs. view flipping in this context? -

i amateur hobbyist has been working on trivia game past several weeks. first version of game works user perspective, code super messy , i'm writing second version of game scratch. i'm making significant change way game moves between pages, converting view flipping use of fragments. based on research far, think new design more in line best practices, not sure understand how arguments , against use of fragments apply game. design #1. old design relied on 3 activity files: mainactivity served splash page allowed users select appropriate difficulty level, gameactivity delivered both trivia questions and answers of viewflipper, , scoreactivity reported user's score while making sure highestscoreachieved recorded in preferences. design #2. new design rely on single activity file single fragment container , 4 fragments. startfragment splash page, questionfragment question page, answerfragment answer page, , scorefragment reports final game score. i think fragment-based ...

fragment - Filtering listview data of simple_list_item_2 items using searchview and arrayadapter -

i'm writing android application (min api 14) consists of 3 tabs hold fragment each. 1 of fragments holds list view (with list view item defined simple_list_item_2) , search view. now, i'm trying filter data in list view room's name (room model) protected searchview searchview; protected listview view; protected list<room> rooms; protected arrayadapter<room> roomadapter; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(getlayoutid(), container, false); view = (listview)rootview.findviewbyid(getlistviewid()); searchview = (searchview)rootview.findviewbyid(r.id.rooms_search_view); view.settextfilterenabled(true); .... roomadapter = new arrayadapter<room>(this.getactivity(), android.r.layout.simple_list_item_2, rooms){ @override public view getvie...

hide DIV when radio button is clicked with Javascript -

i want hide div when radio button clicked, cannot figure out life of me.. here code: <li> residential&nbsp;&nbsp;&nbsp; <input type="radio" name="fee" id="residential" class="app_fee" value="<?php echo "$applicationfee_residential" ?>" onchange="mech_application.fee1.value = eval(mech_application.residential.value)" <?php if (isset($_post['fee'])) { print($residentialyes ? "checked" : ""); } ?> /> </li> <li> apartment/commercial <input type="radio" name="fee" id="apartment" class="app_fee" value="<?php echo "$applicationfee_apartment" ?>" onchange="mech_application.fee1.value = eval(mech_application.apartment.value)" <?php if (i...

python - pypdf for lists of pdfs -

i have got pypdf work fine single pdf file, can not seem work lits of files, or in loop multiple pdfs, without failing because of string not being callable. ideas can use work around? def getpdfcontent(path): content = "" # load pdf pypdf pdf = pypdf.pdffilereader(file(path, "rb")) # iterate pages in range(0, pdf.getnumpages()): # extract text page , add content content += pdf.getpage(i).extracttext() + "\n" # collapse whitespace content = " ".join(content.replace(u"\xa0", " ").strip().split()) return content #print getpdfcontent(r"z:\gis\masterpermits\12300983.pdf").encode("ascii", "ignore") #find pdfs root, dirs, files in os.walk(folder1): file in files: if file.endswith(('.pdf')): d=os.path.join(root, file) print getpdfcontent(d).encode("ascii", "ignore") traceback (m...

dc.js - Simple line chart in DC and CrossFilter -

i have data this var data = [{date:'2013/01/01', claimno:1}, {date:'2013/01/01', claimno:2}, {date:'2013/01/02', claimno:3}] i want plot line chart in dc days on x-axis , total # of claims on y-axis. i have code this var ndx = crossfilter(data); data.foreach(function (e) { e.dd = dateformat.parse(e.dd); e.month = d3.time.month(e.dd); }); var datedim = ndx.dimension(function (d) { return d.dd; }); var datesclaimsgroup = datedim.group(); var claimslinechart = dc.linechart("#claims-line-chart"); claimslinechart .width(200) .height(40) .renderarea(true) .margins({ top: 0, left: -1, right: 2, bottom: 1 }) .group(datesclaimsgroup) .dimension(datedim) .x(d3.time.scale().domain([data[0].dd, data[data.length - 1].dd])) .title(function (d) { return d.value; }); the chart plotted values in y-axis date occurance counts , not claim counts. know supposed use function...

A bundle with Infinite Loop on Equinox OSGI Framework -

i have bundle running infinite loop on equinox osgi framework. because of bundle, not able start new bundle when run framework again. how can stop bundle in situation? here command type start framework: java -jar org.eclipse.osgi_3.9.0.v20130529-1710.jar -console it shows message infinitely: hello world! hello world! hello world! hello world! hello world! ........... answering question answer how stop osgi bundle while executing method, , if allowed or not. i assume bundle has entered infinite loop in bundleactivator.start method, , therefore tied osgi callback. not should do!! have no choice shutdown jvm, perhaps forcibly. now problem stop bundle being started again automatically next time launch osgi. simplest way ensure delete "storage" directory osgi remembers list of bundles started last time ran. unfortunately storage directory location subject configuration property , have not specified how have configured osgi. default equinox configuration/o...