Posts

Showing posts from July, 2010

Android - How the state of views are preserved during Fragment Transforamtion -

Image
this confuses me lot. i had 2 fragments, , use fragmenttransaction.replace() swap 2 fragments. state of input controls radiogroup , checkbox preserved when switch other fragments , switch again. . i set break point on oncreateview() of fragment, , every swap seems trigger method , new views created each time. savedinstancebundle null well. since new views created, how state of old views? public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment_fieldsetup_marking, container, false); // ... return v; } this effect fine app, want know how implemented. where states stored? where android sdk code restore (i can not find in class fragmenttransection).

html - Tumblr Theme - Text from custom pages not showing up? -

i'm adapting existing tumblr theme , having few problems. when user creates custom page , uses standard layout text put in doesn't show anywhere on page. i've trawled through docs , tutorials try , find out how text custom pages rendered there doesn't appear information on topic. can find few hacky ways displaying on custom page, can't figure out how actual text or title user enters. ideas?

php - route codeigniter not working -

i have problem routes file in codeigniter. on wamp, routes run correctly. but, on server (shared hosting), routes doesn't run. my homepage in fr folder. controller index. default controller 'fr/index'. $route['default_controller'] = 'fr/index'; $route['404_override'] = ''; when write www.domainname.tld, "file not found." without css style. in source code have 1 file not found. 2 while when write www.domainname.tld/aaaa (404 error), have 404 error : <!doctype html> <html lang="en"> <head> <title>404 page not found</title> <style type="text/css"> ::selection{ background-color: #e13300; color: white; } ::moz-selection{ background-color: #e13300; color: white; } ::webkit-selection{ background-color: #e13300; color: white; } body { background-color: #fff; margin: 40px; font: 13px/20px normal helvetica, arial, sans-serif; color: #4f5155; } { c

asp.net mvc - Secure a single action with Forms Authentication & Basic Authentication simultaneously -

my mvc application secured using forms authentication . have global filter applies authorizeattribute . i have controller called development action called report . can access fine authenticating in normal way , going http://localhost:8080/development/report . if not authenticated redirects me forms authentication login. i trying embed page ios app user can view information without having manually authenticate themselves. confuse things ios app uses different authentication system, holds device id , unique token mvc app store. what trying make report action available both via forms authentication , ios app using basic authentication username device id , password token . it's important when authenticated using method user can access report action. what's best way implement whilst keeping secure? i thinking of marking report action allowanonymous attribute , creating custom authentication action. best way? authentication strategies that: strategies. they&

php - Correctly Passing data from Controller to View CodeIgniter -

