Posts

Showing posts from June, 2010

SQL - Get AVG from count from another table -

so have 2 tables: listing , reviews. try listing best reviews, based in state. need avg reviews listing , desc listings. table structure: listing: id; title; state; ... reviews: id; listing_id; rating (from 1-5) i solve desc listing of reviews try avg of rating of reviews. select *, (select count(*) reviews rv ls.id = rv.listing_id) count listing ls ls.state ='$get_state' order count desc sample data: listing: id title state 1 hotel nice view arizona 2 hotel stay arizona review: id listing_id rating 1 1 4(stars) 2 1 4(stars) 3 1 3(stars) 4 2 5(stars) listing id 1 got 3 reviews , total star value of 11 / 3 reviews = 3.6 stars listing id 2 got 1 review , total star value of 5 / 1 = 5 stars now should first listing 2 , listing 1 want display whole thing on php page. what can next? help you can use avg() function average rating select ls.id,

java - Detecting planes and tap events with ARCore -

i'm trying understand google's arcore api , pushed sample project ( java_arcore_hello_ar ) github . in example, when deploy app android, horizontal surfaces/planes detected. if tap on detected plane, "andy" andrid robot rendered in location tap. pretty cool. i'm trying find in code: thats horizontal surface/plane gets detected; and where logic lives resize & re-orient andy correctly (i assume if point tap further away camera, rendered small, etc.) i believe when planes detected, android framework calls onsurfacecreated method: @override public void onsurfacecreated(gl10 gl, eglconfig config) { gles20.glclearcolor(0.1f, 0.1f, 0.1f, 1.0f); // create texture , pass arcore session filled during update(). mbackgroundrenderer.createonglthread(/*context=*/this); msession.setcameratexturename(mbackgroundrenderer.gettextureid()); // prepare other rendering objects. try { mvirtualobject.createonglthread(/*context=*/t

php - Using array_filter() with a callback that returns an array -

