Posts

Showing posts from March, 2015

c# - How to Find Path to a Certain Object Without Knowing Its Position in a Grid Based Video Game? -

Image
i´m in middle of development of personal project . in video game there grid based movement , creation , pathfinding system . , have used a* pathfinding in order make characters move towards known position . but have encountereda big question . there character in game has go kind of object , character doesn´t know exact coordinate of such object . easiest way of doing know coordinates of objects , calculate 1 nearest 1 , use a* pathfinding in order point , aproach seems rigged , not dynamic enough type of game i´m making. so know if there pathfinding algorithm searches around point (the location of character using algorithm) , in radial way , , keeps searching until finds object type looking , returns path object. look dijkstra's algorithm. covers whole graph before calculating shortest path destination, unlike a* goes towards destination upfront. in other words, dijkstra finds all paths nodes source, choose destination , shortest path or least cost. there nice gif

c# - Cannot build the Caliburn.Micro.HelloScreen sample due to missing references -

i've downloaded source package of caliburn.micro this page , version 1.5.2. have vs2010 professional, , have downloaded , installed blend sdk. i've extracted entire thing, , able build actual caliburn.micro.dll after removing projects aren't supported on system (meaning can build caliburn.micro.dll only). however, cannot figure out how build helloscreens sample. appears sample configured use nuget, whatever can't seem proper references work. i've tried right-clicking solution end enabling nuget package restore, hoping thing smart enough resolve had resolve, nope. the following references have yellow exclamation points on them (and don't exist on disk): caliburn.micro microsoft.expression.effects microsoft.expression.interactions system.windows.interactivity can remove caliburn nuget package through visual studio , reinstall it? packages.config might mixed up. nuget should set references right.

ruby on rails - Capybara click_link works wrong -

