Posts

Showing posts from January, 2011

jquery - Android Disable zoom button inside a webview -

i'm using inappbrowser cordova plugin make webview website. it's working properly, 2 zoom buttons appears when start scroll webpage. how hide ? i'm using open webview: var ref = window.open("http://m.estadao.com.br", "_self", "location=no", "closebuttoncaption=return", "enableviewportscale=no"); zoom tks! you can pass zoom attribute value no option when using inappbrowser. var ref = window.open("http://m.estadao.com.br", "_self", "location=no","zoom=no", "closebuttoncaption=return", "enableviewportscale=no"); source - cordova inappbrowser github documentation .

python - Initial (default) value on Django ChoiceFilter select box -

i trying set initial, default value on select box created djangofilter choicefilter (more info here ). code seems pretty simple: class myfilter(filterset): choices = ( ('', 'any'), ('closed', 'closed'), ('new', 'new'), ) my_select_box = choicefilter(choices=choices, initial='new') class meta: model = mymodel fields = ('my_select_box') def __init__(self, *args, **kwargs): super(myfilter, self).__init__(*args, **kwargs) self.form.helper = formhelper() self.form.helper.form_method = 'get' self.form.helper.add_input(submit('submit', 'search')) self.form.helper.form_class = 'form-inline' self.form.helper.field_class = 'm-r m-b-sm' self.form.helper.label_class = 'm-r' on views.py: class myview(baselistview): content_template = "template.html...

c# - Xunit test IHttpActionResult web api 2 function for custom message -

i refactor web api functions (to take advantage of web api 2 changes) can't figure out how refactor xunit tests testing custom exception messages. i refactor this: [route("resetpassword"), httppost] public httpresponsemessage resetpassword([frombody] resetpasswordrequest request) { try { var resetpermission = _userpasswordresetrequestrepository.getbytoken(request.token); if (resetpermission.expires < datetimeoffset.now) throw new exception("token expired"); _userpasswordrepository.setpassword(resetpermission.userid, request.password); return request.createresponse(httpstatuscode.ok, "request received"); } catch (exception ex) { return request.createresponse(httpstatuscode.internalservererror, ex.message); } } to (return type changed ihttpactionresult, , return statements changed): [route("resetpassword"), httppost] public ihttpactionresult resetpassword([frombody] resetpasswordrequest re...

oracle11g - Cannot create Oracle user with specific password -

in oracle tried query create user act_app identified password profile app_profile default tablespace ts_module_d temporary tablespace temp; after sending query , got these 2 errors. password verification specified password failed password should contain @ least 1 digit, 1 character , 1 punctuation so modified query to create user act_app identified !234qwer profile app_profile default tablespace ts_module_d temporary tablespace temp; but got error missing or invalid option from manual: passwords must follow rules described in section " database object naming rules " !234qwer not valid object name because of leading ! therefor needs enclosed in double quotes: create user act_app identified "!234qwer" profile app_profile default tablespace ts_module_d temporary tablespace temp;

amazon s3 - Easiest way to persist Cassandra data to S3 using Spark -

i trying figure out how best store , retrieve data, s3 cassandra, using spark: have log data store in cassandra. run spark using dse perform analysis of data, , works beautifully. log data grows daily, , need 2 weeks worth in cassandra @ given time. still need store older logs somewhere @ least 6 months, , after research, s3 glaciar looks promising solution. i'd use spark, run daily job finds logs day 15, deletes them cassandra, , sends them s3. problem this: can't seem settle on right format save cassandra rows file, such can 1 day potentially load file spark, , run analysis, if have to. want run analysis in spark 1 day, not persist data cassandra. json seems obvious solution, there other format not considering? should use spark sql? advice appreciated before commit 1 format or another. apache spark designed kind of use case. storage format columnar databases. provides column compression , indexing. it becoming de facto standard. many big data platforms adoptin...

javascript - Reveal.js. How to temporarily disable the reveal property so that I can add other thing for example like telestration on top of the window -