i have data this: a|b|c|d|e|f|g h|i|j|k|l|m|n o|p|q|r|s|t|u i can use explode("\n", $data) array of lines (this ~4.0gb file), want make multi-dimensional array using explode() based on vertical pipe. here tried: $data = explode("\n", './path-to-file.txt'); $results = array_filter($data, function ($el) { return explode('|', $el); }); however, results in single-dimensional array original line in string form. how can use array_filter() callback happens return array? edit: could use foreach($data $datum) , explode() way, when tried that, utilized 4 times amount of ram size of file, , not desirable. seems perfect opportunity use callback function, seemingly cannot array_filter() . array_filter() filters elements include or exclude them , expects true include element or false exclude. use array_map() : $data = explode("\n", './path-to-file.txt'); $results = array_map(function ($el) { return explo

amazon web services - Scheduling SQS messages -

my use case follows: need able schedule sqs messages in such way scheduled messages can added queue on specific date/time, , on recurring basis needed. at implementation level, i'm looking have function can call pass in sqs queue, message, , schedule want run on, without having build actual scheduler logic. i haven't seen in aws seems allow that, didn't impression lambda functions need unless i'm missing something. is there other third party cloud service scheduled processes should into, or better off in end running scheduling machine @ aws , have rest api can add cron jobs/windows scheduled tasks handle scheduling of sqs messages? i see 2 different ways of accomplishing this, both based on cloudwatch scheduled events . first have cloudwatch fire off lambda. lambda either have needed parameters or them somewhere else - example, dynamodb table. otherwise, rule target allows specify sqs queue - skipping lambda. i'm not sure if have configuration

linux - Using CMake to find symbols in libraries -

i trying use cmake find if external library depends on library. example: hdf5 library can optionally linked zlib in linux, can found with readelf -ws /usr/local/lib/libhdf5.so | grep inflateend 54: 0000000000000000 0 func global default und inflateend with cmake seems can found checklibraryexists https://cmake.org/cmake/help/v3.0/module/checklibraryexists.html in cmake script set(cmake_required_libraries ${hdf5_library}) check_library_exists(${hdf5_library} inflateend "" need_zlib) message(${need_zlib}) if (need_zlib) message("-- zlib library needed...") else() message("-- zlib library not needed...") endif() output not found -- looking inflateend in /usr/local/lib/libhdf5.so - not found -- zlib library not needed... because of did cmake version of using readelf, finds symbol but, still know why above cmake script fails :-) the working version is set(have_read_symbols "no") find_program(read_symbols_prg reade

java - Send File WhatsApp via SQlite -

i've developed routine inserts directly android sqlite database rooted, upload in whatsapp. messages come out after 40 seconds. need send video, audio , image files should not same procedure. tried doing manually , looked @ tables, after playing via app, not send. has tried yet?

kendo ui - KendoGrid Filter not full width -

Image
i using kendogrid , using bootstrap, in _layout have <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.223/styles/kendo.common-bootstrap.min.css" /> <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.223/styles/kendo.blueopal.min.css" /> its placement after bootstraps css. the code generates grid function showdepartmentgrid(a) { $('#department-grid').kendogrid({ norecords: { template: "no records." }, datasource: { data: }, schema: { model: { fields: { departmentid: { type: "number" }, departmentname: { type: "string" }, division: { type: "string" }, county: { type: "string" } } } }, filterable: { mode: "

windows - Why Doesn't External Triggering of System Beep Trigger Hooked Code? -

this code works expected "cin" line removed , "beep(750, 300);" uncommented: beep "caught" hook function. when run is, open shell, , hit control-g, followed enter, triggers system beep- beep doesn't seem triggering print statement in code. tried sleep(30000), didn't work either. #include "stdafx.h" #include "mhook-lib/mhook.h" #include <iostream> using namespace std; // goal: detect use of 'beep' function via hook // define _beep in order dynamically bind function (what function???) typedef bool (winapi *_beep)(dword, dword); // backup address of beep function, need restored after hooking _beep backupaddress_beep = (_beep)getprocaddress(getmodulehandle(l"kernel32"), "beep"); // function inserted before beep function once hook in place bool winapi hookbeep(dword dw_freq, dword dw_duration) { printf("***** call beep(%u, %u).\n", dw_freq, dw_duration); // continue cha

r - Get specific part of a string for each line -

i have data want take specific part of doseresponse_curves/drcurve_aaatt.pdf doseresponse_curves/drcurve_agmk1.pdf doseresponse_curves/drcurve_agu.pdf doseresponse_curves/drcurve_alh1l2.pdf doseresponse_curves/drcurve_alkb1.pdf doseresponse_curves/drcurve_as2.pdf doseresponse_curves/drcurve_ank1.pdf doseresponse_curves/drcurve_ankrd54.pdf i want take whatever comes after second _ , before . means output looks this aaatt agmk1 agu alh1l2 alkb1 as2 ank1 ankrd54 note: working gene names, can contain characters such c(".", "-") . you can sub , regular expression. files = c( 'doseresponse_curves/drcurve_aaatt.pdf', 'doseresponse_curves/drcurve_agmk1.pdf', 'doseresponse_curves/drcurve_agu.pdf', 'doseresponse_curves/drcurve_alh1l2.pdf', 'doseresponse_curves/drcurve_alkb1.pdf', 'doseresponse_curves/drcurve_as2.pdf', 'doseresponse_curves/dr

How to share on a facebook page from iOs App - Objective-c? -

when share link ios app (with uiactivityviewcontroller ) share link on facebook profile or facebook's group. how can share on page? have "facebook pages manager" app installed on device, app doesn't appear on list . nsstring *text = @"https://stackoverflow.com/questions/ask"; nsarray *activityitems = @[text]; nsarray * applicationactivities = nil; nsarray * excludeactivities = @[];//@[uiactivitytypeassigntocontact, uiactivitytypecopytopasteboard, uiactivitytypeposttoweibo, uiactivitytypeprint, uiactivitytypemessage]; uiactivityviewcontroller * activitycontroller = [[uiactivityviewcontroller alloc] initwithactivityitems:activityitems applicationactivities:applicationactivities]; activitycontroller.excludedactivitytypes = excludeactivities; uiviewcontroller *vc = ...my controller..; // ios 8 - set anchor point popover if ( [activitycontroller respondstoselector:@selector(popoverpresentationcontroller)] ) { activitycontroller.popoverpresentationco

python - pycurl error: Transfer-Encoding in 200 response from HTTPS proxy -

trying write http client using pycurl library talks origin server via proxy. expecting below flow - 1. http client -> proxy: ssl exchange ## success 2. http client -> proxy: http connect https://origin_server ## sucess 3. proxy -> origin server: tcp connection handshake ## success 4. proxy -> http client: 200 ok ## response received transfer-encoding header set. following client code - import pycurl stringio import stringio buffer = stringio() c = pycurl.curl() url = 'https://origin_server/index' proxy = 'https://local_proxy:8445' c.setopt(c.url, url) c.setopt(c.proxy, proxy) c.setopt(c.proxy_sslcert, 'client.cer') c.setopt(c.proxy_cainfo, 'ca.pem') c.setopt(c.proxy_sslkey, 'private.key') c.setopt(c.proxy_ssl_verifypeer, true) c.setopt(c.writedata, buffer) c.setopt(c.verbose, true) c.setopt(c.transfer_encoding, false) c.perform() c.close() error received: traceback (most recent call last): file "pycurl

reactjs - Getting GeoJson data from the map using React-Leaflet -

i'm trying retrieve geojson data of circle fixed radius on map. i'm not able understand how retrieve geojson data object map. according docs, using featuregroup should help, i'm failing understand how implement in react. in advance ! import react, {component} 'react'; import geosuggest 'react-geosuggest'; import { map, marker, popup, tilelayer, circle, featuregroup } 'react-leaflet'; import slider 'react-rangeslider'; class app extends react.component { constructor(props) { super(props); this.state = { lat: 18.572605, lng: 73.878208, zoom: 13, value: 500 } this.onsuggestselect = this.onsuggestselect.bind(this); } onsuggestselect(suggest) { console.log(suggest) this.setstate({ lat: suggest.location.lat, lng: suggest.location.lng, }) } handlechangestart = () => { console.log('change event started') }; handlec

highcharts - Sorting Scatter Highstock Chart with Multiple Series -

i running issues when attempting sort highstocks chart series. continue highcharts error #15. understand why i'm getting error i'm looking way around it. have 3 element array following [[x],[y],[time]] im attempting use stock chart allow me slide through time while updating x , y scatter plot. understand i'm plotting reasoning plot type may helpful. x in case engine load percent while y exhaust temp. i error because no matter how sort data because have 2 x series , highstock requires data sorted according x-axis. can imagine, x1 , x2 not dependent on 1 , limited programming skills have left me scratching head here. a js fiddle of code i'm using located here - jsfiddle thanks in advance help! highcharts.stockchart('container', { xaxis: { labels: { enabled: false } }, rangeselector: { buttons: [{ type: 'day', count: 1, text: '1 day' }, { type: 'day', count: 3, text:

flexbox - Best practice for splitting viewport with CSS flex -

hoping not nonsense question in way tad non-specific. it's quite simple - aiming produce design splitting viewport/screen rough halves (60/40) vertically, similar how airbnb do: - airbnb new york is simple using flexbox columns (i using bootstrap 4), specifying column widths , setting right-hand side column position: fixed? any advice has welcome have never approached type of design before , want make sure not overlooking anything. here's flex layout based solution. html, body { height: 100%; margin: 0 } .box { display: flex; flex-flow: column; height: 100%; } .box .row { border: 1px dotted grey; } .box .row.header { flex: 0 1 60vh; } .box .row.content { flex: 1 1 40vh; } <div class="box"> <div class="row header"> <p><b>header</b> (60%)</p> </div> <div class="row content"> <p> <b>conten

java - Controlling a dweet.io device through local network -

i have iot device made interact through dweet.io works fine. however, wish able control device in absence of internet connection, somehow need create own dweet server. the dweet.io uses pretty simple tcp protocol string commands. device sends message server responds post message containing commands. device can configured use server ip , can set machine's local ip. want use java control device. code got far server = new serversocket(9999); while (running) { socket socket = server.accept(); bufferedreader br = new bufferedreader( new inputstreamreader(socket.getinputstream())); bufferedwriter bw = new bufferedwriter( new outputstreamwriter(socket.getoutputstream())); string inputline = "", msg = ""; while (!(inputline = br.readline()).equals("")) { newmsg += inputline; } system.out.println(msg); bw.write(command); bw.newline(); bw.flush(); bw.close(); br.close();

javascript - How to slide div in when it is in viewport and then out when it is no longer in viewport -

i trying have div slide in , out of view on scroll. slide view when in viewport , out of view when out of viewport. when slides out, replaced div(next div in code) sliding in. the problem having each div want show/hide shares class next div. so, code showing/hiding 3 divs @ once instead of showing/hiding according there place in viewport. thanks help! html: <body> <header id="legendary__intro"> <div class="section__title"> <h1 class="header__title">lorem ipsum</h1> <p class="header__description"lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum</p> <div class="header__subtitle uppercase"> <p>lorem ipsum</p> </div> <div class="line"></div> <i class="fa fa-chevron-down&quo

r - ggplot2 with gradient density fill? -

Image
i have generated ggplot2 graph , want fill showing density of points. have managed using following formula density: get_density <- function(x, y, n = 250) { dens <- mass::kde2d(x = x, y = y, n = n) ix <- findinterval(x, dens$x) iy <- findinterval(y, dens$y) ii <- cbind(ix, iy) return(dens$z[ii])} and getting density of points in new "density" column based on formula, "lfc" , "pval" being x,y variables: data.ma$density <- get_density(data.ma$pval, data.ma$lfc) the ggplot object plotting is: heatmap2 <- ggplot() + geom_point(data = filter(data.ma, chg == "unchanged"), aes(basemean, lfc, color = density)) + geom_point(data = filter(data.ma, chg == "changed"), aes(basemean, lfc, fill = dir), shape = 21, size = 2, stroke = 0.1) + scale_fill_manual(values = c("#ffa600", "#00b2ff", "#00b2ff")) + scale_colour_gradient

rest - How do I make this Salesforce cURL request in PHP? -

i'm using php make curl requests salesforce's rest api. i've got of requests need make figured out, i'm not sure how convert following curl command on following salesforce api page curl request in php: curl https://yourinstance.salesforce.com/services/data/v20.0/sobjects/account/customextidfield__c/11999 -h "authorization: bearer token" -h "content-type: application/json" -d @newrecord.json -x patch https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm i know that -h option headers, i'm handing following: curl_setopt($ch, curlopt_httpheader, $headers); and think -x patch part can accomplished following php curl option: curl_setopt($ch, curlopt_customrequest, 'patch'); however, how handle -d @newrecord.json part in php curl? thanks. what doing -d @newrecord.json uploading (json) file endpoint use. replicate in php, need pass array file element curopt_postfields , this:

Grails 2.5.5 URLMapping issue -

i running in issue controllers not being able hit directly. have following 2 lines in urlmappings.groovy "/secondary/$action?/$id?(.$format)?" (controller:"managesecondary") "/manage/$action?/$id?(.$format)?" (controller:"manageaccount") however, when try navigate directly url/managesecondary/secondary1 throws 404 error. trying hit url/manage/secondary1 manageaccount doesnt have secondary1 debugging defaulturlmappingsholder following: debug defaulturlmappingsholder - matched uri [/managesecondary] pattern [/( )/( )?/( )?], adding posibilities debug defaulturlmappingsholder - matched uri [/managesecondary] pattern [/manage/( )?/( )?(.( ))?], adding posibilities i can't figure out why /managesecondary matching /manage/ / should stop happening. any mutely appreciated

python - I'm getting an IndentationError. How do I fix it? -

Image
i have python script: if true: if false: print('foo') print('bar') however, when attempt run script, python raises indentationerror : file "script.py", line 4 print('bar') ^ indentationerror: unindent not match outer indentation level i kept playing around program, , able produce 3 other errors: "indentationerror: unexpected indent" "indentationerror: expected indented block" "taberror: inconsistent use of tabs , spaces in indentation" what these errors mean? doing wrong? how can fix code? why indentation matter? in python, indentation used delimit blocks of code . different many other languages use curly braces {} delimit blocks such java, javascript, , c. because of this, python users must pay close attention when , how indent code because whitespace matters. when python encounters problem indentation of program, either raises exception called indentat

is this a bug of stringr::str_view in R? -

i tried following call in r , expected 'ccc' matched because supposed greedy matching, str_view('accc','c{0,3}') but nothing matched. following call works fine ('a' removed, 'ccc' matched) str_view('ccc','c{0,3}') is bug of stringr::str_view? or misunderstand something?

javascript - Can a node.js cryptocurrency bot fall behind the market -

if trading bot built on node.js reacting every single market update won't start drift away reality without client-side conflation on separate child thread? in other words, receive order book update, update current book, bot execute trading logic, , during time won't handling next update. bot receives , handles more market data updates won't start lag behind , worse each update? i suppose there gaps in market activity allow catch that's not guaranteed. examples i've seen of nodejs bots not handle wonder if it's non-issue , there not know or understand. of course spawn child process handling prices , conflating them , trading logic , talk via ipc. however, assuming measured correctly, there's around 500 microseconds in latency last time tried. , well, we'd faster. depends on how make it, if execute trading logic on infinite loop feeds database systems ~ , cache systems redis, can make parallel requests store db, while calculating, hav

android - What size of an image should I use to get sharp images? -

i making app android , having trouble providing right resources right dpi-folders make resource sharp , not pixelated. have made different resources every folder , sharp on lg g5 when loading app tablet pictures smaller , not sharp. i gonna put sizes of different image sizes in here no 1 asks: mdpi - 54x47 | hdpi - 81x70 | xhdpi - 108x94 | xxhdpi - 162x141 my tablet uses xhdpi resources , phone uses xxxhdpi resources. i've wanted redo images sharp possible. took ruler , messured size of image should appear on screen , multiplied dpi calculate size of image. i came width tablet: 0.866in * 320dpi = 277px but when checked , calculated width of image phone, got this: 0.413in * 640dpi = 264px at point confused because width hdpi larger 1 xxxhdpi. i know if had tablet 640dpi image bigger 1 320dpi, still don't know size image should be. is there maybe way categories images? saw screens have different screen sizes (small, normal, large, xlarge), far know deter

Uploading files to google cloud datalab VM instance -

i have open google cloud datalab notebook, , i'm looking @ folder contents. there upload button, , can use upload files. works fine files under 500kb, moment try upload larger, hangs forever. i'm not trying upload massive files via web interface, 10mb or less worth of data, still won't go through. does datalab have maximum file size can use web uploader for? there's an outstanding issue on github repo datalab discusses this, it's datalab inherits jupyter 4, on it's based, , there's unfortunately no way around it.

php - Custom s2i in OpenShift as an Image Stream - permissions error -

i have using custom source-to-image project build drupal images, run on openshift. the s2i project works when run locally, cli. i tried set in openshift using instructions https://docs.openshift.com/container-platform/3.4/dev_guide/managing_images.html#writing-image-streams-for-s2i-builders . s2i project the drupal s2i project located @ https://github.com/hughestech/s2i-shepherd-drupal imagestream my yam file looks like: apiversion: v1 kind: imagestream metadata: name: drupal annotations: openshift.io/display-name: drupal spec: tags: - name: '2.0' annotations: openshift.io/display-name: drupal builder description: >- build , run drupal applications on centos 7. iconclass: icon-php samplerepo: 'https://github.com/hughestech/open_social.git' tags: 'builder,php, drupal' version: '1.0' from: kind: dockerimage name: '172.30.1.1

python - Remove spaces between bars in barchart -

Image
i want there no spaces between bars on chart. searched question before posted, , while there variety of answers, none have effect on chart. assume i'm doing wrong, can't figure out how make work. i tried both of these methods , spaces between bar remained unchanged: plt.axis('tight') bin = np.arange(my_list) plt.xlim([0, bin.size]) here code: my_list = [2355, 2259, 683] plt.rcdefaults() fig, ax = plt.subplots() width = .35 kitchen = ("cucumber", "legacy", "monkey") y_pos = np.arange(len(kitchen)) barlist = ax.bar(y_pos, my_list, width, align='center', ecolor='black') barlist[0].set_color('dodgerblue') barlist[1].set_color('orangered') barlist[2].set_color('khaki') def autolabel(rects): rect in rects: height = rect.get_height() ax.text(rect.get_x() + rect.get_width()/2., 1*height, '%d' % int(height), ha='center', v

visual studio 2015 - How do I compile VBoxRecorder -

i've been trying extract data program uses animations. program runs under windows xp x86 , requires code page , system settings set japanese. i've been extracting frames virtualbox , codec lagarith. reading use program called vboxrecorder better job of recording, can't compile. the compiler complains; fatal error c1083: cannot open include file: 'libavcodec\avcodec.h' which assume ffmpeg source. vboxrecorder https://github.com/waterflames/vboxrecorder ffmpeg https://github.com/ffmpeg/ffmpeg i've downloaded both source codes, , i'm stuck. i'm using visual studio 2015 , don't know how mix 2 compile vboxrecorder. how compile vboxrecorder?

javascript - Load dynamic content with Ajax and Nodejs -

i implement following project. page has navigation bar several items. content of each tab should displayed without reloading page. use nodejs ejs template engine. have done lot of research, couldn't find solution. think have send ajax request server , sends needed html part. can me example? understood logically, can't directly implement yet. if need further information me feel free write me. regards. the nodejs server app should send json data, example. html element need can dynamically created using javascript, need insert created data html elements. this brief example: <div id="div1"> <p id="p1">this paragraph.</p> <p id="p2">this paragraph.</p> </div> <script> var para = document.createelement("p"); var node = document.createtextnode("this new."); para.appendchild(node); var element = document.getelementbyid("div1"); element.ap

machine learning - Extrapolating precision/recall metrics to real-world distribution -

Image
i've been asked report classification metrics extrapolating them real world distribution have no idea how so. here of details of problem. i've 30k records in total. out of these, run algorithm classify these 30k records 3 classes : a) correct, b) incorrect , c) unsure. correct count : 26387 incorrect count : 1101 unsure count : 2512 out of these classes, randomly sample ~ 460 records , manually annotate create gold set. after human judgment, following counts: correct count : 741 incorrect count : 541 unsure count : 103 here's confusion matrix: i can compute precision/recall metrics, how extrapolate them real world. colleague says can consider percentage obtained classifier output metric real world scenario. mean ?

python 3.x - Display coordinates in pyqtgraph? -

i'm attempting develop gui allows tracking mouse coordinates in plotwidget, , displaying in label elsewhere in main window. have attempted several times emulate crosshair example in pyqtgraph documentation, have not been able agree this. part of difficulty unable understand how access mouse tracking can enable in qtdesigner. i attempted use the: proxy = pg.signalproxy(plotted.scene().sigmousemoved, ratelimit=60, slot=mousemoved) plotted.scene().sigmousemoved.connect(mousemoved) however, not quite understand allows "update" in real time, nor @ level should have statement. should def mousemoved(evt): pos = evt[0] if plotted.sceneboundingrect().contains(pos): mousepoint = vb.mapscenetoview(pos) index = int(mousepoint.x()) if index > 0 , index < len(x): mousecoordinatesdisplay.settext("<span style='font-size: 12pt'>x=%0.1f, <span style='color: red'>y1=%0.1f</span>" % (mousepoi

Docker Compose: volumes without colon (:) -

i have docker-compose.yml file following: volumes: - .:/usr/app/ - /usr/app/node_modules first option maps current host directory /usr/app , second option do? the second 1 creates anonymous volume. listed in docker volume ls long unique id rather name. docker-compose able reuse if update image, it's easy lose track of volume belongs names, recommend giving volume name.

android - Custom JobIntentService onHandleWork not called -

i updating app work on handle notifications push using jobintentservice instead of regular intentservice because seems correct way handle on pre-lollipop devices post. enqueueing work such: enqueuework(context, myjobserviceextension.class, job_id, work); this manifest declaration: <service android:name="com.example.myjobserviceextension" android:permission="android.permission.bind_job_service" android:exported="true" tools:node="replace"> i never see callbacks in onhandlework or error logs in logcat. has integrated help? update: tested on api level 21 device , worked.. doesn't seem getting called on android o pixel xl device.. clues why? update #2: seem seeing intentservice's oncreate called, none of other lifecycle methods (including onhandlework). has encountered either? i had same issue after upgrading intentservice jobintentservice. make sure remove method old implemen

Recursive Chudnovsky Algorithm in Java -

i computer engineering student, , i've got project chudnovsky algorithm calculate pi, problem i've got decimal decimal(i mean if got length 3 it's going 3.14), have done code , 3.141592653589734 don't have idea how bit bit using recursive method.the code got far is //this class implements interface contains method calcularpi public class chudnovsky_implements implements chudnovsky { public double calcularpi(int k)//this i'm trying bit bit i'm doing wrong. { if(k==0) return pi(k); else { double resultado= (pi(k))+(pi(k-1)); return resultado; } } public double pi(int k)//here calculated number pi constant k user give(k supposedly number of digits) { double numerador=(factorial(6*k)*((545140134*k)+13591409)); double denominador =(factorial(3*k)*math.pow(factorial(k), 3)*math.pow(-640320, (3*k))); double pi=(numerador/denominador); return pi; } public double factorial(int n)// class calculate factor

database - How to access the tab Data from the inside Android Device Monitor -

Image
i have problem can not access tab, using emulator or physical device connected pc cable usb. error can due permission, not know how solve. if wrote wrong point of view grammarian, sorry, still learning english, , on it's not native language.

regex - Use Python Match object in string with backreferences -

does python have capability use match object input string backreferences, eg: match = re.match("ab(.*)", "abcd") print re.some_replace_function("match is: \1", match) // prints "match is: cd" you implement using usual string replace functions, i'm sure obvious implementation miss edge cases resulting in subtle bugs. you can use re.sub (instead of re.match ) search , replace strings. to use back-references, best practices use raw strings, e.g.: r"\1" , or double-escaped string, e.g. "\\1" : import re result = re.sub(r"ab(.*)", r"match is: \1", "abcd") print(result) # -> match is: cd but, if have match object , can use expand() method: mo = re.match(r"ab(.*)", "abcd") result = mo.expand(r"match is: \1") print(result) # -> match is: cd

c++ - How to simplify call syntax to function which accepts generic method pointer C++14 -

i'm designing message queue actor system, message queue contains std::function objects. client code add message queue has complex syntax i'd simplify. example code: class actor { std::deque<std::function<void()>> fmessagequeue; template <class f, class ... args> void addmessage(f &&fn, args && ... args) { fmessagequeue.push_back(std::bind(std::forward<f>(fn), std::forward<args>(args)...)); } } class myactor : public actor { void behaviour1(float arg) {/*do something*/} } to use above classes, i'd this: int main(int argc, const char **argv) { myactor a; a.addmessage(&myactor::behaviour1, &a, 1.0f); // redundant 2nd argument &a, needed std::bind() } ideally, i'd use following code syntax: int main(int argc, const char **argv) { myactor a; a.addmessage(&myactor::behaviour1, 1.0f); // notice no 2nd argument &a } i client api not require 2nd

python - How to perform linear correlation on a data set and return the column name which has the most correlation? -

i working on data set has closing prices of stock. 'goog' : [ 742.66, 738.40, 738.22, 741.16, 739.98, 747.28, 746.22, 741.80, 745.33, 741.29, 742.83, 750.50 ], 'fb' : [ 108.40, 107.92, 109.64, 112.22, 109.57, 113.82, 114.03, 112.24, 114.68, 112.92, 113.28, 115.40 ], 'msft' : [ 55.40, 54.63, 54.98, 55.88, 54.12, 59.16, 58.14, 55.97, 61.20, 57.14, 56.62, 59.25 ], 'aapl' : [ 106.00, 104.66, 104.87, 105.69, 104.22, 110.16, 109.84, 108.86, 110.14, 107.66, 108.08, 109.90 ] these closing prices period of last 12 days. need determine pair of stocks given companies had highly correlated percentage change of daily closing prices , return them array. import pandas pd import numpy np class stockprices: # param prices dict of string list. dictionary containing tickers of stocks, , each tickers daily prices. # returns list of s

java - ListView of images and String arrays not working -

i new android programming. can me out? testing how display images , string in list view using arrayadapter. tried base adapter in different method same issue, app crashes , never runs. here code mainactivity.java import android.app.activity; import android.content.context; import android.content.res.resources; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.listview; import android.widget.textview; public class mainactivity extends activity { listview l; int [] images = {r.drawable.img1,r.drawable.img2, r.drawable.img3, r.drawable.img4, r.drawable.img5, r.drawable.img6, r.drawable.img7, r.drawable.img8, r.drawable.img9, r.drawable.img10}; string [] titles; string [] description; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); s