i have such bug. here code: it "shows places sorted date of creation" click_button( i18n.t("models.places.actions.index.sort_by")) click_link(i18n.t("models.places.actions.index.date_of_creation")) sorted_places_names = places.map(&:name).reverse link_names = all("a.place-link").map(&:text) expect(link_names).to eq(sorted_places_names) end and problem click link here must send params: " ?by_created_at: true " , controller response sorted places date of creation, in descendant order. problem when capybara clicks on link, request have path, without params needed.i`m using poltergeist here. also have such test: it "shows orders today" today_order.customer.reputations << create(:reputation, place: place) visit place_statistics_loyalty_path(place) click_link(i18n.t("statistics.loyalty.today")) expect(page).to have_selector("#order_#{today_order.id}") end it tes

wpf - Binding an image in a datatemplate -

i'm trying add menu application, i'd menu header connected user's picture. my issue every binding works except 1 image, i've understood on net datatemplate use replace menu header picture doesn't have access it's parent datacontext. tried use stuff relative source , other tricks no luck (certainely related fact i'm new in mvvm , still have lot learn :) ) here's code i'm using : <grid datacontext="{binding user}"> <dockpanel> <label content="{binding strings.hello, source={staticresource stringlocalizer} }" verticalalignment="center" padding="0,0,5,0" fontfamily="{dynamicresource font_normal}" fontsize="15" foreground="white"/> <textblock text="{binding displayname, targetnullvalue='guest', fallbackvalue='guest'}" verticalalignment="center" horizontalalignment="left" fontfamily="{dy

c# - Visual Studio having conflict between referenced DLL's: only one is actually referenced -

while building project, message no way resolve conflict between "system.data.sqlserverce, version=4.0.0.1, culture=neutral, publickeytoken=89845dcd8080cc91" , "system.data.sqlserverce, version=3.5.1.0, culture=neutral, publickeytoken=89845dcd8080cc91". choosing "system.data.sqlserverce, version=4.0.0.1, culture=neutral, publickeytoken=89845dcd8080cc91" arbitrarily. 33> consider app.config remapping of assembly "system.data.sqlserverce, culture=neutral, publickeytoken=89845dcd8080cc91" version "3.5.1.0" [c:\windows\assembly\gac_msil\system.data.sqlserverce\3.5.1.0__89845dcd8080cc91\system.data.sqlserverce.dll] version "4.0.0.1" [...\bin\debug\system.data.sqlserverce.dll] solve conflict , rid of warning. the issue is, version 3.5.1.0 not referenced in part of project. not in app.config files. can search inside visual studio or outside within windows, references assembly, , not exist.

python - Anaconda problems modifying PYHTONPATH in .profile and .bash_profile -

Image
so have .profile , .bash_profile setup follows: but using anaconda python package. i'm following these set of instructions found here: http://www.skirt.ugent.be/pts/_install_mac_set_up.html and receiving error message: "no module named pts" does know have gone wrong?? there seems comflict anaconda , pythonpath= command in .bash_profile file...? any suggestions on how fix this/marry 2 appreciated! you have set pythonpath incorrectly. included 1 path component many. from configuring paths , aliases add following lines: export pythonpath=~/pts alias pts="python -m pts.do" alias ipts="python -im pts.do" but added equivalent of export pythonpath=~/pts/pts which path includes pts module error complaining about. remove /pts bit pythonpath line , things should work.

wpf - IValueConverter to convert a resource referenced by StaticResource -

i looking use ivalueconverter value getting resources of application. noticed similar question asked few years ago here: how bind staticresource converter? . however, updating source attribute object in resources didn't work me. particular case: <textblock text="sampletext" foreground="{binding source={staticresource appthemecolor}, converter={staticresource themecolortobrushconverter}, converterparameter={staticresource applicationforegroundthemebrush}, mode=oneway}" /> the appthemecolor defined , set dynamically in code behind @ stage of app launch. logic in converter says use color provided unless app in highcontrast mode, in case uses brush supplied in converterparameter. does know of pitfalls might running here? there no compile or run time errors. text doesn't appear , converter's convert doesn't seem getting called. edit: asking how setting appthemecolor dynamically. added following one-liner here in app.xaml.cs'

flask - '400 Bad Request' when post JSON in PostMan but working fine using curl despite setting Content-Type -

Image
i having issues using postman create same post request working using curl. curl -i -h "content-type: application/json" -x post -d '{"daturl":"insert_base_64_here"}' http://localhost:5000/api here settings postman , error get: <!doctype html public "-//w3c//dtd html 3.2 final//en"> <title>400 bad request</title> <h1>bad request</h1> <p>failed decode json object: no json object decoded</p> it being caused line in code, have set content-type application/json not sure causing it: request.get_json(force = true)

javascript - Finding and clicking an check box that is part of the jstree using xpath? -

i trying click checkbox part of jstree , every thing have tried far has been unsuccessful. please assist. the goal check checkbox id 733 here html code: <div id="jstree-1" class="jstree jstree-2 jstree-default jstree-default-responsive jstree-checkbox-no-clicked" role="tree" aria-activedescendant="8528"> <ul class="jstree-container-ul jstree-no-dots jstree-no-icons"> <li id="733" class="jstree-node jstree-open jstree-last" role="treeitem" aria-selected="false" aria-expanded="true"> <i class="jstree-icon jstree-ocl"/> <a class="jstree-anchor" href="#"> <i class="jstree-icon jstree-checkbox"/> <i class="jstree-icon jstree-themeicon false jstree-themeicon-custom"/> accepts cash </a> <ul class="jstree-childre

how to compare real/float while using "AND" .(unix) -

i'm new shell scripting, have written small script check if input in specified (integer) range: echo "enter number btw 50 , 100:" read num if [ $num -le 100 -a $num -ge 50 ]; echo "you in limits." else echo "you out of limits." fi how can check if number in real/floating range? you can't sh/ ksh 1 /bash(/zsh?) -- integer arithmetic only. you can like if [ "$(echo "50 <= $num && $num <= 100" | bc)" = "1" ]; echo "you in limits." else echo "you out of limits." fi ( 1 - ksh93 can floating point arithmetic)

html - Bootstrap - Align multiple select elements -

so trying simple can seem figure out. have 2 select elements want align horizontally text in between. have: ( on codepen ) <div class="row"> <div class="col-xs-2"> <select class="form-control input-sm">...</select> </div> <div class="col-xs-1"> vs </div> <div class="col-xs-2"> <select class="form-control input-sm">...</select> </div> </div> however when try put vs (versus) between them , if use <p> or <div> no class defined second select gets misaligned. if wrap vs in div class=col-xs-1 gap big , doesnt nice. best way vs between 2 select while keeping alignment , not having huge space between 2 elements i assume using bootstrap looking @ codepen. bootstrap has class inline forms use this: <div class="container"> <form action="" class="form-inline"> &l

jquery - Multiple identical rows in a table, how to trigger one onclick event? -

i have rows in table, click event triggered anchor. each row identical, , click event shows div whilst hiding another. how trigger onclick event relating corresponding li on same row? here jquery i'm using (function($) { $(document).ready(function() { $('.split-trigger').click(function() { $(this).toggleclass('splittrigger-active'); $('.split').toggleclass('split-active'); }); }); })(jquery); to apply changes via .click() event, used .siblings() trigger element so: (function($) { $(document).ready(function() { $('.split-trigger').click(function() { $(this).toggleclass('splittrigger-active'); $(this).siblings('.split').toggleclass('split-active'); }); }); })(jquery);

jquery - Multiple tables don't work -

this question has answer here: event binding on dynamically created elements? 19 answers i have button: <td class="rigaconto"> <a class="btn btn-default separa_conto" data-conto="2" data-toggle="tooltip" data-original-title="newaccount"><i class="fa fa-sitemap"></i></a> </td> and jquery code: $(function(){ $(".separa_conto").click(function() { var conto = $(this).data('conto'); var nuovoconto = conto + 1; alert(conto); $('#showaddeb_conto_'+ conto).removeclass('hidden').show('slow'); $('#showaddeb_conto_'+ conto).append('<tr><td></td><td>sogg</td><td>1000</td><td></td></tr>'); $('.rigaconto').append('<a class

php - Yet another regex. Getting image from markdown, bugged if markdown inside -

i'm trying images info wiki, have working regex i'm failing when description has markdown also. format of images on markdown: //[[image:williamgodwin.jpg|thumb|right|150px|william godwin]] //[[image:johannmost.jpg|left|150px|thumb|[[johann most]] outspoken advocate of violence]] //[[image:cnt-armoured-car-factory.jpg|right|thumb|270px|[[spain]], [[1936]]. members of [[cnt]] construct [[armoured car]]s fight against [[fascist]]s in 1 of [[collectivisation|collectivised]] factories.]] [[image:cnt_tu_votar_y_ellos_deciden.jpg|thumb|175px|cnt propaganda april 2004. reads: don't let politicians rule our lives/ vote , decide/ don't allow it/ unity, action, self-management.]] [[image:flag of anarcho syndicalism.svg|thumb|175px|the red-and-black flag, coming experience of anarchists in labour movement, particularly associated anarcho-syndicalism.]] [[image:leotolstoy.jpg|thumb|150px|[[leo tolstoy|leo tolstoy]] 1828-1910]] {{main articles|[[christian anarchism]] , [[a

css - IE9 - unwanted padding inside div when inner div is absolute and outer div is relatively positioned -

Image
i have been battling problem 6 hours on ie. there seems padding when use before tag position absolute. css .rteeditable{ background-color:green; position: relative; width: 200px; height: 400px; min-height: 400px; } .rteeditable p{ padding-left: 46px; } .rteeditable:before{ position: absolute; height: 100%; width: 40px; content:''; background-color:red; } html <div class="rteeditable" contenteditable="true"> <p> hello teast </p> </div> the code have written jsfiddle here images better explanation. chrome ie9 see https://jsfiddle.net/evouvj7v/ add left: 0; right: 0; top: 0; bottom: 0;

twitter bootstrap - Select field as input group addon -

Image
i want use <select> field input group addon bootstrap3 somehow this ------------------------------------- | select v | input text field | ------------------------------------- so assume achieve using .input-group , .input-group-addon , , .form-control classes. <div class="input-group"> <select class="input-group-addon" id="protocol"> <option>http://</option> <option>https://</option> </select> <input type="text" class="form-control" id="domain" aria-describedby="protocol"> </div> ( see bootply example ) but .input-group-addon class doesn't seem work <select> items. looks this: how can fix align this? you need wrap <select> <div> class .input-group-addon this <div class="input-group"> <div class="input-group-addon"> <select

java - HTTP Status 500 at line 35 -

when running create-dest.jsp , fill form taking error , can , , suggest me solution? ps: know coding java in jsp bad... type exception report message exception occurred processing jsp page /assets/jsp/create-dest-code.jsp @ line 35 description server encountered internal error prevented fulfilling request. exception org.apache.jasper.jasperexception: exception occurred processing jsp page /assets/jsp/create-dest-code.jsp @ line 35 32: //out.print(id); 33: if ( cat != null) { 34: for(int i=0;i } else { stacktrace: org.apache.jasper.servlet.jspservletwrapper.handlejspexception(jspservletwrapper.java:574) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:461) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:396) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:340) javax.servlet.http.httpservlet.service(httpservlet.java:729) org.apache.tomcat.webs

flashair - Upload files without restart -

i'm using upload.cgi delete file sd , upload newer version of file sd, device sd still recognize old version. the flashair sd seems cache old file contents until reboot it. i know writing 1 sd card 2 devices bad idea understand why implemented this, need swap file on sd without unplugging device ... is there kind of hidden setting, shell, whatever use make card "have" edited file without unplugging card? the device sd card in not write sd @ (so, no data corruption due 2 devices writing @ same time), recognizes when unplug sd , refuses work (because validates file on restart or when re-insert sd). i'd swap file "live" without device noticing strange...

group - Count unique data point in grouped data in R -

this question has answer here: calculate elapsed “times”, reference time depends on factor 2 answers i've been searching hours on , cannot find solution. i have below data set: id rank 1 1 1 3 1 3 1 4 2 2 2 3 2 3 2 3 3 1 4 2 4 2 i'm trying group id , produce count of how many unique times rank shows within group id results id rank unique 1 1 1 1 3 2 1 3 2 1 4 1 2 2 1 2 3 3 2 3 3 2 3 3 3 1 1 4 2 2 4 2 2 i'm using formula , it's providing result of in rank column unique <- with(data, rank, id, fun = function(i) length((unique(i)))) any extremely appreciat

java - Why is Hibernate adding schema name to Hsql functions? -

we have legacy app uses hibernate 3.0.3. unit testing hsqldb. 1 of queries generated hibernate looks this: select transactio0_.reason_id reason1_0_, transactio0_.description descript2_93_0_, transactio0_.reason_name reason3_93_0_ apps.mtl_transaction_reasons transactio0_ transactio0_.reason_id=54 , transactio0_.nvl (transactio0_.disable_date, now() + 1 day) > now() note schema name "transactio0_" prepended nvl function. why? how can configure hibernate not that? the next question deals version of hsqldb using. we're using hsqldb 2.2.8 , move hsqldb 2.3.2. above query works fine hsqldb 2.2.8 fails in hsqldb 2.3.2 "invalid schema name" error. there way can configure hsqldb 2.3.2 can execute query hsqldb 2.2.8 does? the generated sql looks strange , incorrect sql. transactio0_ table alias , shouldn't prepended function name. perhaps selected hibernate dialect not hsqldb dialect. in case, old version of hibernate , needs used ver

javascript - Jquery : Product between 2 lists of inputs into a 3rd list -

i don't have experience in jquery, i'm facing following challenge i have following table <table> <thead> <tr> <td>qty</td> <td>description</td> <td>unit price</td> <td>total price</td> <tr> </thead> <tbody> <tr id="itemrow"> <td><input type="text" name="quantity"/></td> <td><input type="text" name="description"/></td> <td><input type="text" name="unitprice"/>/td> <td><input type="text" name="totalprice"/></td> <tr> </tbody> </table> <input type="text" name="total"/> additionally, i'm able clone #itemrow many times required, enlarging

Smart way of solving marshalling datatypes from library to C++ primatives -

i'm using library (don't have access sources) has it's own data types, e.g. library::object::library_string, library::object::library_number. there enum stored alongside type tells type (i.e. library::object::type) the library provides methods on library::object isstring(), isnumber() query type. library provides getstring(), getnumber() throw exception if called on wrong type. i'm using library application , want populate c++ primitives little tedious code possible. 1 issue because library::object null or unexpected type, should check type using isxxxx() use getxxxx() populated c++ model. to prevent lots of code mymodel.myprimativevariable = isxxxx() ? getxxxx() : null_condition_type_for_this_type "" or 0 what's best achieve this? it's shame library didn't provide trygetvalue() method. i write bunch of functions each type (different signatures) can do: mymodel->myint = getintvalue(objectinstance) mymodel->mystring = getstring

PHP automatically destroys the session after login -

warning: unknown: write failed: no space left on device (28) in unknown on line 0 warning: unknown: failed write session data (files). please verify current setting of session.save_path correct () in unknown on line 0 what error this? your disk or partition full

subset - Transposing and Merging datasets in R -

i sure there answers out there question can't seem find 1 works , im absolutely new r apologies redundancy! so have huge dataset - 17k obs 35 variables. txt file imported , coerced as.matrix. 1st column has character values , rest 34 columns has numeric values. structure - >str(data_m) chr [1:17933, 1:35] "rab12" "trim52" "c1orf86" "plac9" "morn3" "loc643783" "loc389541" "oaz2" ... - attr(*, "dimnames")=list of 2 ..$ : null ..$ : chr [1:35] "name" "x118" "x12" "x21" ... now there small long form dataset 2 columns - id , gender. > str(data_maleids) 'data.frame': 24 obs. of 2 variables: $ id : factor w/ 34 levels "x118","x12","x21",..: 8 23 9 19 10 7 5 4 2 30 ... $ gender: factor w/ 2 levels "female","male": 2 2 2 2 2 2 2 2 2 2 ...` eg. - row.names id gen

