Posts

Showing posts from June, 2013

java - Influence the order of digits and charachters in compare method -

i have wicket web application, sorts table rows in following order: ascending: first charachters (a-z) then numbers (1-9) now i'm writing webunit test test sorting mechanism, seems switch order of charachters , numbers like: ascending: first numbers (1-9) then charachters (a-z) so code fail, when sorting ascending , encounters 2 entries: ... zzz 111 ... my simplyfied sorting code: protected int compare(string val1, string val2) { return val1.compareto(val2); } what's "java way" of telling test code test order web application produces it? may collator ? prefer jre solution on selfwritten comparator on 3rd party library. you try using rulebasedcollator this: string rule = "<a,a<b,b<c,c<[...]<'1'<'2'<'3'<'4'[...]"; rulebasedcollator collator = new rulebasedcollator(rule); return collator.compare(val1,val2);

c++ - Recommended values for OpenCV SVM parameters -

any idea on recommended parameters opencv svm? i'm playing letter_recog.cpp in opencv sample directory, however, svm accuracy poor! in 1 run got 62% accuracy: $ ./letter_recog_modified -data /home/cobalt/opencv/samples/data/letter-recognition.data -save svm_letter_recog.xml -svm database /home/cobalt/opencv/samples/data/letter-recognition.data loaded. training classifier ... data.size() = [16 x 20000] responses.size() = [1 x 20000] recognition rate: train = 64.3%, test = 62.2% the default parameters are: model = svm::create(); model->settype(svm::c_svc); model->setkernel(svm::linear); model->setc(1); model->train(tdata); setting trainauto() didn't help; gave me weird 0 % test accuracy: model = svm::create(); model->settype(svm::c_svc); model->setkernel(svm::linear); model->trainauto(tdata); result: recognition rate: train = 0.0%, test = 0.0% update using yangjie's answer: $ ./letter_recog_modified -data /home/cobalt/opencv/sampl

android - Unpublished application Still getting Showing Warning from Google Play -

i published android application on 31 march 2012 , unpublished android application google play on 1 jun 2015. but, 2 days got warning alert playstore unpublished application. security alert we wanted let know application statically linking against version of openssl has multiple security vulnerabilities users. please migrate app updated version of openssl 7 jul 2015. starting on date, google play block publishing of new apps , updates use older, unsupported versions of openssl (see below details). reason warning: violation of dangerous products provision of content policy , sections 4.4 of developer distribution agreement. the vulnerabilities fixed in openssl versions beginning 1.0.1h, 1.0.0m, , 0.9.8za. confirm openssl version, can grep via: $ unzip -p yourapp.apk | strings | grep "openssl" for more information vulnerability, please see openssl security advisory. confirm you've upgraded correctly, upload updated version of app developer

java - Calculate the distance between two points -

i tried following code.but gives 2 errors.i want calculate distance between 2 points formula line , display result in textview1 . not know did make mistake in code? cal.java import android.view.view; import android.content.context; import java.lang.math; public class cal extends view { cal(context context){ super(context); } public double result; double parameter = ((10-80)^2) + ((15-90)^2); public void cal(){ result = math.sqrt(parameter); } } mainactivity.java import android.app.activity; import android.os.bundle; import android.widget.textview; public class mainactivity extends activity{ cal cal; textview textview; public void oncreate(bundle s){ super.oncreate(s); setcontentview(r.id.textview1); cal = new cal(this); textview.settext(cal).; } } errors: gradle: failure: build failed exception. what went wrong: execution failed task ':www:compiledebug'. compilation failed; see compiler e

delphi - How to process only the newest message using an out-of-context hook -

in application use winevent hook focus changes system-wide. because there no timing problems, use out-of-context hook, if know slow. if there multiple events fired on after another, system queues them , gives them hook callback function in right order. now process newest focus change. if there other messages in queue, want callback function stop , restart parameters of newest message. there way that? when receive focus change, create asynchronous notification yourself, , cancel previous notification(s) may still pending. you can use postmessage() , peekmessage(pm_remove) that. post custom message yourself, removing previous custom message(s) still in queue. or, can use ttimer / settimer() (re)start timer on each focus change, , process last change when timer elapses. either way, last notification processed once messages slow down.

