Posts

Showing posts from May, 2010

apache - Lost message when stoping and restarting Embedded ActiveMQ -

hi trying write test-case implementing fail on support activemq. here code val brokera = createbroker("a") brokera.start val failoverurl = s"failover:(vm://brokera?create=false)" + s"?randomize=false&maxreconnectattempts=-1&reconnectsupported=true" val cfactory = new activemqconnectionfactory(failoverurl) val qconnection = getqueueconnection val session = createqueuesession(qconnection) private def totalreadmessagescount(queuereceiver: queuereceiver) = { val messages = iterator.continually(option(queuereceiver.receive(2000))).takewhile(_.isdefined).flatten.toseq messages.size } private def getreceiver = { val queueconnection = getqueueconnection queueconnection.start() val queuesession = queueconnection.createqueuesession(false, session.auto_acknowledge) val queuereceiver = createqueuereceiver(queuesession, brokera.getbrokername) queuereceiver } def getqueueconnection =cfactory.createqueueconnection("admin", "") de

LeaveOneOut Cross Validation in scikit learn -

does know how can remove error below? nameerror traceback (most recent call last) <ipython-input-31-d3625a93ead4> in <module>() 11 loo = leaveoneout(num_of_examples) 12 train_index, test_index in loo: ---> 13 print("%s %s" % (train, test)) 14 nameerror: name 'train' not defined and code causing error below: from sklearn import datasets import numpy np sklearn.preprocessing import standardscaler iris = datasets.load_iris() x = iris.data[:, [2, 3]] y = iris.target x, y sklearn.cross_validation import train_test_split x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=0) sc = standardscaler() sc.fit(x_train) x_train_std = sc.transform(x_train) x_test_std = sc.transform(x_test) num_of_examples = len(x_train_std) this getting error: from sklearn.cross_validation import leaveoneout loo = leaveoneout(num_of_examples) train_index, test_index in loo: print

javascript - Can't resolve all parameters for MapsPage:(?,NavController,LaunchNavigator,.......) in Angular 2 -

