Posts

Showing posts from January, 2011

java - JaxB Name space Prefix related -

java marshalling process assigning name spaces prefix ns2 or ns3 randomly, there way see why ns2 come first , ns3 later , vice versa? check these questions: jaxb :need namespace prefix elements jaxb custom namespace prefix issue in short, use @xmlns or specify namespaceprefixmapper .

android - How to add custom InputMethodService to Activity? -

i decided create custom keyboard application. know not best idea, since it's hurting user friendliness, that's why make optional in preferences. after having done in class public class customkeyboard extends inputmethodservice implements keyboardview.onkeyboardactionlistener . struggle add softinputmethod . tried inputmethodmanager incompatible types when casting it. i found can w/o service highly unrecommended , need whole new implementation. ideally, use edittext command line in app. direct binding job. after hiding system input method, how make input service default one? thanks. p.s. if there obvious easy way this, sorry, made transition android , still learning. use android:inputmethod on text field want change input method on. see https://developer.android.com/reference/android/widget/textview.html#attr_android:inputmethod you cannot set default input method entire device, can override on field field basis in app. adding default input metho...

ios - How do I set a top layout constraint for a stack view that is embedded in another stack view? -

Image
i want set vertical gap of 5px between give label , top of givelabelstack view. when set using layout constraints, error; see below. stack view automatically adds constraint of give.top = givelabelstack.top . in addition, can't select delete , remove constraint. on image, can't select give.top = givelabelstack.top remove. does how can achieve this? thanks put label inside own vertical stack view (which inside horizontal givelabelstack ). set vertical stack view's top layout margin 5. before: after: here's set stack view's layout margins:

android - Is there actually a method to disable showing admob's interstital banner after the app was closed? -

interstitial loads in app , showing after closed app. how prevent that? interstital has no methods cancle or destroy. is solution interstital = null; ??? i'm not sure regarding method might available, can easly prevent it. you can call finish on activity, if possible. if not, set flag (boolean) , set false using onpause or onstop events, check flag before calling show () on interstitial. if (your_fancy_new_flag) { //show interstitial }

Nashorn memory leak Much memory is consumed by jdk.nashorn.internal.scripts.JO4P0 -