php - How to configure XAMPP to send mail from localhost? -

i trying send mail localhost. unable send mail localhost can tell me how reconfigure xampp send mail localhost you can send mail localhost sendmail package , sendmail package inbuild in xampp. if using xampp can send mail localhost. for example can configure c:\xampp\php\php.ini , c:\xampp\sendmail\sendmail.ini gmail send mail. in c:\xampp\php\php.ini find extension=php_openssl.dll , remove semicolon beginning of line make ssl working gmail localhost. in php.ini file find [mail function] , change smtp=smtp.gmail.com smtp_port=587 sendmail_from = my-gmail-id@gmail.com sendmail_path = "\"c:\xampp\sendmail\sendmail.exe\" -t" now open c:\xampp\sendmail\sendmail.ini . replace existing code in sendmail.ini following code [sendmail] smtp_server=smtp.gmail.com smtp_port=587 error_logfile=error.log debug_logfile=debug.log auth_username=my-gmail-id@gmail.com auth_password=my-gmail-password force_sender=my-gmail-id@gmail.com now have done!! cre

Rails: Display database query on HTML page, ActiveRecord -

i trying create search form rails app, user enters query , based off query, want them see list of links associated query (these links come 'links' table). created html form , has user enter query. use query <%= form_tag links_path, :method => 'get' %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "search", :name => nil %> </p> <% end %> in controller links table, have if statement checks user has entered , assigns link.where('title ?', '%{#params[:search]}%') @links . , converts array ( .to_a ) here statement in index action: def index @links = link.all if params[:search] #@links = link.find(:all, :conditions => ['title ?', '%{#params[:search]}%']) @links = link.where('title ?', '%{#params[:search]}%') @links.to_a end end in index.html.erb display result. used <%= @links %> however, displays a

android - Starting Map Activity from Nav Drawer -

