Posts

Showing posts from August, 2012

mysql - SELECT latest date in a group of results distinctly -

i have query (i show below) generating following result set (this goes on 53,000 more records) +--------+---------+--------+--------+------------+------------+ | emp_no | counter | emp_no | salary | from_date | to_date | +--------+---------+--------+--------+------------+------------+ | 10001 | 1 | 10001 | 60117 | 1986-06-26 | 1987-06-26 | | 10001 | 1 | 10001 | 62102 | 1987-06-26 | 1988-06-25 | | 10001 | 1 | 10001 | 66074 | 1988-06-25 | 1989-06-25 | | 10001 | 1 | 10001 | 84917 | 1999-06-23 | 2000-06-22 | | 10001 | 1 | 10001 | 85112 | 2000-06-22 | 2001-06-22 | | 10001 | 1 | 10001 | 85097 | 2001-06-22 | 2002-06-22 | | 10001 | 1 | 10001 | 88958 | 2002-06-22 | 9999-01-01 | | 10002 | 2 | 10002 | 65828 | 1996-08-03 | 1997-08-03 | | 10002 | 2 | 10002 | 65909 | 1997-08-03 | 1998-08-03 | | 10002 | 2 | 10002 | 67534 | 1998-08-03 | 1999-08-03 | | 10002 | 2 | 10002 | 69366 | 1999-08-03 | 20

javascript - Dropzone: Global Events and Custom Messages -

i searching solution handle own messages inserted sticky elements on top of page instead of dropzone ones according preview-template each file in dropzone-container. my problem is, remove invalid files , when user selects 100 files , maximum 20 allowed, 80 files removed dropzone-container, 80 error messages blow screen. @ point, not interested file , why can't uploaded. is there global dropzone-event called once if condtition true or possibilty handle this? dropzone.on("complete", function (file) { if (!file.accepted){ dropzone.removefile(file); messages.showerror("some files not valid , have been removed "); } }); i think looking maxfilesreached can dropzone.on("maxfilesreached", function (file) { messages.showerror("some files not valid , have been removed "); ); but think dropzone sanctioned way set event in init dropzone.options.dropzone = { maxfiles: 20, accept: function(file

MySQL compare leading zeros comparison -

i have database table account no 001 , 01 want update 01 record not 001 . query update account_name account_no = 01. update both records in database want one. using number type account number not work then, since number of leading zeros arbitrary. consider using string type: under such scheme leading zeros significant. (if in fact field type account number string-like type, use account_no = '01' query).

jquery - How to style column of datatable who is being sorted dynamically? -

i have created datatable using jquery has 7 column. default applied sorting column 4th, 5th , 1st column. though columns of datatable sortable. means if user click on table header of column, table sorted column. my requirement that, whenever user click on table header of column, column's border become thick. image: this image, click here basically, column being sorted, column header should have thick border. below datatable code: $('#multiple-account-table').datatable({ "data": [ {"accountnumber":"034-202553701","name":"account 1","alias":"dummy1","duedate":"10/19/2016","statementbalance":"34.60"}, {"accountnumber":"678-202553702","name":"account 2","alias":"dummy 2","duedate":"10/19/2015","statementbalance":"14.50"},

oop - what is Classification in Object-Oriented Design? -

i read object-oriented analysis , design applications .in chapter 4 read classification.i dont understand classification? finding object?is finding module? it categorization of entities or objects or somethings can imagine using "common characteristic". for example, banana, apple, book, sun, computer, phone before categorizing, object -> banana, apple, book, sun, computer, phone they can categorized as.. eatable(common characteristic) -> banana, apple electronics(common characteristic) -> computer, phone when categorize somethings, behavior self called classification.

How do I update a variable value across modules Python? -

i have main script , importing module class in it. when instantiate class 1 of arguments y , therefore have equivalent self.y = y in __init__ method. problem in main script have for loop changes y value , calls method 'live_plotting' same class. have pass in y value argument again , have self.y = y inside method. not neat, there way of updating self.y across modules without having pass in argument again? thought of using pointers apparently pointer in python. can offer alternative solution? i'm not sure if it's want, understanding want update value of self.y without method? this done executing object_name.y = new_value where object_name name gave instance of class, seeing self variables declared in __init__ attributes belong instance of class.

osx - Dbeaver icon is blurry on MAC -

when run dbeaver on mac , application loads. icon in dock becomes blurry. if low quality. way fix it? no! refresh of dock icons not help. picking running icon somewhere else in package. the solution found this: go //dbeaver/dbeaver.app/contents/eclipse/configuration/org.eclipse.osgi/82/0/.cp/icons rename old dbeaver.png dbeaver-old.png , add new high quality png same name.

java - How to format array in string -

i want format log this: "order orderid=1,orderid=2,orderid=3,orderid=4" i have array values [1,2,3,4] . understand enough easy use loop want know if there tool in jdk (or library) can this. using java 8: int[] n = new int[]{1,2,3,4}; string orders = arrays.stream(n).maptoobj(i -> "orderid=" + i).collect(collectors.joining(",")); string result = "order " + orders;