r - Getting "node stack overflow" when cbind multiple sparse matrices -

i have 100,000 sparse matrices("dgcmatrix") store in list object. row number of every matrix same(8,000,000) , size of list approximately 25 gb. when do: do.call(cbind, thelistofmatrices) to combine matrices 1 big sparse matrix, got "node stack overflow". actually, can't 500 elements out of list, should output sparse matrix size of 100 mb. my speculation cbind() function transformed sparse matrix normal dense matrix , cause stack overflow? actually, have tried this: tmp = do.call(cbind, thelistofmatrices[1:400]) this works fine, , tmp still sparse matrix size of 95 mb, , tried: > tmp = do.call(cbind, thelistofmatrices[1:410]) error in stopifnot(0 <= deparse.level, deparse.level <= 2) : node stack overflow and error occurred. however, having no trouble doing like: cbind(tmp, tmp, tmp, tmp) thus, believe has do.call() reduce() seems solve problem, though still don't know reason why do.call() crushes. in r: 2-col

Cannot pass JSON array to array -

i trying pass json array array called array can query array submission_id value 27 obtain safety_rating_id , schedule_job_id , score , submission_id json https://codeshare.io/uqjmv i'm being thrown error cannot convert value of type '[json]' expected argument type 'json' code pass json array: var array: [json] = [] func gettask(oncompletion: () -> (), onerror: ((nserror) -> ())? = nil) { guard let endpoint = data.sharedinstance.weeklyendpoint else { print("empty endpoint"); return } alamofire.request(.get, endpoint, encoding: .json) .validate() .responsejson { response in switch response.result { case .success: if let value = response.result.value { let json = json(value) (_,subjson):(string, json) in json { if let date = subjson["start_date"].string{ self.date = date }

