Posts

Showing posts from July, 2014

python - Merging two Pandas series with duplicate datetime indices -

i have 2 pandas series (d1 , d2) indexed datetime , each containing 1 column of data both float , nan. both indices @ one-day intervals, although time entries inconsistent many periods of missing days. d1 ranges 1974-12-16 2002-01-30. d2 ranges 1997-12-19 2017-07-06. period 1997-12-19 2002-01-30 contains many duplicate indices between 2 series. data duplicated indices same value, different values, or 1 value , nan. i combine these 2 series one, prioritizing data d2 anytime there duplicate indices (that is, replace d1 data d2 data anytime there duplicated index). efficient way among many pandas tools available (merge, join, concatenate etc.)? here example of data: in [7]: print d1 flddate 1974-12-16 19.0 1974-12-17 28.0 1974-12-18 24.0 1974-12-19 18.0 1974-12-20 17.0 1974-12-21 28.0 1974-12-22 28.0 1974-12-23 10.0 1974-12-24 6.0 1974-12-25 5.0 1974-12-26 12.0 1974-12-27 19.0 1974-12-28 22.0 1974-12-29 20.0 1974-12-30 16.0 1974-12-...

javascript - Why are these tests passing? -

i have function: let removepresentation = function(presentationname, callback) { let rimraf = require('rimraf'); callback(); callback(); callback(); if(!presentationname || !presentationname.trim()) { callback(); return; } presentationname = presentationname.replace('.zip', ''); rimraf('./presentations/' + presentationname, function(err) { if(err) { console.log(err); } callback(); }); }; exports.removepresentation = removepresentation; and trying test following: var chai = require('chai'), expect = require('chai').expect, sinonchai = require('sinon-chai'), sinon = require('sinon'), mock = require('mock-require'); chai.use(sinonchai); describe('removepresentation', function() { var sandbox; var callback; var rimrafspy; beforeeach(function() { sandbox = sinon.sandbox.create(); mock('../business/communications_business', {})...

python 3.x - How to programically quit mainloop via a tkinter canvas Button -

my program generates several graphs 1 @ time , each has quit button. program pauses in mainloop until press button, generates next graph. i way programmically press or invoke action associated button, in case root.quit() i have tried calling invoke() on button doesn't work. feeling event lost before mainloop started. from tkinter import * pause = false # passed in arg root = tk() root.title(name) canvas = canvas(root, width=canvas_width, height=canvas_height, bg = 'white') canvas.pack() quit = button(root, text='quit', command=root.quit) quit.pack() # make sure drawn canvas.update() if not pause: # invoke button event can draw next graph or exit quit.invoke() root.mainloop() i realised problem event being lost , mainloop blocking used pause arg determine when run mainloop , i.e. on last graph. see tkinter understanding mainloop all graphs displayed , when press quit on window windows disappear , program ends. if...

android - What is the `Authorization` part of the http post request of Google's Firebase Downstream message? -

Image
i want try send message using google's fcm messaging service , document says, http request should this: https://fcm.googleapis.com/fcm/send content-type:application/json authorization:key=aizasyz-1u...0gbyzpu7udno5aa { "data": { "score": "5x1", "time": "15:10" }, "to" : "bk3rnwte3h0:ci2k_hhwgipodkcizvvdmexudfq3p1..." } my problem have not idea authorization 's value should , when delete header , make request, error 401:unauthorized .i think must kind of api key or cannot find in project. can me? ps: testing purposes using this site send messsage device according about firebase cloud messaging server documentation: authentication to send message, app server issues post request. example: https://fcm.googleapis.com/fcm/send a message request consists of 2 parts: http header , http body. the http header must contain following headers: auth...

python - Early stopping in lgbm or xgb if score doesn't improve "enough" -

is there way, in xgboost or lgbm in python perform stopping if score doesn't improve more threshold? i know early_stopping_rounds = n makes algorithm stop if score hasn't improved on evaluation set during n consecutive iterations, if score doesn't improve more fixed threshold. i have learning task, in score on cv improves 0.65 0.25 in first 50 rounds (it's binary logloss) , continues on 1000 rounds achieve score of 0.241 . rather stop when score doesn't improve more 0.001 in 10 rounds. there way that?

amazon ec2 - Store ansible output to variable -

i want use ansible information aws ec2 instance. looking it's instance-id. going use loop through template. can't seem instance-id. here have far: --- - name: including variables include_vars: file: linux.yml - name: gathering ec2 facts ec2_remote_facts: aws_access_key: "{{ access_key }}" aws_secret_key: "{{ secret_key }}" region: us-east-1 filters: "tag:name": "{{ ansible_hostname }}" register: instanceid - debug: var=instanceid.instances.id i know incorrect when run get: "instanceid.instances.id": "variable not defined!" can tell me of way return instanceid? if first time, gradually... understand what's inside. like: - debug: var=instanceid # see raw result , find out `instances` there - debug: var=instanceid.instances # see `instanses` is, , see list - debug: var=instanceid.instances[0] # see first element of list , see it's properties - debug:...

Delphi - Extract multiple substrings from a string -

i have string ";;;caption=c:;freespace=103571001344;size=162527178752;;;caption=d:;freespace=129889742848;size=336805752832;;;caption=v:;freespace=516807241728;size=1000207282176;;;; how can extract each partition data variable obtain this: partition_1:='caption=c:;freespace=103571001344;size=162527178752'; partition_2:='caption=d:;freespace=129889742848;size=336805752832'; partition_n:='caption=v:;freespace=516807241728;size=1000207282176'; thank you! this question applies well. basically, use tstringlist , set linebreak property 3 semicolons ( ;;; ) , text property string.

javascript - Changing CSS proprety of another div located in another page -

hello change dom of html page page tried sharing same script between 2 pages didnt work here illustration trying do 1-first page <div> <p id="simpletext">hello world</p> <script src="jquery.min.js"></script> <script src="script.js" type ="text/javascript"></script> <!-- same script file present in second page --> </div> 2-second page <div> <button>click me </button> <script src="jquery.min.js"></script> <script src="script.js" type ="text/javascript"></script><!-- same script file present in first page --> </div> script.js $("button").on("click",function(){ $("simpletext").css("color","blue"); }); i trying when click on button wish located on second page change color of text on first page you can send messages 1 page another. ...

c++ - Template function on struct members -

is there way code single template function able run on different members of given struct ? a wrong example : struct foo { int a, b; } template <member x> //which not exist cout_member(foo foo) { cout << foo.x << endl; } int main() { foo foo; cout_member<a>(foo); cout_member<b>(foo); return 0; } i imagined answer based on switch, wondered if switch tested on run-time (what avoid) or on compile-time ? as long want pick data member set of data members having same type, can use pointer data member: template <int foo::*m> void cout_member(foo foo) { std::cout << (foo.*m) << std::endl; } and use as: cout_member<&foo::a>(foo); if want indicate type, can this: template <typename t, t foo::*m> void cout_member(foo foo) { std::cout << (foo.*m) << std::endl; } and use as: cout_member<int, &foo::a>(foo); just out of curiosity, second snippet simpler i...

spring - Difference between Autowired Environment and EnvironmentAware -

doing spring application multiple components (to access property deeper in code) the main 1 spring bootapplication a dispatcher component a main prototype component a client prototype component a server prototype component everything below main runnable better thread handling. because client , server 1 created main 1 created dispatcher one, main , dispatcher applicationcontextaware. now thing need access environment inside of client , server. first did via @autowired, noticed environmentaware. what pro , cons of using them or isn't there of difference in case?

java - Hibernate loading associated entities not by primary key -

i have 2 tables (really simplified sake of question): book { id integer, name string, author_id integer } author { id integer, fullname string } now need save book , don't have author_id , have author's fullname . i can author name, book.set(thatauthor) , have more fields in many classes, have fill objects , it's more code this, since i'm using map-struct map , call persist , done it, can't, have set fields manually. question: there possiblity tell hibernate it? have entity class filled data (author's fullname set) , it's unique if hibernate tried find 1 result, no problems there. i have in mind such functionality: hibernate looks @ class. sees fields set , other not. takes fields set , puts them in where clause (in case it's authors fullname ) , tries find single result, throws exception otherwise. not sure if can understand me, tried best. don't hate me question, find did, loading objects manually. if can possibly avoid...

PHP Find Match in Array Key and Sum the Value -

input: array ( [address check failed, address discrepancy] => 716 [ssn check failed, dob check failed] => 15 [dob check failed] => 139 [no issues] => 189 [dob check failed, address discrepancy] => 51 [dob check failed, address check failed, address discrepancy] => 23 [ssn check failed] => 3 [address discrepancy] => 33 ) i need sum value of key not contain phrase "ssn check failed" i using function: function in_array_r($needle, $haystack, $strict = true) { foreach ($haystack $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false; } like this: foreach ($issues_totals $key => $value){ if (!in_array_r("ssn check failed", $key)){ $total_with_no_issue += $value; } } where $issues_totals above array , $total_with_no_issue value looking for. problem code $tota...

c# - Set can we change the name Tag when serializing with Json.net? -

i new in json , using jsonconvert c#, change name of xml tag "builder" "children" using json attributes/properties (i don't know how call it) in xml tag such "json:array='true'" : input xml: <information> <builder json:array='true'> <condition></condition> <condition></condition> <condition></condition> </builder> </information> output json: { name:"information", children:[ { "name":"builder", "children:[ { "name":"condition" }, { "name":"condition" }, { "name":"condition" }, ] } ] } any please, thank you

Build currently opened file in Visual Studio Code -

i have workspace use smaller test programs write practice concepts. hence, in vs code, have build task each file in folder. by default, vs code builds task "isdefault": true, flag. ideally, figure out way me build opened file, when switch files editing, not need manually reset flag build task want use. to knowledge, vs code tasks documentation doen't provide solution. there must way accomplish without manually adjusting flag. appreciated. to build on rob's answer, can set shortcut key combination trigger each task adding keybindings.json , e.g. { "key": "ctrl+h", "command": "workbench.action.tasks.runtask", "args": "run tests" } where args component replaced task name. you use in combination ${file} in tasks.json differentiate between separate build types. e.g. hit ctrl + h python , ctrl + shift + h tsc

java - app crashes on real device due to udev rule error -

error shown follows: com.android.ddmlib.adbcommandrejectedexception: insufficient permissions device: verify enter code here udev rules. see [ http://developer.android.com/tools/device.html] more information. error while installing apk the java code mainactivity shown below: import android.manifest; import android.location.location; import android.support.v4.app.activitycompat; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.text.textutils; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class mainactivity extends appcompatactivity { edittext t1; edittext t2; textview textview; button calc; float lat1; float lon1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentv...

r - Add second caption to polar coordinates based ggplot2 plot -

Image
i have been asked recreate pie chart using ggplot2 , having difficulty adding second caption plot. need caption on bottom left of plot and bottom right. my current approach can 1 or other using hjust option caption placement (0 left-align; 1 right-align): library(ggplot2) dat <- data.frame(variable = c("v1", "v2", "v3"), value = c(.80,.50,.63)) p1 <- ggplot(dat, aes(x = 1, y = value, fill = variable)) + geom_bar(stat = "identity") + coord_polar(theta = "y") + theme(legend.position = 'none', plot.caption = element_text(hjust = 1)) + labs(caption = "right caption") print(p1) this produces: i've seen approaches use annotate() cannot seem them work coord_polar() . does know how can second caption appear on left-hand side of plot (horizontally aligned right caption)? maybe possible overlay blank layer has left caption? using grid pack...

ios - Linphone error You must fill a reason when changing call state -

i trying decline incoming call code below , keep getting exception on linphone_core_terminate_call , message of must fill reason when changing call state let call = linphone_core_get_current_call(lc) if call != nil { linphone_core_terminate_call(lc, call) } else { var currentcall = linphone_core_get_current_call(lc) if currentcall == nil && linphone_core_get_calls_nb(lc) == 1 { currentcall = linphone_core_get_calls(lc) as? opaquepointer! linphone_core_terminate_call(lc, currentcall) } } i tried: linphone_core_decline_call(lc, call, linphonereasondeclined) and get: 2017-08-14 13:21:01:260 ortp-message-terminate call [0x1038b1600] in state linphonecallincomingreceived 2017-08-14 12:43:52:065 ortp-error-linphone_call_set_state(): must fill reason when changing call state (from linphonecallincomingreceived o linphonecallerror).

c# - Trying to separate sessions for MVC apps -

we working on c# mvc project has 2 mvc uis, frontend , admin section. we're using iis express debugging locally. when debugging both apps, can see values both apps shared in session. i modified our myapp.vs\config\applicationhost.config , added app pool section each app, , set them use it, this: <sites> <site name="website1" id="1" serverautostart="true"> <application path="/"> <virtualdirectory path="/" physicalpath="%iis_sites_home%\website1" /> </application> <bindings> <binding protocol="http" bindinginformation=":8080:localhost" /> </bindings> </site> <site name="myapp.frontend" id="2"> <application path="/" applicationpool="myappfrontendapppool"> <virtualdirectory path="/" physicalpath=...

javascript - Twilio End Video Capture from Local Webcam -

i have functioning twilio video-chat application working expect, other cannot end video-stream when user hits close button. i've looked through javascript quick-start , have tried following implementations: (attempting use webrtc's method, complains twilio.media.mediastream undefined); function endvidconf(room){ console.log('attempting end vid conf'); room.localparticipant.tracks.foreach(function(track) { var attachedelements = track.detach(); attachedelements.foreach(function(element){ element.remove(); }); }); twilio.media.mediastream.getaudiotracks()[0].stop(); twilio.media.mediastream.getvideotracks()[0].stop(); room.disconnect(); }; (using track.stop() -- webcam still on): function endvidconf(room){ console.log('attempting end vid conf'); room.localparticipant.tracks.foreach(function(track) { var attachedelements = track.detach(); attachedelements.foreach(function...

Using Asp.NET Identity with custom user manager/database -

i use parts of identity system of asp.net access custom database, not of parts. database portion wasn't difficult, trying find out how write code put work of identity methods custom implementation. example 1 of differing items not use usermanager password hash, instead use other 3rd party password hash function. of things i'd take advantage of cookie authentication, password validator fields, etc. so, first thing tried @ standard createasync method does, , takes me blank line looking this: [asyncstatemachine(typeof(usermanager<>.<createasync>d__73))] public virtual task<identityresult> createasync(tuser user, string password); how can make custom create-async , password-verification functions? oh, 'custom database' mean, not want use tables come identity, no roles, claims, own users table all. i did there's code post here answer unfortunately. for createasync need make custom userstore class implements `iuserstore<your custom ...

c# - Zedgraph Does not display Symbols on Line -

i'm using zedgraph plot data. used code : private void creategraph( zedgraphcontrol zg1 ) { // reference graphpane graphpane mypane = zg1.graphpane; // set titles mypane.title.text = "my test date graph"; mypane.xaxis.title.text = "date"; mypane.xaxis.title.text = "my y axis"; // make random data points double x, y; pointpairlist list = new pointpairlist(); ( int i=0; i<36; i++ ) { x = (double) new xdate( 1995, 5, i+11 ); y = math.sin( (double) * math.pi / 15.0 ); list.add( x, y ); } // generate red curve diamond // symbols, , "my curve" in legend curveitem mycurve = mypane.addcurve( "my curve", list, color.red, symboltype.diamond ); // set xaxis date type mypane.xaxis.type = axistype.date; // tell zedgraph refigure axes since data // have changed zg1.axischange(); } it's work fine. when change : mypane.xaxis.type = axistype...

java - Jackson's Access.WRITE_ONLY during test null -

i'm playing around jackson's de/serialization features , encountered problem, don't know how solve. during test @jsonproperty(access = jsonproperty.access.write_only) annotation ignored , shows null . e.g. postman works expected. i using spring boot starter web starter , test starter dependency. example code: @springbootapplication public class demoapplication { public static void main(string[] args) { springapplication.run(demoapplication.class, args); } } @restcontroller class jacksonexamplerestcontroller { @postmapping("/api") public void getresti(@requestbody jacksonmodel jacksonmodel) { system.out.println(jacksonmodel.getid()); system.out.println(jacksonmodel.getpassword()); } } class jacksonmodel { private string id; @jsonproperty(access = jsonproperty.access.write_only) private string password; public string getid() { return id; } public void setid(string id) { ...

python - Is it possible for a process to kill (downscale) its own Heroku dyno -

i'm working in python project (though principle similar in other languages) needs variable numbers of workers @ different times. i'm running on heroku , have way of upscaling on demand, downscaling trickier - easiest if each process decide when die , take dyno it. is possible python worker on heroku kill , downscale own dyno?

DSC: adding a custom resource to a composite resource -

i have composite resource. understanding composite resource collection of configurations treated resource. think of resources powershell module (but not). current file structure looks like: composite resource: …1 modules └ 2 defaultconfiguration └ 3 {version} ├ 4 dscresources │ ├ 5 happlygpo │ │ ├ 5a happlygpo.psd1 │ │ └ 5b happlygpo.schema.psm1 │ └ 6 hstoragepool │ ├ 6a hstoragepool.psd1 │ └ 6b hstoragepool.schema.psm1 └ 4a defaultconfiguration.psd1 i have written custom dsc resource using xdscresourcedesigner, has produced following file structure: custom resource: … 7 modules └ 8 happlygpo └ 9 1.0.0.0 ├ 10 dscresources │ └ 11 happlygpo │ ├ 11a happlygpo.psm1 │ └ 11b happlygpo.schema.mof └ 10a happlygpo.psd1 is possible merge 2 in happlygpo r...

import - Including JS file in Vue.js 2 component -

i have js file here i'd include in single-file component. i can't include script tag in template section, results in error. i tried: require('/static/sql.js'); import '/static/sql.js' etc. following instructions here . in script section of .vue file, either complained file couldn't found, or dependency wasn't installed. it's large js file (2 mb) i'd prefer not compiled vuejs/webpack. if 'import', function import sql.js? should instead install node version of sql.js library, along fs dependency? serve static webpage, don't know if makes sense have 'fs' module in there. i'm including script tag in index.html of entire app, prefer loaded when need specific component.

java - More relaxed restriction in wildcard instantiations than in declaration -

consider following class: class a<t extends number> { } i wonder why line compile successfully? a<? extends object> = new a<integer>(); while piece of code not class b { static <t extends object> void m(a<t> a) {} } in both cases compiler "knows" range ? extends object on range ? extends number declaration of type a accepts 1st , rejects 2nd. is there in java language or jvm specifications?

javascript - VueJS extend component: remove parent's property -

i have 2 vue components, 1 extends other: // compa.vue export default { props: { value1: object, }, data: function () { return { value2: 'hello2 a', value3: 'hello3 a' } } } // compb.vue import compa './compa.vue'; export default { extends: compa, props: { value4: object }, data: function(){ return { value2: 'hello2 b' } } } as described in docs , compb's options merged compa's, resulting: { props: { value1: object, value4: object }, data: function () { return { value2: 'hello2 b', value3: 'hello3 a' } } } however desired result having property value1 removed: { props: { value4: object }, data: function () { return { value2: 'hello2 b', value3: 'hello3 a...

android - Skip test tasks for specific build types -

i have 4 different build types: release dev mock test when want make clean build task project see gradle making clean build unit tests. it ok unit tests running every build type, takes 4 times longer clean build. how can make clean build unit tests release build type? there no nice task that . have write yourself. try add next build.gradle : project.afterevaluate { // grab build types , product flavors def buildtypes = android.buildtypes.collect { type -> type.name } def productflavors = android.productflavors.collect { flavor -> flavor.name } // when no product flavors defined, use empty if (!productflavors) { productflavors.add('') } productflavors.each { productflavorname -> buildtypes.each { buildtypename -> def sourcename if (!productflavorname) { sourcename = "${buildtypename}" } else { sourcename = "${productflavorname}${buildtypename.capitalize()}" ...

php - How can I test/install an untagged version of a composer package? -

i test private composer package on localhost without need commit new tag perform test. my package tree ├── composer.json ├── readme.md └── src ├── controllers │  ├── models ├── providers │   └── routegenericserviceprovider.php ├── repositories ├── routes │   └── generics.php ├── services │  └── transformers as alternative suggested bey @matteo, can use inline alias , reference commit hash instead of tag. assume x.y.z version have installed, , #123abc hash of commit tag once tested (probably head of whatever branch want test), run: $ composer require "my/package:dev-master#123abc x.y.z" for reference, see: https://getcomposer.org/doc/articles/aliases.md#require-inline-alias

xaml - How to do the image fill the text - the same size always - xamarin.forms -

Image
i trying button image, , each button has text inside...but don't know xamarin forms, i'm beginner , images little while text bigger it... i using grid...and inside 1 other grid 1 colunm , 1 row each button (image , texts) neet image (that button) size of texts inside it my xml @ moment: <!-- buttons grid--> <grid horizontaloptions="center" margin="20,20,20,20" rowspacing="30" columnspacing="10" backgroundcolor="aquamarine" verticaloptions="fillandexpand"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <rowdefinition height="auto"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/> </grid.columndefinitions>...

Spring SpEL: how to write ternary operation in XML config? -

in spring xml config, need set value specific property value depending on value of property. i need this: <bean id="myid" class="myclass"> <property name="myprop" value="#{${property_a} == 'test-a' ? ${property_b} : 'anothervalue'}" /> i want myprop set value of property_b if property_a equal "test-a", otherwise myprop must set "anothervalue". property_a , property_b both defined in config.properties file. is possible write such statement in xml spel? <property name="myprop" value="#{'${property_a}' == 'test-a' ? '${property_b}' : 'anothervalue' }" /> you have ensure result of properties placeholder resolution still literal . so, that's why must wrap ${...} '' .

angular - Load external config, and use this config for another http call -

for our application need read our configuration external url, http://myhost/config.json . configuration file contains apiurl should use other http requests (rest). i tried use app_initializer factory method calls our service load config. returns observable. when open our page request executed our customers. done via http request should use apiurl config. however, system doesn't wait till first call (to config) ready, apiurl not available yet. one option wrap each call (pseudo): this.configservice.getconfig().subscribe(config => { this.customerservice.getcustomers(config); }) this not prefered because other developers should call customerservice directly, , shouldn't bother config. it should nice when can inject config object in constructor , use directly. possible? if not, how can make sure config available other api calls (loaded on startup) ? synchronized http.get request. angular version 4.3.4 it seems when convert observable promise wait...

subplot - Python: add y labels on both sides of plot -

Image
i have series of 8 subplots, sharing x-axis , sharing 1 colorbar: f, ax = plt.subplots(8, sharex=true) in range(8): data = np.random.random((100,100)) im = ax[i].pcolormesh(data) ax[i].set_ylabel(i) f.colorbar(im, ax=ax.ravel().tolist(), orientation='vertical') i want add second y-label on right side of of these plots; lets want label them a-h. i attempted adding empty parasite axis each subplot. fails when adding colorbar in end. ylabel_2 = ['a','b','c','d','e','f','g','h'] f, ax = plt.subplots(8, sharex=true) in range(8): data = np.random.random((100,100)) im = ax[i].pcolormesh(data) ax[i].set_ylabel(i) ax2 = ax[i].twinx() ax2.set_ylabel(ylabel_2[i]) ax2.yaxis.set_major_locator(plt.nulllocator()) f.colorbar(im, ax=ax.ravel().tolist(), orientation='vertical') what best way accomplish want?

How I can hide the console during c++ program run-time? -

how can hide console during c++ program run-time? my compiler : mingw (g++) i tried lot of things didn't work: add -mwindows command showwindow(getconsolewindow(), sw_hide); winmain(...) code problem here (from comment): #include <iostream> #include <windows.h> int main() { std::cout << "recompiling compile app..."; system("taskkill /im compile.exe"); system("g++ compile.cpp -o compile.exe"); system("start compile.exe"); return 0; } how can resolve problem? seems problem arising calls system function, runs console window default. if need @ least 1 console window own programm, example you. if don't need output, uncomment line in example. #include <iostream> #include <windows.h> int main() { // uncomment next line if don't need output @ // freeconsole(); std::cout << "recompiling compile app..."; winexec("taskkill /im compil...

nrvo - C++: should I explicitly use std::move() in a return statement to force a move? -

this question has answer here: when should std::move used on function return value? [duplicate] 6 answers c++11 return value optimization or move? [duplicate] 4 answers edit : not duplicate because question asks compiler's decision in o0. it said here name return value optimization (nrvo) optimization many compiler support. must or nice-to-have optimization? my situation is, want compile -o0 (i.e. no optimization), convenience of debugging, want nrvo enabled return statements return objects (say, vector). if nrvo not must, compiler won't in -o0 mode. in case, should prefer code: std::vector<int> foo() { std::vector<int> v(100000,1); // object big.. return std::move(v); // explicitly move } over below? std::vector<int> foo() { ...

how change the position of the ads admob responsive to all cellphone android studio -

i want change position of ads responsive position, see in celphones, code in xml of ads. com.google.android.gms.ads.adview android:id="@+id/adview" android:layout_width="match_parent" android:layout_height="966dp" ads:adsize="banner" ads:adunitid="@string/banner_ad_unit_id" com.google.android.gms.ads.adview

javascript - Algorithm - locating enough space to draw a rectangle given the x and y axis of all other rectangles -

Image
every rectangle has x , y coordinates, width , height. the total width of screen maxwidth , total height maxheight. i have array containg drawn rectangles. i working on web app users drawing rectangles on screen using thier mouse. using #javascript draw on canvas element. the challenge rectangles must not intersect @ given point. i trying avoid kind of case: or this: this how output aiming should like: what need algorithm (preferably in javascript) can locating enough space draw rectangle knowing axis, height , width. bm67 box packing. this method use pack rectangles. made myself create sprite sheets. how works. you maintain 2 arrays, 1 holds rectangles of available spaces (space array), , other rectangles have placed. you start adding space array rectangle covers whole area filled. rectangle represents available space. when add rectangle fit search available space rectangles rectangle fit new rectangle. if can not find rectangle bigger or s...

c# - NUnit 3.7.1: Assert.Inconclusive with InnerException -

i have onetimesetup want verify integration connections prior running tests (databases, rest endpoints, etc.), short-circuiting suite if there issue. consider like try dim testcontext dbcontext = new dbcontext(_configuredconnectionstring) verifysqlconnection(testcontext) catch ex exception dim actionableerror string = string.format(_verify_sql_connection_template, _configuredconnectionstring) dim actionableexception new configurationexception(actionableerror, ex) 'throw actionableexception assert.inconclusive(actionableerror) end try if connection fails, don't want fail test, want assert entire suite inconclusive, because actual test never ran. i'm noticing assert.inconclusive lacks overload taking in inner exception. forces me either fail tests, full inner exception inspect, or mark tests inconclusive, lose actionable information nunit test runner window. is there reason or overload missing oversight? is there alternative use both ...

android - Why does this code add a list item only once? -

i'm making button add list item each time click it. have code adds list item first time. how can make adds 1 each time click button. or maybe specific range of times? declaration of variables in class. //list of array strings serve list items arraylist<string> listitems = new arraylist<>(); //defining string adapter handle data of listview arrayadapter<string> adapterforpic; //recording how many times button has been clicked int clickcounter=0; private listview mlistview; initialisation inside oncreate(). if (mlistview == null) { mlistview = (listview) findviewbyid(r.id.photoslistview); } adapterforpic=new arrayadapter<>(this, android.r.layout.simple_list_item_1, listitems); setlistadapter(adapterforpic); the methods inserting. //method handle dynamic insertion public void additems(view v) { listitems.add("clicked : "+clickcounter); adapterforpic.notifydatasetchanged(); clic...

javascript - JQuery isn't working but works on JSFiddle -

i've tried , i've been @ few days, jquery isn't working code in dreamweaver. contacted them , it's coding issue. when copy code jsfiddle works, doesn't work html. here jsfiddle link: https://jsfiddle.net/mufeeza/36cmxwxc/ here how link in html: <script src="jquery-latest.js"></script> <script type="text/javascript" src="/resources/js/home.js"></script> here js file: $('#contact').on('mouseenter', function () { "use strict"; $('body').css('background-image', 'url("https://image.ibb.co/fmoqzv/contact.png")'); $('.intro').css('opacity', '0'); }); $('#contact').on('mouseleave', function () { "use strict"; $('body').css('background-image', 'url(http://www.solidbackgrounds.com/images/2560x1440/2560x1440-white-solid-color-background.jpg)'); $('.i...