Posts

python - nested if statements based on values in an array -

i try check several modules of numbers based on values of array. array = [1,2,3,4,5] number = 10 now want automate following: if 10%1 ==0: if 10%2 == 0: if 10%3 == 0: if 10%4 == 0: if 10%5 ==0: print "10 dividable numbers in array" i want make number of nested if statements based on length of array , number check if 10 dividable out of array. there way loops? thanks. use all : array = [1,2,3,4,5] number = 10 if all(number % x == 0 x in array): print "%s dividable %s" % (str(number), str(array))

c# - Passing value from view to controller -

ok, asked similar question , got answers back. however, did not express problem accurately give go here: this view @using (html.beginform()) { <h3 class="editable">@model.title</h3> <input type="submit" value="submit"> } the <h3> has class "editable" in case means can edited inline-editor. @model.title is properties database able change inline-editor . this code generate same result: @using (html.beginform()) { <h3 class="editable">@model.title</h3> <input type="text" id="testinput" name="testinput" /> <input type="submit" value="submit"> } controller: [httppost] public actionresult faq(string testinput) { page.title = testinput; return view(); } allthough, not use inline-editor like. is there maybe way treat <h3> if textbox allowi...

android - display ProgressBar ontop of ListView -

Image
asking simplest question, have searched lot related problem didn't find solution. have layout in android application in i'm using listview progressbar . task in doing in asynctask class. want show progress bar in centre of activity before loading list. can tell me i'm going wrong or changes required solution. in advance. how tried activity_main: <progressbar android:id="@+id/progressbar1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_gravity="center_horizontal" android:visibility="invisible" /> <listview android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="fill_parent" > </listview> mainactivity: public class gettingalerts extends listactivity { // initialization ipaddress ipaddressobject =...

ubuntu - Cassandra not coming up after installing dse-full -

i had working 3 node cassandra cluster , found during installation didn't install dse. installed dse-full & opscenter in of 3 nodes. after installation found none of cassandra node rebooted cluster nodes. after reboot when tried run caassandra service faced following exception: fatal exception during initialization org.apache.cassandra.exceptions.configurationexception: saved cluster name db cluster != configured name test cluster @ org.apache.cassandra.db.systemkeyspace.checkhealth(systemkeyspace.java:542) @ org.apache.cassandra.service.cassandradaemon.setup(cassandradaemon.java:246) @ com.datastax.bdp.server.dsedaemon.setup(...

codeigniter - Extending CI_Model for use with report database -

i trying add separate report database application extending ci_model , setting correct database use based on if database defined. report database replicated version of regular database performance reasons. is proper way? in application/core/my_model: <?php class my_model extends ci_model { function __construct() { parent::__construct(); include apppath.'config/database.php'; //if have reporting database load , use reporting functions if (isset($db['reports'])) { $this->report_db = $this->load->database('reports', true); } else { $this->report_db = $this->load->database('default', true); } } } ?> you can use both of databases within code. have define in config/database.php database.php $active_group = 'default'; $active_record = true; $db['default']['hostname'] = 'loc...

Send variable from javascript to php and receive it back as a link for file download -

i need send variable javascript php file receive link file download. variable send list.php: <a href="javascript:filesave(<?php $val ?>);">pdf</a> <script language="javascript" type="text/javascript"> function filesave($fid) { $.post( "getfile.php", { id: $fid }) ... ... </script> link recieved getfile.php: <?php if (isset ($_post['id'])) { $link = "./pdfs/vers".$_post['id']; } ?> i want without page reload or redirect. can i? if list.php , getfile.php on same server, can use ajax. in javascript function filesave($fid) { $.ajax({ type: 'post', url: 'list.php', data: { 'id': $fid },success: function(data){ // process after received data getfile.php } }); in php if (isset($_post['id'])) { header("content-type: text/plain; charset=utf-8"); $link = "./pdfs/vers".$_p...

scala - an error in spark sbt assembly -

in spark installing readme,i write command './bin/spark-shell', got hint follwing: found multiple spark assembly jars in /opt/spark-0.9.0-incubating-bin-hadoop1/assembly/target/scala-2.10: spark-assembly-0.9.0-incubating-hadoop1.0.4.jar spark-assembly_2.10-0.9.0-incubating-hadoop1.0.4.jar please remove 1 jar. i ever try remove 1 of them ,but fail success. if can deal ,please tell me. thanks. all need cd assembly/target/scala-2.10 dir, , use sbt compile again. this caused incompatible between different compile method, may used maven , sbt both?