Posts

Showing posts from February, 2012

tensorflow - Install Keras on Heroku with Theano backend as default -

i've been trying deploy heroku webapp uses keras models. unfortunately, importing keras default tensorflow backend takes atrociously long, , causing web dyno timeout (due heroku's 30sec limit), causing endless termination , restart cycle. i've since discovered keras imports faster theano backend, don't know how specify use keras w/ theano in heroku deployment. locally, change ~/.keras/keras.json file, how specify heroku's environment? python 3.6.0 keras 2.0.4 theano 0.9.0 tensorflow 1.2.1 thanks much!

php - Laravel Own model for users on request property in middleware -

Image
in middleware can access laravel's user model comes laravel via if($request->user() === null) { echo 10000; } but have own models, , own table of users. model users not user when try do: if($request->users() === null) { echo 10000; } i error: how attach own users model request? instead of using built in user?

testing - Predefined mock response in Spock -

i'm new spock , question refers example on page 178 of java testing spock. class under test basket class shopping application, , method of class being tested canshipcompletely() public class basket { private warehouseineventory warehouseinventory; private shippingcalculator shippingcalculator; protected map<product, integer> contents = new hashmap<>(); ... public void addproduct(product product) { addproduct(product, 1); } public void addproduct(product product, int times) { if (contents.containskey(product)) { int existing = contents.get(product); contents.put(product, existing + times); } else { contents.put(product, times); } } public boolean canshipcompletely() { if(warehouseinventory.isempty()) return false; try { (entry<product, integer> entry : contents.entryset()) boolean ok = warehouseinventory.isproductavailable( entry.getkey().getname()...

linux - hammer csv content-hosts command fails with undefined method '+' for nil -

i trying execute hammer csv content-hosts command export subscription consumption usage red hat satellite server 6.2.2. when execute command following error. 'undefined method '+' nil:nilclass (nomethoderror)'. has 1 encountered error. attaching screen shot error. enter image description here

babel - Using Jest with Typescript + preact -