so using angular2 ionic2 mobile application. application compiling , running until added new module application have navigation in google maps. using phonegap-launch-navigator so. class importing modules maps class , structure of class looks this; import { launchnavigator, launchnavigatoroptions} 'ionic-native'; import { component, ngzone } "@angular/core"; import { navcontroller, platform, navparams } 'ionic-angular'; import {googlemap, googlemapsevent, googlemapslatlng, googlemapsmarkeroptions, cameraposition } 'ionic-native'; import { observable } 'rxjs/observable'; import 'rxjs/add/operator/map'; import { geolocation } 'ionic-native'; import { injectable,forwardref,inject } "@angular/core"; @component({ selector: 'maps-page', templateurl: 'maps.html', }) export class mapspage { private map: googlemap; destination:string; start:string; constructor(public launchnavigatoroptions:

amazon web services - AWS RDS server timed out -

i followed steps given on create ec2 instance , install web server . i tried run samplepage.php code there server @ my-endpoint.amazon.com taking long respond , can't understand why.

ubuntu - Device or resource busy - Docker -

when doing apt-get -y upgrade on new ubuntu 14.04 machine ubuntu:latest (xenial) image, raised error: setting makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ... mv: cannot move 'console-' 'console': device or resource busy makedev console c 5 1 root tty 0600: failed i've fresh install of docker on fresh ubuntu 14.04, using these command: sudo apt-get remove docker docker-engine sudo apt-get update sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual wget -qo- https://get.docker.com/ | sudo sh su - $user # logout , login docker hello-world runs fine: $ docker run hello-world unable find image 'hello-world:latest' locally latest: pulling library/hello-world 78445dd45222: pull complete digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 status: downloaded newer image hello-world:latest hello docker! message shows installation appears working correctly. generate message, docker took following ste

preg match - Thursday 6th of April 2017 to date via pregmatch php -

still learning php, know general programing having hard time convert following string date date format follows thursday 6th of april 2017 hi, still learning php, know general programing having hard time convert following string date thursday 6th of april 2017. can explode using space separator , remove letters date , month can array have think pregmatch should able solve have not been able figure out right combination. apreciated.. i can explode using space separator , remove letters date , month can array convert number month have seen examples pregmatch , should able solve have not been able figure out right combination. appreciated. try this, might helpful you. $date = "thursday 6th of april 2017"; $date = str_replace("of ", "", $date); $d = date_create_from_format('l js f y', $date); echo date_format($d, "y-m-d"); //2017-04-06

How to accept values as doubles in a textbox in ASPX C# Website? -

the following code allows enter integers, instead of integers, need give option user enter double (0.00). suggestions or modification? if (_txstaticpressureupdate.trim() == "") { txsystemmessage.text = "field 'static pressure' empty. please enter valid value."; txsystemmessage.forecolor = system.drawing.color.red; return; } //check record info entered consists of numbers / no special characters or letters (int j = 0; j < _txstaticpressureupdate.length; j++) { if (!char.iscontrol(_txstaticpressureupdate[j])) { txsystemmessage.text = "field 'static pressure' has invalid value."; txsystemmessage.forecolor = system.drawing.color.red; return; } else { staticpressure = double.parse(txstaticpressureupdate.text.trim()); } } i working on aspx/c# website. many of options available winforms. sitll

MySQL Trigger Code to enter statement based on another value -

edit ********** i couldn't below code work have tried run in diagram tool on workbench. code create definer = current_user trigger `measureup_data`.`bmd_results_before_insert` before insert on `bmd_l_arm` each row begin insert bmd_results values ( new.bmd_l_arm_typ case new.l_arm_tscore when < -2.5 'osteoporosis' when > -2.4 < -1.0 'osteopenia' when > -1.0 'normal' else null end); end im getting red crosses though code. values automatically entered data.bmd_l_arm , want field in data.bmd_results labelled bmd_l_arm_typ have text entry based on numerical result pushed l_arm_tscore thanks ongoing help! i new coding game , have been creating db on mysql add value company. have created db schema , want have field in 1 of table insert value based on entry comes table. medical reporting database , diagnosis appear in text on in field entry. this table values appear, more specially column (for example) bmd_sp_ty

Is CMAKE_CXX_FLAGS_PROFILE deprecated in CMake? -

i maintaining old project, , find following statements in cmakelist.txt : set (cmake_cxx_flags_profile "${cmake_cxx_flags} -pg") set (cmake_exe_linker_flags_profile "${cmake_exe_linker_flags} -pg") but can't find these variable definitions in current cmake : # cmake --help-variable-list | grep profile # my cmake version 3.7.2 : # cmake --version cmake version 3.7.2 cmake suite maintained , supported kitware (kitware.com/cmake). so cmake_cxx_flags_profile , cmake_exe_linker_flags_profile deprecated? if existed, function of them? if talking makefile generators can do cmake -dcmake_build_type=profile .. anyone can invent new configuration types in project in case seems have been done. just hint: code simplified since flags anyway concatenated cmake_cxx_flags + cmake_cxx_flags_profile . reference how add custom build type cmake ? (targetting make) cmake generators visual studio not set cmake_configuration_types is cmak

node.js - How can I login to yarn non-interactively? -

when using npm , can login non-interactively with: $ printf "jesstelford\n<password>\nexample@email.com\n" | npm login however, similar command yarn hangs: $ printf "jesstelford\nexample@email.com\n" | yarn login yarn login v0.21.3 question npm username: jesstelford question npm email: in interactive mode, can run: $ yarn login yarn login v0.21.3 question npm username: jesstelford question npm email: example@email.com ✨ done in 22.53s. how can run yarn login non-interactively? yarn appears pause after username entered. need pause when in non-interactive mode: $ { echo "jesstelford"; sleep 1; echo "example@email.com"; } | yarn login this give following output: yarn login v0.21.3 question npm username: jesstelford question npm email: example@email.com ✨ done in 0.84s. how works echo "jesstelford" enters string, followed newline character sleep 1 insert 1 second pause after entering usernam

javascript - how to set paper height in TM-P60II based on html content height? -

Image
i have developed billing info label using html width 58mm , height 150mm . if give print html, in print window paper size coming "rollpaper 58 x 297 mm" . so taking paper size "rollpaper 58 x 297 mm" , paper wastage happening because page height 150mm.so 143mm height paper coming empty. how resolve this? there way set paper height javascript or have set printer settings? thanks in advance.

How to create radio button dynamically using javascript? -

i want display list of data stored in array , against each data want put yes , no radio button. have generated radio button dynamically, radio buttons can select 1 @ time, should like, each data can select either yes or no. please new javascript. function displaydata() { var data=['apple', 'banana', 'kiwi']; var output=""; var output2=""; var datalist; for(var i=0; i< data.length; i++) { datalist=data[i]; output+= '<input type="checkbox" value='+datalist+' name="box2">' + ' ' + datalist+' '+'<br><br>'; output2+= 'yes:<input type="radio" value="yes" name="box2">'+'no:<input type="radio" value="yes" name="box2">'+'<br><br>'; document.getelementbyid("datalist").innerhtml=output; document.getelementbyid(&q

quickblox - binary operator |= cannot be applied to two AVAudioSessionCategoryOptions operands -

error on binary operator |= cannot applied 2 avaudiosessioncategoryoptions operands in swift 3.1. need help here code qbrtcaudiosession.instance().initialize { (configuration: qbrtcaudiosessionconfiguration) in configuration.categoryoptions != avaudiosessioncategoryoptions.allowbluetooth } here solution found qbrtcaudiosession.instance().initialize { (configuration: qbrtcaudiosessionconfiguration) in configuration.categoryoptions = [configuration.categoryoptions, avaudiosessioncategoryoptions.allowbluetooth] }

php - installing xcache on xampp -

im trying install cxcache on xampp. have done: copied dll file php/ext/ folder added xcache.ini php.ini so xcache part of php.ini looks this: [xcache-common] ;; install zend extension (recommended), "$extension_dir/xcache.so" zend_extension = c:/xampp/php/extensions/non-debug-non-zts-xxx/xcache.so ; zend_extension_ts = c:/xampp/php/extensions/non-debug-zts-xxx/xcache.so ;; windows users, replace xcache.so php_xcache.dll zend_extension_ts = c:/xampp/php/extensions/php_xcache.dll ;; or install extension, make sure extension_dir setting correct ; extension = xcache.so ;; or win32: ; extension = php_xcache.dll ; required >=php5.1 if turn xcache on auto_globals_jit = off [xcache.admin] xcache.admin.user = "moo" ; xcache.admin.pass = md5($your_password) xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99" [xcache] ; ini settings, values here default unless explained ; disable: xcache.size=0 ; enable : xcache.size=64m etc (any size > 0) , s

rake - getting the error warning: already initialized constant Mime::DOCX during bundle install in rails -

when try run rake db:migrate in rails application, tables not getting migrated , instead getting deprecated warning messages below. no idea on how fix this. mahesh@mahesh-optiplex-390:~/proj/support_app$ rake db:migrate warning: parser/current loading parser/ruby22, recognizes warning: 2.2-compliant syntax, running 2.3.1. [deprecation] `last_comment` deprecated. please use `last_description` instead. [deprecation] `last_comment` deprecated. please use `last_description` instead. [deprecation] `last_comment` deprecated. please use `last_description` instead. /home/prashanth/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.6/lib/action_dispatch/http/mime_type.rb:163: warning: initialized constant mime::docx /home/prashanth/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.6/lib/action_dispatch/http/mime_type.rb:163: warning: previous definition of docx here mahesh@mahesh-optiplex-390:~/proj/support_app$

html - Need to change url and params from jquery -

html: <a class="col-lg-12" href="{{:~url(name, type)}}" data-toggle="tooltip"> $.views.helpers({ url: function (name, type) { return encodeuri("@url.action("index", "home", new { id = viewcontext.routedata.values["id"]})"); } i need refresh param id jquery. , don't want use dummy value , replace jquery. because id may couldn't replace jquery dummy value. i tried below. $("a").attr("href", '<%= url.action("index", "home", new { id= ' + $("a li.active").attr("data-value")}) %>'); but not working. how change param value dynamically jquery ?

python - Find a root of a function in a given range -

i have set of functions f_t several roots (two actually). want find "first" root , doing fsolve works fine of time. problem is, 2 roots converge, t goes infinity. (a simple exmple of functions f_t(x) = x^2 - 1/t ). larger t gets, more mistakes fsolve makes. there predefined function, similar fsolve can tell should in given range (e.g. find root in [0, inf )). the question same https://mathematica.stackexchange.com/questions/91784/how-to-find-numerically-all-roots-of-a-function-in-a-given-range?noredirect=1&lq=1 , answers there mathematica, want them in python. ps: how can write own algorithm, these tend slower builtins hoping find builtin same. i've read post find root of function in given interval it accepted smooth, well-behaved functions, brent method fastest method guaranteed give root. other 2 methods listed, must provide interval [a,b] across function continuous , changes sign. the scipy implementation documented here . example use ca

session - OAuth 2.0 malicious interceptor on browser -

i going through auth 2.0 protocol [1], along proof key rfc [2]. explains how protocol protects against malicious apps listening network traffic. however, i'm unable understand how auth 2.0 protocol protects against malicious code working on browser itself. let's take simple case of proof key rfc protocol. generate high-entropy code verifier, have store somewhere in browser (possibly in cookies/browser's local storage) use again token. now, in case there malicious code executing on browser, can access cookies/local storage , code verifier. is there protocol enhancement (similar rfc-7636) protects against cookie based exploits? if not, how mitigate it? [1] https://tools.ietf.org/html/rfc6749 [2] https://tools.ietf.org/html/rfc7636 oauth 2.0 caters different types of clients i.e. web clients, in-browser clients , native mobile app clients. the pcke oauth 2.0 mechanism designed native mobile apps. allows public clients protect against malicious apps , att

External library in Android -

i wondering if it's use external libraries took git hub , use in professional app.this libraries may produce low performance or lag? big company use external libraries own apps? sometimes big companies use external libraries , have enough resources or coders create own library . external libraries doesn't creates lag in app, infact , enhance app increase performance. of external libraries in github open , many coders go through code making more efficient group of coders in company creating library. hence suggest review libraries want use , if having positive review go it.

Exclude certain documents from all search results in Solr? -

i newbie in solr , have task block documents result search queries. i searched , found few ways in results can blocked. elevate.xml ( https://wiki.apache.org/solr/queryelevationcomponent ) using " excludeids " parameter in query ( http://localhost:8983/solr/elevate?q= : &elevatedids=doc3,doc4&excludeids=doc6,doc8) using following : <lst name="appends"> <str name="excludeids">doc_id_1,doc_id_2</str> </lst> but there limitations 3 solutions above. elevate.xml works static keywords/search, won't work searches. appending exculdeids in query increase length of post request java code. updating solrconfig.xml append exculdeids give expected result have restart solr everytime there change in list of ids need block. so there way block list of document ids in solr dynamically searches ? an answer question add new field , storing "status" (to displayed or should not) there

c# - Iterate throuh list to determine hierarchy level of elements -

Image
there list of items contain field called "hierarchylevel" (type of string ) determines hierarchy of elements this: link image . tree structure this: <ul> <li>1</li> <ul> <li>1.01</li> <ul> <li>1.01.01</li> <li>1.01.02</li> </ul> <li>1.02</li> <ul> <li>1.02.01</li> </ul> <li>1.03</li> </ul> <ul> and on. my goal implement class contain information parent , children of each element. far have class: class treenode<dbitem> { public dbitem value { get; private set; } public list<treenode<dbitem>> children = new list<treenode<dbitem>>(); public treenode<dbitem> parent { get; private set; } public string level { get; private set; } public treenode (dbitem item, string level) { this.value = item; this.level = level; } public treenode&

javascript - Image of an embeddable Bandcamp iframe not loading until clicked -

i trying include 2 separate iframes bandcamp static website building friend. using html template allows different sections (via section tag) shown or hidden depending on navigation menu have clicked. code comprised of 7 different sections @ point, , hide , show fine. of elements within each of these sections viewable, however, 2 iframes not display background image unless click on iframe itself. of particular interest if add iframes "home" section (the section shown on page load), images show fine, makes me wonder if there issue regarding "active" class being added , taken away via jquery functions the jquery block allows hide , show functionality follows: // global. active menu item var current_item = 0; // few settings var section_hide_time = 1300; var section_show_time = 1300; // jquery stuff jquery(document).ready(function($) { // switch section $(".menu-item", '.mainmenu').click(function() {

jquery - PHP array string key add number at the end -

good day fellas! i have block of code create json string , have dynamic number of data need dynamic name key.. if (mysql_num_rows($result) > 0) { $response["members"] = array(); $x = 0; $members = array(); while ($row = mysql_fetch_array($result)) { $members = array(); $members["member" + (string)$x] = array(); $member["member_id"] = $row["member_id"]; $member["firstname"] = $row["firstname"]; $member["mi"] = $row["mi"]; $member["lastname"] = $row["lastname"]; $member["email"] = $row["email"]; $member["username"] = $row["username"]; $member["password"] = $row["password"]; $member["guild_id"] = $row["guild_id"]; $member["guild_name"] = $row["guild_name"]; $member["

java - Dagger 2: avoid exporting private dependencies -

lets have module want export instance of a . a requires instances of b and c passed in constructor. declare them in module: public class samplemodule { @provides @singleton providea(b b, c c){ return new a(b, c); } @provides @singleton b provideb(){ return new b(); } @provides @singleton c providec(){ return new c(); } } this works, b , c available elsewhere in code. want keep them private , force client classes have access a . is there way achieve this? the easiest way accomplish goal bind types don't want made available (in case b , c ) @qualifier not accessible. then, while b , c might be accessible outside module, in order inject them need supply qualifier, not. @module public final class samplemodule { @qualifier @retention(runtime) private @interface samplemoduleonly {} @provides @singleton static providea(@samplemoduleonly b b, @samplemoduleonly c c){ r

javascript - How to include css files with scss when compiling with gulp -

this gulpfile.babel.js: 'use strict'; import plugins 'gulp-load-plugins'; import yargs 'yargs'; import browser 'browser-sync'; import gulp 'gulp'; import rimraf 'rimraf'; import yaml 'js-yaml'; import fs 'fs'; // load gulp plugins 1 variable const $ = plugins(); // set local url project let url = 'sf.admin.lelo.com/'; // check --production flag const production = !!(yargs.argv.production); // load settings settings.yml const { compatibility, port, paths } = loadconfig(); function loadconfig() { let ymlfile = fs.readfilesync('config.yml', 'utf8'); return yaml.load(ymlfile); } // build "dist" folder running of below tasks gulp.task('build', gulp.series(clean, gulp.parallel(sass, cssvendors, javascript, javascriptloose, javascriptcustom, images, copy))); // build site, run server, , watch file changes gulp.task('default', gulp.series(

oracle - Refreshing image displayed in form when selected from table in adf -

i saving image on every data enter , data displays in table. when select data 1st time image gets shown if select same row time image doesn't show up. instead shows codes in image block. like if go row1 row2 images shows properly.but if got row2 row1 again,image doesn't show up. is there logic needed refresh table selecting each row? please suggest . thanx in advance

Neo4j lowest node java procedure -

i creating procedure return lowest node in database have problem. code not work me. compile using maven after start crash. code here: @context public graphdatabaseservice db; @procedure @description("return lowest node") public stream<stringresult> get() { resourceiterable<string> low = db.getallpropertykeys(); list<string> node = new arraylist<string>(); while(low.iterator().hasnext()){ string next = low.iterator().next(); node.add(next); } string = collections.min(node); return stream.of(new stringresult(collections.min(node))); } public class stringresult { public final string value; public stringresult(string value) { this.value = value; } } i thankfull if u me because confused.

android - Lock screen prompt while closing the window on lockscreen -

i have application shows notification of top 5 recent contacts when click on contact in lock screen, opens window on lock screen. when close want prompt user unlock device can please let me know if there way sample example thanks

xamarin.ios - How to Expose Objective-C Pointer Method WithResultBuffer in IOS Binding -

i'm trying invoke objective-c method -(nabto_status_t)nabtorpcinvoke:(nsstring *)url withresultbuffer:(char **)jsonresponse; i used objective-sharpie tool generate follow method [export("nabtorpcinvoke:withresultbuffer:")] unsafe nabto_status_t rpcinvoke(string url, ref byte jsonresponse); please expose me correctly can jsonresponse string can use in ios app. i made these changes generated method [export("nabtorpcinvoke:withresultbuffer:")] unsafe nabto_status_t rpcinvoke(string url, ref intptr jsonresponse); and got jsonresonse follow. intptr buff=new intptr() ; status = client.rpcinvoke(url, ref buff); byte[] newarray = new byte[buff.toint32() + 1]; (int m = 0; m < buff.toint32(); m++) { byte b = marshal.readbyte(buff,m); newarray[m] = b; } var jsonresponse = system.text.encoding.utf8.getstring(newarray);

url - Jboss 6.4 only works on localhost and how do i specify some other name instead of localhost -

i able access application in jboss https://localhost/appname but how change localhost whatever name wanted have? i have https://nameiwanted/appname i using jboss 6.4 , windows 7 professional thanks in advance open jboss server @ eclipse , check check box in server behavior: listen on interfaces allow remote , web applications

c++ - How to read wstring by wcin, and write it in console by wcout? -

i have such problem. i'm polish. use polish letters in console. i've found how write unicode literals wcout stackoverflowanswer . still don't know, how read unicode literals wcin, , write them back, console (when read 'ĄĘÓŁŚŻŹĆŃ', have wierd output). how read polish letters wstring wcin, able correctly write them wcout? when add: _setmode(_fileno(stdin), 0x00020000); it doesn't read numbers; please help, thanks. mike. edit: here's code (of function): void dodaj() { wcout << l"dodawanie nowego pracownika:\n"; wstring imie, nazwisko; short dzien, miesiac, rok; wstring adnotacjadodatyurodzenia, stanowisko, adnotacjadopracownika; wcout << l"podaj imię nazwisko:\nimie: "; getline(wcin, imie); wcout << l"nazwisko: "; getline(wcin, nazwisko); wcout << l"podaj datę urodzenia:\n"; dzien = pobierzshort(l"dzień: "); miesiac = pobierzshort(l"miesi

php - What is the difference in accessing relation directly and using with in Laravel? -

consider following model class user { public function roles() { return $this->hasmany('roles'); } } i can fetch user details below $user1 = user::find(1); $user2 = user::with('roles')->find(1); both above methods works same. without using with('roles') , can still access roles of particular user. echo $user1->roles; // outputs roles of user so, question actual difference/advantage using with('relation') ? the with() function used eager loading . when loading 1 user have little impact. when try roles property, query roles user executed, user. now consider loading list of users database. when call roles property each of these users, query executed every user. not way work. when use with() function, relations eager loaded. wich means laravel load roles in 1 query , assign them correct user objects. when call roles property on user objects now, values loaded no database query needed. reducing a

unity3d - Take photo in unity c# -

i'm trying build program takes photo , places different background, monument or so. far, able turn camera on when start project code webcamtexture = new webcamtexture(); rawimage.texture = webcamtexture; rawimage.material.maintexture = webcamtexture; webcamtexture.play(); texture2d phototaken = new texture2d (webcamtexture.width, webcamtexture.height); phototaken.setpixels (webcamtexture.getpixels ()); phototaken.apply (); however, can't take screenshot or photo because ends black. i've tried different codes nothing working. can please help? thanks edit after tries, code have: webcamtexture webcamtexture; public rawimage rawimage; void start () { webcamtexture = new webcamtexture(); rawimage.texture = webcamtexture; rawimage.material.maintexture = webcamtexture; webcamtexture.play(); rendertexture texture= new rendertexture(webcamtexture.width, webcamtexture.height,0); graphics.blit(webcamtexture, texture); button btn =

r - Merge data files -

i have following data frames in r: id class @a 64 @b 7 @c 98 and second data frame: source target @d @b @c @a this describes nodes , edges in social network. users (all @ in front) belong specific community , number listed in column class. analyse connections between columns want merge data frames , create new data frame looking this: source target source.class target.class @a @i 56 2 @f @k 90 49 when try merge() r stop responding , need terminate r. data frames constitute 20000 (node file) , 30000 (edge file) rows. then want know how many records in given source class have same target class , percentage of connections between classes. i happy if me since i'm new r. edit: think manage create columns code using match() instead of merge() (rt_node contain columns "id", "class" , rt_node contain columns "source","target"):

file - Android espresso compare strings on the screen with string from assets -

i compare content of .txt file have in assets folder text on screen. usually when assert text on screen use: onview(withid(r.id.someid)).check(matches(withtext("string"))); is ther easy way can assert file? also, if want shorten assertions , actions when using expresso, check library: https://github.com/schibstedspain/barista (disclaimer: i'm contributor). it contains set of quick actions , assertions make tests more readable.

r - Assignment algorithm variant -

Image
i have square matrix in r containing distances between cities: set.seed(3) x <- matrix(sample(1:15, 16, replace = true), nrow = 4) x # [,1] [,2] [,3] [,4] #[1,] 3 10 9 9 #[2,] 13 10 10 9 #[3,] 6 2 8 14 #[4,] 5 5 8 13 every row represents city courier can sent, , every column represents city package has delivered. couriers have same package, can assigned every other city. use hungarian algorithm in clue::solve_lsap() find optimal assignment total cost (in case total distance) minimized: y <- clue::solve_lsap(x) y #optimal assignment: #1 => 1, 2 => 4, 3 => 2, 4 => 3 however, in specific case minimize spread of distances. have been searching quite time now, , found following here in book @ page 270 (and similar here in book @ page 195 ): so stated objective minimize difference between maximum , minimum assigned distance, looking for. assignment of hungarian algorithm gives following difference between maximu

java - Best way to create a object pool if objects needs to load the same huge file for initialization -

does know way create pool of objects containing heavyweight objects? i tried , works far, problem is, each object needs load same huge model file initialization (~200mb), initialization of pool takes around 2 , half minutes , takes lot of memory. currently, have array of objects filled objects loop , know classes genericobjectpool , don't think make difference or wrong? you can use object pooling api ( i;e apache api ) may resolve problem.

c - Function run 2 times.? -

i made program, code compiled thought program takes 5 inputs user takes 10 inputs. #include <stdio.h> int greatest_number(); int main() { greatest_number(); printf("greatest number %d", greatest_number()); return(0); } int greatest_number() { int a[6], x, i, z, y; i don't know why loop takes 10 inputs user programmed take 5 inputs for(x=0; x<5; x++) { printf("enter number:"); scanf("%d", &a[x]); } a[x]=0; x=0, i=1; y=0; z=a[x]; while(a[x]) { if(z>a[i]){ z=a[y]; }else { z=a[i]; y=i; } x++; i++; } return(z); } in code snippet function greatest_number called twice greatest_number(); ^^^^^^^^^^^^^^^^^ printf("greatest number %d", greatest_number());

java - how to sort trimmed values in hash map -

i'm having trouble sorting trimmed values in hash map after parsing json string. //read data string line; while ((line = bufferedreader.readline()) != null) { result.append(line); } jsonobject jsonobjectresult = new jsonobject(result.tostring().trim()); jsonarray jsonarrayapps = jsonobjectresult.getjsonarray("apps"); try { (int i=0; i<jsonarrayapps.length(); i++) { hashmap<string, string> map = new hashmap<string, string>(); jsonobject e = jsonarrayapps.getjsonobject(i); map.put("name", e.getstring("package").trim() ); map.put("cate", e.getstring("category").trim()); mylist.add(map); //mylist variable listview } } catch (jsonexception e) { log.e("log_tag", "error parsing data "+e.tostring()); } the following results list of installed apps , categories (click view) i need in sorting out trimmed values sorted d

swift - Cannot get first(where:​) to work with [NSDictionary] -

i have array of nsdictionary's , want dictionary out of array specific key "id". tried following error: cannot call value of non-function type 'nsdictionary?' consider following example of trying do: let dictionaries: [nsdictionary] = [nsdictionary(dictionary: ["id": "123", "name": "the name"]), nsdictionary(dictionary: ["id": "456", "name": "the other name"])] if let dictionary = dictionaries.first(where: { $0.objectforkey("id") == "123" }) { print(event.objectforkey("name") ?? "") } the problem result of objectforkey ( object(for:) in swift 3). nsdictionary , has no types, result any? . cannot compare any? string . cast string needed: if let dictionary = dictionaries.first(where: { $0["id"] as? string == "123" }) { print(dictionary["name"] ?? &

Last row of expandable listview not full view in android -

Image
here uses view , there code per given below. <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <tablerow android:id="@+id/tab_stone_info" android:layout_width="match_parent" android:layout_height="30dp" android:layout_margintop="1dp" android:background="@color/stylebreaktabcolor" android:weightsum="9"> <textview android:id="@+id/stone_type" android:layout_width="match_parent"

javascript - How to mock a click in jasmine/karma -

i struggling mock out click check prevent.default. in directive got this. mycustomthing.addeventlistener('click', event => { event.preventdefault(); }); then in test m trying test so. it('prevents default on click', function () { mycustomthing.addeventlistener = jasmine.createspy('addeventlistener'); mycustomthing.click(); expect(mycustomthing.addeventlistener) .tohavebeencalled(); }); when test following error: expected spy addeventlistener have been called. appreciated. thank in advance.

java - How to ask a user a set of questions and store the answers -

i'm making text based adventure game. i'm trying have game choose "class" player based on answers questions. (e.g. if player chooses sneaky or stealthy leaning answers game assign them "rogue" class fits type of person. so far, i've created method want call later in main program, , based on return value is, i'll use conditional statement set player class calling set method. here method far. way i'm heading, have very long choosespec method want @ least maybe 10 questions. question efficient way write out, , doing in 1 method right way go? public static int choosespec(scanner in) { int war = 0; //counter warrior class int rog = 0; //counter rogue class int mag = 0; //counter magic class int choice; //users choice, number between 1 , 3. system.out.println("while out hunting, come across deer has been badly mauled wolf. do?" + "\n" + "1. draw dagger , end it's sufferi

Neon version of eclipse compatibility with osb 11g(11.1.1.6.0) -

i have been working on eclipse ide 11.1.1.8.0 compatible ofm_osb_generic_11.1.1.6.0. however, have been asked switch eclipse neon version (eclipse-dsl-neon-2-win32-x86_64). i'm not able correct plugin info required integrate osb 11g ide. info appreciated. in advance.

android - java.lang.RuntimeException: Package manager has died -

i got following exception crashlytics on api level 22 yu5510 device. frequency of occurring exception not higher. hardware related issue or device specific issue? exception java.lang.runtimeexception: unable start receivercom.google.firebase.iid.firebaseinstanceidinternalreceiver: java.lang.runtimeexception: package manager has died android.app.activitythread.handlereceiver (activitythread.java:2649) android.app.activitythread.access$1800 (activitythread.java:154) android.app.activitythread$h.handlemessage (activitythread.java:1398) android.os.handler.dispatchmessage (handler.java:102) android.os.looper.loop (looper.java:135) android.app.activitythread.main (activitythread.java:5292) java.lang.reflect.method.invoke (method.java) java.lang.reflect.method.invoke (method.java:372) com.android.internal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:904) com.android.internal.os.zygoteinit.main (zygoteinit.java:699) arrow_drop_down caused java.lang.runtimeexception: package man