we using nashorn use javascript java (jdk 1.8 u66),after profiling seeing larger data getting occupied jdk.nashorn.internal.scripts.jo4p0 object. know if 1 have idea? jdk.nashorn.internal.scripts.jo4po , other similar instances used represent scripts objects scripts. but, need provide more info further investigation. suggest please write nashorn-dev openjdk alias profiler output + more info. application (like project, if open source, useful

php - Woocommerce add or hide shipping method based on category -

i want remove or add shipping options depending on category of product in cart. example: have 1 product category x , want add shipping-method-x cart. , if have 1 product category x , 1 category, shipping-method-x disabled. function below checks if array contains category id=49 , if there category, doesn't work. nothing happens in cart :( please help add_filter( 'woocommerce_package_rates', 'hide_shipping_based_on_tag' , 10, 1 ); function check_cart_for_share() { global $woocommerce; $cart = $woocommerce->cart->cart_contents; $found = false; foreach ($woocommerce->cart->cart_contents $key => $values ) { $terms = get_the_terms( $values['product_id'], 'product_cat' ); $tmp = array(); foreach ($terms $term) { array_push($tmp, $term->term_id); } array_unique($tmp); if (sizeof($tmp) > 1 , in_array('49', $tmp)) { $found = true; } } return...

SAS: Can't paste text into user input prompt (using %WINDOW) -

i wondering if there way allow user paste text user input prompt created using %window statement. example, simple code in sas documentation follows: /** %window defines prompt **/ %window info #5 @5 'please enter userid:' #5 @26 id 8 attr=underline #7 @5 'please enter password:' #7 @28 pass 8 attr=underline display=no; /** %display invokes prompt **/ %display info; %put userid entered &id; %put password entered &pass; i have similar 1 of fields asks user put in path folder (like c:\mydocuments\2015\testfolder). path can pretty long , reason cannot paste path name user input field. there sas option allow this? you auto-populate field clipboard using macro variable generated via previous data step, suppose. if remember syntax correctly: filename temp clipbrd; data _null_; infile temp; input; call symput('longvar',_infile_); run; filename temp clear; this require user have copied file path clipboard before running code...

Importing python modules from folders -

so, having following structure in python package: ./main.py __init__.py ./mymods/ __init__.py a.py b.py my module a.py imports module b: import b now, want import module main when following: import mymods.a importerror: no module named 'b' i googled couldn't find solution particular problem. samaritan knows how this? p.s. prefer not have import module b explicitly main, if possible. you need make mymods package. can done creating empty __init__.py file in directory. ➜ tree . ├── main.py └── mymods ├── __init__.py ├── a.py └── b.py 1 directory, 4 files ➜ cat main.py import mymods.a print 'printing main' ➜ cat mymods/a.py . import b print 'printing a' ➜ cat mymods/b.py print 'printing b ➜ python main.py printing b printing printing main for python 3, change import b from . import b .

asp.net - The simpleType 'Infinite' has already been declared -

Image
i in visual studio 2015 (asp.net web forms project) , seeing following warning signs in web.config file, i not sure how fix warning. please let me know suggestions.

c++ array error while executing -

when run program keep getting error. program still execute , run , display correct nymbers in terminal, need ouput file , put them on there. please new c++. bash-3.2$ g++ -wall 1.cpp 1.cpp: in function 'std::string ip_calculation(std::string*, std::string, int)':1.cpp:71:1: warning: control reaches end of non-void function [-wreturn-type] string ip_calculation(string ip[], string company_name, int total_ips) { string temp = ""; char buf[80]; char buf2[80]; if (total_ips != 0) { int uniqueip_count = total_ips; (int = 0; < total_ips; i++) { (int j = + 1; j < total_ips; j++) { if (strcmp(ip[i].c_str(), ip[j].c_str()) == 0) { if (strcmp(ip[i].c_str(), "") == 0) { continue; } ip[j] = ""; uniqueip_count--; ...

c# - How to send url segment as parameter to action method? -

in mvc web app route urls 1 url segment same controller action. example: http://example.com/onepage here's action method in controller: public actionresult someaction(string urlsegment) { ... } now, want url segment (like "onepage" example), sent input action method. can show maproute should make happen? it this. routes.maproute( "urlsegment", // route name "{urlsegment}", // url parameters new { action="someaction",controller="controllername" }, // parameter defaults new[] { "namespace.controllers" } // controller namespaces); i'm on phone unfortunately can't verify should you're looking for.

sumifs - Sum IF VBA error '438' - object doesn't support this property or method -

i dont know why gives me '438' - object doesn't support property or method error, in "sumif" function line. how can sumif function in vba? application.worksheetfunction.sumifs(range("n2:n" & rsum), range("c" & rw), range("s2:s" & rsum)) and here's whole code: sub macro1() dim lr integer dim rw integer dim rsum integer lr = range("c" & rows.count).end(xlup).row rsum = range("n" & rows.count).end(xlup).row rw = 2 lr if not isempty(range("c" & rw).value) range("g" & rw).value = application.worksheetfunction.sumifs(range("n2:n" & rsum), range("c" & rw), range("s2:s" & rsum)) end if if range("g" & rw).value = 0 range("g" & rw).value = "-" range("f" & rw...

php - Get all id's from table MYSQL -

i'd echo id's user table can't work. tried below , searched stacks can't find right answer. $query = $db->query( "select * users" ); $num = $db->num( $query ); while( $array = $db->assoc( $query ) ) { $active_ids = $array['id']; } $query = "select u.username, u.habbo, count(*) n users u, timetable tt u.id=tt.dj , u.id in (".$active_ids.") group tt.dj"; $result = $mysqli->query($query); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()){ echo "<tr id='uren-table-row'>"; echo "<td width='60px'><div style='height:50px;padding-top:25px;overflow:hidden;float:left;margin-top:-25px;'><img style='margin-top:-28px;float:left;' src='http://habmoon.org/moonstream/dj?habbie={$row['habbo...

java - Why can't I find my File? -

i'm trying open csv file name "logger.csv" have saved in source folder itself. public static void main(string[] args) { string filename = "logger.csv"; file motor_readings = new file(filename); try { scanner inputstream = new scanner(motor_readings); while (inputstream.hasnext()){ system.out.println(inputstream.next()); } inputstream.close(); } catch (filenotfoundexception e) { system.out.println("error: file not found!"); } } however, keeps on giving me "file not found" error. if use relative pathing right - file needs exist in project root, not in directory of java file. consider hierarchy: project/ src/main/java file.java logger.csv new file("logger.csv") not work. project/ logger.csv src/main/java file.java new file("logger.csv") now work. (notice, file adjacent src directory.)

javascript - How to hide a HTML class for a selected item in google org chart? -

i have google org chart , here source code in jsfiddle , have function if(collapsed == 0) { $(function(){ $(".plus").hide(); }); } i have class named plus , has picture displays every node want if node has no child item want class (plus image) hidden item has no child items. in case hides nodes , don't need it. in case person carol has no children , not need has plus image same alice thank you you hiding element using class selector, hide elements class present, should identify node other selector if need hide node , have updated data itself, here how can go it. updated fiddle : http://jsfiddle.net/w8ytq/102/ var runonce = google.visualization.events.addlistener(chart, 'ready', function() { // set + sign event handlers var previous; $('#chart_div').on('click', 'div.plus', function () { var selection = chart.getselection(); var row; ...

echo command doesn't work with PowerShell in Windows 10 -

so i'm trying install golang in new laptop has windows 10 installed in, trying make sure working path correct echo $gopath doesn't return anything, , return home path if typed echo $home i used set gopath=/user/folder/path set path, there wrong doing? or there missing files or in new laptop? it looks gopath environment variable, not variable $home . in powershell, can access environment variables this: $env:gopath

xml - XSL for-each combine different operators -

i have xml-file, need filter in 3 ways: 1) colour shold red or green, other colours should filtered away 2) category category, except catb 3) status status, except missing or damaged <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="items.xsl"?> <list> <item> <description>green cata damaged</description> <include>n</include> <colour>green</colour> <category>cata</category> <status>damaged</status> </item> <item> <description>red cata ok</description> <include>y</include> <colour>red</colour> <category>cata</category> <status>ok</status> </item> <item> <description>green catb ok</description> <include>n</include> <colour>green</colour> <category>catb</category> <status>ok</status> ...

c++ - Unicode exception class -

i want implement header-only class unicode exception , i've started following code: #pragma once #include <string> #include <exception> using namespace std; class uexception : public exception { public: explicit uexception(const wchar_t* msg) { this->msg = msg; } explicit uexception(const wstring& msg) { this->msg = msg; } const wchar_t* uwhat() const throw () { return msg.c_str(); } private: wstring msg; const char* what() const throw () //hidden { return null; } }; this works fine, have questions: why need derive std::exception class? may not needed @ all? am miss in class implementation? you don't have inherit std::exception . inheriting directly, or indirectly has advantage of allowing users of interface catch exception reference std::exception - without depending on definition of exception type. of course, accessing uwhat won...

tortoisesvn - How to reinstall SVN using the existing repo files from previous install? -

this question has answer here: attaching visualsvn server existing repository 4 answers preface: after upgrading windows 7 10, things didn't go well. seemed go fine, getting black screen on boot. turned off pc , registry got irreversibly corrupted. have reinstalled windows 10 cleanly. working after month, need svn up. the 'proper' backup have of repos old. need ensure backups done more moving forwards. have entire disk partition had svn data stored on. the file structure on svn partition intact, e.g. x:/myrepo/db/revs , data on x: . have latest copy of c:/myrepo working copy stored. how can reinstall tortoisesvn using existing files (not backup), , retain commit history including log messages? just install tortoisesvn (or other svn-client), , use old repositories (maybe relocation of wc needed due changed path), if the whole repo-tree is...

ios - Swift: Container View layout changes when rotating and rotating back again -

i working in xcode 7, using autolayout , targeting ios 9.3. have main view controller holds container view. container view holds child view controller. the container view has leading , trailing constraint of -20 covers main view controller in horizontal. when main view controller loads first time, however, content child view controller displayed inside container cut off on left , right (almost if not recognize constraint of -20 on left , right). when rotate device landscape , again original portrait orientation child view controller scales correctly , no longer cut off on left , right. so looks layout method being called when rotating device sideways , rotating again not called when view first loaded. method be? there way can manually call method force update on layout/size when child first loaded looks same after rotation , backwards rotation? i found solution problem: instead of setting leading , trailing constraint of -20 on container view, set constraint on c...

R connect to Oracle - library(ROracle) fail -

it won't load library. setwd("c:/users/***/desktop") install.packages('roracle_1.2-1.zip', repos = null) #installing package ‘c:/users/***/documents/r/win-library/3.3 (as ‘lib’ unspecified) #package ‘roracle’ unpacked , md5 sums checked library('roracle') #error in indl(x, as.logical(local), as.logical(now), ...) : unable load shared object 'c:/users/***/documents/r/win-library/3.3/roracle/libs/x64/roracle.dll': loadlibrary failure: specified module not found. i manually checked file path , roracle.dll there. edit: i have rodbc , rjdbc working. don't understand why roracle won't install: library(roracle) error in indl(x, as.logical(local), as.logical(now), ...) : unable load shared object 'c:/users/robsoo01/documents/r/win-library/3.3/roracle/libs/x64/roracle.dll': loadlibrary failure: specified module not found. error: package or namespace load failed ‘roracle’ install.packages("roracle") installi...

jquery - Why unbind event on image is not working -

i have got image on want disable click event , have used unbind event shown below $('#myimage').unbind("click"); but please let me why click event still working ?? this code $(document).ready(function () { $('#myimage').unbind("click"); }) $(document).on('click', ' #myimage', function (event) { alert('i called'); }); this fiddle http://jsfiddle.net/ygbxdspc/5/ the issue in fiddle code block running in document.ready handler (due settings you've chosen) unbind() called before event bound, hence no event removed . to fix actual problem, need use delegated form of off() method attached delegated event handler using on() , this: <script> $(document).ready(function() { $(document).off('click', '#myimage'); }) $(document).on('click', '#myimage', function(event) { alert('i called'); }); </script> working...

python - Find unique pairs in list of pairs -

i have (large) list of lists of integers, e.g., a = [ [1, 2], [3, 6], [2, 1], [3, 5], [3, 6] ] most of pairs appear twice, order of integers doesn't matter (i.e., [1, 2] equivalent [2, 1] ). i'd find pairs appear once , , boolean list indicating that. above example, b = [false, false, false, true, false] since a typically large, i'd avoid explicit loops. mapping frozenset s may advised, i'm not sure if that's overkill. ctr = counter(frozenset(x) x in a) b = [ctr[frozenset(x)] == 1 x in a] we can use counter counts of each list (turn list frozenset ignore order) , each list check if appears once.

database - MYSQL Insert Data into table using Foreign Keys from different tables -

i have temporary table "teststepdump" created "load data local infile". temporary table contains data of different tables connected foreign keys in table testresult: teststepdump (dummyno, stationno, name, result) duttest (id, dutid, processtime) dut (id, dummynr) station (id, stationno) teststepname(id, name) teststepresult(duttestid,teststepid,result) i´m trying way using stored procedure, error 1452: sql fehler (1452): cannot add or update child row: foreign key constraint fails ( database . teststepresult , constraint teststepresult_ibfk_1 foreign key ( duttestid ) references duttest ( id ) on delete cascade on update cascade) begin declare dt_id int; select teststepresult.duttestid dt_id teststepresult inner join duttest on teststepresult.duttestid = duttest.id inner join dut on duttest.dutid = dut.id inner join station on duttest.stationid = station.nummer inner join teststepdump on teststepresult.id = teststepdump.id dut.dummyn...

touch - Responding to Manipulation delta - strange effect and overflow -

Image
in test uwp form have basic manipulation test, code below. draws 3 circles on canvascontrol , sets translation , scaling manipulation. when test on touch screen expect, translating , zooming circles based on position of 2 fingers on screen. if pinch down beyond point, image starts oscillate between 2 extents , cause code stop overflow. i put canvas control in grid , tried doing manipulation on canvas control grid control, , not suffer same problem although effect of zooming , panning not seem correct. so looks effect of code is, iteration, manipulation causing render transform change cause manipulation, , goes in circles until settles - or if there problem of precision, perhaps due distance between touch points getting small, iteration diverges until overflow. is expected? correct way this? private withevents canv new canvascontrol private withevents gr new grid private sub canv_draw(sender canvascontrol, args canvasdraweventargs) handles canv.draw args.drawingsessi...

html - Website displays perfect everywhere but in Chrome Mobile -

i building website dad , displayed everywhere in chrome browser mobile (tested on android lollipop phone). i have forced width 1000px nothing should resize or scale seems getting scaled on chrome android. firefox android displaying fine. to honest, have no idea share direct url page talking : http://tinyurl.com/pu5rmee chrome android (bad scaled) : http://i.imgur.com/rv2xs9k.jpg firefox android (perfect) : http://i.imgur.com/qooxf3r.jpg thanks chrome mobile increases font-size better site readability. disable feature add viewport meta tag inside head section: <meta name="viewport" content="width=device-width, initial-scale=1"> or css: body { -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; } alternatively (not recommended, "old" way is) can set parent element max-height unreasonable big number, example max-height: 999999px .

javascript - Can a promise resolver/rejecter trigger its opposite? -

if have promise following, answers questions in comments? p.then(function ok () { // can err() trigger inside here? }, function err () { // can ok() trigger inside here? }); i know 1 can attach new then can wait results or reverse results of p , i'm wondering, assuming p constant, whether conditions can call each other recursively (and without assigning functions variables , invoking them name)... update my use case follows. in indexeddb, when opening database, can listen following: db.onsuccess = ... db.onerror = ... db.onblocked = ... db.js , library i'm expanding meet needs, adds these events promise api, such success resolve promise, , errors or blocking reject it. a common use case listening blocking close database connection causing blocking , indexeddb thereupon automatically call onsuccess . problem if treat onblocked rejection, apparently has no way retrigger resolve condition (i.e., onsuccess ). in order around this, can have blocking su...

Comparing Strings using java -

this question has answer here: overriding java equals() method quirk 8 answers i have create equals method return true if politicians' titles same. how compare strings? this how i've tried write far: public class politician implements priority{ private string name, title; private int a; public politician(string n, string t, int p){ name=n; title=t; a=p; } public boolean equals(politician a){ if(title.equals(a.title)) return true; return false; } however, return false. when test: priority t4= new politician("arnie", "governor", 4); politician t5= new politician("bill", "governor", 10); system.out.println(t5.equals(t4)); system.out.println(t4.equals(t5)); i've written equals() before , don't know why it's not working anymore public boolean equals(poli...

html - How do I put an image in the center of a div? -

i'm making edits simple bootstrap alert message use on website. want add image darker colored part on div right in center. css: .alert { padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px; font-family: tahoma; } .alert-info { color: #3a87ad; /* background-color: #d9edf7; */ background: linear-gradient(to right, #bce8f1 0%,#bce8f1 5%,#d9edf7 5%,#d9edf7 100%); border-color: #bce8f1; } } .alert-info hr { border-top-color: #a6e1ec; } .alert-info .alert-link { color: #2d6987; } .alert:hover { color: #4dad3a; background: linear-gradient(to right, #bcf1bc 0%,#bcf1bc 5%,#d9f7da 5%,#d9f7da 100%); border-color: #c2f1bc; } .padding { padding-left: 57px; } i added "hover" effect when hover on image turns blue green. html: <div class="alert alert-info padding">{text}</div> product: http://prntscr.com/8xb32o i want put icon/image in dark colored part on left side of "res...

html list item with multiple columns -

i'm trying pretty-up list consists of usernames , real names (e.g. jbloggs (joe bloggs). i'd real names line-up in column, when add <span class="col-xs-6"> around each part (see below) list screws-up! know how this? <ul> <li><a href="#"><span class="col-xs-6">jbloggs</span><span class="col-xs-6">- joe bloggs</span></a></li> <li><a href="#"><span class="col-xs-6">fjibbert</span><span class="col-xs-6">- flipperty jibbert</span></a></li> <li><a href="#"><span class="col-xs-6">beno</span><span class="col-xs-6">- brian eno</span></a></li> </ul> i'm using bootstrap 3 layout, etc. if still want use bootstrap classes, easiest way column lists applying grid classes <li> items themselves. ...

python - How to count the number of group elements with pandas -

i have dataframe , want count number of elements in each group. know, can use groupby().count() counts of columns, me, want number of elements in each group. how can this? here example: mydf = pd.dataframe({"fruit":["apple","banana","apple"],"weight":[7,8,3],"price":[4,5,6]}) mydf >> fruit price weight >> 0 apple 4 7 >> 1 banana 5 8 >> 2 apple 6 3 if use groupby("fruit").mean(), value each column. mydf.groupby("fruit").mean() >> price weight >> fruit >> apple 2 2 >> banana 1 1 but expect output is: >> number_of_fruit >> fruit >> apple 2 >> banana 1 how can this? you want size count number of each fruit: in [102]: mydf.groupby('fruit').size() out[102]: fruit apple 2 b...

python - Parsing hierarchical information from XML to sqlite -

the scripts post long beg patience. believe easy solve people familiar complexity of xml structure. have highly hierarchical xml file. love make sqlite database based on it. 2 files have far extract sibling information xml file structure (note - frequency of work varies 0 4 or 5; nodes can empty): <program> <id>28798031</id> <programid>12345</programid> <orchestra>new york philarmonic</orchestra> <season>1842-43</season> <concertinfo> <eventtype>subscription season</eventtype> <location>manhattan, ny</location> <venue>apollo rooms</venue> <date>1842-12-07t05:00:00z</date> <time>8:00pm</time> </concertinfo> <worksinfo> <work id="52446*"> <composername>beethoven, ludwig van</composername> <worktitle>symphony no. 5 in c...

windows - Specify Go build flag "-H=windowsgui" in code comment -

i creating desktop windows application in go. use line install it: go install -ldflags -h=windowsgui i want users able say go github.com/my/app and automatically have windowsgui flag specified building. possible add flag code comment, #cgo comments. or have provide make file in project directory in old days of go? or not possible @ all? bad news, can't. semi-good news, can tell users use go -ldflags "-h windowsgui" github.com/my/app on windows.

java - How to save console output to a txt file and then display it on the screen right after? -

i kind of confused how write console output txt file , display right after. appreciated. code used far: public static void savedata(){ try { printstream myconsole = new printstream(new file("result.txt")); system.setout(myconsole); myconsole.print(generatereport()); } catch(filenotfoundexception e){ system.out.println(e); } } public static void displaydata(){ file file = new file("result.txt"); try { scanner input = new scanner(file); while (input.hasnext()){ string num = input.nextline(); system.out.println(num); } } catch(filenotfoundexception e){ system.out.println(e); } }

Translating javascript to java -

i have been working on turning large javascript program java. unsure happening in these few lines here , how turn java. int val = 0; //already turned java int o = hash.length() % 4; //already turned java (var = o > 0 ? o - 4 : 0; < hash.length; += 4) { val = ((val << 16) + parseint(hash.substring(i, i+4), 16)) % mod; } it divisible function. hash string (specifically sha256 string hash). able me figure out weird forloop? thanks. i aware parseint turning base 16, have translated part other places in code. for = o o greater 0 . else o-4 set 0 till less hash.length iterate 4 each time in loop each time : val equal - val left shift 16 bits plus remainder of integer value base 16 of (ith element of hash i+4 element ) , "mod" you have not provided definition mod. the substring() method extracts characters string, between 2 specified indices, , returns new sub string. this method extracts characters in string...

c# - Suggesion on Active Directory Integration with Asp.Net MVC 4 -

i know there many posts regarding active directory integration not here ask method integrate(i found), want discuss possible optimize approach here basic requirement: working on mvc4 application , client asked me users of active directory saved in our userprofile table , whenever new user added active directory should reflected userprofile table. my approach : build scheduler fetch active directory users (using system.directoryservices namespace) , check count of users in active directory , if increased i'll add new active directory user database. want take suggestion there direct way reflect new active directory user in sql server userprofile table if possible don't need create scheduler , more light weight process. thanks in advance depending on count of objects not way go. consider case new user added , user deleted. count still same although changes have happened need obtain. one way use directorysynchronization class . class allows synchronize changes ac...

testing - How can I use strings to describe test cases in Java? -

with junit, description of test cases in method name, like: @test public void should_return_6_if_distance_is_2km() { } or @test public void shouldreturn6ifdistanceis2km() { } which not quite readable. but testing frameworks of other lanuage, javascript, or scala, can use: describe("taximeter") { it("should return 6 if distance 2km") { ... } } which more readable plain strings. is possible in java? using assertion framework, hamcrest , assertj or truth automatically result in better error messages @ least. , of course, assertions more readable using asserttrue , assertequals , etc. for example, assertj: assertthat( myvar ).describedas( "myvar" ).isequalto( 6 ); this result in error message (if myvar != 6) includes name "myvar", expected value , real value.

mysql - Edit database row from php page -

Image
i have 2 php pages. - first 1 has form insert data in database. - second diplays data of database. how i, conceptually, adding each row button "update", allow me change of value of row (in exemple value of 2 dropdownlist) , update info in database well. this code able looking in internet , have 2 problems: first , working second update button (so second row updated). second , changes not reflected dropdowlist. (means if change second row value database updated not dropdownlist). note implemented 2 columns <td>" . $row['status'] . "</td> <td>" . $row['priority'] . "</td> only check value in database changes. <form method="post" action="job-status.php"> <?php include("../includes/connection.php"); if($link->connect_errno > 0){ die('unable connect database [' . $link->connect_error . ']'); } ...

Google Analytics relationships between views -

i have custom variable set when user sees page x means customer. this page after log-in , can accessed once user has registered. i have 2 views set in ga based on user having custom variable or not non-customer customer how ga manage view relationship between these 2 users? e.g. a new user comes on site, there no custom variable picked registers 'non-customer' this user registers , logs in , sees page x, variable registers 'customer' would able see user in both views in ga? or user count within view transfer non-customer customer? many help. alex that depends on implementation; in particular scope of custom dimension ( https://support.google.com/analytics/answer/2709828?hl=en#processing ). if it's hit level dimension, 1 view see hits non-customer , , other see customer . if it's session level dimension, whichever value applied last attributed every hit in session.

java - How to read a text file from spring xd module jar -

i have spring xd module, packaged jar file. want put text file in resources , read data file when module launched. what have tried far thread.currentthread().getclass().getclassloader().getresource("file") thread.currentthread().getcontextclassloader().getresource("file") but didn't work. how read text files module jar? i have figured out. you add member tasklet class @autowire resourceloader resourceloader; and when need load file jar this. inputstream stream = resourceloader.getresource("/path/inside/jar/file").getinputstream(); dont' forget close stream :)

html - how to create a hash map so I can loop through or delete in javascript -

i tried creating hashmap in javascript var map ={}; // key string values don't know when want access // values objects i want able loop through map. want able delete map pair using key. i tried bunch of different things saw online , none of worked. what best way this? the for-in statement supposed that. if populate object, can loop through same-level properties such: var obj = {a: 1, b: 2, c: 3}; for(key in obj){ console.log(obj[key]); } // output: // 1 // 2 // 3 now, delete key-value pair, you'd have use delete operator. transforming previous example: var obj = {a: 1, b: 2, c: 3}; for(key in obj){ delete obj[key]; } console.log(obj); // output: // {} the syntax above standard javascript, supported since es1.

angular - Rxjs: The scan operator -

i have been reading code if replace scan map can not property "gettime" of undefined, why happening assume both operator takes item emits observable , apply function on it this.clock = observable.merge( this.click$, observable.interval(5000) ) .startwith(new date()) .map((acc : date)=> { const date = new date(acc.gettime()); date.setseconds(date.getseconds() + 1); return date; }); because merge 2 streams single one. receive events click$ or interval . in these cases, aren't of type date can use gettime method. the scan operator allows keeping state between events. map 1 converts input output. in case of last one, receive event itself...

javascript - safely restyling a page with jQuery has ugly load apperance -

so have website i've styled , made functional css in case users unable use javascript. thing make further style changes jquery , append external stylesheet 'head'. now page loads, style changes can seen split second makes page jittery (since style changes big). not want users seeing jittery load , suggestions on can hide page/provide smooth transition if jquery responds later (slow connection) during style changes. any feedback appreciated! : ) one way solve problem not add css via javascript, instead include css link. stylesheet targeting devices javascript enabled, prepend body class gets added javascript. this: javascript stylesheet body.js header { display: block; } body.js footer { display: block; } body.js .my_jsmenu { display: block; } body.js .etc { display: block; } markup <head> <!-- normal stylesheets --> <link href="styles.css" type="text/css" rel="stylesheet" /> <!-- js sty...

Android build "__pure2" redefined -

i installed latest version of android ndk (r11b) on new machine. when compile c++ code, error "__pure2" has been redefined. appears include file math.h includes sys/cdefs.h . both of them unconditionally define macro called "__pure2" , both of them define differently. the same code works fine on older machine. upon investigation, appears on machine $ndk\platforms\android-9\arch-arm\usr\include\sys\cdefs.h not have definition of "__pure2." looks introduced recently. wondering if else has seen problem. for now, have commented macro definition in sys/cdefs.h . there better way fix this? regards. there's bug ticket tracking issue, actually. might want follow further updates, looks fixed in ndk r12. opt using #ifndef work around mentioned in ticket comments. #ifndef __pure2 #define __pure // whatever original definition #endif

vagrant - Mysql virtual machine remote connection failure -

Image
i created virtual machine on virtual box using vagrant puppet configurations. in vm, can connect mysql db want connect vm's mysql local machine. firstly, tried change " bind-adress " value in my.cnf restarted mysql service didn't work. think not change bind-address should be. when run "mysql --help" command bind-address's value "no default value". vm properties: ubuntu 14.04 mysql 5.6 forwarded_port ( host:7104 -> guest:22 ) part of " mysql --help " command part of " my.cnf " is p.s. => after changed /etc/mysql/my.cnf file, restarted mysql service please :) step1: comment bind address entry in cnf file. step2: restart mysql service. step3: stop iptables service if not using other purpose- service iptables stop step4: grant permission 1 user, connect db remotely. grant privileges on *.* user1@'%' identified 'user1'; here test have provided rights globally, c...

Java use instanceof with iterator -

i have abstract class usuario and arraylist<usuario> objects of 3 subclasses. want iterate through arraylist , return value depending of result of using instanceof against object. i error: java.util.nosuchelementexception . i suppose because of iterator being object of iterator , not of subclasses usuario . right? there solution that? public int comprobardni(string dniacomprobar, arraylist<usuario> listausuarios) { iterator<usuario> itusuarios = listausuarios.iterator(); while (itusuarios.hasnext()) { if (dniacomprobar.equals(itusuarios.next().getdni())) { if (itusuarios.next() instanceof usuariobiblioteca) { return 1; } else if (itusuarios.next() instanceof bibliotecario) { return 2; } else if (itusuarios.next() instanceof bibliotecaexterna) { return 3; } } } return 0; } you invoking itusuarios.next multiple times dur...

sparql - Why did TopBraid Composer FE re-group my multiple OR conditions in a SPIN rule filter? -

i'm using topbraid composer free edition (tbc fe) version 5.1.3. i'm building spin rules / construct queries. part of query has filter statement multiple or'd conditions. enter tbc fe follows: filter ( (?orgstring = substr("af x"^^xsd:string, 1, 4)) || (?orgstring = substr("j x"^^xsd:string, 1, 4)) || (?orgstring = substr("ar x"^^xsd:string, 1, 4)) || (?orgstring = substr("n x"^^xsd:string, 1, 4)) || (?orgstring = substr("ns x"^^xsd:string, 1, 4)) || (?orgstring = substr("mc x"^^xsd:string, 1, 4)) ) . but, when save spin rule in tbc fe, regroups or'd conditions set of binary or's: filter ( (((((?orgstring = substr("af x"^^xsd:string, 1, 4)) || (?orgstring = substr("j x"^^xsd:string, 1, 4))) || (?orgstring = substr("ar x"^^xsd:string, 1, 4))) || (?orgstring = substr("n x"^^xsd:string, 1, 4))) || (?orgstring = subst...

powershell - Moving specific files to specific folders -

i have list of xml file names (including full path file) in .txt document: c:\files\www_site1_com\order\placed\test45.xml c:\files\www_site1_com\order\placed\test685.xml c:\files\www_site2_com\order\placed\test63.xml c:\files\www_site3_com\order\placed\test9965.xml c:\files\www_site4_com\order\placed\test4551.xml etc... the idea need move xml files different folder, example: c:\files\www_site1_com\order\placed\test45.xml moved c:\files\www_site1_com\order\in\test45.xml c:\files\www_site1_com\order\placed\test685.xml moved c:\files\www_site1_com\order\in\test685.xml the problem not sure how can go move each file destination folder supposed go into. below portion of script deals move. first portion takes list of xml files, , replaces \placed\ \in\ , end destination: $content = get-content dump.txt foreach ($path in $content) { $path = $content -split "\\t" $paths = $path -notlike "*t*" $paths = $paths -replace ("placed","in...

Neo4j graph database 2.2.1 -

i want test neo4j mazerunner service developed kenny bastani. , need neo4j 2.2.1 . please can me find the install of neo4j 2.2.1 , because don't find in neo4j website, latest versions. thanks you. some older neo4j versions available on page . not have 2.2.1, have 2.2.9, might suitable needs.

Naming a method that returns 0 for negative values -

i'm writing such method library. can't seem find name nor reference of having named such function before. what name it? i call clipper noun , clip verb. the operation you're describing negativeclip or subzeroclip . of course have generic function 2 or 3 arguments. depending on needs see lowerboundclip or floorclip or bottomclip being paired upperboundclip or ceilingclip or topclip instead. in couple of word clip sounds redundant. words bound, bounds, bounded, boundary used in mathematics think possible function names i'm not sure clear in meaning. , binding used in other programming topics there's potential confusion also.

java - Mapping Unique 16-Digit numeric ID to Unique Alphanumeric ID -

in project i'm working on, need generate 16 character long unique ids, consisting of 10 numbers plus 26 uppercase letters (only uppercase). must guaranteed universally unique, 0 chance of repeat ever. the ids not stored forever. id thrown out of database after period of time , new unique id must generated. ids can never repeat thrown out ones either. so randomly generating 16 digits , checking against list of generated ids not option because there no comprehensive list of previous ids. also, uuid not work because ids must 16 digits in length. right i'm using 16-digit unique ids, guaranteed universally unique every time they're generated (i'm using timestamps generate them plus unique server id). however, need ids difficult predict, , using timestamps makes them easy predict. so need map 16 digit numeric ids have larger range of 10 digits + 26 letters without losing uniqueness. need sort of hashing function maps smaller range larger range, guaranteeing one...

MySQL UNION does not seem to work correctly -

i have sql query using pull data orders database. querying 2 tables , combining results using union all. however, union not seem work expected. here query using: select year(oc_order.date_added) year, count(oc_order.order_id) cnt, sum( ifnull(oc_order.new_total,oc_order.total) ) total oc_order oc_order.order_status_id in (1,3,5) , month(oc_order.date_added) between '01' , '02' , day(oc_order.date_added) between '01' , '31' group year(oc_order.date_added) union select ifnull(year(str_to_date(oc_return_custom.date_added,'%d-%m-%y %h:%i:%s')),year(str_to_date(oc_return_custom.date_added,'%y-%m-%d %h:%i:%s')) ) year, count(oc_return_custom.return_id) cnt, sum( oc_return_custom.total ) total oc_return_custom ifnull(month(str_to_date(oc_return_custom.date_added,'%d-%m-%y %h:%i:%s')),month(str_to_date(oc_return_custom.date_added,'%y-%m-%d %h:%i:%s')) ) between '01' , '02' , ifnull(day(str_to_da...

compilation - ELF, PIE ASLR and everything in between, specifically within Linux -

alrighty before asking question cover few technical details want make sure i've got correct: a position independent executable - pie, code able execute regardless of memory address loaded into, right? aslr ------ address space layout randomization, pretty states in order keep addresses static randomize them in manner, i've read within linux , unix based systems implementing aslr possible regardless of if our code pie, if pie, jumps, calls , offsets relative hence have no problem if it's not, code how gets modified , addresses edited regardless of whether code executable or shared object.... right.... leads me ask few questions if aslr possible implement within codes aren't pie , executables , not shared / relocatable object ( i know how relocation works within relocateable objects !!!! ) how done?, elf format should hold no section states within code sections functions kernel loader modify it, right? aslr should kernel functionality how on earth example ...