Posts

Showing posts from August, 2012

algorithm - Number of nodes in the bottom level of a balanced binary tree -

i wondering 2 questions came when studying binary search trees. following: what maximum number of nodes in bottom level of balanced binary search tree n nodes? what minimum number of nodes in bottom level of balanced binary search tree n nodes? i cannot find formulas in textbook regarding this. there way answers these questions? please let me know. assuming it's full binary tree , number of nodes in leaf equal (n/2)+1 . for minimum number of nodes, total number of nodes 1 (satisfying condition should balanced tree).

oracle - PL/SQL Before Trigger - Inherit column from other table -

i'm very new pl/sql excuse ignorance on subject, i'd appreciate help! i have these 2 tables, let's say, ratings , games. suppose want inherit value ratings table , insert game table automatically depending on gamerating (inheriting ratings table) gave it. on game table have: (gameid, gameprice, gamename, gamerating, gameages, publisherid) and on ratings table have: (ratingid, ratingcode, ratingages) if insert following values game: (1,50,'lost','m') want automatically insert gameages ratings table using gamerating basis reading ratings table, ratingcode. how go on doing this? all know have declare variables , insert ages them depending on gamerating. edit: managed guys, here's format used: create or replace trigger [triggername] before insert on [tablename] for each row declare [variables] begin select [columns populate variables] [variables] [second table] join [first table] on [secondtableid] = :new.[firsttableid]

Only allow writes from service account in Firebase? -

i make writes firebase data node.js server deny writes other client. other client should allowed read access. best approach this? need authenticate node.js server special admin account , setup security rule specific account or there better way accomplish this? thanks! in node server use admin sdk log in service account and in database rules use this: { "rules": { ".write": "false" ".read": "true", } }

amp html - Pass dynamic event label in Google AMP analytics event tracking -

i want track event google analytics when link clicked on amp html page. want pass link(href) eventlabel while tracking event. there way set link url data-* attribute can passed google analytics event tracking script. or there other way this. this pretty standard thing google analytics amp page doesn't cover it. it seems possible. amp supported google analytics extended component . events user interactions content can tracked independently web page or screen load. event tracking clicked links can monitored like: .., "trackanchorclicks": { "on": "click", "selector": "a", "request": "event", "vars": { "eventid": "42", "eventlabel": "clicked on link" }

php - Make Javascript a requirement -

is there way make javascript requirement run pages on website? such if user disables javascript, cannot proceed further? example: have php site , want validate user-inputs javascript only. i apologise if trivial issue. quite new javascript , have never seen nor heard of such implementation, solution love know how implement. thanks. the <noscript> tag defines alternate content users have disabled scripts in browser or have browser doesn’t support script. the element can used in both , . you can thing below , redirect users page saying please enable java script , try again placing below code in head tags <noscript> <meta http-equiv="refresh" content="0;url=showamessagewithjavascriptdisabled.html"> </noscript> the above code in header cause refresh url specified if javascript disabled

bash - Passing a string value will fail to find the file -

i write shell try collect file file path current directory if exists: collect_file() { fpath=$1 echo $fpath if [ -e $fpath ]; fname=`basename $fpath` `cp $1 $fname` retval=$? if [ $retval == 0 ]; echo "collect file '$fpath'" else echo "error: fail copy file '$fpath'" fi else echo "error: file '$fpath' not found" fi } now, if pass bare value ~/.gitconfig , succeed, when pass string value "~/.gitconfig" , fail. collect_file ~/.gitconfig # succeed copy file collect_file "~/.gitconfig" # fail shows: # results bare value /users/xaree/.gitconfig collect file '/users/xaree/.gitconfig' # results string value ~/.gitconfig error: file '~/.gitconfig' not found why , how can fix it? the following refers file in user's home directory: ~/.gitconfig by contrast, following refers file in directory named ~ : "

javascript - How to get rid of old data and of old graph in Chart.js? -