i trying develop map activity initiated navigation drawer. have read this query . my code :- mainactivity.java package com.tadrish.last; import android.graphics.bitmapfactory; import android.os.bundle; import android.support.v4.widget.drawerlayout; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.widget.toast; import android.content.intent; public class mainactivity extends appcompatactivity implements navigationdrawercallbacks { /** * fragment managing behaviors, interactions , presentation of navigation drawer. */ private navigationdrawerfragment mnavigationdrawerfragment; private toolbar mtoolbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mtoolbar = (toolbar) findviewbyid(r.id.toolbar_actionbar); setsupportactionbar(mtoolbar); mnaviga

javascript - LinkedIn API Login With Specific Account -

i login using own account in conjunction linkedinapi. problem have examples can see either use cookie or login interface local users login credentials. aim login own specific account providing username , password. i can extract testimonials profile , display them on website. is possible? , if have examples of how can achieved? after thinking considerable amount of time realised answer quite simple. if make api call on server side can specify credentials. example in mvc application might make call on controller action method.

javascript - Why are extra cells being added to my calendar between the days of the week? -

so javascript course, our book walks through creation of calendar. thought copied appeared in book, maybe not. reason, blank cells being inserted between names of days of week. should not happen. doing wrong? this full script: <html> <head> <title>web 240 assignment 3</title> <style type="text/css"> table { background: #ccc; border: 1px solid #999; padding: 3px; } #calendar_head { background: red; color: white; font-weight: bold; text-align: center; } .calendar_weekdays { background: white; border-bottom: 5px solid #ccc; font-weight: bold; } .calendar_dates { background: white; padding: 5px 25px 10px 5px; } </style>

c# - Error connect to exchange online using of Office365 a/c whencreated property get-mailbox cmdlet -

error : winrm client cannot complete operation within time spe cified. check if machine name valid , reachable on network , firewall exception windows remote management service enabled. error number: -2144108250 ps1 code: param ( [parameter(mandatory=$true)][system.management.automation.pscredential]$credentials ) $session = new-pssession -configurationname microsoft.exchange -connectionuri https://outlook.office365.com/powershell-liveid/ -credential $credentials -authentication basic –allowredirection import pssession $session get-mailbox c# code: pscredential credential; private runspace runspace; private string username = configurationmanager.appsettings["office365username"]; private string password = configurationmanager.appsettings["office365password"]; internal pshelper() { //create object of pscredentials class credential = new pscredential(this.username, createsecurepassword(this.password)); initialsessionstate sessionstate =

javascript - Request main road / curbside StreetView panoramas instead of back alleys from API -

is there way request main road google streetview panorama data instead of alley panorama data given location (latitude/longitude)? i'm using google maps javascript api retrieve street view panorama home address supplied our users. works quite addresses i've tried, i'm noticing lot of properties in california have street views alleys, , api seams consistently returning alley panorama instead of main road (front of property) panorama. i don't want show user alley panorama of home, instead main road panorama. if lookup same address on maps.google.com see front of house, when request same address through api alley. the process i'm using is: geocode address get panorama given geocode location (lat/long) compute heading , display panorama on page test addresses: 325 s peck dr, beverly hills, ca, usa, 90212 333 s rodeo dr, beverly hills, ca, usa, 90212 any ideas or suggestions appreciated. thanks! use directions service directions desired

c# - unable to handle Amazon.DynamoDBv2.Model.ConditionalCheckFailedException -

when execute following code amazon.dynamodbv2.model.conditionalcheckfailedexception not catching. button click public delegatecommand savecommand { { _savecommand = new delegatecommand(async (arg) => { await this.savecommandexecuted(arg); }, this.savecommandcanexecute); return _savecommand; } set { _savecommand = value; onpropertychanged("savecommand"); } } save method content public async task savecommandexecuted(object parameter) { try { await patientdatasource.instance.savepatient(patient); } catch (amazon.dynamodbv2.model.conditionalcheckfailedexception ex) { exception = ex.message; } } database operation method public async task savepatient(patient patient) { var context = commonutils.instance.dynamodbcontext;

javascript - tweeting from node.js "Timestamp out of bounds" -

i've been trying work twitter streaming api node.js , tried make simple test program logs tweets. console.log("start"); var twitter = require('twitter'); var client = new twitter({ consumer_key: '****', consumer_secret: '****', access_token_key: '****', access_token_secret: '****' }); console.log("middle"); client.stream('statuses/filter', {track: "coffee"}, function(stream) { stream.on('data', function(tweet) { console.log(tweet); console.log("this won't show up."); }); console.log("this will."); }); console.log("end"); when run "node twitter.js" logs start,middle,this will,end. why client not streaming in data?

maintainscrollpositionon - Document is scrolling back to the top -

the document contains fixed top navigation bar. when button (provided ajax response) clicked document scrolling top. fixed navigation bar covering upper portion of div equal height of fixed navigation bar can me find out solution? of coding done using native html, css , javascript.

how to make a multiple string to single string in linux shell scripting -

am having string ("50342364232 , munish inspiring") when giving input taking 3 string in linux shell how make single string ? gave input ./filename "50342364232 , munish inspiring " if invoke program ./program "50342364232 , munish inspiring" , including quotes, interpreted single argument program . however, if within program call other-program $1 , when $1 expanded, expanded multiple arguments. work around that, want invoke other-program "$1" , preserve single argument.

html - PHP multiply each value in the array by an additional argument -

i trying create php function multiplies values/content of array given argument. modify function can pass additional argument function. function should multiply each value in array additional argument (call additional argument 'factor' inside function). example $a = array(2,4,10,16). when say $b = multiply($a, 5); var_dump($b); should dump b contains [10, 20, 50, 80 ] here's code far: $a = array(2, 4, 10, 16); function multiply($array, $factor){ foreach ($array $key => $value) { echo $value = $value * $factor; } } $b = multiply($a, 6); var_dump($b); any idea? thanks! your function not right, has return array , not echo values. function multiply($array, $factor) { foreach ($array $key => $value) { $array[$key]=$value*$factor; } return $array; } rest fine. fiddle you can array_map $a

php - Captiva Wordpress theme Error -

i'm using windows 7 operating system , have installed wordpress on localhost. i'm using xampp bundle. want create commerce site in wordpress. chose captiva theme this. however, when install captiva theme, shows following error: warning: post content-length of 36013235 bytes exceeds limit of 8388608 bytes in unknown on line 0 sure want this? please try again. what mistake? how can fix issues? you need increase 1 of server's configuration option. can control these using .htaccess, so: #set max post size php_value post_max_size 50m if not use .htaccess file, can alway set in php.ini file changing line: post_max_size = "50m" unfortunatelly not posible change value ini_set

sprite kit - How Do I Reconfigure Coordinate Plane in Swift -

i experimenting spritekit. template, opens override fun touchesbegan(touches: set<nsobject>, withevent event: uievent) it creates variable stores touch position on screen. when click on screen in area should (0,0) cgpoints off near 120? how can recalibrate , position scene @ (0,0)? after experimenting bit have found fix issue. scene size default (1024, 768) , view size default (667, 375). this code fixes problem: scene?.size = self.view!.frame.size i concerned should have configure , feel missing configuration setting on creation of project. forgot set default xcode or missing something?

multipartform data - Cordova File Transfer remove Multipart or Content-Disposition Header -

i managed upload image server using cordova file transfer plugin. var img = <full path image> var url = <url webservice> var options = new fileuploadoptions(); //no specified options, using defaults var ft = new filetransfer(); ft.upload(img, encodeuri(url), win, fail, options); var win = function (r) { console.log('successfully sent'); } var fail = function (error) { console.log("an error has occurred: code = " + error.code); }; however, server had problems reading image due header added plugin. --+++++..content-disposition: form-data; name="file"; filename="filename.jpg"..content-type: image/jpeg.... took me awhile figure way removed multipart header. here's solution/work around. open: \platforms\android\src\org\apache\cordova\filetransfer\filetransfer.java look for: sendstream.write(beforedatabytes); totalbytes += beforedatabytes.length; comment away or delete these 2 lines. code adds multipar

node.js - mongoose subdocuments don't reflect update after Model.findByIdAndUpdate -

so i've got schema looks like: var projectschema = new mongoose.schema({ scrum_master_id: {type: mongoose.schema.types.objectid, ref: 'user'}, developers: [{type: mongoose.schema.types.objectid, ref: 'developer'}], scrums: [{type: mongoose.schema.types.objectid, ref: 'scrum'}], created_at: {type: date, default: date.now}, meta: { trello_board_id: string, basecamp_url: string }, description: string, title: string }); i can send express server , update properly. route in question looks like: .put(jwt.protect, function (req, res) { project.findbyidandupdate(req.params.id, {$set: req.body}, function (err, project) { console.log(project); res.json(project); }); }) the issue have sub documents developers aren't updated in project variable being passed findbyidandupdate callback. documents updated in database, not in callback of update function. how can refresh sub documents

jquery - Disable initial automatic ajax call - DataTable server side paging -

i have datatable initialized server side paging , working fine. table triggers ajax, pulls data , renders onto table during initialization. need empty table , load table data on click of button using load() or reload() like: mytable.api().ajax.reload(); here table initialization: function inittesttable(){ mytable = $('#testtable').datatable({ "processing": true, "serverside": true, "ajax": { "url": "testtabledata.html", "type": "get", }, "columns": [ { "data": "code" }, { "data": "description" } ] }); } there should way restrict loading of table during initialization? read documentation not find. please suggest. you use deferloading parameter , set 0 . delay loading of data until filter, sorting action or draw/reload ajax happens programmatically. function inittesttable(){

c# - run an exe while install a setup through visual studio installer -

i want fetch system information while run setup.exe file. i used visual studio installer , create setup file. if possible while run setup.exe can run , fetch system information through c#. i has done fetch system information , save in .txt file in c#. how run code while install setup.

Pass unknown class extending parent, then call functions of parent (Java) -

i know classes passed function extending jcomponent, don't know classes themselves. my code specific, asking more general. in code attempting pass unknown class extends jcomponent purpose of calling jcomponent method of setfont() on class. i have written as: public void setcustomfont(string ttffile, class<? extends jcomponent> jc){ try { graphicsenvironment ge = graphicsenvironment.getlocalgraphicsenvironment(); ge.registerfont(font.createfont(font.truetype_font, new file(ttffile))); } catch (ioexception|fontformatexception e) { e.printstacktrace(); } jc.super.setfont(font.truetype_font); } jc.super.setfont( gives error: jc cannot resolved type while ((jcomponent) jc).setfont( gives error: cannot cast class<capture#1-of ? extends jcomponent jcomponent> and jc.setfont( gives error: the method setfont(int) undefined type class<capture#1-of ? extends jcomponent> so, cannot figure out how call functions of

exec.Command does not register error from Go's own pprof tool -

here code: cmd := exec.command("go", "tool", "pprof", "-dot", "-lines", "http://google.com") out, err := cmd.output() if err != nil { panic(err) } println(string(out)) when run exact same command in console, see: $ go tool pprof -dot -lines http://google.com fetching profile http://google.com/profilez please wait... (30s) server response: 404 not found however, go program not register error. oddly, variable out prints empty string , err nil. going on? to clarify, profiling http://google.com purposefully create error. profile real go application. the text fetching profile http://google.com/profilez please wait... (30s) server response: 404 not found is written stderr. program captures stdout, empty. consider calling: out, err := cmd.combinedoutput() to grab both stdout , stderr. cmd.output() , cmd.combinedoutput() return err == nil because command exits status zero. perhaps issue sho

angularjs - Few questions regarding Angular directives -

i have few questions regarding angular directives i'm basing questions based on following block of codes <ul class='parent'> <li class='child1'></li> <li class='child2 active'></li> <li class='child3'></li> </ul> so based on above how can create directive based on above (assuming comes angular plugin, , there no angular directive attribute defined within tag)? assuming above angular plugin, , don't intend edit plugin, how can use directive see list active? how can operations through code above using angular? jquery, can as for checking child length $('.parent').children().length for iterating through child elements $.each($('.parent').children(), function(){ console.log(this); }); but when tried angular way angular.element(document.queryselectorall('.parents')).children().length somehow part returned me wrong value. guess jquery minds

PowerPivot Window won't show: - Index out of range -

powerpivot excel workbook 14 tables. powerpivot window opens not display data. error received is system.argumentoutofrangeexception: index out of range. must non-negative , less size of collection. any thoughts? i found 1 possible solution. in case diagram view still available, , had 1 calculated column in error. deleted column diagram view , table view visible once more. interestingly, same table had measures in error, these did not cause issues.

optimization - Way to optimise a mapping on informatica -

i optimise mapping developped 1 of colleague , "loading part" (in flat file) really slow - 12 row per sec currently, point start writting in file, take 2 hours, know should start looking first otherwise, need @ least 2 hours between each improvment - not efficient. ok, describe done : oracle table (with big query inside - takes 2 hours result) sq 2 lkup on ref table (should not heavy) update strategy 1 transformer 2 lk (on big table - should 1 optimum point guess : change them joiner) 6 stored procedure (these seem bit heavy, think ?) another tranformer load in flat file can confirm either lk or stored procedur part reason why slow ? do think should somewhere else optimize ? thinking may 1 transformer. first check logs carefuly. @ timestamps. should give initial idea part causes delay. lookups big tables not recommended. joiners better way, still need cache data. can limit data cache, perhaps? it'll hard advise without seeing it. which

visual studio 2013 - Exception 00x8007000B VS2013 -

i need start microsoft visual studio 2013. didn't find solution after searching internet problem. error appeared using vs2012 , problem persisted when moved vs2013. this first error in activitylog.xml setsite failed package [microsoft visual studio server explorer package] end package load [microsoft visual studio server explorer package]

memory - How to write a piece of java code that will consume lots of memories and the memories can be released if needed -

i wrote such piece of code: public class testclass { private static list<string> stringlist = new arraylist<>(); long num; public void testhighload() { stringlist.clear(); (int = 0; < num; i++) { string string = getrandomstring(10000); stringlist.add(string); } } public void setnum (int num) { this.num = num; } } and can call make cost high memories: testclass.setnum(500000); testclass.testhighload(); but if call in way, cannot release memory: testclass.setnum(0); testclass.testhighload();

python - Using yahoo_finance api in PySide Simple Application -

i'm trying system tray indicator price of different companies. i'm using pyside ui , yahoo_finance package data. this code shows prices of 2 different companies: import yahoo_finance labels = ['san', 'ixd1.sg'] x in labels: o = yahoo_finance.share(x) print(o.get_price()) but, after call qapplication method, error: from pyside import qtgui, qtcore import yahoo_finance app = qtgui.qapplication([]) labels = ['san', 'ixd1.sg'] x in labels: o = yahoo_finance.share(x) print(o.get_price()) file "/usr/local/lib/python3.4/dist-packages/yahoo_finance/__init__.py", line 23, in edt_to_utc date_ = datetime.strptime(date.replace(" 0:", " 12:"), mask) file "/usr/lib/python3.4/_strptime.py", line 500, in _strptime_datetime tt, fraction = _strptime(data_string, format) file "/usr/lib/python3.4/_strptime.py", line 340, in _strptime data_string[found.end():]) valueerror: unconverted dat

How to process data with a one to many relation from MySQL into PHP -

i using following query return data single habit. a habit can have many steps , many comments. when run following query repeats data habit every step , comment there is. select habit_id, habit_user_id, habit_name, habit_category_id, habit_description, habit_target_user, habit_up_votes, habit_down_votes, step_id, step_description, comment_id, comment_user_id, comment_description habits, steps, comments habit_id = ? , habit_id = step_habit_id , habit_id = comment_habit_id order step_order example output (the ids should enough idea of going on): habit_id step_id step_description comment_id comment_description 1 1 x 1 works great! 1 1 x 2 awful! 1 1 x 3 nice job 1 2 y 1 works great! 1 2 y

ggplot2 - unit test ( testthat ) graphs produced using ggplot -

what best way unit test ( test r package) graphs produced using ggplot2 ? i using fixed data validating input table dt ggplot2 using equal. aware unit tests need done in isolation we need validate data passed correctly ggplot?

xmpp - Send broadcast message to 100K subscribers using ejabberd -

i creating pubsub messaging application in subscribers of particular channel message if publishers sends channel 100k maximum subscriber count. using ejabberd may know possibility of performance i.e can ejabberd handle 100k subscribers , able send message ? performance depends on many elements. payload size, push frequency, node configuration, type of online clients connection (slow / fast), machine specification. however, should able reach level, indeed.

Mongodb failed after reboot on Raspberry Pi -

i've installed mongodb following install script on raspberry pi https://github.com/svvitale/mongo4pi/blob/master/install.sh . i've tested , got connection test database via mongo , worked well. i've rebooted raspberry (b) , noticed, mongod failed start on reboot. after tried start mongod manually got following error: pi@raspberrypi /opt/mongo/bin $ ./mongod db level locking enabled: 1 ./mongod --help , startup options wed jul 1 23:26:44 wed jul 1 23:26:44 warning: 32-bit servers don't have journaling enabled default. please use --journal if want durability. wed jul 1 23:26:44 wed jul 1 23:26:44 assertion failure 5 == (int)(g.distance( , b ) ) src/mongo/db/geo/2d.cpp 3111 0x315e08 0x2015b4 0x393554 0x441d84 0x397f80 0x15c1d0 0xb6c7381c ./mongod(_zn5mongo15printstacktraceerso+0x18) [0x315e08] ./mongod(_zn5mongo12saydbcontextepkc+0xc4) [0x2015b4] ./mongod(_zn5mongo12verifyfailedepkcs1_j+0x108) [0x393554] ./mongod(_zn5mongo11geounittest3runev+0x3b84) [0x44

hadoop - Starting hiveserver2 -

i trying run hiveserver2 on hadoop cluster can access hive using jdbc. run following command: $hive_home/bin/hiveserver2. doesn't log stdoutput starts process running, can't see tcp sockets listening on port 10000. turns out no socket open process hiveserver2 running in. how start hiveserver2? try running : hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10000 --hiveconf hive.root.logger=info,console start hiveserver2, on port 10000 , output logs console.

jquery - prevent selecting next dom when dbclicking text in contenteditable -

i have following contenteditable div, mixed text , dom inside follow : some text<span> </span><span>like select </span> my problem is, prevent double clicking word select span arround. exemple, if double click word 'which', selects word , it's needed behavior. problem is, if select word 'would', selects 'would '. how can select 'would' without span on double clic event ? i tried add whitespace before , after, no result. just add small snippet of javascript , single words selectable within span elements: $('span').dblclick(function(e){ e.preventdefault(); var selection = window.getselection(); if (selection.tostring().indexof(' ') > -1) { var range = selection.getrangeat(0); var start = range.startoffset; var finish = range.endoffset - 1; setselectionrange(this, start, finish); } }); function gettextnodesin(node) {

algorithm - Counting number of nodes in a complete binary tree -

i want count number of nodes in complete binary tree can think of traversing entire tree. o(n) algorithm n number of nodes in tree. efficient algorithm achieve this? suppose start off walking down left , right spines of tree determine heights. we'll either find they're same, in case last row full, or we'll find they're different. if heights come same (say height h), know there 2 h - 1 nodes , we're done. otherwise, heights must h+1 , h, respectively. know there @ least 2 h - 1 nodes, plus number of nodes in bottom layer of tree. question, then, how figure out. 1 way find rightmost node in last layer. if know @ index node is, know how many nodes in last layer, can add 2 h - 1 , you're done. if have complete binary tree left height h+1, there between 1 , 2 h - 1 possible nodes in last layer. question how determine efficiently possible. fortunately, since know nodes in last layer filled in left right, can use binary search try figure out las

PHP Giving Fatal Error -

i'm trying make login screen ios app , php giving me error can't find answer to. error: notice: trying property of non-object in /applications/xampp/xamppfiles/htdocs/registration/mysqldao.php on line 67 fatal error: uncaught exception 'exception' in /applications/xampp/xamppfiles/htdocs/registration/mysqldao.php:67 stack trace: #0 /applications/xampp/xamppfiles/htdocs/registration/userregister.php(41): mysqldao->registeruser(null, 'd41d8cd98f00b20...') #1 {main} thrown in /applications/xampp/xamppfiles/htdocs/registration/mysqldao.php on line 67 mysqldao.php: <?php class mysqldao { var $dbhost = null; var $dbuser = null; var $dbpass = null; var $conn = null; var $dbname = null; var $result = null; function __construct() { $this->dbhost = conn::$dbhost; $this->dbuser = conn::$dbuser; $this->dbpass = conn::$dbpass; $this->dbname = conn::$dbname; } public function openconnection() { $this->conn = new m

angularjs - Form validation error when using ion-scroll tag -

i'm creating ionic app , i'm having issues form validation when use < ion-scroll> tag. form: <form ng-show="!success" name="form" role="form" novalidate ng-submit="register()" show-validation> <div class="list list-inset"> <label class="item item-input"> <input type="text" class="form-control" name="firstname" placeholder="nome" ng-model="registeraccount.firstname" ng-minlength=1 ng-maxlength=50 required maxlength="50"> </label> <div ng-show="form.firstname.$dirty && form.firstname.$invalid" class="padding-top padding-left assertive"> <p class="help-block" ng-show="form.firstname.$error.required"> message </p> </div> .