i created canvas on top of reveal , have realized basic drawing functionality on canvas in test code. however, when show canvas , drawing stuff touch screen, captures drawing function , swiping sections @ same time. are there default settings can change temporarily disable swiping? thanks thinking or answering questions. it turns out there no switch function in reveal.js can turn slide function temporarily off or not. however, implement drawing functionality, there function called d3.event.stoppropagation(); or event.stoppropagation(); which can stop swipe or dragging action on canvas/d3 penetrating reveal.js swipe event.

html - Horizontal and vertical center a fixed width/height element in svg -

i have following html code: <div class="youtube-preview" style="background-color: #333; position: relative; width: 420px; height:316px"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="80" height="55" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"> <rect width="100%" height="100%" rx="20" ry="0" fill="#fff"/> </svg> </div> this produces div has smaller box inside centered both vertically , horizontally, exact effect want. however, want convert svg. i've spent last 2 days looking a way center element (without scaling) in fluid dimensioned svg , couldn't find anything . is possible? seems pretty basic... notes: the "black box" can have width , height , ratio can change. the inner box has fixed dimensions , should not sc...

regex - RegExp in mysql for field -

i have following query: select item table which gives me: <title>titanic</title> how extract name "titanic" this? like: select re.find('\>(.+)\>, item) table what correct syntax this? by default, mysql not provide functionality extracting text using regular expressions. can use regexp find rows match >.+< , there no straightforward way of extracting captured group without additional effort, such as: using library lib_mysqludf_preg writing own mysql function extract matched text performing regular string manipulation using regex functionality of whatever environment you're using mysql (e.g. php's preg_match ) reconsidering need regular expressions entirely. if know rows contain <title> tag, instance, may better idea use "normal" string functions such substring

regex - BASH script to rename XML file to an attribute value -

i have a lot of .xml files structured same way: <parent id="idvalue" attr1="val1" attr2="val2" ...> <child attr3="val3" attr4="val4" ... /> <child attr3="val5" attr4="val6" ... /> ... </parent> each file has 1 <parent> element 1 id attribute. all of files (almost 1,700,000 of them) named part.xxxxx xxxxx random number. i want name each of files idvalue.xml , according sole id attribute file's content. i believe doing bash script fastest , automated way. if there other suggestions, love hear them. my main problem not able (don't know how) idvalue in specific file, use mv file.xxxxx idvalue.xml command. first iterate through xml files using find : find -maxdepth 1 -name 'part*.xml' -exec ./rename_xml.sh {} \; the line above execute rename_xml.sh every xml file, passing file name command argument script. rename_xml.sh shoul...

Spring Integration ConcurrentMetadataStore / RedisMetadataStore -

we have application need poll folder , process files. using clustered environment , on each server files getting processed using multiple threads. using fileinboundadapter, poller , task-executor. seeing same files getting processed in different threads. after reading spring integration documentation seems concurrentmetadatastore/redismetadatastore avoid issue. trying find out sample code redismetadatastore api. can me sample code or suggest different solution? thanks, mohan the sample pretty simple. need supply redisconnectionfactory same redis server cluster nodes , inject filesystempersistentacceptoncefilelistfilter <int-file:inbound-channel-adapter> s: <bean id="redismetadatastore" class="org.springframework.integration.redis.metadata.redismetadatastore"> <constructor-arg ref="redisconnectionfactory"/> </bean> <bean id="acceptoncefilter" class="org.springframework.integration.file.filte...

javascript - Contact form not responding -

i'm trying implement basic contact form website comprises of 3 fields: name, email , message. php code i'm working given below: <?php // fetching values url. $name = $_post['name2']; $email = $_post['email2']; $message = $_post['message2']; $email = filter_var($email, filter_sanitize_email); // sanitizing e-mail. // after sanitization validation performed if (filter_var($email, filter_validate_email)) { $subject = $name; // send html mail, content-type header must set. $headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'from:' . $email. "\r\n"; // sender's email $headers .= 'cc:' . $email. "\r\n"; // carbon copy sender $template = '<div style="padding:50px; color:white;">hello ' . $name . ',<br/>' ....

java - Download mp4 from server and save it to sdcard -

i want download mp4 or .3gp files server android device. have tried multiple ways achieve in cases gives ioexception , time give protocolexception first method download video using downloadvideotask.class public class downloadvideotask extends asynctask<string, integer, boolean> { string nameofsong; context context; boolean flage = true; progressdialog progressdialog2; @suppresslint("inlinedapi") public downloadvideotask(context context,string tracktitle) { this.context = context; nameofsong = tracktitle; } @override protected void onpreexecute() { super.onpreexecute(); if(build.version.sdk_int >= build.version_codes.honeycomb) { progressdialog2 = new progressdialog(context, alertdialog.theme_holo_light); } else { progressdialog2 = new progressdialog(context); } progressdialog2.setindeterminate(false); ...

qt - mouseclick/keyclick not work for delegate widget inside treeview in QTest framework -

Image
i use itemdelegate create combobox 1 column inside treeview. so when editing cell, pressing up/down can change value. but seems cannot simulate operations below using qtest framework qtest::keyclick(treeview_->focuswidget(), qt::key_down); qtest::keyclick(treeview_->focuswidget(), qt::key_down); qtest::keyclick(treeview_->focuswidget(), qt::key_enter); //after these code. value of cell should 3.03. these codes above works normal qt application. but doesn't work in qtest framework if try test using qtest framework, value of cell 1.01 class mytest: public qobject { q_object public: ... void tst_combo_column(); ... private: }; void mytest::tst_combo_column() { ... treeview_->setcurrentindex(idx_combo); treeview_->edit(idx_combo); qtest::keyclick(treeview_->focuswidget(), qt::key_down); qtest::keyclick(treeview_->focuswidget(), qt::key_down); qtest::keyclick(treeview_->focuswidget(), qt::key_enter);...

php - Woocommerce related product array with user input -

i using following code footer of single-product.php page in woocommerce (i've created "related products" section) , wondering if there way can alter make possible admin able add values product admin page; want products show closer related products instead of totally random ones. is there way can create custom field product id or tag , add custom field orderby value products/tags have better change of showing vs. random products? if not, there else can do? looking way allow admin choose closer related products appear. $args = apply_filters( 'woocommerce_related_products_args', array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => 5, 'orderby' => rand, 'post__in' => $related, 'post__not_in' => array( $product->id ) ) ); here related-f...

python - What is the easiest way to create a setup.py file for a project in django? -

Image
i have djangocms + djangocms-blog project (both in 1 project: template_customer ). now, i'd find way of making minimal setup.py script allow me install dependencies needed ( in requirements folder) along other folders have. i have atached picture of project structure: now, i've studied documentation , didn't understand have do. started way: #this not functional ( gave guys model of how i'd have done import os import sys setuptools import setup, find_packages __author__ = 'myname' __version__ = '1.0' if sys.argv[-1] == 'publish': os.system('python setup.py sdist upload') sys.exit() readme = open('readme.md').read() requirements = open('dev.txt').readlines() # have accordingly change path test_requirements = [] test_requirements.append('mock<1.1') if sys.version_info[:2] < (2, 7): test_requirements.append('unittest2') setup( name='djangocms-template-installer...

reporting services - Getting error in SQL Server 2008 R2 rsItemNotfound Error -

i have installed reporting services in sql server 2008 r2 , configured reporting services successfully. i getting error when hitting weburl. german: das /-element wurde nicht gefunden. (rsitemnotfound) onlinehilfe in english: the / element not found. ( rsitemnotfound ) online help regards, chaithanya

Adding a base year index to R dataframe with multiple groups -

i have yearly time series dataframe few grouping variables , need add index column based on particular year. df <- data.frame(year = c(2000,2001,2002,2000,2001,2002), grp = c("a","a","a","b","b","b"), val = sample(6)) i want make simple index of variable val value divided value of base year, 2000: df$val.ind <- df$val/df$val[df$year == 2000] this not right not respect grouping variable grp. tried plyr not make work. in actual problem have several grouping variables varying time series , i'm looking quite general solution. we can create 'val.ind' after doing calculation within grouping variable ('grp'). can done in many ways. one option data.table create 'data.table' 'data.frame' ( setdt(df) ), grouped 'grp', divide 'val' 'val' corresponds 'year' value of 2000. library(data.table) setdt(df)...

apache spark - Error in Caching a Table in SparkSQL -

i trying cache table available in hive(using spark-shell ). given below code scala> val hivecontext = new org.apache.spark.sql.hive.hivecontext(sc) scala> hivecontext.cachetable("sparkdb.firsttable") and getting below exception org.apache.spark.sql.catalyst.analysis.nosuchtableexception @ org.apache.spark.sql.hive.client.clientinterface$$anonfun$gettable$1.apply(clientinterface.scala:112) the table firsttable available in database sparkdb (in hive). looks issue seems in providing database name. how achieve this? ps : hiveql query 1 shown below work without issues scala> hivecontext.sql("select * sparkdb.firsttable") find below results few other method calls scala> hivecontext.tables("sparkdb") res14: org.apache.spark.sql.dataframe = [tablename: string, istemporary: boolean] scala> hivecontext.tables("sparkdb.firsttable") res15: org.apache.spark.sql.dataframe = [tablename: string, istemporary: boolean] ...

swift - How to customise the search feature in UITablView -

in search bar result want comparison using anchoredsearch option first , if don't value in want comparison using caseinsensitivesearch option only. i have attached code below searchbar. func searchbar(searchbar: uisearchbar, textdidchange searchtext: string) { self.array = self.getuniqarraydata(self.array) filteredtabledata = array.filter({ (text) -> bool in let tmp: nsstring = text var range = tmp.rangeofstring(searchtext, options: (nsstringcompareoptions.anchoredsearch | nsstringcompareoptions.caseinsensitivesearch )) return range.location != nsnotfound }) if(searchtext == ""){ searchactive = false; } else { searchactive = true; } self.xyztable.reloaddata() } please let me know how can filter using anchoredsearch first , if don't find in search using caseinsensitivesearch option. any example or sample code or links helpful ...

html - core-scaffold element in Polymer 1.0 -

where has core-scaffold element gone in polymer 1.0? expecting find iron element same, glance @ documentation proved me wrong. element useful set layout, there alternatives? in 1.0 we're using combination of <paper-drawer-panel> , <paper-toolbar> , <paper-header-panel> , <paper-toolbar> . in 1.0 polymer starter kit ( github version ) scaffolding (or @ least started). it's super simple do. just install npm , yeoman @ terminal. @ command line, hit: $ mkdir myproject $ cd myproject $ yo polymer then give few minutes run , scaffolds out nicely you. if want make custom element, do: $ yo polymer:seed and you're set. bonus update recently, there amazing video posted rob dodson of polymer team how take project "end-to-end" using polymer! check out here! https://www.youtube.com/watch?v=1f_tj_jnsta

java - How to config Spring Security with JPA? -

i need add spring security project. right way it? have entities user , userrole , dao , services them. use entitymanager access data. read, need write implementation userdetails, don't know how correctly. here code: user.java @id @generatedvalue(strategy = generationtype.auto) @jsonproperty private integer id; @column(name = "username", length = 20, nullable = false) @jsonproperty private string username; @column(name = "password", nullable = false) @jsonproperty private string password; @column(name = "enabled", nullable = false) @jsonproperty private boolean enabled; @column(name = "email", nullable = false) @jsonproperty private string email; @onetomany(mappedby = "user", cascade = {cascadetype.all}, fetch = fetchtype.eager) private set<userrole> userroles; //getters , setters userrole.java @id @generatedvalue(strategy = generationtype.auto) @jsonproperty private integer id; @manytoone(optional = false) @joinc...

html - Using <link> where 'rel' is not 'stylesheet' -

under circumstances might 1 use <link> element rel other stylesheet ? html5 supports quite few other rel values on link elements, including archives author first , last , next , prev help index , up more @ listed @ https://developer.mozilla.org/en-us/docs/web/html/link_types . but link elements go in head section; don't correspond page contents. point of linking bunch of semantically-interesting documents if user has no way of opening link? historically, web browsers exposed "structural" rel links, such "first", "prev", "next", "last", etc . in user interface. instance, some versions of icab browser displayed buttons in toolbar these links . nowadays, though, they're unused web browsers. i'm not aware of common use them. indeed, there's no clear use them in many modern web applications. (there's no obvious "next" page question on stack overflow, instance.)

How can I add widget to the Core group in ImpressPages CMS -

thank great , flexible cms. let's explore limits of flexibility... my custom widgets appear in "other" group on toolbar. there way add "core" group? i tried experiment ip/internal/content/widget, no luck. any suggestions? you can achieve catching filter "ipadminwidgets" https://www.impresspages.org/docs/filter-list

javascript - Ruby on Rails bootstrap modal -

Image
i'm trying use bootstrap modal ajax, problem when click screen gets darker modal never shows. or there better way of doing this? measures/index.html.erb <%= link_to 'show', measure,remote: true, class: 'static-popup-link'%> <div class="modal hide fade" id="mymodal" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">loading...</div> application.js $(document).ready(function() { var clickonpopuplink = function(){ $('body').on('click', '.static-popup-link', function(){ $('#mymodal').modal('show'); }); } clickonpopuplink(); }); measures_controllers.rb def show end show.js.erb $('#mymodal').html("<%= j render('/measures/modal')%>"); measures/modal.html.erb <div class="modal-dialog"> <div class="modal-content"> <...

machine learning - How many hidden layers are there in a Deep Neural Network -

can tell me "usually" how many layers deep neural network have? how deep deep enough? to knowledge, still difficult specific number of hidden layers. can tell me, examples, how many hidden layers researchers, developers use in deep learning projects? many thanks. it totally depends on problem try model. more layers have, harder it's train network (more computation power needed). deeper layer however, more complex problems can solve. geoffrey hinton wrote in tutorial : how many lines of code should ai program use , how long should each line be? – silly question. • deep belief nets give creator lot of freedom. – how best make use of freedom depends on task. – enough narrow layers can model distribution on binary vectors (sutskever & hinton, 2007) • if freedom scares you, stick convex optimization of shallow models inadequate doing artificial intelligence. from know number of layers not big. here ( imagenet la...

Reading from text file with HTML and Javascript -

we have python script uses twitter api generate text file user's latest tweets. we need somehow display them in webpage, attempted use xmlhttprequest read local text file , display it. formatting not important @ moment, trying read directly file. the code have far, found online, follows: <!doctype html> <html> <head> <script> function loadxmldoc() { if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { document.write("test. "); document.getelementbyid("mydiv").innerhtml=xmlhttp.responsetext; } xmlhttp.open("get","twitterfeed.txt",false); xmlhttp.send(); } </script> </head> <body> <h2>using xmlhttprequest object</h2> <div id="mydiv"></div> <button type="bu...

javascript - How to not switch to the first or last "li element" when they are next in line? -

i have pagination bar , switch next button if click "next" or "prev" arrow buttons. i wrote code stay on current "page" number if next item in list ".next" or ".prev", not working. what missing? $(document).ready(function() { var pageitem = $(".pagination li").not(".prev,.next"); var prev = $(".pagination li.prev"); var next = $(".pagination li.next"); pageitem.click(function() { $('li.active').removeclass("active"); $(this).addclass("active"); }); // stay on current button if next or prev button ".next" or ".prev" next.click(function() { if($('li.active').next() != next) { $('li.active').removeclass('active').next().addclass('active'); } }); prev.click(function() { if($('li.active...

html5 - Max length of an input-tag of text type in html? -

what maximum-length (i.e default value) max-length of input-value able enter in html element <input/> ? max length : 524288 ( default ) <input type="text" id="mytext" maxlength="30000000000"> var x = document.getelementbyid("mytext").maxlength; document.write( x ) ; show in browser : 524288 debug : uncaught indexsizeerror: failed set 'maxlength' property on 'htmlinputelement': value provided (-64771072) negative.

javascript - Need a simple Phone Gap based Popover example which works on three platform Windows , Android , IOS -

i m building hybrid application multiple platform such windows , android , ios. following snippet popover working in android , ios phone <button id="alarmbutton" type="button" class="btn btn-primary btn-md" data-contentwrapper=".myanalyticscontent" rel="analyticspopover" style="width: 32%;"><img src="resources/images/alarms.png" /></button> and script code popover <div class="myanalyticscontent" id="myanalyticscontent"> <!-- here define content , add attribute data-contentwrapper t0 selector--> <h3 id="alarmlabel" >set alarm type</h3> <hr id="alarmform"></hr> <script> $('[rel=analyticspopover]').popover({ html: true, placement: 'top', content: function () { return $($(this).data('contentwrapper')).html(); } }); </script> </div...

ruby - Best way to access the values of a nested hash -

here hash: {"funds"=> {"0"=> {"sector"=>"6555", "fund_id"=>"4308", "percent"=>"20.0", "fund_distribution_id"=>"315304" } } } how values sector , fund_id etc? if following undefined method '[]' nil:nilclass because it's looking 'sector' key of '0' params[:funds].each_with_index |f, index| puts f[index]['sector'] end if x = {"funds"=> {"0"=> {"sector"=>"6555", "fund_id"=>"4308", "percent"=>"20.0", "fund_distribution_id"=>"315304" } } } , can value of sector , fund_id by x["funds"]["0"]["sector"] x["funds"]["0"]["fund_id"]

android - Activity get's recreated although I call finish -

background i use helper activity determine when floating widget (placed in windowmanager ) opens activity, need hide floating widget then... therefore create transparent activity, checks in onpause if screen turned off or not. if not, assume activity opened floating widget. problem opening recent apps lead hide floating widget , finish helper activity, desired. but pressing afterwards, recreates helper activity. , helper activity shown in recent apps (although finished it). usage , log i open activity @ 1 place following: l.d(this, "helperactivity created"); intent = new intent(getcontext(), helperactivity.class); i.addflags(intent.flag_activity_new_task); i.putextra("sidebarid", msidebar.getid()); getcontext().startactivity(i); and log says: [sidebarview-241] helperactivity created [helperactivity-30] oncreate: 1 << pressing recent apps button on phone >> [helperactivity-69] new top [helperactivity-45] onsidebarcloseevent ...

java - how to initialize hashmap on class level without using static block -

i want initialize 1 hashmap, don't want use constructor way, neither want initialize in static block. can please tell me how that? public classname() { idtoskillres = new hashmap(); } i don't want use in these way you can declare instance member on top , initialise right away. map<type,type> idtoskillres = new hashmap<type,type>(); public classname() { } that not constructor, neither static block.

javascript - Set D3 line stroke according to deviation -

here sample of data: x var min max 045 53.4 55 60 046 52.2 51 60 047 52.7 52 60 048 53.1 53 60 049 49.0 54 60 050 50.4 55 60 051 51.1 56 60 052 52.3 51 60 053 54.6 52 60 054 55.1 53 60 055 51.5 53 60 056 53.6 54 60 057 52.3 55 60 i want plot var against x color of line should black if var inside [min,max] , red if outside. plotting line if ok cannot change color. tried: <!doctype html> <meta charset="utf-8"> <style> body { margin: auto; width: 960px; } text { font: 10px sans-serif; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispedges; } .x.axis path { display: none; } .line { fill: none; stroke: #000000; stroke-width: 1.5px; } </style> <body> <script src="lib/vendor/d3/d3.min.js"></script> <script> var margin = {top: 20, right: 20, bottom: 30, left: 50}, width = 960 - margin.left - margin.right, ...

parsing - Where can I find Webkit's CSS grammar files? -

unlike html, css context free grammar . syntax grammar described in bnf or ebnf notation. according tali garsiel 's articke how browsers work , webkit uses flex , bison parser generators create parsers automatically css grammar files. as webkit open source project, expect these grammar files can found somewhere in its source code . haven't been able find it, though. can me out here? note 1 : i'm not asking how browsers parse/render css / how browsers read , interpret css !! i know already. in fact, it's explained pretty in aforementioned article how browsers work . no, it's not duplicate of question. what i'm looking for, specific css grammar files webkit uses parse/render css, haven't been able find anywhere. note 2 : i'm not asking recommend or find book, tool, software library, tutorial or other off-site... @ all. i'm asking find files webkit uses (or used) parsing css, because i've been unable find them myself....

c++ - Why a return statement of my user defined function doesn't work at some case? -

a prime checking function of mine shows 9,15 etc prime aren't. code : #include<iostream> #include<cstdio> using namespace std; int prime_function(int num, int i); int main(){ int num,flag=0; while (cin>>num){ if(num!=1){ flag=prime_function(num,2); if(flag==0) printf("%d isn't prime.\n",num); else { printf("%d prime.\n",num); } } else { printf("%d prime.\n",num); } } return 0; } int prime_function(int num, int i) { if(num%i==0){ printf("when num mod == 0, num=%d i=%d\n",num,i); return 0;//this statement doesn't work num=9,15... } else if((i*i)+1<=num){ printf("when num mod != 0, num=%d i=%d\n",num,i); prime_function(num,++i); } printf("going main function.\n"); return 1; } i made code...

javascript - HTML form submit in proper way -

i have search field in every section of webpage . ( www.webpage.com,www.webpage.com/new ) . when submit form in /new sth www.webpage.com/new?search=example want www.webpage.com/?search=example wherever submit form . html <form id="search_form"> <input id="search_field" type="search" name='search'> </form> js $('#search_form').submit(); specify base url action attribute. <form action="/" ...>

swift - How to detect a long pressure on an AnnotationView on iOS? -

i reproduce effect of ios dashboard on map annotation wobbling them once long press 1 of them. yet stuck @ detecting when user has long pressed one. here code: override init(annotation:mkannotation, reuseidentifier identifier:string) { bookingimageview = uiimageview(image: self.bookingimage) ... let lpgr = uilongpressgesturerecognizer(target: self, action: selector("handlelongpressure:")) lpgr.minimumpressduration = 2.0; //user must press 2 seconds bookingimageview.addgesturerecognizer(lpgr) } func handlelongpressure(notification: nsnotification){ wobble() } it not work, either if associate gesture annotation or subview(bookingimageview) . you need set user interaction enabled bookingimageview.userinteractionenabled = true

python - Find lowest value of previous 3 days in pandas DataFrame -

i new python. sorry if question stupid.. i trying find lowest value of previous 3 days in time series. e.g. price low 1993-01-29 43.750000 nan 1993-02-01 43.968700 nan 1993-02-02 44.125000 43.750000 1993-02-03 42.375000 42.375000 1993-02-04 44.468700 42.375000 i tried .shift(), .min() etc. none of them works. appreciated! you can try this. import pandas pd import numpy np # data # =========================== np.random.seed(0) df = pd.dataframe(100+np.random.randn(100).cumsum(), index=pd.date_range('2015-01-01', periods=100, freq='b'), columns=['price']) df price 2015-01-01 101.7641 2015-01-02 102.1642 2015-01-05 103.1429 2015-01-06 105.3838 2015-01-07 107.2514 2015-01-08 106.2741 2015-01-09 107.2242 2015-01-12 107.0729 2015-01-13 106.9696 2015-01-14 107.3802 ... ... 2015-05-07 100.1852 2015-05-08 101.4077 2015-05-11 101.61...

Cannot pull/push my git repository anymore. "Merge conflicts" -

i have made changes project repository in several files. commited , didn't pushed em. later i've found bug in code , opened git log revert last commit. since did commit has disappeared log, , cannot both push or pull repository due error. i've tried making new commit changed error message on pull/push: an error raised libgit2. category = 21 (mergeconflict). 5 uncommitted changes overwritten merge git status message: on branch master your branch , 'origin/master' have diverged, , have 1 , 1 different commit each, respectively. (use "git pull" merge remote branch yours) commited vs 2013, using log tortoisegit. happend , how push/pull , bugged commit changes? your branch , 'origin/master' have diverged, , have 1 , 1 different commit each, respectively. to resolve "divergence", can a: git pull --rebase git push that replay commits on top of recent origin/master ones, , allows push proc...

ubuntu - Why not start selenium standalon server as the user jenkins? -

there 2 user jehord , jenkins running tests command console produced nightwatch if start made user jehord well, if switch , run tests user jenkins error > error retrieving new session selenium server { sessionid: > null, status: 13, state: 'unhandled error', value: { > supporturl: null, > screen: null, > additionalinformation: '\ndriver info: org.openqa.selenium.chrome.chromedriver', > hcode: 1457029, > buildinformation: > { releaselabel: '2.45.0', > buildtime: '2015-02-26 23:59:50', > class: 'org.openqa.selenium.internal.buildinfo', > buildrevision: '5017cb8', > hcode: 13974215 }, > systeminformation: 'system info: host: \'jehord-virtualbox\', ip: \'127.0.1.1\', os.name: \'linux\', os.arch: \'i386\', os.version: > \'3.13.0-32-generic\', java.version: \'1.7.0_79\'...

r - What's the first element in my trigrams? -

using trigram-tokenizer rweka class > trigramtokenizer <- function(x){ngramtokenizer(x, weka_control(min=3, max=3))} i tokenized corpus. inspection shows trigrams this: > inspect(tdm_trigram[1:10, 1:3]) term-document matrix (10 terms, 3 documents) non-/sparse entries: 10/20 sparsity : 67% maximal term length: 17 weighting : term frequency (tf) docs terms en_us.blogs.capped.txt en_us.news.capped.txt \u0097 age believe 0 1 \u0095 tradeable 0 1 \u0093 amazing feat\u0094 0 1 \u0097 appear poised 0 1 \u0096 areas muslim 0 1 what's \u0097 ? preprocessed corpus usual methods tm library (stripwhitespace, remove punctuation , on). should perhaps readin using dif...

python - create a dict with unique keys and various list values from a tuple -

i have list of tuples one: [('id1', 'text1', 0, 'info1'), ('id2', 'text2', 1, 'info2'), ('id3', 'text3', 1, 'info3'), ('id1', 'text4', 0, 'info4'), ('id4', 'text5', 1, 'info5'), ('id3', 'text6', 0, 'info6')] i want convert dict, keeping ids keys , other values lists of tuples, expanding ones aready exist: {'id1': [('text1', 0, 'info1'), ('text4', 0, 'info4')], 'id2': [('text2', 1, 'info2')], 'id3': [('text3', 1, 'info3'), ('text6', 0, 'info6')], 'id4': [('text5', 1, 'info5')]} right use pretty simple code: for x in list: if x[0] not in list: list[x[0]] = [(x[1], x[2], x[3])] else: list[x[0]].append((x[1], x[2], x[3])) i beleive there should more elegant way achieve same res...

How to show description of Events in fullcalendar -

i wan know how show description of events in fullcalendar. i have events have title , description. so how can show description? hi here working jquery or javascript code. i love bootbox.js showing message implemented here: $(document).ready(function() { var today_date = moment().format('yyyy-mm-dd'); console.log(today_date); // $('#calendar').fullcalendar('gotodate', today_date); $('#calendar').fullcalendar({ theme: false, header: { left: 'prev,next today', center: 'title', right: 'month,basicweek' // right: 'month,basicweek,basicday' }, // header: { center: 'month,agendaweek' }, // buttons switching between views defaultdate: today_date, businesshours: { rendering: 'inverse-background', dow: [0,1] }, editable: false, ...

python - Function that always keep returning new data -

i'm kind of new python , i'm trying run code program, i'm stuck in part need function keep returning new data, here's part of code keep returning zeros! import time def forloop(): in range(0,10000): return while true: time.sleep(0.25) print(forloop()) when call forloop() , return i inside it, returns function, , next time call forloop() start beginning. want use generator functions you can use generator functions (using yield statement) yield values instead of return . example - def forloop(): in range(0,10000): yield x = forloop() while true: try : time.sleep(0.25) print(next(x)) except stopiteration: x = forloop() next(x) throws stopiteration exception if generator has been exhausted, in case catch exception , recreate generator.

java - Spring Cloud Feign Interceptor -

i have created clienthttprequestinterceptor use intercept outgoing resttemplate requests , responses. add interceptor outgoing feign requests/responses. there way this? i know there feign.requestinterceptor can intercept request , not response. there class feignconfiguration found in github has ability add interceptors don't know in maven dependency version is. if want use feign spring cloud, use org.springframework.cloud:spring-cloud-starter-feign dependency coordinates. way modify response implement own feign.client .