i'm using chart.js make graph. i encounter problem when use graph. old graph old values not gone when hover cursor on graph. according doc, tried use .destroy() or .clear() rid of old data, doesn't work. here following codes: <!doctype html> <html> <head> <title>hp mp</title> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.1.3/chart.min.js"></script> </head> <body onload="hpmpgraph()"> <script> function hpmpgraph() { var hp = document.hpmpform.hp.value, mp = document.hpmpform.mp.value, ctx = document.getelementbyid('hpmpratio').getcontext('2d'); var data = { labels: ["hp","mp"], datasets: [{ data: [hp,mp], backgroundcolor: ["#ef0000","#0000ef"], hoverbackgroundcolor: ["#ff0000","#0000

node.js - How to deal with readFile when file is currently written to -

this might bit fuzzy have node app writes small counter file after doing bunch of stuff: fs.readfile( blender.log , function(error, data) { //read log file if( error ) { throw error; } counter = parseint( data ) + 1; //add blend if(!isnan( counter )) { //check if number number fs.writefile( blender.log, counter, function(error) { if( error ) { throw error; } blender.debugging( 'counter: added', 'report' ); }); } else { //throw error blender.log.error(' counter number not valid ("' + counter + '"). leaving alone now!'); } }); due high demand on app more not isnan in callback of readfile because file open write writefile previous instance. (it interesting me there no errors thrown though) how deal this? don't want make blocking write keep app fast perhaps queue write? open though. :) thanks i

jquery - dynamically populated select does not let to select the options -

i dynamically populate select using jquery $ajax when select value, reloads again, looks keeps re-populating whenever click, options gets selected when add "alert(this.value)". can me understand missing? added snippet of code here : .... $("select#tassigned").change(function(){ $("select#tassigned option[value=28]").prop("selected", true).end().change(); }); .... $.ajax({ type: "post", url: profilesaction , async: false, datatype: "json", data: {'select' : 1 }, success: function(request) { $("select#tassigned").html("<option></option>"); $.each(eval(request), function(i,item){ $("select#tassigned").append("<option value="+item.cid+">"+ item.second + " - " + item.third +"</option>"); }); } }); html code:

c# - How to get particular row of data in Strongly typed view in MVC application..? -

Image
my view index.cshtml (strongly typed view class name:busdetails.cs)contains code below: model ienumerable<mvc_dal.busdetails> @html.actionlink("create new", "addbus") <table> <tr> <th> @html.displaynamefor(model => model.bussrlno) </th> <th> @html.displaynamefor(model => model.busname) </th> <th></th> </tr> @foreach (var item in model) { <tr> <td> @html.displayfor(modelite => item.bussrlno) </td> <td> @html.displayfor(modelitem => item.busname) </td> <td> @html.actionlink("edit", "edit", new { id=item.bussrlno }) | @html.actionlink("details", "details", new { id=item.bussrlno */ })| @html.actionlink("delete", "delete", new { id=item.bussrlno */ })| </td> </tr> } </table&

Convert row to columns in SQL Server -

i have query returns results this: location id location code location name division code ssourcecode division name business unit code business unit name 83806 d4009 vanier mitsubishi fuso sales_01 sales_01 sales_01 sales department fuso vehicle sales department 83806 d4009 vanier mitsubishi fuso parts_a0 parts_a0 parts district a0 parts department fuso parts department 83806 d4009 vanier mitsubishi fuso service_c1 service_c1 service division c1 service department fuso service department i want have results this: location id location code location name parts division code parts ssourcecode parts division name sales division code sales division name sales business unit code sales business unit name parts business unit code parts business unit name so each locationid need 1 row, respective parts/service/sales division/business unit codes , names showing on same row separate columns....not convince

linux - Bash echo with an $ character outside the string -

can explain difference between echo $"starting $cmd" and echo "string $cmd" they seem same. look quoting section of bash man page: words of form $'string' treated specially. word expands string, backslash- escaped characters replaced specified ansi c standard. backslash escape sequences, if present, decoded follows: \a alert (bell) \b backspace \e escape character \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \ backslash \' single quote \nnn eight-bit character value octal value nnn (one 3 digits) \xhh eight-bit character value hexadecimal value hh (one or 2 hex digits) \cx control-x character the expanded result single-quoted, if dollar sign had not been present. and note follow description double quoted strings preceded $ ( $"string" ): a double-quoted st

devops - How do I check for the existence of a conda package before installing in ansible? -

in ansible playbook doing install pillow (using conda): - name: install pillow shell: conda list | grep -q -i pillow || conda install --yes -c conda-forge pillow two questions: why fail idempotence test ? what better way of doing ? i don't know enough conda know pillow installed to, this: - name: install pillow shell: conda list | grep -q -i pillow || conda install --yes -c conda-forge pillow args: creates: /path/to/pillow/binary

php - My While loop is not working, why? -

i have question in relationship loops in php. trying play actions elements of array, last one. need: 1- know array not empty. 2- pickup last item name of array. because need execute step0.php script. 3- delete last item of array. i want repeat action until value of array 0 , go out loop. i tried had not lucky. :-( any idea? $array2; $array1; $diffe_array = array_diff($array2, $array1); //create condiction $diffe=count($diffe_array); { $lastone=end($diffe_array); require('./step0.php'); $extract=array_pop($diffe_array); $diffe=count($diffe_array); print_r($diffe_array); } while ($diffe > 0); echo 'just have 0 items in array!!!!'; to complete question think necessary have clear (with example): step1 .- have $array2 this: array2 ( [0] => 00004.csv [1] => 00007.csv [2] => 00005.csv [3] => 00003.csv [4] => 00002.csv [5] => 00001.csv [6] => 00006.csv [7] => 00000.csv ) step2 .- have &array1 t

python - AttributeError at /login/ 'bool' object has no attribute 'rindex' - Django 1.5 issue -

i'm getting following error in browser everytime try log django app i'm creating: request method: post request url: http://127.0.0.1:8000/login/ django version: 1.6 #update: have downgraded django 1.5 , still getting error exception type: attributeerror exception value: 'bool' object has no attribute 'rindex' exception location: /library/python/2.7/site-packages/django/core/urlresolvers.py in get_mod_func, line 141 python executable: /usr/bin/python python version: 2.7.2 python path: ['/users/gersande/public/compwebsite/uc', '/library/python/2.7/site-packages/web.py-0.37-py2.7.egg', '/library/python/2.7/site-packages/pymysql-0.5-py2.7.egg', '/system/library/frameworks/python.framework/versions/2.7/lib/python27.zip', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin', '/system/libra

Alert Notification in android -

i want make notification line notification. have tried using alert doesn't work. can me problem? if looking notification sent if app not running in foreground , this example give brief idea that.

scala - Akka-HTTP JSON serialization -

how 1 control deserialization spray-json? example, have class defined as: case class (name:string, value:string) and deserialize following json list of objects: { "one": "1", "two": "2" } and should become: list(a("one", "1"), a("two", "2")) the problem default json representation of list one, not want: [ { "name": "one", "value": "1" }, { "name": "two", "value": "2" } ] how can accomplish this? you can write own custom deserializer structure looking for: case class a(name:string, value:string) implicit object listaformat extends rootjsonreader[list[a]] { override def read(json: jsvalue): list[a] = { json.asjsobject.fields.tolist.collect { case (k, jsstring(v)) => a(k, v) } } } import spray.json._ def main(args: array[string]): unit = { v

html - footer height is too small in Chrome -

Image
i'm looking here @ element footer.mdl-mini-footer . given sizes measured using f12 developer tools in responsive mode screen size of 768x884 (chrome's tablet breakpoint size). in firefox, element footer.mdl-mini-footer has size of width: 736px; height: 36px; . in chrome, element footer.mdl-mini-footer has size of width: 736px; height: 10.438px; . the key point here height difference. in both browsers, child element ul.mdl-mini-footer__link-list has size of width: 268px; height: 36px; , causing footer's content sink beneath footer element. note style="padding: 8px 16px" on footer element is not required issue occur, makes more visible cutting down on default padding provided material design lite of 32px 16px . specifically, issue the footer's height decreases in chrome page's content has scroll more . does not happen in firefox, , desired behavior. for completeness sake, tested page in microsoft edge, behaves firefox. also, changing ch

php - Variables: overwriting vs if/else -

this php question applicable other languages. which better way handle variable assignments? // use default value , overwrite $var_one = 'x'; if ($var_two) { $var_one = 'y'; } // use complete if/else if ($var_two) { $var_one = 'y'; } else { $var_one = 'x'; } i'm curious how software works @ lowest levels. i use first 1 because remove 1 process. cleaner second one: $var_one = 'x'; if ($var_two) $var_one = 'y'; or $var_one = ($var_two ? 'y' : 'x'); the above code cleaner #1 example.

How to pass testng Dataprovider first set parameters to first test and second set Paramater to second test ans so on -

here code, want pass first set data {"shankar","admin123"} test1() , second set data {"siva","admin@123"} test2(), please me on have tried @ factory also...please me guys. package com.vmetry.dataprovider; import org.testng.annotations.dataprovider; import org.testng.annotations.test; public class dataprovidertest { @test(dataprovider="dp") public void test1(string uname, string pass){ system.out.println("the test1 param are: "+uname+"-"+pass); } @test(dataprovider="dp") public void test2(string uname, string pass){ system.out.println("the test1 param are: "+uname+"-"+pass); } //passing data provider data @dataprovider(name="dp") public object[][] data(){ object[][] obj={{"vasanth","admin123"},{"shanmugam","admin@123"}}; return obj; } } ****************

c# - How can I change tabs when testing Nintex form with Selenium WebDriver? -

i have nintex have setup tabs described in post. https://community.nintex.com/docs/doc-1198 using choice control displaying buttons, , rules hiding panels. i creating selenium test test of our common sharepoint forms , controls, can't selenium trigger rule hide , unhide panels when clicking tab buttons. has else tried testing nintex forms selenium , solved issue? just clarify software using. have sharepoint 2013 on premise nintex forms 2013 , creating c# selenium webdriver script.

sql - getting repeated rows -

i not able why getting repeated data below query. although have used distinct. the query below- please : might problem joins select distinct(um.username)'user_name' ,um.firstname + ' ' + um.lastname 'employee name' ,us.user_name 'user_id' ,us.ms_rit_reporting_group_mst_key ,rg.reporting_group_name ,us.ms_rit_region_mst_key ,rm.region_name ,us.ms_rit_sub_region_mst_key ,sm.sub_region_name ,tp.task_mst_key ,ttm.task_type_name ,ct.* ,fm.task_status ,fm.task_start_date ,fm.task_end_date ,srm.role_name rolename users_master um inner join ms_rit_user_skillset_map on um.userid = us.user_name inner join dim_ms_rit_reporting_group_mst rg on us.ms_rit_reporting_group_mst_key = rg.ms_rit_reporting_group_mst_key , upper(rg.active) in ('yes','1','y') inner join dim_ms_rit_region_mst rm on us.ms

c - Using clang matchers to detect sequence of patterns -

is possible use clang matchers identify sequence of patterns in program? for example need find cases in pattern1 happens before pattern2. for instance: pattern1 = assigning value pointer p pattern2 = dereferencing pointer p i can identify cases pattern1 , pattern2 happen in code, possible specify ordering? (say pattern1 has happen before pattern2 , match cases) thanks! correct answer in reality traversing asts sequence patterning (which basis of static analysis) not correct approach because don't know whether statement pattern1 going happen before pattern2 consider int foo() { int = 0; int *b; int c = -1; if(c < 0) goto fixit; nowhat: b = &a; fixit: c = *b; goto nowhat; } as can see ast not going here cfg correct thing use. somewhat of answer using asts if @ traversal matchers in ast (v6.0.0) are, pretty much, hierarchical in nature. looking extend matching siblings. much of assumes

delphi - Flickering when TPageControl has many tabs -

my problem have tpagecontrol contains dynamically created number of tabs each containing single ( alclient ) tmemo . when number of tabs exceeds width of control , scroll arrows appear on tab header, (well large number) of controls start flicker lot. flicker occurs when pagecontrol visible once scroll out of view of tpagecontrol stops. when pagecontrol resized scroll arrows no longer required see of tabs flickering stops. i'm confident problem caused scroll arrows causing painting occur because when set tpagecontrol.multiline true there no flickering. ideally wouldn't want use multiline tabs , hope can provide solution. information form layout i have (personal details) form contains number of tspeedbuttons , tlabels , tedits , timage , on. many of these elements inside of tscrollbox , grouped sections using tpanels . panels set altop in scrollbox , have autosize set true height never changes. i have tried setting controls have doublebuffered set true possible

c# - Unable to fetch returnurl in asp.net mvc Controller -

i have 2 controllers base , login. base controller: public actionresult start() { string action = request.querystring[wsfederationconstants.parameters.action]; } login controller: public actionresult login(string user,string password,string returnurl) { if (formsauthentication.authenticate(user, password)) { if (string.isnullorempty(returnurl) && request.urlreferrer != null) returnurl = server.urlencode(request.urlreferrer.pathandquery); return redirecttoaction("start","base", returnurl }); } return view(); } after authentication done gets redirected start action in base controller expected. querystring doesnot fetch value. when hovered on querystring shows length value not uri. how use url sent login controller in base controller , fetch parameters it? you returning 302 client. docs . returns http 302 response browser, causes browse

c# - Pass a user to a ViewModel -

ok, little stuck here. viewmodel public class userprofileedit { public virtual applicationuser applicationuser { get; set; } [required] public string firstname { get; set; } public string twitterhandle{ get; set; } [required] [display(name = "email")] [datatype(datatype.emailaddress)] public string email { get; set; } // etc etc } controller public actionresult yourprofile() { string username = user.identity.name; applicationuser user = db.users.firstordefault(u => u.username.equals(username)); // construct viewmodel userprofileedit model = new userprofileedit(); model.applicationuser = user; return view(model); } and on view have @model mysite.models.userprofileedit @ top. how can pass user viewmodel? know can line line model.email = user.email; for example, should simpler? you can line line, or can use automapper. give try http://automapper

parse.com - Android Parse implementation cannot verify custom server hostname -

when initializing parse on android , able connect parse server when: 1) don't specify server url, or 2) set server url parse server. because intend migrate our data parse different host, connect different server url. however, when try specify different server url ( https://api.ourhostname.com/1/ ) redirects (serves proxy) parse server, app fails connect server altogether. when implemented ios project, server url works fine. however, when implemented on android equivalent: parse.initialize(new parse.configuration.builder(this) .applicationid(app_id) .clientkey(client_key) .server("https://api.ourhostname.com/1/") .build() ); i receive i/o failure: 05-24 21:46:55.319 7140-7140/com.ourapp w/system.err: com.parse.parserequest$parserequestexception: i/o failure 05-24 21:46:55.324 7140-7140/com.ourapp w/system.err: @ com.parse.parserequest.newtemporaryexception(parserequest.java:290) 05-24 21:46:55.324 7140-7140/com.ourapp

Can't seem to remove extra whitespace in php or javascript -

hey guys =) i'm having small problem. have php code gets string stored in database favoritegamelist, , in database, doesn't appear have white space. when try echo string out generates bunch of new line characters. used javascript character code of characters creating space , 10 , that's new line? either way, figured preg_replace function work, or maybe trim? tried trim, no avail. have code: $gamelist = preg_replace('/[\x00-\x1f\x80-\x9f]/u', '', $row['favoritegamelist']); echo $gamelist; after code executes, javascript runs , collects echo, log console , see ton of white space , i'm stuck trying rid of it. javascript code here: var mygames = document.getelementbyid("favoritegamesdiv").innerhtml; console.log(mygames); favoritegamesdiv area echo statement in php applicable. , console log is: llamas in distress,bow master halloween,squary, with space... i'm not sure do. apprecia

testng - Java: how to pass and use this array in another class -

i've got csv reader class , i've got user creator class. want user creator class take array, generated csv reader , assign data variables, im getting nullpointerexception here csv reader class: public class csvdata { private static final string file_path="c:\\250.csv"; @test public static void main() throws exception { csvreader reader = new csvreader(new filereader(file_path)); arraylist<arraylist<string>> array = new arraylist<arraylist<string>>(); string[] nextline; while ((nextline = reader.readnext()) != null) { arraylist<string> list = new arraylist<string>(); (int i=0;i<5;i++) { //5 number of sheets list.add(nextline[i]); } array.add(list); } /*for(int x=0;x<array.size();x++) { for(int y=0;y<array.get(x).size();y++) { } }*/ apptest3 i

asp.net mvc - MVC 5, true SEO Friendly Routes -

i wanna make urls seo friendly. have seen lot of articles , other posts on subject, of them ends urls like: /products/34/my-handbag i wanna end urls like: /gucci/my-handbag i have controls product names "gucci" , "my-handbag", need routing send me products controller. this working right now: routes.maproute( name: "productdetails", url: "{brand}/{title}", defaults: new { controller = "productviews", action = "details", brand = "", title = "" } any suggestions? you're on right path. can generate url like: www.domain.com/gucci/some-gucci-product-name means of following route. routes.maproute( "default", // route name "{brand}/{details}", // url parameters new { controller = "productviews", action = "details", brand = urlparameter.optional, details = urlparameter.optional }// parameter defaul

How to speed up the search by the overpass-api -

i'm new overpass api. need find street in particular city in particular country. here's query created: [out:xml] area[name="Беларусь"]->.a; (rel(area.a)[name="Ганцевичи"]; way(area.a)[name="Ганцевичи"];); map_to_area -> .b; (way(area.b)["highway"~".*"]["name"~"веры хоружей",i]; ._;>;)->.c; .c out; waiting results takes long time. how speed process, possible wrong in query?

android - how to make app that uses play service to work without it? -

i have developed android app uses play services maps. possible made part of app doesn't need play services works without it? google maps android api part of google play services platform. if want use it, need set google play services sdk in app development project also can see in attribution requirements states that: if use google maps android api in application, must include google play services attribution text part of "legal notices" section in application. including legal notices independent menu item, or part of "about" menu item, recommended. by checking other so question , find here that, if google play services application not installed on user's device, may fall other providers google static maps you can check so question more information.

How to truncate tables genarated by persisted streams in WSO2 DAS -

is there way truncate tables created persisting event streams in wso2 data analytics server (wso2 das) yes. can either purge old data using management console per stream or purge data in table globally. plase refer https://docs.wso2.com/display/das301/purging+data

How to enable local storage for my firebase app -

my app send somme data firebase storage possible connection off when app want send data. hear can achieve enabling local storage, want known how? you can see following site - https://www.firebase.com/docs/web/guide/offline-capabilities.html

java - Migrating from jboss AS5 to JbossAS6.1 -

i migrating jboss 5 6 , endup errors caused by: javax.jms.invaliddestinationexception: mqjms2008: failed open mq queue @ com.ibm.mq.jms.mqqueueservices.getqueueopenexception(mqqueueservices.java:412) [:6.0.0.0 - j000-l050519.1 ] @ com.ibm.mq.jms.jmsservicesmgr.getqueueopenexception(jmsservicesmgr.java:120) [:6.0.0.0 - j000-l050519.1 ] @ com.ibm.mq.jms.mqsession.createqreceiver(mqsession.java:6000) [:6.0.0.0 - j000-l050519.1 ] @ com.ibm.mq.jms.mqqueuesession.createreceiver(mqqueuesession.java:278) [:6.0.0.0 - j000-l050519.1 ] @ com.ibm.mq.jms.mqqueuesession.createconsumer(mqqueuesession.java:332) [:6.0.0.0 - j000-l050519.1 ] @ org.jboss.internal.soa.esb.rosetta.pooling.wrappedsession.createconsumer(wrappedsession.java:167) [:] @ org.jboss.internal.soa.esb.rosetta.pooling.jmssession.createconsumer(jmssession.java:229) [:] @ org.jboss.soa.esb.listeners.gateway.jmsgatewaylistener.preparemessagereceiver(jmsgatewaylist