excel - how to change existed data in array vba -

in excel, have list of items weight. i've made function in vba picks random items out of list long total weight under 10. before function made array of zero's should belong each item. when random function picks item, place in array should change one, part of function doesn't work. can me solve problem/repair function? code: sub test() dim weight single, totweight single dim finish boolean dim r integer const maxweight = 10 'here makes array of zero's dim arr(1 66) string, integer r = 1 66 arr(r) = 0 next r until finish = true 'pick random row out of excel sheet r = int((65 * rnd()) + 2) 'the first titles (item, weight), that's why start row 2 if (totweight + cells(r, 2)) < maxweight 'sum picked weight total weight totweight = totweight + cells(r, 2) 'change position of item in array 1 'but doesn't work --> arr(r) = 1 else 'do lon

null - Populating dictionary in Swift -

i've got simple function compiles dictionary 2 others according last. compiler shows no errors, after execution resultdict empty. in debug vars counter , type.1 , tempdict have correct not-nil values. func compilebasefromcsv(original: [int:[string]], headers: [int:string]) -> [int:[string:[string]]] { var resultdict = [int:[string:[string]]]() var tempdict = [string]() var counter = 0 type in headers { object in original { tempdict.append(object.1[type.0]) } resultdict[counter]?[type.1] = tempdict counter += 1 } print(resultdict) return resultdict } what's wrong code? thanks! for one, never set resultdict[counter] , need like: if resultdict[counter] == nil { resultdict[counter] = [:] } before pushing values it. but there seem few more issues in code (e.g. should tempdict reset?). use debugger step through code , @ values , check how change (and whether matches desire).

ios - How to build a dynamic UI in Swift/Xcode? -

i have build app need display ui elements according info database. i have tabelview custom cell has label , have text there database. works. in database each cell store text , have column other ui elements. example if column has 1 have display button under label, if column stores 2 have display datapicker under label. 3 - switch, 4 - slider, 5 etc. is solution put ui elements in prototype cell in stack view, set height dynamic , display (hide = true/false) proper ui element? but if have 10-12 different ui elements can become messy , long. what's best solution this? make empty view place element depending on 1 or 2 or 3 etc. method place specific button, picker or there ui faster way

angularjs - Redirect to external site, passing Authorization header -

i route user web site angular application using $window.open(url, '') . directed login page there requirement single sign on user can access external site if logged in application. external site has asked send javascript web token in authorisation header using bearer schema when redirect user. how can set authorization header in angular when sending user anther site. i've ever used header in context of communicating api ( $http.get() ), rather sending user elsewhere. don't think $window.open has means might need use else. although question similar, answer describes sending token parameter in url. authorization header not used. how add authentication header $window.open

Modeling condition, nested forms with elm-simple-forms -

i have form starts select. depending on selected form expands common main bit , details section depends on selection. i started modeling separate details section type productdetails = book book.model | brochure brochure.model | card card.model type alias model = { form : form customerror estimate , details : productdetails -- form customererror cardmodel / bookmodel / .... , msg : string } but becoming quite convoluted handle in e.g. view . the alternative seem conditionally add details main form model - e.g. type alias estimate = { customer : string , project : string , product : string , details : productdetails } before started i’d welcome experience others on has worked well if understand correctly, have separate modules book, brochure , card? don't quite understand purpose of model structure this: import book import brochure import card type products = book | brochure | card type msg = details pr

angularjs - Could I write a HttpInterceptor as a service? -