this question may asked numerous times facing difficulty in doing so. var_dump($lex_post_data); works fine on controller my controller code try{ // need manage functionality initialized. $manage_mode = false; $appointment = array(); $provider = array(); $customer = array(); $lex_post_data = $this->input->post('lexname'); var_dump($lex_post_data); // load book appointment view. $view = array ( 'available_services' => $available_services, 'available_providers' => $available_providers, 'company_name' => $company_name, 'manage_mode' => $manage_mode, 'appointment_data' => $appointment, 'provider_data' => $provider,

Javascript Recursion returning undefined -

i'm struggling in recursive javascript function find specific subdirectory. code: function navigatetoparent() { var parentfullpath = parentdirectory(); // gets full path string if (parentfullpath != null) { var parent = getdirectorybyname(parentfullpath, rootdirectory); // set parent directory object current 1 currentdirectory(parent); } } function getdirectorybyname(fullname, mydirectory) { if (mydirectory.fullname == fullname) { return mydirectory; } else { var subs = mydirectory.subdirectories; (i = 0; < subs.length; i++) { return getdirectorybyname(fullname,subs[i]); } } } every directory object has properties fullname (string), subdirectories (array of directories) , files (array of files). aim correct directory object, it's fullname matching. i know, have break loop in way, don't know how exactly. after overthinking logic came solution (seems work): fun

css - Locating an element under div -

<div class="form-item"> <label class="form-item-label">mailing account:</label> <div class="form-element"> <div class="form-field-wrap> <input class="form-text x-form-field x-combo-noedit"> </input> i trying locate element <input class="form-text x-form-field x-combo-noedit"> comes under <label class="form-item-label">mailing account:</label> . first element should matched on text "mailing account:" , second element on of these classes "form-text x-form-field x-combo-noedit". can suggest logic using using xpath or cssselector please? let me see if understand correctly, want find element classes 'form-text' 'x-form-field' , 'x-combo-noedit', if containing div sibling of label text "mailing account" way using xpath: webelement firstelement = driver.findelement(

c# - StructuralComparisons for arrays -

in f#: [0] = [0] = true in c# or .net bcl in general: structuralcomparisons.equals(new int[] { 0 }, new int[] { 0 }) == false why? postscript: the reason thought had "right" equals because turned out true: var = new { x = 3, y = new { z = -1 } }; var b = new { x = 3, y = new { z = -1 } }; structuralcomparisons.equals(a, b) == true; that's because you're going down object.equals(obja, objb) won't able handle kind of comparison. instead this: structuralcomparisons.structuralequalitycomparer.equals(..., ...)

php - why do we need to place the source name to redirect? -

i saw in post ( jquery ajax php redirecting page ) when using ajax redirect php page need set event : $.ajax({ type: "post", url: "ajax.php", data: datastring, success: function(r) { window.location = 'new.php';//window.location.href = 'new.php'; //$("#div").html(r); }, }); however it's not clear me : why need indicate " url: "ajax.php"," should url entry contain name of current file we're redirecting ? if i'm redirecting file called abc.html ? should replace ajax.php abc.html ? thanks! let me explain $.ajax({ type: "post", url: "ajax.php", data: datastring, success: function(r) { window.location = 'new.php';//window.location.href = 'new.php'; //$("#div").html(r); }, }); $.ajax function makes ajax request files .. your questions why need indicate " url: "ajax.php"," should url entry co

c# - Custom Exceptions in PCL files -

Image
i'm converting our .net business objects library pcl file can used xamarin ios/android , while contains poco objects, contains custom exceptions throwing errors. take typical custom exception: [serializable] public class encryptkeynotfoundexception : exception { public encryptkeynotfoundexception() : base() { } public encryptkeynotfoundexception(string message) : base(message) { } public encryptkeynotfoundexception(string format, params object[] args) : base(string.format(format, args)) { } public encryptkeynotfoundexception(string message, exception innerexception) : base(message, innerexception) { } public encryptkeynotfoundexception(string format, exception innerexception, params object[] args) : base(string.format(format, args), innerexception) { } protected encryptkeynotfoundexception(serializationinfo info, streamingcontext context) : base(info, context) { } } as expected pcl doesn't [s

PHP code doesn't return any results from MySQL Database -

i have problem connecting mysql search fields. php code looks logical doesn't show results. direct search in mysql working absolutely fine. when comes website search doesn't work. i removed/swapped host, user, password, dbname before pasted here. thank help! <body> <?php $q = intval($_get['q']); $con = mysqli_connect('host','user','password','dbname'); if (!$con) { die('could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"dbname"); $sql="select * user id = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table> <tr> <th>first name</th> <th>last nname</th> <th>city/village</th> <th>oblast</th> <th>language</th> <th>download</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row

Python check if string contains dictionary key -

i have these strings: >>> a="foo" >>> b="foo_key" and dictionary like: >>> dict { 'key': ['...'], 'key2': ['...', '...'], ... } i'd build function check if test value in key of input dict: >>> has_key(a, dict) false >>> has_key(b, dict) true what elegant way task in python 3? has_key = lambda a, d: any(k in k in d)

android - Database id and listview items id get discrete -

getting stuck issue getting messages database , shows in list, list having check boxes when pressed delete checked check box deleted database. , when again click see message position of message's changed in database id remain same , further delete message message database not deleted because position id , database message id become different. please give me suggestion solve issue thank in advance... this code clicking position , send position database database id different next time of deletion. onclicklistener listenerdel = new onclicklistener() { @override public void onclick(view v) { /** getting checked items listview */ sparsebooleanarray checkeditempositions = getlistview().getcheckeditempositions(); int itemcount = getlistview().getcount(); for(int i=itemcount-1; >= 0; i--){ if(checkeditempositions.get(i)){

Padding arrays with zeros dynamically - Octave / Matlab -

i have add multiple arrays in loop , arrays in size need pad array x , need pad array y how can have arrays padded dynamically? i know how pad manually (see code below) how can dynamically if size of array x or size of array y vary? x = [1 2 3 4 5 6]' y = [3 5 7 8]'; = x + [y;zeros(2,1)]; result in = [4 7 10 12 5 6]' ps: i'm using octave 3.8.1 matlab find max length , pad both of them difference. l = max(length(x), length(y)); = [x; zeros(l-length(x),1)] + [y; zeros(l-length(y),1)]; it can extended more 2 vectors: l = max(length(x), length(y), length(z)); = [x; zeros(l-length(x),1)] + [y; zeros(l-length(y),1)] + [z; zeros(l-length(z),1)];

javascript - Refreshing datetimepicker in angular -

i'm using http://dalelotts.github.io/angular-bootstrap-datetimepicker/ i'm i18ning site. after selecting language i'm changing date using moment.js. this: $scope.changelanguage = function (key) { $translate.use(key); moment.locale(key); }; and here's problem: dates in calendar changing after use first time (select date/change month etc). it's because of refreshing first time. how can manually refresh datetimepicker in code? (ex: in section quote) with latest release can fire event have re-render.

numbers - Fixed decimal places double and power of ten format in java -

i'm writing code in java supposed manipulate data text file. in text file coordinates saved. layout of numbers always: 5.000000000000000+0 data read, manipulated , printed file. printing part not yet working, number of decimal places varies , haven't succeeded append power of ten in shown way. decimal numbers tried: formatter.setminimumfractiondigits(15); and formatter.setmaximumfractiondigits(15); but still displays more digits sometimes. how can achieve shown format double numbers or @ least right amount of decimal digits? use string.format: double x = 1.1231523235; system.out.print(string.format("%.5f", x)); that print 1,12346 and if want dot delimiter use system.out.print(string.format(locale.english,"%.5f", x));

Get JSON format from MySql to javascript using PHP -

Image
i want json format sql database using php here capture of mysql database data.php <?php include("include/connexion.php"); $requete = "select * statistika"; $resultat = mysql_query( $requete ) or die( mysql_error() ); $rows = array(); $total_vue = 0; here php code data while( $data = mysql_fetch_assoc( $resultat ) ) { $total_vue+=$data['temps']; $rows[] = array( "date" => strtotime( $data['date']) * 1000, "value" => $data[ 'temps' ] ); } ?> json_encode.php <?php include("data.php"); echo json_encode($rows); ?> the content of json_encode valid , json format successfully [{"date":1439769600000,"value":"5"},{"date":1439787600000,"value":"12"},{"date":1439806631000,"value":"8"},{"date":1439821320000,"value":"18"},{"date":1439919

python - How to get data from HTML? -

i use django-autocomplete. there 2 fields: first tag-search uses autocomplete , second full-text search. full-text search works, tag search not. here code of web-page: <div class="content-section-a"> <div class="container"> <div class="row"> <div class="col-lg-12"> <form action="" method="get"> <p> <span id="id_tag_query-wrapper" class=" autocomplete-light-widget tag_query single" data-widget-bootstrap="normal" data-widget-maximum-values="1" data-widget-ready="1"> <span id="id_tag_query-deck" class="deck" style="display: inline;"> <span data-value="12" class="hilight"> <span style="display: inline-block;" class="remove"> ˣ

python - Pandas: index of max value for each group -

my pandas dataframe, df , looks this: parameter1 parameter2 value 1 1 0.1 2 0.2 2 1 0.6 2 0.3 value result of groupby(['parameter1','parameter2']).mean() on dataframe . now, can find maximum value of value each value of parameter1 using df.max(level='parameter1') however, need find corresponding value of parameter2 maximum value. seems df.idxmax() not support level= , how can instead? a nice way be df.unstack().idxmax(axis=1) unstacking dataframe gives dataframe parameter_1 column index.

java - Unable to get required JDBC Exception -

i have created login form using java servlets , jsp's. login information such username , password saved in database. question when user enters information java class fails find in database dont exception. how create exception if login data isnt available in db? public boolean loginvalidator(string e, string p) throws sqlexception { string username = e; string password = p; boolean validate = false; try{ preparedstatement ps = connection.preparestatement("select * user email = ? , password = ?"); ps.setstring(1, username); ps.setstring(2, password); resultset rst = ps.executequery(); while (rst.next()) { validate = (rst.getstring("email").equals(username)) && ((rst.getstring("password").equals(password))); }} catch(sqlexception ex){ system.out.println(ex.getmessage()); validate = false; } return validate; } this method in java class validates , send boolean type

jquery - I am trying to make a link popup a javascript -

so have script, subscriber popup, want write link on post allow popup fire clicking link i know how create java popups, issue how code newsletter site link anyone? here code needs go in link <script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="useplainjson: true, isdebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/loader"], function(l) { l.start({"baseurl":"mc.us10.list-manage.com","uuid":"9277d2ea37fce583555bef789","lid":"4fcff7a4f6"}) })</script> one possible option open pop-up using window.open() , modify content of pop-up using document.write() . the html this: <button onclick="openwindow()">open window</button> or this: <a href="javascript:openwindow()">open window</a>

php - How do I keep the parameters on the URL (HTML GET) without duplicating them? -

i'm trying implement simple multi-language form in html. form has buttons open database tables in div, , has select choose language. the buttons like: <button type='submit' name='table' value='x'> the select like: <select name='lang' onchange='changelang()'> ... function changelang() { document.getelementbyid('form1').submit(); } when click button, shows table (and parameter 'table=x' shows in url). when change language, 'lang=y' parameter shows, 'table' parameter disappears. i tried solutions here , here , here , it's not working. hidden parameters add existing button , 2 'table' parameters on url. how can keep parameters on url without duplicating them? edit: trying on line: <?php session_start(); $erroconn = include(".../dbfile.php"); if (isset($_get['lang'])) { // language $lang = $_get['lang']; ledic($lang); } else {

windows - How do I get my Windows7 symlink to execute from command line? -

i have couple of batch files want use regularly, decided drop them symlinks binaries folder in path. idea being use them other command, without having change directories. e.g. > odbimport -u user -f filename where odbimport symlink batch file odbimport.bat. the process used make symlinks follows: c:\users\user>mklink c:\utils\odbimport c:\util-files\odbimport.bat symbolic link created c:\utils\odbimport <<===>> c:\util-files\odbimport.bat c:\users\user>path path=c:\....;c:\utils\ c:\users\user>where odbimport c:\utils\odbimport from i've seen, looks i've made symlink, , path knows find it. however, after i've made symlink , attempt execute, get: c:\users\user> odbimport -u me -f somefile 'odbimport' not recognized internal or external command, operable program or batch file. " i've been looking answer no success. find seems deal more how create working symlinks addressing issue. closest thing found this . qu

sql server 2008 r2 - Filtering a CUBESET using a different variable without hierarchies -

i'm trying produce cubeset returns members correspond field in powerpivot dataset. because organisation behind we're using old version of powerpivot (sql server 2008r2 version) doesn't allow hierarchies etc. can't use functionality; i've been trying use filter mdx function can't work. in example below, [level 1] , [level 2] are product groups, 2 being below one. i'm trying return members of [level 2] correspond [level 1].[product 1]: =cubeset("powerpivot data", "filter([table].[level 2].[all].members, [table].[level 1].[all].currentmember='product 1')","caption") this returns #n/a error in excel. if has way result please shout! looks string error - need double speach marks around product 1?: "filter([table].[level 2].[all].members, [table].[level 1].[all].currentmember=''product 1'')" the above not problem. the problem condition not valid mdx [tabl

amazon web services - What needs to be enabled to support curl -I? -

i have aws instance failing custom health check. if hit health check directly, passes: curl -v http://localhost:8080/batch/health produces 200/ok reponse expected: * connect() localhost port 8080 (#0) * trying ::1... connected * connected localhost (::1) port 8080 (#0) > /batch/health http/1.1 > user-agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 nss/3.16.2.3 basic ecc zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > host: localhost:8080 > accept: */* > < http/1.1 200 ok < server: apache-coyote/1.1 < etag: "0d41d8cd98f00b204e9800998ecf8427e" < content-type: text/plain;charset=iso-8859-1 < content-length: 0 < date: wed, 19 aug 2015 14:38:40 gmt < * connection #0 host localhost left intact * closing connection #0 now aws troublshooting checklist recommends using curl -i, retrieves headers. , indeed, fails on instance: curl -i "http://localhost:8080/batch/health" produces: http/1.1 405 method not allowed

ssl - Transport Layer Security without Server Certificate -

is there way secure transport layer without server certificate? i read rfc 4492 , saying there key exchange algorithm name ecdh_anon this, on many of links found not recommended use prone mitm (man in middle) attack. i want mention server not public , server , clients in same local subnet. server accepting connection on websocket. what options if want secure transport layer? don't want manually encrypting payload. you use solution called tls-srp , if supported server , client(s). more common install self-signed server certificate local system, or set own ca , issue own cert server , install ca's root cert trusted root on clients.

css - How to style select option elements in Ionic for Android? -

i'm using ionic framework build application. application includes lots of select elements. when view application on android 4.4, selects , options expected. when view application on android 5.0 or 5.1, text of options grey, leads users think options disabled (they not). ionic's documentation select css includes following: "ionic's select styled appearance prettied relative browser's default style. however, when select elements opened, default behavior on how select 1 of options still managed browser." can tell me how can control styling of select options don't appear disabled? monkeying around ionic's css doesn't appear change anything, , i'm guessing that's because android "styling" element, rather ionic. thanks.

regex - "partial grep" to accelerate grep speed? -

this thinking: grep program tries pattern-match every pattern occurrence in line, like: echo "abc abc abc" | grep abc --color the result 3 abc red colored, grep did full pattern matching line. but think in scenario, have many big files process, words interested occur in first few words. job find lines without words in them. if grep program can continue next line when words have been found without having check rest of line, maybe faster. is there partial match option maybe in grep this? like: echo abc abc abc | grep --partial abc --color with first abc colored red. see nice introduction grep internals: http://lists.freebsd.org/pipermail/freebsd-current/2010-august/019310.html in particular: gnu grep avoids breaking input lines. looking newlines slow grep down factor of several times, because find newlines have @ every byte! so instead of using line-oriented input, gnu grep reads raw data large buffer, searches buffer using b

.net - Does publish to IIS in production safe -

i have application hosted on several servers on aws load balancer. push updates servers microsoft web deploy. lets want push update servers. should remove server load balancer before deploying it? happen requests being processed application pool , happen new requests coming server? it depends on mean "safe". standpoint of state of current deployment, nothing affected. data integrity standpoint, process may not safe. when .dll project replaced in server, application pool recycles immediately. the result of current process terminated impunity. more users using system, more prevalent result of undefined behavior be. main thing gets taken out database connections, , user in middle of posting , okay part or none of transaction complete. ajax requests spin indefinitely @ times result of well. nukes running , there no grace period or forgiveness. to around this, large services issue warning. the server restarting in 15 minutes. in order facilitate t

wpf - How can I use this font? -

i want use custom otf font in universal windows application, can't work. i using in xaml : <textblock fontsize="16" text="question" fontfamily="../assets/fonts/neosansstdmedium.otf#neo sans std medium"/> the font located in assets/fonts , so: project.windows (windows 8.1) > assets > fonts > neosansstdmedium.otf and windows fontviewer shows font name as: neo sans std medium so doing wrong? the font name after # has match font name, , in case apparently medium not part of name... some more info: set .otf file's properties build action: content , copy output directory: not copy . the xaml excerpt looks this: <textblock fontsize="16" text="question" fontfamily="../assets/fonts/neosansstdmedium.otf#neo sans std"/>

css - Flexbox item widths are affected by padding -

see http://jsfiddle.net/56qwuz6o/3/ : <div style="display:flex"> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> </div> div div { flex: 1 1 0; border:1px solid black; box-sizing: border-box; } #a { padding-right: 50px; } when have padding set on flex item ( #a ), width (in border-box sense) affected. how make computed width ignore padding? ie. want each of boxes take 33% of document width. edit: answers far. in reality, have more boxes in row have fixed width: ie. @ http://jsfiddle.net/56qwuz6o/7/ , want #a , #b , #c have same width. <div style="display:flex; width: 400px"> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> <div id="d">d</div> </div> div div { flex: 1 1 33%; border:1px solid black;

hadoop - Save JSON to HDFS using python -

i have python script accesses api returns json. takes json string , saves off file on local file system, move hdfs manually. change python script saving directly hdfs instead of hitting local file system first. trying save file using , hdfs dfs command don't think copy command correct way because isn't file rather json string when trying save it. current code import urllib2 import json import os f = urllib2.urlopen('restful_api_url.json') json_string = json.loads(f.read().decode('utf-8')) open('\home\user\filename.json', 'w') outfile: json.dump(json_string,outfile) new code f = urllib2.urlopen('restful_api_url.json') json_string = json.loads(f.read().decode('utf-8')) os.environ['json_string'] = json.dump(json_string) os.system('hdfs dfs -cp -f $json_string hdfs/user/test') i think problem same thread stream data hdfs directly without copying . firstly, command can redirect stdin hdfs fil

ubuntu - How do I update the modules that come with python? -

i having trouble subprocess module. missing check_output function , wondering if there way update/replace without doing complete reinstall of python. yes, it's possible, can add function in if necessary (only suggested if need backwards capability). if 'check_output' not in dir(subprocess): def check_output(cmd_args, *args, **kwargs): proc = subprocess.popen( cmd_args, *args, stdout=subprocess.pipe, stderr=subprocess.pipe, **kwargs) out, err = proc.communicate() if proc.returncode != 0: raise subprocess.calledprocesserror(args) return out subprocess.check_output = check_output but code shows, can write little more verbosely , doesn't operate differently. edit: copy directly subprocess module version python 2.7 def check_output(*popenargs, **kwargs): if 'stdout' in kwargs: raise valueerror('stdout argument not allowed, overridden.') process = s

vba - Excel 2010 - Take whole rows from one sheet and display them in the 2nd sheet based on match in 3rd sheet -

i'll cut chase: excel 2010 i have sheet1 list of orders. customer name in column f . sheet2 contains list of customers names in column a . i run macro / vlookup / index (whatever works) run through list of thousands of orders in sheet1 , copy sheet3 rows (whole rows) customer name sheet2 matches. sheet1 has 10 columns , 10000 rows. sheet2 has 50 rows in column only. i have tried few types of macros , did proper search couldn't find work. paste have embarrassment. i might add need run weekly , list of orders changing. list of names may little frequency. can help? :) edit : answers far can see need use vba script. appreciate know next nothing language. should able manage modifying script suit needs need start. perhaps pseudocode make easier people: read data a1:a50 in sheet2 compare f1, sheet1 a1:a50, sheet2 if no match - continue f2 if match - copy whole row a1 in sheet3 (...) compare fx, sheet1 a1:a50, sheet2 if no match - continue

mysql limit rows returned for each group -

i have result in table +------------------------------------------------+ |adm_no | code | value | group_id | +------------------------------------------------+ |1200 | 101 | 50 | 1 | +------------------------------------------------+ |1200 | 102 | 60 | 1 | +------------------------------------------------+ |1200 | 121 | 62 | 1 | +------------------------------------------------+ |1200 | 233 | 50 | 2 | +------------------------------------------------+ |1200 | 231 | 98 | 2 | +------------------------------------------------+ |1200 | 232 | 85 | 2 | +------------------------------------------------+ |1200 | 511 | 75 | 3 | +------------------------------------------------+ |1200 | 585 | 38 | 3 | +------------------------------------------------+ |1

javascript - Extracting text between end and start of tags -

i'm looking extract telephone number: i using nodejs / expressjs / request / cheerio. this code part of web crawler. <div class="info"> <h3> home </h3> <p> <strong> tel: </strong> 01345 000000 <strong> fax: </strong> 01345 000000 </p> <p> </p> i'm able retrieve text "tel:". here's progress i've made: $('div.info p').filter(function() { $(this).find('strong').filter(function() { var phonenumber = $(this).text(); console.log(phonenumber); }); }); this should work: var temp = $('p'); temp = temp.text().trim(); temp = temp.substring(4, 22); $('.info').html(temp); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="info"> <h3> home </h3> <p&

java - Sum of elements of an Integer ArrayList without looping -

i have gone through few web resources , links, however, unable find sum of elements of integer arraylist without looping. looking function allow me in single line. i able find same normal array follows import java.util.arraylist; import java.util.stream.intstream; public class sumarray { public static void main(string[] args) { int[] = {10,20,30,40,50}; int sum = intstream.of(a).sum(); system.out.println("the sum " + sum); } } i can write user-defined function follows import java.util.arraylist; public class sumal { public static void main(string[] args) { arraylist<integer> al = new arraylist<integer>(); al.add(1); al.add(3); al.add(5); system.out.println(sum(al)); } static int sum(arraylist<integer> al) { int value = 0; for(int : al) { value += i; } return value; } } however, i'm looki

java - How to extract Object[] and get it into query using preparedstatement setObject()? -

this question has answer here: preparedstatement in clause alternatives? 25 answers might silly question cant query running. code: arraylist<attraction> getattraction(object[] obj) throws sqlexception { connection connection = facade.getconnection(); arraylist<attraction> attractions = new arraylist<>(); // check obj value system.out.println(java.util.arrays.tostring(obj)); preparedstatement ps = connection.preparestatement("select distinct attra.attractid,attractname,x,y,z,age,weight," + "height,duration,price,status attraction attra " + "inner join attrib_bridge ab on attra.attractid = ab.attractid " + "inner join attribute attri on ab.attributeid = attri.attributeid" + "where attri.attributename in ?"); ps.setstring(1,

c# - Using an integer value from a class in another class -

please trying values class: class movierating { // block of code user ratings of movie public void detailsrate() { console.writeline("\n rate acting on scale of 0 5"); rateacting = int.parse(console.readline()); console.writeline("\n rate music of movie on scale of 0 5"); ratemusic = int.parse(console.readline()); console.writeline("rate cinematography of movie on scale of 0 5"); console.writeline("rate plot of movie on scale of 0 5"); console.writeline("rate duration of movie on scale of 0 5"); rateduratn = int.parse(console.readline()); } } and use in class: class executerating { public void overallrate() { movierating movrate = new movierating(); int rateact = movrate.rateacting; int ratemus = movrate.ratemusic; int ratecin = movrate.ratecinema; int rateplot = movrate.rateplot; int ra

PHP replace only working once -

i have string containing html coming form ($postcontent). want assign unique id every image. i have following code: $numimages=substr_count($postcontent, '<img'); for($o=0; $o<$numimages; $o++){ $pos = strpos($postcontent,"<img"); $postcontent = substr_replace($postcontent,"<img id='$o' height='50px' onclick='resize(\"$o\")' ",$pos,4); } it works fine first occurence of tag, rest not work. further explaination: <div><img src="http://image1"><img src="image2"></div> after going trough code gives this: <div> <img id='1' height='50px' onclick='resize("1")' id='0' height='50px' onclick='resize("0")' src="http://image1"><img src="http://image2"></div> anyone has idea problem might be? your call strpos finding first instance of &

Grep a 1 or 2 character number from a variable in R -

i have 2 tables, grow , temp . grow details growing , nongrowing seasons each area i'm concerned (these static), while temp details average temperature each month of wide range of years (these columns) same areas. i'm trying identify average temperature each year growing , nongrowing seasons, i've run problem how pick columns - i'm using grep , can't figure out how account two-digit months! at point i've isolated each column of years, , have vector of column names single year - "tmp_2001_1" "tmp_2001_2" "tmp_2001_3" ... "tmp_2001_11" "tmp_2001_12" . have, stored in pair of variables, start , end of growing season, stored integers representing months: start <- number between 1 , 12 , end <- number between 1 , 12 . can't figure out how grep identify growing season when start or end has 2 digits. have works case of them both being 1 digit numbers: grow_months <- grep(paste('tmp_',&

How to call another activity method in android studio? -

i have 2 different activities. first calls menu(base) if user logged in, have method display user information. public class mainactivity extends actionbaractivity implements view.onclicklistener { userlocalstore userlocalstore; edittext etname, etage, etusername; button blogout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); etusername = (edittext) findviewbyid(r.id.etusername); etname = (edittext) findviewbyid(r.id.etname); etage = (edittext) findviewbyid(r.id.etage); blogout = (button) findviewbyid(r.id.blogout); blogout.setonclicklistener(this); userlocalstore = new userlocalstore(this); } @override public void onclick(view v) { switch (v.getid()){ case r.id.blogout: userlocalstore.clearuserdata(); userlocalstore.setuserloggedin(false)

javascript - Why do we need a new object in bookshelf.js fetch() method? -

i'm new node , using bookshelf.js orm current project. documentation of bookshelf.js contains snippet under fetch() method: // select * `books` `isbn-13` = '9780440180296' new book({'isbn-13': '9780440180296'}) .fetch() .then(function(model) { // outputs 'slaughterhouse five' console.log(model.get('title')); }); http://bookshelfjs.org/#model-fetch what confuses me why need create new object here if querying existing record? way bookshelf.js works requires new object created every returned result? this confusing. @ moment there 1 type of object represents both "model" , "query builder". fetch prefills where clause set attributes on model. there plans underway change this. discussion here . instead of writing code above, i'd recommend doing this: // select * `books` `isbn-13` = '9780440180296' book.where({'isbn-13': '9780440180296'}) .fetch() .then(function

ajax - jQuery Error connection refused -

i created java web application using apache tomcat 8, , used jquery ajax call servlet. used same application using apache tomcat 7, , when call servlet via jquery ajax, gives me following error: net::err_connection_reset here ajax code: $.get("servletname", { label: data1value }, function(responsetext){ alert('response text: ' + responsetext); }); }); where going wrong? kindly assist me.

java - Android App Sample App crashed after including project dependency -

i created blank application in android studio having 1 activity. when running without including shared project hello world displayed. when include shared project in app's build.gradle dependencies section: dependencies { compile (project(':shared')) } when running following error event when not use shared: unfortunately, testapp has stopped. 08-19 18:45:07.903 1628-1667/? e/backup﹕ [legacybackupaccountmanager] fail legacy transport context. android.content.pm.packagemanager$namenotfoundexception: application package com.google.android.backup not found @ android.app.contextimpl.createpackagecontextasuser(contextimpl.java:2172) @ android.app.contextimpl.createpackagecontext(contextimpl.java:2148) @ android.content.contextwrapper.createpackagecontext(contextwrapper.java:671) @ com.google.android.gms.backup.an.<init>(sourcefile:47) @ com.google.android.gms.backup.backuptransportmigrato