Posts

java - How to add back button arrow functionality in navigation bar -

i beginner programmer , resent started android developing. watched many answers , couldn't find answer witch fit me. have added arrow button in action bar, couldn't figure out how add navigation first loaded screen. mainactivity.java public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); actionbar actionbar = getsupportactionbar(); if (actionbar != null){ actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true); } drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); final actionbardrawertoggle toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer...

discrete mathematics - Floating point number and range of floating point numbers that can be represented by a string -

refer string of bits 010011110110 we assume when number stored floating point (real) number, 6 of 12 bits reserved mantissa (or significand) if string represents floating point number, (smallest) number? and find range (or interval) of floating point numbers represented same string. value=(-1)^s (1+m/26 )^{e-24} think need in order solve 1 of the, these last 2 questions have assessment due on thursday 28th, i've completed other questions , @ point in time have no idea if of them right , i'm stuck on these question. have no idea why have computer science class networking major it's killing me. since base 2 , mantissa 6 , assuming 12 digit precision, according wikipedia on floating point numbers , believe range 100000 * 2^011111 011111 * 2^011111 or rather -32*2^31 31*2^31, smallest value 1*2^100000 or rather 1*2^-32.

php - fetch only X Product Model via eager loading in a ManyToMany Product Category relationship -

i have manytomany relationship between category , product model. product model : class product extends model { protected $primarykey = 'product_id'; public function categories () { return $this->belongstomany('app\category', 'category_product', 'product_id', 'cat_id'); } } and category model : class category extends model { protected $primarykey = 'cat_id'; public function products (){ return $this->belongstomany('app\product','category_product','cat_id','product_id'); } } now , want fetch last 4(for example) products of each category. write : $categories = category::with([ 'products' => function($query){ $query->select('products.product_id')->orderby('created_at','desc')->take(4); } ])->get(); but not work , re...

Using index.html as UI doesn't work with eventReactive Shiny R -

i've been struggling issue in last 2 days , nothing seems work me far. what want piece of code do: user click searchbutton, empty data frame created. eventreactive works fine me on normal ui.r when tried use index.html doesn't work. code below: server.r: new_search <- eventreactive(input$searchbutton, { search_term <<- input$searchtext test <- data.frame() }) index.html <!-- search bar --> <form class="sidebar-form"> <div class="input-group"> <input id="searchtext" type="text" class="form-control" placeholder="ask me anything.."> <span class="input-group-btn"> <button id="searchbutton" type="button" class="btn btn-flat action-button"> <i class="fa fa-microphone"></i> </b...

javascript - Changing a background image of <body> (in CSS) depending on the season (Current Calendar Month) -

i'd change html background depending on date, i've written isn't working properly. can't find applicable examples , i'm struggling complete it. i want start of new season change background of html page altering image used in css file. javascript: var d = new date(); var day = d.getdate(); var month = d.getmonth(); if (month == <3 && month == 5) { document.background-image: url("springtree.jpg"); } else if (month == < 6 && month == > 8) { document.background-image: url("summertree.jpg"); } else if (month == < 9 && month == > 11) { document.background-image: url("autumntree.jpg"); } else (month == 12 && month == > 2) { document.background-image: url("wintertree.jpg"); css: div.body { background-image: url("summertree.jpg"); width: 640px; height: 1136px; background-repeat: no-repeat; background-attachment: fixed; backgr...

spring - java.lang.NullPointerException at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChainContents -

i have war application (spring + jsf1.2/richfaces + hibernate) running on was8.5 server, when try access http://localhost:9080/name_app/login.xhtml , java.lang.nullpointerexception coming server internal source, below log trace of error : [28/01/16 09:45:06:325 wet] ffdc exception:java.lang.nullpointerexception sourceid:com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters -re probeid:1123 reporter:com.ibm.ws.webcontainer.filter.webappfiltermanagerimpl@9afb2765 java.lang.nullpointerexception @ com.ibm.ws.webcontainer.filter.webappfiltermanager.getfilterchaincontents(webappfiltermanager.java:775) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.getfilterchain(webappfiltermanager.java:379) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.dofilter(webappfiltermanager.java:931) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters(webappfiltermanager.java:1107) @ com.ibm.ws.webcontainer.webapp.webapp.handlerequest(webapp.java:3...

java - Improving Intersection Algorithm -

i have algorithm build intersection of 2 sorted lists. if compare java.util.bitset in performance test, algorithm slow. public static list<integer> intersection(list<integer> list1, list<integer> list2) { int size1 = list1.size(), size2 = list2.size(); int capacity = size1 < size2 ? size1 : size2; list<integer> intersection = new arraylist<integer>(capacity); int i1 = 0, i2 = 0; while (i1 < size1 && i2 < size2) { if (list1.get(i1) < list2.get(i2)) i1++; else if (list2.get(i2) < list1.get(i1)) i2++; else { intersection.add(list2.get(i2++)); i1++; } } return intersection; } anyone sees improvement? thanks are inputs function of type arraylist ? if are, algorithmically there noth...