i'm rather confused on difference between factory , service , why 1 choose 1 on other. here have factory possible write service , if like? what's advantage of using service or factory here? app.factory('testinterceptor', ['$q', function ($q) { return { 'request': function (config) { return config; }, // optional method 'requesterror': function (rejection) { return $q.reject(rejection); }, // optional method 'response': function (response) { return response; }, // optional method 'responseerror': function (rejection) { return $q.reject(rejection); } } }]); app.config(['$httpprovider', function ($httpprovider) { $httpprovider.interceptors.push('testinterceptor'); }])

java - Spring @Autowired detection -

if have class uses spring bean, (will wired via @autowired ). noticed not class injected needs @component class uses (inject it). why that? should not spring inject wherever @autowired is? without having use @component injector class? spring processes , manages classes marked 1 of stereotype annotations @component , @controller , @repository , @service . it not scan of classes (that make startup slow). if class not managed spring not process of annotation inside particular class.

gitlab - Git push: Error: unpack failed: index-pack abnormal exit -

i try push git repository empty gitlab repo. following error: remote: error: object e2c586089171e13888609613eca5e589f49b717b: nullsha1: contains entries pointing null sha1 remote: fatal: error in object error: unpack failed: index-pack abnormal exit git@gitlab.domain.de:newrepo.git ! [remote rejected] master -> master (unpacker error) error: failed push refs 'git@ggitlab.domain.de:newrepo.git' i using same repo remote , github , works fine. i tried git repack remote/origin/master suggested post , not help. i know old question, guess many people might still experience issue. in case, has happened every single time tried push bigger commit (not few staged hunks, multiple new directories , files) gitlab via ssh (https never allowed me checkout @ on gitlab, though bitbucket, github , our own gitblit worked fine) using windows build of sourcetree. lost hours messing repack , compression settings, trying different versions of git , sourcetree, never worked

apache kafka - ERROR Error when sending message to topic -

while producing message in kafka, getting following error : $ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic nil_pf1_p1 hi hello [2016-07-19 17:06:34,542] error error when sending message topic nil_pf1_p1 key: null, value: 2 bytes error: (org.apache.kafka.clients.producer.internals.errorloggingcallback) org.apache.kafka.common.errors.timeoutexception: failed update metadata after 60000 ms. [2016-07-19 17:07:34,544] error error when sending message topic nil_pf1_p1 key: null, value: 5 bytes error: (org.apache.kafka.clients.producer.internals.errorloggingcallback) org.apache.kafka.common.errors.timeoutexception: failed update metadata after 60000 ms. $ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic nil_pf1_p1 topic:nil_pf1_p1 partitioncount:1 replicationfactor:1 configs: topic: nil_pf1_p1 partition: 0 leader: 2 replicas: 2 isr: 2 any idea on this?? instead of changing server.properties include 0.0.0.0 in code itself.

php - Get 10 lines from remote url to function -

i have api gives me clear 10 ip's of proxy, want use in pac file in extension firefox. this file looks like: 1.1.1.1:8080 2.2.2.2:8080 etc. (10 lines = 10 ip's) and have pac file, should this: function findproxyforurl(url, host) { return "proxy 4.5.6.7:8080; proxy 7.8.9.10:8080"; } how print ip external rule function, this: function findproxyforurl(url, host) { return "proxy 1.1.1.1:8080; proxy 2.2.2.2:8080; proxy 'line3', proxy etc...."; }

wordpress - .htaccess too many redirects. Redirect all users except ip to different part of website -

i'm trying make website users redirected specific part in domain can see "comming soon" page. while ip addresses can still access normal website can see how going look. what i'm trying do: create wordpress website in root of public_html, create directory in public_html , redirect users except few ip's http://www.domain.com/soon/index.html my .htaccess looks followed: rewriteengine on rewritebase / rewritecond %{remote_host} !^1.2.3.4 rewriterule (.*) http://www.domain.com/soon/index.html [r=302,l] however whenever go website test out tells me: err_too_many_redirects is there i'm doing wrong in .htaccess? use rule very first rule in .htaccess: rewriteengine on rewritecond %{remote_addr} !^(1\.2\.3\.4|11\.22\.33\.44)$ rewritecond %{request_uri} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ rewriterule !^soon/index\.html$ http://www.domain.com/soon/index.html [r=302,l,nc] variable remote_addr matches client's ip in web request. rewrite

java - MapStruct : Getting error of implementation is not abstract and does not override abstract method -

i new mapstruct , doing poc. can see mapstruct able generate implementation class interface general method set<string> integersettostringset(set<integer> integers); but when use project specific classes gives me compilation error of <interfacename>impl not abstract , not override abstract method <custommethod>. i using interface 1 method. interface annotated @mapper method simple one-to-one mapping no need of @mapping annotation. as mentioned earlier, if put general method works fine not project specific classes. can give me pointers on issue?

c++ - Using VM in CMS ActiveMQ -

i trying to implement interprocess communication in c++ project using activemq cms library. matter use following uri: failover:(vm:(broker:(tcp://localhost:6000)?persistent=false)?marshal=false) though not seem work. connection broker stucks while waiting response it. think maybe vm protocol not implemented in cms. in fact not find "vm" string reference in cms source code. if best library inter-process communication. need consumer/producer pattern works fast. there no vm transport in cms there no 'vm' since c++ client. need more standard mechanisms interprocess communication.

I'm having troubles with index.php in my urls -

hello have main domain have instabuilder setup on , when creating page instabuilding creates "maindomain.com/pagename" the problem i'm having addon domain when create page instabuilder creates link addondomain.com/index.php/pagename why index.php coming up, link doesn't nice. any appreciated. thank this code can use in .htaccess (under document_root) remove index.php uri: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?$1 [l,qsa] rewritecond %{the_request} ^[a-z]{3,}\s(.*)/index\.php [nc] rewriterule ^ %1 [r=301,l] copy remove 'index.php' url .htaccess

java - openFileOutput not working -

i'm debugging step step following snippet , doesn't create or read file supposed nor throw excpetion. lives inside main activity of application. wrong lines of code? public void onclick(view v) { try { fileoutputstream outputstream = openfileoutput("test.txt", context.mode_private); try { outputstream.write("this text".getbytes()); outputstream.close(); fileinputstream inputstream = openfileinput("test.txt"); string string = new string(); inputstream.read(string.getbytes()); toast.maketext(getapplicationcontext(), string, toast.length_long).show(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } catch (filenotfoundexception e1) { // todo auto-generated catch block e1.printstacktrace(); } } string string = new string(); inputstream.read(string.getbytes()); toast.maketext(getapplicationcontext(), string, toast.le

azure - AzureAD can't authorize users from another ADs. Is there a way? -

This summary is not available. Please click here to view the post.

How to handle exception on remote views in Android (custom widgets or custom notifications)? -

during our attempts solve problem encountered exceptions on remote views in android (on custom widgets , notifications) on users' devices found remoteviews.actionexception object nested class in remoteviews object it's not clear how use it. any best practices should take when handling exceptions occur in remote views? it turns out exception in our app occurred after update of our app on user's device. when user clicked on notification created previous version (the 1 before upgrade). we decided on our app startup after upgrade - we'll remove notifications (in our case makes sense).

c# - Listing all permutations and combinations of a string -

Image
how go getting combination , variation of array of strings? let's a, b, c, d expected this, able compute out ab , ba view differents combination. a ab ac abc abcd acbd ... b ba bc bcd badc ... edit: currently try code below using list, thinking should make permutation(like set= abcd,bcda,cdab..... ) string set in order full list? string set = "abcd"; // init list list<string> subsets = new list<string>(); // loop on individual elements (int = 1; < set.length; i++) { subsets.add(set[i - 1].tostring()); list<string> newsubsets = new list<string>(); // loop on existing subsets (int j = 0; j < subsets.count; j++) { string newsubset = subsets[j] + set[i]; newsubsets.add(newsubset); } subsets.addrange(newsubsets); } // add in last element subsets.add(set[set.length - 1].tostring()); subsets.sort(); as

regex - Multiline pattern after pattern match using sed -

i have config file consists of multiple sections , lots of them contain property same name, let host . need replace host property of 1 particular section only. here's file: section1 { ... setting1 = "true" ... host = "localhost" ... } section2 { ... host = "whatever" ... } i want replace host value of section2 else. note there may number of lines in between, marked ... sed -i.bak '/^section2 {/,/^}/s/host .*/host = "newvalue"/' file this search between section2 { , next } , changing host = occurences. gnu sed syntax, should use eg sed -i '' ... on osx.

machine learning - How to increase the accuracy of neural network model in spark? -

import org.apache.spark.ml.classification.multilayerperceptronclassifier import org.apache.spark.ml.evaluation.multiclassclassificationevaluator import org.apache.spark.mllib.util.mlutils import org.apache.spark.sql.row // load training data val data = mlutils.loadlibsvmfile(sc,"/home/.../neural.txt").todf() val splits = data.randomsplit(array(0.6, 0.4), seed = 1234l) val train = splits(0) val test = splits(1) val layers = array[int](4, 5, 4, 4) val trainer = new multilayerperceptronclassifier().setlayers(layers).setblocksize(128).setseed(1234l).setmaxiter(100) val model = trainer.fit(train) // compute precision on test set val result = model.transform(test) val predictionandlabels = result.select("prediction", "label") val evaluator = new multiclassclassificationevaluator().setmetricname("precision") println("precision:" + evaluator.evaluate(predictionandlabels)) i using multilayerperceptronclassifier build neural network in s

avfoundation - iOS: AVPlayerViewController enable fullscreen rotation in portrait oriented application -

i have uiviewcontroller, contains avplayerviewcontroller avplayer. want enable rotation avplayerviewcontroller(when video on fullscreen) , disable rotation uiviewcontroller. how can enable rotation videos(on fullscreen) in app? swift 2.2 in appdelegate allow rotation player: func application(application: uiapplication, supportedinterfaceorientationsforwindow window: uiwindow?) -> uiinterfaceorientationmask { guard let vc = (window?.rootviewcontroller?.presentedviewcontroller) else { return .portrait } if (vc.iskindofclass(nsclassfromstring("avfullscreenviewcontroller")!)) { return .allbutupsidedown } return .portrait } than create , use subclass of avplayerviewcontroller portrait mode when player exit full screen mode: class yourvideoplayer: avplayerviewcontroller { override func viewdidlayoutsubviews() { super.viewdidlayoutsubviews() if view.bounds == contentover

c# - Json Dropdown Postback Response -

my ajax calls: $(document).ready(function() { $.ajax({ type: "post", url : "hazzardsdashboards.aspx/getreport", data: "{}", contenttype: 'application/json', datatype: 'json', complete: function (jqxhr) { var data = json.parse(jqxhr.responsetext); trendchart(data); }, error: function (error) { alert("error"); } }); $(".ddlchange").change(function () { $.ajax({ type: "post", url : "hazzardsdashboards.aspx/getreport1", data: json.stringify({ company: $("#ddl_permitcmpny").val(), dept: $("#ddl_agency").val() }), contenttype: 'application/json', datatype: 'json', complete: function (jqxhr) { var data = json.parse(jqxhr.responsetext);

office365 - OneNote API - no HTTP Resource found? -

Image
i'm calling endpoint https://graph.microsoft.com/beta/me/notes/ , , while right user id fetched, below error occurs... not sure what's going on @ all, error not documented: { error: { code: "unknownerror", message: "{ "message": "no http resource found matches request uri 'https://www.onenote.com/api/beta/users('b2909c67-ab0e-45cf-a823-b0f945c22c00')/notes'." }", innererror: { request-id: "01b7d80f-aa04-463a-be58-c5a12414e243", date: "2016-02-27t07:07:06" } } } -- when trying notebooks/ apparently oauth token doesn't have scope - seems oauth token registration not include notes? { error: { code: "40004", message: "the oauth token provided not have necessary scopes complete request. please make sure including 1 of following scopes: notes.readwrite.all,notes.read.all", innererror: { request-id: "73202234-970e-42c8-a569-eca4266ae75a", date: "2016-03-01t0

Python Selenium disable CSS with PhantomJS webdriver -

there seems confusion on whether it's possible disable css when using phantomjs webdriver selenium. appears possible when using firefox adapting firefox profile, i'm hoping use phantomjs since faster firefox. is possible disable css in instance? if so, provide idea of how implement it? phantomjs doesn't seem have option disable css. can work around limitation removing css yourself: driver.execute_script(""" var toremove = []; toremove.push.apply(toremove, document.queryselectorall('link[type*=\"/css\"]')); toremove.push.apply(toremove, document.queryselectorall('style')); toremove.foreach(function(s){ s.parentnode.removechild(s); }); [].foreach.call(document.queryselectorall('[style]'), function(e){ e.removeattribute('style'); }); """) this removes linked, local , inline styles , leaves default browser style alone. might want add kind of res

sql - ORA-00904: invalid identifier in subquery (in select clause) -

i have subquery needs use value outer query. fails because of notorious "subquery in oracle can't access value parent query more 2 level deeper" issue. however, can't figure out how re-write it. examples on web when subquery in clause; mine in select clause. help anyone? select agre.*, agre.orga_ky, orga.name_la_lb orga_name, pers.last_name_la_lb signatory_orga__lastname, pers.first_name_la_lb signatory_orga_firstname, upper(pers.last_name_la_lb) || ' ' || pers.first_name_la_lb signatory_orga_fullname, -- current agreement orga , compare row find out if row current or expired case when ( select agre_ky ( select a.agre_ky t_agreement a.orga_ky = agre.orga_ky -- fail!!! ora-00904: invalid identifier order a.rec_creation_dt desc ) rownum = 1 ) = agre.agre_ky 'current' else 'expired&

android - Space between first and second line when styling a text with Drop Cap? -

Image
i trying style text drop cap there gap between first , second line. here code: spannable wordtospan = new spannablestring(quote); wordtospan.setspan(new textappearancespan(mview.getcontext(), r.style.specialtextappearance), 0, 1, spannable.span_exclusive_exclusive); quotetext.settext(wordtospan); this describes issue https://code.google.com/p/android/issues/detail?id=191187 , @ end there message said bug fixed. still have problem.

Selenium unhide elements C# -

i have menu group: <div class="menugroup"> some of div contain class hide or show menu contents class="togglemenuchildren"> when click on it, change on class="togglemenuchildren opened"> so want show content menu (click on classes togglemenuchildren ) show it. i try this iwebelement zi = driver.findelement(by.classname("togglemenuchildren")); zi.click(); but opened (unhide) first element, , if call again hide content. how can show content (click on elements) ? you can use xpath - //div[contains(@class,'togglemenuchildren') , not(contains(@class,'opened'))] (sorry in java) list<webelement> allelements = driver.findelements(by.xpath("//div[contains(@class,'togglemenuchildren') , not(contains(@class,'opened'))]")); for(webelement ele: allelements){ ele.click; }

php - Adding text from mySQL query onto canvas -

in code, 5 random text strings mysql database, , can echo them via php. instead of echoing them via php, rather display them text in canvas (in place of "hello world" text) of attached code. any ideas of how have go doing this? <html> <head> <title></title> </head> <body> <canvas id="mycanvas" width="200" height="100" style="border:1px solid #000000;"> </canvas> <script> var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.font = "30px arial"; ctx.filltext("hello world",10,50); </script> <?php //create connection $con=mysqli_connect('localhost','',''); //select database if(!mysqli_select_db($con,'test')) { echo "database not selected"; } //select query //select random question $sql= &qu

jquery - Javascript Get Key from data (not showing key) -

i have data looks this: var mydata =[{ "493":{ "name":"name 1", "subhere":{ "subhere1":2 } }, "673":{ "name":"name 2", "subhere":{ "subhere1":20 } } }]; i want keys value variable i’ve done this: var data = []; (var = 0; < mydata.length; i++) { var obj = mydata[i]; for(var key in obj){ var newobj = { name: obj[key].name, y: obj[key].subhere.subhere1, id: i, test: obj[key] }; data.push(newobj); } } if @ line has test: obj[key] that’s line want value of key when console.log(this.test) object { name="name 1",…etc it’s not giving me 493 or 673 how can key number? if @ line has “test: obj[key]” that’s line want value of key when console.log(this.test)

Get price of a magento product with options -

i price of product without adding cart, have array like (option_id => option_value,option_id => option_value) i need price of product options, try using "addcustomoption" $product->addcustomoption($option->getcode(), $option->getvalue()); but when use $product->getfinalprice() he still returning original price.please me ! thanks i solve problem, discovering "final price" calculated when call "mage::getmodel('catalog/product')", if change option have reset "final price" data null, , when you're calling $product->getfinalprice() magento re-calculate nice price

node.js - Unit test with promise not working -

im using mocha test api, problem function async , test suite called before getting resutls function, how can overcome this? i try chain test following raise error empty test suite. describe("validations", function () { var validator = require('../utils/validator'); var isvalid = null; validator.validatejs() .then(function (args) { isvalid = args; }).then(function(){ it("init validations ", function () { expect(isvalid).to.equal('valid1'); }); }); }) my initial usage following if call , expect inside before answer(isvalid) coming promise,any idea? describe("validations", function () { var validator = require('../utils/validator'); var isvalid = null; validator.validatejs() .then(function (args) { isvalid = args; }).done(); it("init validations ", function () { expect(isvalid).to.

mysql - ORDER month TABLE by current month -

i want order months current month in final position. i have subquery returns this: +-----+-----------+ | 1 | monthname | +-----+-----------+ | 1 | jan | | 2 | feb | | 3 | mar | | 4 | apr | | ... | ... | +-----+-----------+ then want order current month ( month(now()) ) last value. keep getting default month order. for example, today, in july (month n°7), have: +-----+-----------+ | 1 | monthname | +-----+-----------+ | 8 | aug | | 9 | sep | | 10 | oct | | 11 | nov | | 12 | dec | | 1 | jan | | 2 | feb | | 3 | mar | | 4 | apr | | 5 | mei | | 6 | jun | | 7 | jul | +-----+-----------+ is possible in sql query? if so, best way proceed? edit my current query following select `months`, ifnull(case_result.total_rows,0) results (select `one`,`monthname` months (select 1 `one`, 'january' `monthname` union select 2 `one`,'feburary

excel - Why XSSFworkbook object is unable to work in android 4.4 and lower -

i getting exception when run module after merging app ,org.apache.poi.poixmlexception: java.lang.reflect.invocationtargetexception opcpackage pkg = opcpackage.open(temp); xssfworkbook workbook = new xssfworkbook(pkg); numberofsheet = workbook.getnumberofsheets(); (int = 0; < workbook.getnumberofsheets(); i++) { xssfsheet sheet = workbook.getsheetat(i); int rowscount = sheet.getphysicalnumberofrows(); formulaevaluator formulaevaluator= workbook.getcreationhelper().createformulaevaluator(); (int r = 0; r < rowscount; r++) { row row = sheet.getrow(r); int cellscount = row.getphysicalnumberofcells(); (int c = 0; c < cellscount; c++) { string value = getcellasstring(row, c, formulaevaluator); al.add(new excelvalues(i, r, c, value)); } } }

r - Converting a vector with numerical and NA values to a vector with binary values -

i want convert vector negative values (-inf,0] , na 0 , positive values (0,inf) same new vector binary variables in r use in logistic regression. more specifically, data set med consists of matrix vector can retrieved med$amount_total . vector consists of numbers ranging -10,000 100,000 na values. want convert these vector 0s in place of negative, 0 , na values , convert positive values 1s use in glm (logistic regression model) i'm going fit other vectors in med. example: input <- c(50,na,-4,32,0,0,12) desired_output <- c(1,0,0,1,0,0,1) we can try as.integer(replace(v1, is.na(v1)|v1 < 0, 0)!=0) or as.integer(!(is.na(v1) | v1 <= 0)) #[1] 1 0 0 1 0 0 1

machine learning - zero-inflated negative binomial regression returns singular matrix error when integrating with recursive feature elimination in R -

i'm trying use caret's recursive feature elimination on zero-inflated negative binomial regression. have created set of customized functions per github tutorial here: http://topepo.github.io/caret/rfe.html here custom functions: rfzeroinfl <- list( # explicit default add print statement summary = function(data, lev=null, model=null){ print("summary function called") if (is.character(data$obs)) data$obs <- factor(data$obs, levels = lev) postresample(data[, "pred"], data[, "obs"]) }, fit = function(x, y, first, last, ...){ print("fit function called") library(pscl) tmp <- if (is.data.frame(x)) x else as.data.frame(x) tmp$y <- y zeroinfl(y ~ ., data = tmp, dist = "negbin", em = true) #zeroinfl(y ~ ., data = tm

laravel 5 - Eloquent relation query with some column -

i'm running query give me result.query given below model file public function units() { return $this->hasmany('app\powerconsumption','device_id','device_id'); } controller file return device::with('units')->where('user_id',2)->get(); result of query is: [{ device_id: 1, user_id: 2, device_name: "bulb 1", relay_num: 22, sensor_num: 4, status: 1, created_at: "2016-07-11 02:11:32", updated_at: "2016-07-19 08:25:30", units: [ { p_id: 1, device_id: 1, unit: 0.022121944444444, month: "7", hour: "1", minute: "0", created_at: "2016-07-18 00:00:00", updated_at: "2016-07-18 00:00:00" }, { p_id: 2, device_id: 1, unit: 0.022121944444444, month: "7", hour: "1", minute: "5", created_at: "2016-07-18 00:00:00", updated_at: "2016-07-18 00:00:00" } ] but want run query device::with('u

node.js - How to use Webpack loaders in a Node app? -

is there way use webpack loaders in node app / run node app in webpack environment? for instance i've got webpack config has style-loader. in node app following: import style 'style.css' console.log(style.someclass) i wanna run $ node app.js i've got idea might work, based on webpack nodejs api . if put code want able use webpack environment (with configured module loaders) module: appmodule.js: import style 'style.css' console.log(style.someclass) and require following: app.js: import webpack 'webpack' import memoryfs 'memory-fs' ... webpackconfig.entry = 'appmodule.js' webpackconfig.output = 'appmodule-out.js' let compiler = webpack(webpackconfig) let mfs = new memoryfs() compiler.outputfilesystem = mfs compiler.run(function (err, stats) { require(webpackconfig.output) }) probably won't work because require looks output on physical fs... can require memory fs? have not tried yet - i

python - Concatenating Boolean to DataFrames sqlQuery str -

i attempting query weather database building decision trees. in there 14 instances , making new dataframes based on intend subset want query e.g --> new_data = data.query("'rainy' in outlook") will produce new dataframe 5 instances. id d rainy mild high false yes e rainy cool normal false yes f rainy cool normal true no j rainy mild normal false yes n rainy mild high true no to make program more dynamic iterating through datasets parsed headers new_data = data.query("'rainy' in " + column_names[0]) where column_names[0] equal outlook. working fine , issue having when come windy boolean. question how parse boolean string make df query ? @ moment code reads new_data = data.query("'" + false + "' in windy") but error getting typeerror: cannot concatenate 'str' , 'bool' objects hav

excel - How do I Count Cells in Columns of a non-rectangular range -

so have range selected user. 2 columns, not next each other. need count number of cells in each column of selected range determine if number of cells in each column equal. (if it's not need adjust range.) for example, user may select b5:b10 , d6:d9. need code return 6 , 4 respectively. i've tried: set rng = selection rng.columns(1).count this returns 1, isn't number need. thanks in advance! you can use areas method of range object areas of range. areas groups of contiguous ranges within non-contiguous range. set rng = selection = 1 rng.areas.count debug.print rng.areas(i).cells.count next there caveat here may need test for, , if user selects, example, a1:b10, 1 mouse drag. since contiguous range, have 1 area , not 2 distinct numbers. if need test this, can below. set rng = selection 'non-contiguous ranges return 1 column, if there mutiple columns both cell counts equal default if rng.columns.count = 1 = 1 rng.areas.count

google api - Android how can I take the access token from the authServerCode? -

so googleapiclient: gso = new googlesigninoptions.builder(googlesigninoptions.default_sign_in) .requestemail() .requestserverauthcode(serverid) .build(); mgoogleapiclient = new googleapiclient.builder(pssigninflowactivity.this) .enableautomanage(this/* fragmentactivity */, this) .addapi(auth.google_sign_in_api, gso) .build(); this happens when press login button: public void login(){ log.i("", "handlesigninresult login:"); intent signinintent = auth.googlesigninapi.getsigninintent(mgoogleapiclient); startactivityforresult(signinintent, rc_sign_in); } which takes me here: @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); log.i("", "handlesigninresult onactivityresult:" + requestcode + ".." + resultcode); // result returned launching i

html - Vertically align text in a div -

i trying find effective way align text div. have tried few things , none seem work. .testimonialtext { position: absolute; left: 15px; top: 15px; width: 150px; height: 309px; vertical-align: middle; text-align: center; font-family: georgia, "times new roman", times, serif; font-style: italic; padding: 1em 0 1em 0; } vertical centering in css http://www.jakpsatweb.cz/css/css-vertical-center-solution.html article summary: for css2 browser 1 can use display:table / display:table-cell center content. sample available @ jsfiddle : <div style="display: table; height: 400px; overflow: hidden;"> <div style="display: table-cell; vertical-align: middle;"> <div> vertically centered in modern ie8+ , others. </div> </div> </div> it possible merge hacks old browser (ie6/7) styles using # hide styles newer browsers: <div style

javascript - Setting properties of object to undefined deallocates memory? -

i have lot of collections lot of records , need manage them, loading , unloading them depending on think user going need. the collections like: { users { 1: { id: 1, name: 'jhon', }, 2: { ... }, ... }, products: { ... } } i using redux cannot mutate collections make changes on them, have redeclare them. need purge users collection users, except 1 logged application. to assign undefined of users purge, operation (of course don't manually write every id): { users: { ...users, 1: undefiend, 2: users[2], 3: undefined ... } } ¿does deallocate memory used whole collection?

javascript - AngularJS repeat with table and Rowspan and filtering of elements -

i want create html table groups data using rowspan ng-repeat . the layout working fine got problem when add filters table. for example, when filter table "category" column "std" value breaks layout. i have created jsfiddle show issue. any recommended approach manage this? this related question : best regards. i did not have time on this, seems issue here: <tr ng-repeat-start="state in country.states | filter:{statecode:statecodefilter}" ng-if="false"></tr> <tr ng-repeat="city in filteredmappings = (state.cities | filter:{category:categorycodefilter})"> <th ng-if="$parent.$first && $first" rowspan="{{country.rowspan}}"> {{country.countrycode}} </th> the $parent.$first set false in case of filter usage because $parent.$first first item in not-filtered countries list never reach 1 in second repeater removed filter. leads first cell in

javascript - Are browsers supposed to repeat a request if there is no server response after a while? -

i have opened asked question on sails project, might not related sails @ -- maybe related node.js, express.js or own code, wonder if has ever experienced this: i have noticed browser requests "replayed" on server. in order test it, did this: created simple controller action prints "this request" on server -- nothing else: doesn't send response browser. when hit route, server console prints "this request", expected. keep waiting. browser keeps looping. after 2.5 minutes, "this request" printed again on server. expected behavior? worst : reload server. hit route. "this request" printed on console. ctrl+c server shut down , right away sails lift again while browser still looping. browser stop, , right after server lifted.... "this request" printed on console. more info: using sails sockets-io , code has "reconnect" function: io.socket.on('disconnect', function(){ socketclean

MS Access 2010 Ribbon rest -

in design mode have keep resetting ribbon remove whatever customization happening ribbon. how stop ribbon changing? example, can build query and/or form , have go reset ribbon before option run query or see form in form mode. i have compacted , repaired , have created new database , imported objects new database. what has happen? how can fix this.

elasticsearch - How to filter by ids together with filter fields value? -

how add additional filter match category values in blog.post.notes fields? first want filter ids, filter notes category, possible? i can filter ids: get posts/posts/_search?fields=_id&_source=blog.post.notes { "query": { "filtered": { "query": { "match_all": {} }, "filter": { "ids": { "values": [ "100000000001234" ] } } } } } how filter e.g. "test" category current results: { "took": 58, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 1, "max_score": 1, "hits": [{ "_index": "posts", "_type": "posts", "_id": "100000000001234", &q

javascript - Chrome on android 6 clear session storage when minimizing chrome app -

chrome on android 6:: behavior: if set value on session storage -> going app / home screen -> going chrome. result: session storage cleared, browser reload, , value doesn't exist longer. do know if it's chrome / android 6 bug? or it's desired behavior...? thanks

asp.net - c# keydown code not working -

i have textbox used make research keyword. have checkboxes filter results , graph display occurences of keyword in table. search done once click on button made it, works if click on enter key. problem if decide check 2 checkboxes , click on enter, research not made, or if change keyword , click again on enter result of graph not made. i'd work whenever click on button or enter. i'm using keydown saw on internet it's not changing anythhing, no error either. my code : protected void btnsearch_click(object sender, eventargs e) { populate(); } protected void tbsearch_keydown(object sender, keyeventargs e) { if (e.keycode == keys.enter) btnsearch_click(null, null); } can me ? on textbox, add attribute autopostback="true" add attribute ontextchanged="btnsearch_click" and want without jquery --> autopostback: postback server when event tri

javascript - BX-Slider to adjust adaptive height with Read More button -

i'm using bx-slider. tasked @ adding "read more" button 1 of slides, should expand slide height. problem bx-slider won't recalculate height when run readmore.js function. there way call adaptive height function @ same time click "read more" function different plugin? thank you $(document).ready(function() { $('.bxslider').bxslider({ adaptiveheight: true, pagercustom: '#bx-pager' }); }); $('.readmore').readmore(); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.5/jquery.bxslider.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.5/jquery.bxslider.min.js"></script> <script src="https://fastcdn.org/readmore.js/2.1.0/readmore.min.js"></script> <