problem transpiling jsx h() in tests. config files similar create-react-app, exclude changes typescript , preact i create app via create-react-app my-app --script=react-scripts-ts - typescript project. eject , change react preact (don't use preact-compat ). for migrating preact i'm add package.json babel.plugins section new plugin ["babel-plugin-transform-react-jsx", { pragma: "h"}] - transpiling <jsx /> h(jsx) function calls, instead default react.createelement(jsx) (migration guide https://preactjs.com/guide/switching-to-preact ). and works fine. but test has different configuration of transpiling <jsx /> : it's transpile react.createelement(jsx) default. , in test take error referenceerror: react not defined @ object.<anonymous> (src/linkify/linkify.test.tsx:39:21) . if manually change <jsx /> h(somecomponent) in test , tested file - work. how transpile <jsx /> h(jsx) tests? // typescriptt...

sql - R - Leave one out aggregation on a grouping variable (NA exist) -

i want compute new variables "have" data set, in r, follows: re: average of "r" values within given "cat" variable value excluding specific observation (note: missing data exists , re group mean re when r missing). ie: re, average of "i" responses within given "cat" variable value excluding specific observation (same missing data technique). an example data set , desired output given below. have: id cat r … (additional variables need retain) 1 1 1 3 … 2 1 2 na … 3 1 1 1 … 4 2 na 3 … 5 2 4 5 … 6 2 4 na … the desired data set ("want") should be: want: id cat r re ie … (additional variables retained) 1 1 1 3 1.5 1 … 2 1 2 na 1 2 … 3 1 1 1 1.5 3 … 4 2 na 3 ... ... … 5 2 4 5 … 6 2 4 na … notably, following sql based solution produces desired output in sas ...

ios - Slow Tableview with custom cell with images, Swift 3 and core data -

i trying solve slow, sluggish scrolling on table. i'm using core data wrapper aerecord fetch data, , scrolls smooth without cell.toneimage.image = uiimage(named: tone.image) the images aren't big ( 350 x 170) def freezes second scroll enough load new image. i checked blended images in simulator, etc.. data being fetched + loading image @ same time? ideas or suggestions? override func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "cell", for: indexpath) as! mwcelltableviewcell self.configurecell(cell, atindexpath: indexpath) return cell } func configurecell(_ cell: mwcelltableviewcell, atindexpath indexpath: indexpath) { if let frc = fetchedresultscontroller { if let tone = frc.object(at: indexpath) as? tone { // set data cell.tonetitle.text = tone.name.uppercased() let img:uiimage = tone...

java - Springfox JSON PUT request with String Request Body not formatting correctly -

i'm using springfox 2.7.0 generate swagger ui docs spring rest api. operations (get, put, delete) testing fine on of endpoints via integration test cases. requests returning data fine via swagger ui put operations via "try out!" part failing due how request body sent. have following signature in 1 of rest api endpoints (which typical of how put endpoints are): @requestmapping(value = "/runsql", method = requestmethod.put) public responseentity<string> runsql(@requestbody string json, httpservletrequest request) when use "try out!" via swagger ui produced springfox, json request body comes in looking this: "{ \"id\" : \"1234\", \"sql\" : \"select * users\" }" jackson doesn't json string. how can configure springfox and/or spring process json string correctly via "try out!" section on swagger ui?

Checking AppState prior to dispatching Redux Action? -

say have redux store keeps track of appstate comprised of single 'color' variable string. initialstate = { color: 'red' } and action updating this: const set_color = 'set_color'; function setcolor(color) { return { type: set_color, color }; } and have sort of input allows user set color whatever please. (how done irrelevant) let newcolor = <got new color somehow> now lets user inputs 'red' (the same current state). should care if newcolor , current color differ? ie, should first check store see if newcolor different old color , , dispatch setcolor action iff color different? or should dispatch setcolor action, regardless if there's difference. in general, easiest thing , call setcolor again. reason keeps logic more straightforward. time user changes color via input field, code dispatch action. now, need write test case verify behavior. may sound trivial 1) adds , 2) have test case of rapidly switching , ...

csv - R removes spaces in read.table -

i came across surprising behavior today doesn't seem right me. have csv file several columns, numeric , text. 1 of text columns contains spaces between words. when read file r using read.csv (or more read.table), removes spaces. not talking leading or trailing whitespace, spaces inside string. i have looked through docs , can find option turn off behavior. surely there must way tell r read data , not remove these spaces. or there?

py.test - How do I execute code after pytest generates a report (using pytest)? -

so i'm trying automatically sftp html report (that pytest creates) server after pytest finishes execution. exist in pytest or have create wrapper? i know there "setup" , "teardown" methods , there exists teardown method can execute after tests have ran, occurs before report generated (not want!). you can handle in pytest_unconfigure hook. if using pytest-html generate test reports, can access path of reports # in conftest.py def pytest_unconfigure(config): html_report = config._html.logfile # provides full path of generated html report # or html_report = config.option.htmlpath # provides value passed --html command line option # code upload sftp goes here

php - User extended from FOSUserBundle causes unserialize() Error at offset at Easyadmin list -

i use 1.16.10 version of easyadminbundle. created user entity, extended fosuser's model (as in documentation) , added easyadmin configuration file. result got following error: an exception has been thrown during rendering of template ("notice: unserialize(): error @ offset 0 of 34 bytes"). the full description stack trace: critical - uncaught php exception twig_error_runtime: "an exception has been thrown during rendering of template ("notice: unserialize(): error @ offset 0 of 34 bytes")." @ \vendor\javiereguiluz\easyadmin-bundle\resources\views\default\list.html.twig line 132 so, code of entity: namespace backofficebundle\entity; use doctrine\orm\mapping orm; use fos\userbundle\model\user baseuser; use gedmo\mapping\annotation gedmo; /** * acluser * * @orm\entity(repositoryclass="backofficebundle\repository\acluserrepository") * @orm\table(name="acl_user") */ class acluser extends baseuser { /** * ...

javascript - Can't change attribute data-*** with jquery -

i don't understand why request button not performed. must change direction mobile screens, until it's work. $( "button.btn-tooltip" ).attr( "data-placement", "left" ); body { padding: 10px; } button { width: 100px; height: 30px; margin: 10px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script> <button type="button" class="btn btn-tooltip" data-toggle="tooltip" data-placement="right" title="tooltip"></button> you're looking @ default tooltip, r...

Github Pages site not detecting index.html -

i created github pages repository. reason when give https://[username].github.io/ , doesn't work. works when give https://[username].github.io/index.html . whys not detecting index.html. it got fixed automatically. had wait while settings take effect.

Does not work sharing facebook -

yesterday still worked. for example <meta property="fb:app_id" content="1495651450680325" /> <meta property="og:description" content=""> <meta property="og:title" content="test page facebook sharing"/> <meta property="og:type" content="website" /> <meta property="og:url" content="http://archspeech.com/ttt.php" /> <meta property="og:image" id="share_meta" content="http://archspeech.com/image/article/b_673e3dfec90c94aac432e2ed2a9f979d.jpg"/> <link rel="image_src" id="share_link" href="http://archspeech.com/image/article/b_673e3dfec90c94aac432e2ed2a9f979d.jpg" /> in facebook debug when sharing thanks! you should put og tags before javascript, facebook scraper takes part of website check og tags. issue, because there lot of js (and css) fil...

multidimensional array - How to group the repeated columns in the text file - perl (groups, subgroups) -

input description it tab delimited file. first 5 columns id's , relations has in final print anyway. want group columns 6, if repeated. different groups exist hierarchy. column 3 criteria grouping. in example, 4 , 5 criterias. please check output. input ag1_4099 13 4 2 2 uv1040 uv0000 uv3770 uv3890 ag1_9001 20 4 2 1 uv1040 uv0000 uv3770 uv3890 ag1_9011 63 4 2 4 uv1040 uv0000 uv3770 uv3890 ag1_7013 11 4 1 1 uv1040 uv0000 uv3770 uv3890 ag1_9010 37 4 1 1 uv1040 uv0000 uv3770 uv3890 ag1_1011 33 4 2 7 uv1040 uv2080 uv3770 uv3890 ag1_1013 101 4 1 1 uv1040 uv2080 uv3770 uv3890 ag1_0001 7 4 2 1 uv1040 uv2100 uv3770 uv3890 ag1_1010 23 4 1 1 uv1040 uv8000 uv3770 uv3890 ag1_2099 13 4 2 2 uv1040 uv1000 uv3770 uv3890 ag1_3133 24 5 2 2 uv1040 uv300 uv2100 uv3770 uv3890 ag1_3433 343 5 7 3 uv1040 uv2118 uv2100 uv3890 uv3770 ag1_1100...

android - Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i'm using android studio. app stops when try , switch tabs , gives me error: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.class java.lang.object.getclass()' on null object reference @ android.support.v4.app.backstackrecord.doaddop(backstackrecord.java:394) @ android.support.v4.app.backstackrecord.add(backstackrecord.java:389) @ android.support.v4.app.fragmentpageradapter.instantiateitem(fragmentpageradapter.java:103) @ android.support.v4.view.viewpager.addnewitem(viewpager.java:1005) @ android.support.v4.view.viewpager.populate(viewpager.java:1219) @ android.support.v4.view.viewpager.setcurrentiteminternal(viewpager.java:665) @ android.support.v4.view.viewpager.setcurrentiteminternal(viewpager.ja...

node.js - Redirect after download file - Nodejs -

i'm trying redirect page after downloading file. code: app.get('/log', function(req,res){ return res.download('file.txt', function(err){ if(!err){ return res.render('index.html'); } }); }) but every time error: error: can't set headers after sent. there way redirect/render after downloading? (at server-side, please). you can't in way think headers sent download response. you can accomplish manipulating response send required headers file download , send location header along with. requester should understand location header , redirect accordingly. for eg. const filedata = /* read file */; res.set({ 'content-type': 'text/plain', 'location': '/' }); res.end(filedata);

multithreading - Java: TCP connection in the background thread. How to display JDialog? -

i trying send message server via tcp/ip, wait response, , perform further actions dependent on response. while communication in background process, dialog spinning activity indicator should displayed. furthermore, if there error in connection, jdialog should displayed. this method invokes connection result of pressing button: public void sendmessage() { jframe f = new jframe(); jdialog modaldialog = new jdialog(f, "busy", dialog.modalitytype.modeless); modaldialog.setsize(200, 100); modaldialog.setlocationrelativeto(f); modaldialog.setundecorated(true); // remove menu buttons modaldialog.getrootpane().setwindowdecorationstyle(jrootpane.none); modaldialog.getcontentpane().setbackground( color.white ); // add rotating activity indicator imageicon loading = new imageicon("src/images/activityindicator.gif"); modaldialog.add(new jlabel("please wait... ", loading, jlabel.center)); // set activity indicator visible ...

android - ThreadEnforcer usage in Event Bus register method -

can simplify code register object able listen events posted event bus? also, need wrap post call in handler contact ui thread ?? main question thread enforcer doing here public void register(object object) { if (object == null) { throw new nullpointerexception("object register must not null."); } enforcer.enforce(this); map<class<?>, eventproducer> foundproducers = handlerfinder.findallproducers(object); (class<?> type : foundproducers.keyset()) { final eventproducer producer = foundproducers.get(type); eventproducer previousproducer = producersbytype.putifabsent(type, producer); //checking if previous producer existed if (previousproducer != null) { throw new illegalargumentexception("producer method type " + type + " found on type " + producer.target.getclass() + ", registered type " + previousproducer.target.getclass() + "."); } ...

asp.net - [Solved]check holiday or not from online Calendar or server with C# ASP -

i have date database. want check date holiday or not in japanese calendar online or server. there lots of holiday type in japan. please me... [solved] created isholiday function , used wc.openread("http://s-proj.com/utils/checkholiday.php?kind=h&date=" + date) check selected date holiday or not online directly.. thank soo everyone.. you may try holiday api , haven't used myself quick @ documentation reveals can make request , they'll return json response similar : { "status": 200, "holidays": [{ "name": "independence day", "date": "2015-07-04" "observed": "2015-07-03" "public": true, }] } as pointed in comments above question doesn't contain code samples , broad answer. hope helps !

java - How to avoid type-checking of a subclass? -

i have code: public abstract class character { public abstract void attack(character victim); public abstract void receiveattack(attack attack); } public class charactera extends character { public void attack(character victim) { if (victim.getclass().equals(this.getclass()) return; victim.receiveattack(new attack(base_dmg)); } } the idea character can attack , receiveattacks to/from other characters, cannot receive attack comes character of own class (charactera cannot attack charactera attack characterb or receive attack characterb). i know checking type of object bad smell , caused because of bad design, question how change design don't have check object type? edit the class not named character , name simplify example. there no teams. charactera can attack other character not charactera . final edit thanks everyone, solved using visitor pattern. a simple solution/ work-around have 1 class, , every chara...

javascript - captureStream() on dynamically created video element -

i trying capture stream dynamically created video element. when video element , try videoelement.capturestream() firefox returns videoelement.capturestream not function same code works on chrome. problem seems firefox has issue dynamically created video element. tried mutation observer detect newly added video element , access capturestream method no luck posting code sample below (i using adapter.js webrtc https://webrtc.github.io/adapter/adapter-latest.js ) (function (win) { var listeners = [], doc = win.document, mutationobserver = win.mutationobserver || win.webkitmutationobserver, observer; function ready(selector, fn) { listeners.push({ selector: selector, fn: fn }); if (!observer) { observer = new mutationobserver(check); observer.observe(doc.documentelement, { childlist: true, subtree: true }); } check(); } function check() { ...

html - Which is the correct way to horizontally center this Bootstrap form in MVC? -

when want center div inside div, re-read this post . works. doesn't , million years away expert in css. here how form constructed: <h2 class="no-margin-top">revisiones administrativas</h2> @using (html.beginform()) { @html.antiforgerytoken() <div class="form-horizontal"> <hr /> @html.validationsummary(true, "", new { @class = "text-danger" }) <div class="form-group"> @html.labelfor(model => model.tipovisitante, htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> <select name="tipovisitante" id="tipovisitante" class="form-control"> @foreach (var item in model.tiposvisitante) { <option value="@item.descripcion...

utf 8 - python print format for Chinese characters -

i working python 3.6.0 on linux (centos). python print format cannot work chinese characters. following simple codes produce unexpected wrong alignment. tmp = '%32s %32s' print(tmp % ('first', 'second')) print(tmp % ('第一', '第二'))

sorting - MySQL sort line2 after line1 IF line2.id2=line1.id -

i have 2 little problem sorting tables in mysql querying 1 or more tables, don't doubt subqueries can me, don't know theses types of queries , second example doesn't work expected first. first, consider table messages , table user, have id table message table messages id id2 userid1 userid2 message senddate readdate id=unique id2:self referencing table message avoid compute dates fields userid1:a message user userid2:a message user ... so can retrieve messages userid1=userid , userid2=userid using order greatest function on userid1 , userid2, messages ll sorted user sent , received messages same user, column id ll automatically sorted in case of doubt. the main problem when want same don't figure how table comments , table posts. i want retrieve comments post, have filter post , take comments how sort comments that: table comments id id2 comment userid how sure ll comments id2=id of previous line? edit: oops maybe simpler --->...

javascript - How to pass many ajax results to different input values? -

my ajax return results 4 values.i want assign these values 4 input value.here ajax code: $.ajax({ type:"post", url:"modify_cbndtb.php", data: {cabinetnum:id}, success:function (res) { } }); modify_cbndtb.php code: if(isset($_post['cabinetnum'])) { $q=$_post["cabinetnum"]; $sql="select num1,num2,num3,num4 hpc sysid= '".$q."';"; $sel = $conn->query($sql); } my html code: <div id="content" class="content"> 1u:<input type="text" id="1u" value="">11u:<input type="text" id="11u" value=""><br /> 2u:<input type="text" id="2u" value="">12u:<input type="text" id="12u" value=""><br /> </div> 1u.value should num1. 2u.value should num2. 3u.value should num3. 4u.value should num4. don't know how realize. can me? ...

Visual studio code installer display language -

does there exist english installer non-english locale pc? it seems display language of vs code installer based on locale settings. unlike visual studio installer, locale settings can changed using command line. e.g. vs_installer.exe --locale en-us i have googled , try command line options above in vain. installer still display chinese language. for reasons, can't change pc locale settings. btw, know how change display language after installing vs code.

ios - Vcard does not import on android -

hi guys have been working on application in ios swift exports vcard can/should imported on iphone , android. iphone vcard works android vcard not import. used following code that. please have , let me know doing wrong. func textbasedvcard()-> data?{ let imagestring = self.imagedata.base64encodedstring() var string = "begin:vcard\nversion:3.0\n" string += "n:\(self.name!);\nfn:\(self.name!)\norg:\(self.company!)\ntitle:\(self.title!)\ntel;type=work,voice:\(self.phone!)\nadr;type=work:;;\(self.address!)\nnote:\(self.notes!)\nitem1.url:\(self.web!)\nitem2.url:\(self.blog!)\nitem3.url:\(self.socialmedia1!)\nitem4.url:\(self.socialmedia2!)\nitem5.url:\(self.socialmedia3!)\nemail;type=pref,internet:\(self.email!)\nphoto;encoding=b;type=jpeg:\(imagestring)\nend:vcard" print(string) let utf8str = string.data(using: string.encoding.utf8) //utf8str?.base64encodedstringwithoptions(nsdata.base64encodingoptions(rawvalue: 0)) if let base64encoded = utf8str?.base64encode...

javascript - What to use to build an interactive map application -

Image
i'm trying build web app nodejs. there feature want implement: main page should interactive (or not) map. when user posts picture location info (probably longitude , latitude), show marker or small preview picture on location on main page. "places" in iphone's album app. there open-source javascript modules can use? or ideas on how build this? thanks!

html - How to get length of getElementsByTagName with javascript -

Image
working through example code sort list of within : function sortlist() { var list, i, switching, b, shouldswitch; list = document.getelementbyid("timelineul"); switching = true; /*make loop continue until no switching has been done:*/ while (switching) { //start saying: no switching done: switching = false; b = list.getelementsbytagname("figcaption"); //loop through list items: console.log(b); console.log(b.length); (i = 0; < (b.length - 1); i++) { //start saying there should no switching: shouldswitch = false; /*check if next item should switch place current item:*/ console.log(b[i].innerhtml); console.log(b[i+1].innerhtml); if (b[i].innerhtml.tolowercase() > b[i + 1].innerhtml.tolowercase()) { /*if next item alphabetically lower current item, mark switch , break loop:*/ shouldswitch= true; break; } } if (shouldswitch) { ...

php - Sabre EnhancedAirBookRQ Upgrade from 3.1.0 to 3.8.0 -

i upgrading our sabre enhancedairbookrq v3.1.0 3.8.0, have checked sabre api docs, couldn't find changes in request structure. when call soap api using php curl version changed v3.8.0, curl error 22 request <?xml version="1.0" encoding="utf-8"?> <enhancedairbookrq xmlns="http://services.sabre.com/sp/eab/v3_1" version="3.8.0" ignoreonerror="true" haltonerror="true"> <ota_airbookrq> <haltonstatus code="no" /> <haltonstatus code="nn" /> <haltonstatus code="uc" /> <haltonstatus code="us" /> <origindestinationinformation> <flightsegment flightnumber="9862" departuredatetime="2017-08-28t02:10:00" numberinparty="1" status="nn" resbookdesigcode="b"> <destinationlocation locationcode="pvg" /> <equi...

javascript - React.js How do I get the id in props with the getElementById method? -

start learn react.js , encounter following problem: enter image description here i want div element using getelementbyid doesn't work , console alerts can not read property 'props' of null . how can div element? has troubled me several hours. thanks. the whole idea react don't access dom, work virtual dom. to achieve trying accomplish (which little unclear since code incomplete), you'll want use stateful component stores user input on this.state . check out this page on react forms. you'll want this, tracking user input storing on component: class nameform extends react.component { constructor(props) { super(props); this.state = {value: ''}; this.handlechange = this.handlechange.bind(this); this.handlesubmit = this.handlesubmit.bind(this); } handlechange(event) { this.setstate({value: event.target.value}); } handlesubmit(event) { alert('a name submitted: ' + this.state.value); e...

completionhandler - Swift 3 Completion Handler on Google Places Lookup. Due to delay how do I know when Im "done"? -

sorry, newbie here , ive read extensively completion handlers, dispatch queues , groups can't head around this. my app loads array of google place ids , wants query google full details on each place. problem is, due async processing google lookup place returns , callback happens further down line whats "proper way" know when last bit of data has come in inquiries because function ends immedately ? code attached. in advance. func testfunc() { let googleplaceids = ["chij5ftxdp8mk4crjikzek6l6nm", "chij9wd6mgygk4criwd0_bkohhg", "chijaext08ask4crkcgpggzypu8", "chijkrks4bapk4crxct8-sjxndi", "chij3wdv_2zx5ikrtd0hg2i1lhe", "chijb4wusi5w44krnere7ywqaja"] let placesclient = gmsplacesclient() placeid in googleplaceids { placesclient.lookupplaceid(placeid, callback: { (place, error) in if let error = error { print("lookup place id query error: \(error.loca...

java - Thread.sleep() crashes my GUI -

my thread.sleep(rand.nextint(delay)) command in buttonlistener class crashes gui. ideas? program supposed add people arraylist, randomly select them , display them @ random time between 0 , timetext jtextfield, , works until add sleep command. appreciated thanks! import javax.swing.*; import java.awt.event.*; import java.util.*; import java.awt.*; import javax.swing.timer; public class myprogram extends appclass{ protected int x,y,width,height; protected color color; private arraylist<string> people = new arraylist<string>(); private static jlabel person; private timer timer; private buttonlistener listener; private random rand = new random(); private jlabel addpeople; private jtextfield newperson; private jtextfield timetext; private font font1 = new font("arial",1,17); private font font2 = new font("arial",1,65); public myprogram(){ setpreferredsize(new dimension(1000,800)); people.add("me"); p...

Why IPython is much faster than python? -

import numpy np import time xyz = np.random.rand(3,2399,2399) t1 = time.time() = [] _ in range(10): a.append((xyz/np.linalg.norm(xyz, axis=0)-np.array([0,0,1])[:,np.newaxis,np.newaxis])/3) t2 = time.time() print(t2-t1) this code. python 3 run code in 21.24s while ipython use 12.6s. magic ipython do? python 3.6.1 ipython 5.3.0

php - Invisible when page load "No result found" -

$search_code = $_post['search_code']; global $wpdb; $helloworld_id = $wpdb->get_var("select s_image search_code s_code = $search_code"); if (empty($helloworld_id)) { echo '<div class="no_results">no results found</div>'; }else { ?> <img src="http://igtlaboratories.com/wp-content/uploads/images/<?php echo $helloworld_id; ?>"style="width:200px;height: auto;"> <?php } } i using code when page load default "no result found" visible . how disable on page load. help. thanks in advance it simple, add condition above search code , put code inside condition. please check below code used isset () in condition determine if variable set , not null , !empty() if(isset($_post['search_code']) && !empty($_post['search_code'])) { // code goes here $search_code = $_post['search_code']; global $wpdb; $helloworld_id = $wpdb-...

javascript - Vue.js component image blank -

Image
i've bound computed property src of image tag in vue.js. code appears correct, not work consistently baffling me. additionally, switching /about page , main books page displays images. any information causing issue wonderful! a hosted version of app available here: https://books.surge.sh/ the relevant code book-item component. the full github repo. the code generating book component , image src follows: <template> <article class="book-item"> <img :src="imgsrc" class="image"> <div class="meta"> <div class="name">{{ book.title }}</div>* <div class="author">{{ book.author }}</div> </div> <div class="description"> <p v-html="book.description"></p> </div> </article> </template> <script> export default { props: ['book'], computed: { imgsr...

python - Pandas - Replacing NaN by aggregate of non-null values -

suppose have dataframe nan - import pandas pd l = [{'c1':-6,'c3':2}, {'c2':-6,'c3':3}, {'c1':-6.3,'c2':8,'c3':9}, {'c2':-7}] df1 = pd.dataframe(l, index=['r1','r2','r3','r4']) print(df1) c1 c2 c3 r1 -6.0 nan 2.0 r2 nan -6.0 3.0 r3 -6.3 8.0 9.0 r4 nan -7.0 nan problem - if there nan value in row cell has replaced aggregate of non-null values same row. instance, in first row, value of (r1,c2) should = (-6+2)/2 = -2 expected output - c1 c2 c3 r1 -6.0 -4.0 2.0 r2 -1.5 -6.0 3.0 r3 -6.3 8.0 9.0 r4 -7.0 -7.0 -7.0 use apply axis=1 process rows: df1 = df1.apply(lambda x: x.fillna(x.mean()), axis=1) print(df1) c1 c2 c3 r1 -6.0 -2.0 2.0 r2 -1.5 -6.0 3.0 r3 -6.3 8.0 9.0 r4 -7.0 -7.0 -7.0 also works: df1 = df1.t.fillna(df1.mean(1)).t print(df1) c1 c2 c3 r1 -6.0 -2.0 2.0 r2 -1.5 -6.0 3.0 r3 -6.3 8.0 ...

excel - Trying to apply advanced filter using range as input from a dialog box? -

getting error in advanced filter line of code. object doesn't support property or method. dim rng range set rng = application.inputbox(prompt:="select range or enter a1 notation:", type:=8) workbooks(filename).sheets("sheet1").rng.advancedfilter action:=xlfiltercopy, criteriarange:=range( _ "a1:a2"), copytorange:=range("a3"), unique:=false you don't need define workbook , sheet that's being defined range when set range. change code: rng.advancedfilter action:=xlfiltercopy, criteriarange:=range( _ "a1:a2"), copytorange:=range("a3"), unique:=false