tomcat - Access folder outside of webapp -

i having hard time trying configure apache tomcat 8 access folder stand outside of webapp. tried multiple things including context server.xml , learned isn't correct way because docbase refers location of web application. i tried adding / project properties > web project settings: contect root. have node_modules folder @ root level of project. 404 error on script tags trying access folder. <script src="node_modules/core-js/client/shim.min.js"></script> since js file outside webapp , there solution, use absolute path . by ways, maybe put js file inside webapp, this: <script src="${pagecontext.request.contextpath}/node_modules/core-js/client/shim.min.js"></script>

linux - Unmet dependencies? Broken packages held? -

i trying vpn , running , doing through shrew soft client. when go run command: sudo apt-get install libqt4-core libqt4-dev libqt4-gui qt4-dev-tools i following stream of output: some packages not installed. may mean have requested impossible situation or if using unstable distribution required packages have not yet been created or been moved out of incoming. following information may resolve situation: following packages have unmet dependencies: libqt4-core : depends: libqt4-dbus (= 4:4.8.1-0ubuntu4.9) 4:4.8.1-0ubuntu5~precise1~test1 installed depends: libqt4-network (= 4:4.8.1-0ubuntu4.9) 4:4.8.1-0ubuntu5~precise1~test1 installed depends: libqt4-script (= 4:4.8.1-0ubuntu4.9) 4:4.8.1-0ubuntu5~precise1~test1 installed depends: libqt4-test (= 4:4.8.1-0ubuntu4.9) not going installed depends: libqt4-xml (= 4:4.8.1-0ubuntu4.9) 4:4.8.1-0ubuntu5~precise1~test1 installed depends: libqtcore4 (= 4:4.8.1-0ubunt

oracle - Orace SQL - sorting with all upper case first -

what if wanted sorting have upper case first lower case? a b c d b c d i tried searching net , find sorting make it a b b c c etc.. but wanted upper case values sorted first lower case ones. any idea? thanks use case expression conditionally order column, based on upper or lower case. order original column. select * tablename order case when upper(col) = col 1 else 2 end, col note: ordering above works when there 1 character in string or when entire string either upper case or lower case.

google spreadsheet - query formula combining cells -

i trying query formula work in google spreadsheets. large data set (formula =query(sheet1!a3:eh) ). having trouble because after few rows (and of course taking forever catch data), starts combine cells systematically. sheet 1 have rows separated, sheet formula have sheet1!a3 combined sheet1!a4, sheet1!b3 combined sheet1!b4, merged them space in between. idea why happening? there different formula can use more reliable? the query formula combines header rows one. if not provide number of header rows 3rd argument of formula, guesses based on data — , guesses wrong. so, use =query(sheet1!a3:eh, "select ...", 0) if range a3:eh not include header rows.

c# - asp.net mvc routing with multiple optional parameters did not work -

i wrote attribute route route("home/{category?}/{subcategory?}/list") want match following examples /home/c1/s1/list , /home/c1/list , /home/list but match first url, optional parameter did not work. how use routing rule matches above 3 examples? public class homecontroller : controller { public iactionresult index() { return view(); } [route("home/{category?}/{subcategory?}/list")] public iactionresult list(category? category = null, subcategory? subcategory = null) { return content(category.tostring() + "/" + subcategory.tostring()); } [route("home/{code}/detail")] public iactionresult detail(string code) { return content(code); } } public enum category { c1, c2, c3, c4 } public enum subcategory { s1, s2, s3, s4 } similar questions routing optional parameters in asp.net mvc 5 mvc routing 1 fixed action , controllers multiple o

nginx - nunjuncks not rendering because of Content-Security-Policy -

the error: uncaught template render error: (result.html) evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in following content security policy directive: "default-src *". the nginx config: [..] more_set_headers "content-security-policy: default-src * 'unsafe-eval' 'unsave-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' 'unsafe-inline' https://cdn.raygun.io https://cdn.segment.com https://platform.instagram.com https://www.google-analytics.com https://cdn.mxpnl.com https://maxcdn.bootstrapcdn.com; connect-src 'self' https://api.raygun.io https://api.parse.com https://api.segment.io https://api.mixpanel.com; img-src 'self' data: https://*.amazonaws.com https://www.google-analytics.com https://*.akamaihd.net https://www.google.com https://*.licdn.com; st

php - Column not found in where clause -

i php , trying make page can see public uploads stored in mysql server. out of not code have been using starts giving me error: sqlstate[42s22]: column not found: 1054 unknown column 'public' in 'where clause' i trying see how many rows in db have 'public' // find out how many items in table $p = 'public'; $total = $db->query("select count(*) uploads world_access = $p")->fetchcolumn(); i don't know if php or sql. // prepare paged query $stmt = $db->prepare('select * uploads world_access = :y order upload_time desc limit :limit offset :offset'); // bind query params $stmt->bindparam(':y', $p, pdo::param_int); $stmt->bindparam(':limit', $limit, pdo::param_int); $stmt->bindparam(':offset', $offset, pdo::param_int); $stmt->execute(); pagination simple php pagination script enclose $p quotes $total = $db->query("select count(*) uploads world_access = &

java - Formal Greeting app only displays last if statement can't figure out why -

package chapter6; import java.util.scanner; public class formal_greeting { public static void main(string[] args) { string title; string name; string mr = null; string miss = null; string ms = null; string mrs = null; scanner input = new scanner(system.in); system.out.print("enter name: "); name = input.next(); system.out.print("enter title: "); title = input.next(); if (title.equalsignorecase(mr)) { system.out.println("hello sir"); }else if (title.equalsignorecase(miss)) { system.out.println("hello ma'am"); }else if (title.equalsignorecase(ms)) { system.out.println("hello ma'am"); }else if (title.equalsignorecase(mrs)) { system.out.println("hello ma'am"); }else { system.out.println("hello

Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for it -

this question has answer here: $(document).ready equivalent without jquery 31 answers okay, might silly question, though i'm sure there plenty of other people asking same question time time. me, want make 100% sure either way. jquery know wonderful $('document').ready(function(){}); however, let's want run function written in standard javascript no library backing it, , want launch function page ready handle it. what's proper way approach this? i know can do: window.onload="myfunction()"; ...or can use body tag: <body onload="myfunction()"> ...or can try @ bottom of page after everything, end body or html tag like: <script type="text/javascript"> myfunction(); </script> what cross-browser(old/new)-compliant method of issuing 1 or more functions in manner jquery's $.ready()

html - z-index and stacking; removing a child from stacking context -

i'm trying tweak stacking order of elements; here's sscce . given html snippet: <div id="block1"> <div>lorem ipsum dolor.</div> <div id="widget"> <div>widgety goodness!</div> </div> </div> <div id="block2"> <div>lorem ipsum dolor.</div> </div> <div id="block3"> <div>lorem ipsum dolor.</div> </div> i'm trying display #widget on top of #block2 ; following css, you'll see problematic without changing location of #widget in node tree. #block1, #block2, #block3 { position: relative; min-height: 50px; width: 100%; } #block1, #block3 { background-color: #abc; color: #123; z-index: 1; } #block2 { background-color: #def; color: #456; z-index: 2; } #widget { background-color: #f00; position: absolute; z-index: 999; left: 200px; top: 40px; } as can

PHP - Recursive binary tree -

i've been having fun php trying explore potentials tried see if can implement binary tree structure. here code: class node{ public $leftnode; public $rightnode; public $value; public function node($value){ $this->value = $value; } } class bintree{ public function inserter(node $node, $value){ if($value < $node->value){ if($node->leftnode != null){ inserter($node, $value); } else{ $node->leftnode = new node($value); } } else if($value > $node->value){ if($node->rightnode != null){ inserter($node, $value); } else{ $node->rightnode = new node($value); } } } } now reason, when try call inserter function within (i.e. inserter ($node, $value), error: fatal error: call undefined function inserter(). tried referencing via $thi

clojure.spec: `alt` vs `or` for sequence spec -

i'm following clojure.spec's guide ( http://clojure.org/guides/spec ). i'm confused difference between alt , or sequence spec. for me 2 following examples work equally well. what's difference between two? ; use `alt` (s/def ::config (s/* (s/cat :prop string? :val (s/alt :s string? :b boolean?)))) (s/explain ::config ["-server" "foo" "-verbose" true "-user" 13]) ; use `or` (s/def ::config (s/* (s/cat :prop string? :val (s/or :s string? :b boolean?)))) (s/explain ::config ["-server" "foo" "-verbose" true "-user" 13]) s/alt concatenating nested regex specs using s/or specifies subsequence. in example doesn't make difference since not using nested regex specs. here example: (s/def ::number-regex (s/* number?)) (s/def ::or-example (s/cat :nums (s/or :numbers ::number-regex))) (s/valid? ::or-example [1 2 3]) ;;-> fals

mysql - joining tables in active records ruby -

i have 2 tables, table1 id name age occupation ssn_id 1 18 engineer 12 2 b 19 engineer 67 3 c 14 student 89 4 b 19 engineer 67 table2 id ssn_id limit hours 1 67 2 20 2 12 2 17 3 89 2 78 expexted output ssn_id limit count(*) occupation 67 2 2 engineer sql query - select id, occupation, count(*) total, `limit` table1*table2 table1.ssn_id = table2.ssn_id , occupation = 'engineer' group table1.ssn_id having count(*) > `limit` i want convert query rails active record query. have tried using include can't columns of second table. if have models table1 , table2, can use approach: table1. joins(:table2). select("table1.id, table1.occupation, count(*) total, table2.limit"). where(occupation: 'engineer').where("table1.ssn_id = table2.ssn_id"). group(table1.ssn_id). having(&qu

hash - Is there an MD5 Fixed Point where md5(x) == x? -

is there fixed point in md5 transformation, i.e. there exist x such md5(x) == x ? since md5 sum 128 bits long, fixed point have 128 bits long. assuming md5 sum of string uniformly distributed on possible sums, probability given 128-bit string fixed point 1 / 2 128 . thus, probability no 128-bit string fixed point (1 − 1 / 2 128 ) 2 128 , probability there fixed point 1 − (1 − 1 / 2 128 ) 2 128 . since limit n goes infinity of (1 − 1 / n ) n 1 / e , , 2 128 large number, probability 1 − 1 / e ≈ 63.21%. of course, there no randomness involved – either there fixed point or there isn't. but, can 63.21% confident there fixed point. (also, notice number not depend on size of keyspace – if md5 sums 32 bits or 1024 bits, answer same, long it's larger 4 or 5 bits).

python - Translate image using PIL -

this question has answer here: use python invert , translate images 1 answer how can translate image 5 pixels in 1 of 4 directions using pil , python. have seen can use im.transform(size, affine, data) don't know how to. image.transform(size, method, data) method=image.affine returns copy of image affine transformation matrix (given 6-tuple (a, b, c, d, e, f) via data ) has been applied. each pixel (x, y) , output calculated (ax+by+c, dx+ey+f) . if want apply translation, have @ c , f values of matrix. from pil import image img = image.new('rgb', (100, 100), 'red') = 1 b = 0 c = 0 #left/right (i.e. 5/-5) d = 0 e = 1 f = 0 #up/down (i.e. 5/-5) img = img.transform(img.size, image.affine, (a, b, c, d, e, f)) img.save('image.png')

java - how to create a properties file for keystore? -

i have created key store , extracted public key. in order use key store i've created keyproperties.properties file, i'm not sure property called "private". i'm totally confused whether path or private key password or else. properties file -> .properties extension data not coming anywhere , i'm using static data. private-> path of keystore used private key this snippet of code: public static void main(string[] args)throws exception { properties properties = new properties(); string path = properties.getproperty("private"); keystore ks = keystore.getinstance("pkcs12", "bc"); ks.load(new fileinputstream(path), keystore_password.tochararray()); } when create properties object using new properties() , don't have data stored in object yet. doesn't make sense properties.getproperty("private") because return null . you claim you've made .properties file, don't see l

c++ returning dereference of a pointer causes Segmentation fault -

i have map pointer m , not local variable of function getmap , getmap returns dereference of pointer m , , when run code below, got segmentation fault (core dumped) , why returning dereference of pointer causes segmentation fault. std::map<int, std::string> *m; const std::map<int, std::string>& getmap(){ m->insert(std::make_pair<int, std::string>(0, "hi")); return *m; } int main(){ const std::map<int, std::string>& m = getmap(); std::cout << "length: " << m.size() << std::endl; } m uninitialized global pointer. compiler gives default value of nullptr . invoke undefined behaviour when dereference - try read or write memory @ 0 address causes segmentation fault. how fix: define std::map object , make m point there std::map<int, std::string> glob_map; std::map<int, std::string> *m = &glob_map; ... remaining of code unchanged make getmap return temporary const std

jdbc - difference between connection.close() and connection= null -

if explicitly close connection calling close() on connection object, have set connection object null. difference in close() , null on connection object? if close connection ,still connection object maintained in connection pool? e.g. connection dbconnection=null; preparedstatement preparedstatement = null; resultset rs; try { connection dbconnection= drivermanager.getconnection("jdbc:hsqldb:file:test5","sa", ""); ........... ........... dbconnection.close(); dbconnection=null; } catch (exception e) { logger.error("exception occured while fetching record:item details start method " + e.getmessage()); } { try { if (rs!=null) { rs.close(); rs=null; } } catch(sqlexception e) { logger.error(resultsetcloseexception

couchdb - how replicate only the user's documents -

i need sync document cloudant server ios in swift language. use official library https://github.com/cloudant/cdtdatastore#overview i need understand how replicate user documents. need figure out correct road. imagine ticket assistance system of company. all users can create ticket , save in cloudant/couchdb server. when user uses mobile platform, synchronize him ticket how can it? thank all cdtdatastore designed sync whole database, , cloudant/ couchdb doesn't provide per document acl. in order sync specific users data either need use filter function, hit performance of replication, or use 1 database per user model.

how to write soapclient function in php? -

i want know how write following soap request in php using soapclient function ? wsdl : https://test.edentiti.com/registrations-registrations/dynamicformsservice?wsdl action call : > <soapenv:envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:dyn="http://dynamicform.services.registrations.edentiti.com/"> > <soapenv:header/> <soapenv:body> > <dyn:registerverification> > <accountid>abcdefghijkl</accountid> > <password>1010101010</password> > <ruleid>default</ruleid> > <name> > <givenname>john</givenname> > <honorific></honorific> > <middlenames></middlenames> > <surname>citizen</surname> > </name> >

c++ - Questions about the h.264 JM ldecod -

now i'm doing h.264 video decoding jm's ldecod. use ldecod examine syntax of video clip format h.264, and disable function of yuv frame store while doing video decoding . i have traced source code of ldecod, cannot find related code disable function of store yuv frame. could give me ideas? thanks lot !! i found solution after several experiments. if you'd disable function of output pictures while doing h.264 decoding, should trace following functions , step step: exit_picture() -> store_picture_in_dpb() -> output_one_frame_from_dbp -> write_stored_frame() then can close function of write_stored_frame disable frame output.

c# - Start a stopwatch from specified time -

im trying start stopwatch given time (decimal value pulled database). however, because stopwatch.elapsed.add returns new timespan rather modify stopwatch, can't work out best way forward. var offsettimestamp = new system.timespan(0,0,0).add(timespan.fromseconds((double)jd.actualtime)); stopwatch.elapsed.add(offsettimestamp); stopwatch.start(); any ideas how can this? cheers the normal stopwatch not support initialization offset timespan , timespan struct , therefore elapsed immutable. write wrapper around stopwatch : public class stopwatchwithoffset { private stopwatch _stopwatch = null; timespan _offsettimespan; public stopwatchwithoffset(timespan offsetelapsedtimespan) { _offsettimespan = offsetelapsedtimespan; _stopwatch = new stopwatch(); } public void start() { _stopwatch.start(); } public void stop() { _stopwatch.stop(); } public timespan elapsedtimespan {

c# - Use Proper UniqueIdentifier in SQL with Entity Framework Identity -

i have gone through lot of stackoverflow posts , tons of blogs yet unable figure out missing here.... using: ef 6.1.3 aspnet.identity.core 2.2.1 aspnet.identity.entityframework 2.2.1 applicationuser: [table("users", schema = "user")] public class applicationuser : identityuser<guid,applicationuserlogin, applicationuserrole, applicationuserclaim> { } applicationuserclaim [table("userclaims", schema = "user")] public class applicationuserclaim: identityuserclaim<guid> { } applicationuserlogin [table("userlogins", schema = "user")] public class applicationuserlogin: identityuserlogin<guid> { } applicationuserrole [table("userroles", schema = "user")] public class applicationuserrole: identityuserrole<guid> { } applicationrole [table("roles", schema = "application")] public class applicationrole: identityrole<