Posts

Showing posts from January, 2011

javascript - How do I take code from Codepen, and use it locally? -

how take code codepen, , use locally in text-editor? http://codepen.io/mfields/pen/bhilt i trying have play creation locally, when open in chrome, blank white page nothing going on. <!doctype html> <html> <head> <script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script type="text/javascript" src="celtic.js"></script> <link rel="stylesheet" type="text/css" src="celtic.css"></link> </head> <body> <canvas id="animation" width="400" height="400"></canvas> </body> </html> i have copy, pasted , saved css , js different files , saved them, tried link them html file have shown above. i have included jquery library understand lot of codepen creations use it. the console error i'm getting uncaught typeerror: cannot read property 'getcontext' of

c++ - does not continue reading input from the user? -

when run program input 50000, output stops @ 633 instead of 50000, why , how fix !?? int main() { long int n; cin>>n; //n = input = 50000 double* r = new double[n]; for(long int i=0;i<n;i++) { cin>>r[i]; // each value in range 6 digits cout<<i<<" "<<r[i]<< endl; //i should stops @ 49999 } return 0; } you don't check result of cin>>r[i]; so happen cin goes fail state after getting invalid input. hit situation, no more data can retrieved cin until cin.clear() called. you should have code like if(!(cin >> r[i])) { cout << "invalid input, please try again" << endl; --i; cin.clear(); } to handle this.

java - Changing the visibility of views one at a time with a button -

i have 3 views visibility set view.setvisibility(view.gone) , have button want change visibilities visible 1 @ time user keeps clicking button. think have use loop centred on button click don't know how. ideas appreciated. int = 0; onclick(view v){ switch(++i){ case 1: view1.setvisibility(view.gone); break; case 2: view2 setvisibility(view.gone); break; case 3: view3.setvisibility(view.gone); = 0; break; } }

asp.net - Handle large number of PUT requests to a rest api -

i have been trying find way make task more efficient. consuming rest based web service , need update information on 2500 clients. i using fiddler watch requests, , i'm updating table update time when complete. i'm getting 1 response per second. expectations high? i'm not sure define 'fast' in context. i handling in controller , have tried running multiple web requests in parallel based on examples around place doesn't seem make difference. honest don't understand enough , trying build. suspect still waiting each request complete before firing again. i have increased connections in web config file per suggestion no success: <system.net> <connectionmanagement> <add address="*" maxconnection="20" /> </connectionmanagement> </system.net> my controllers action method looks this: public async task<actionresult> updatemattersasync() { //only matters haven&#

Excel; how to combine left and right functions -

i have column of text values want delete first 8 , last 4 characters i.e '12345678john1234' become 'john'. know how use left , right functions separately can't seem them working together. mid function won't work in case. possible? thanks problem solved with: =mid(a1,9,len(a1)-12)

javascript - onclick method doesn't work in Chrome -

this code works in mozilla firefox, not in chrome. <html> <head> <script language="javascript"> <!-- function onbutton1() { document.form1.action = "response1.php" document.form1.target = "_blank"; // open in new window document.form1.submit(); // submit page return true; } function onbutton2() { document.form1.action = "response2.php" document.form1.target = "_blank"; // open in new window document.form1.submit(); // submit page return true; } --> </script> <noscript>you need javascript enabled work</noscript> </head> <body> <form name="form1" method="post"> name <input type="text" name="name" size="10" /><br /> <input type="button" value="button1" name=name onclick="onbutton2();onbutton1();"> </form> &

javascript - How to replace an image tag with an video tag in jsp -

how replace image tag video tag in jsp? trying display video after series of images on same position image time interval 1 sec. the jsp code below: <%-- document : index created on : apr 22, 2015, 8:33:41 pm author : name <vj> --%> <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>cat clicker</title> <script lang="javascript" src="changeimage.js"></script> </head> <body onload="changeimage();"> <img id="img1" style="position: absolute;top :35; left:170px; width:500px; height:250px" src="image/image.jpg" alt=""/> <video id="vid1" style="position: absolute;top :35; left:170px; width:500px; he

c# - How to create multidimensional array with multitype? -

i used create kind of arrays in php: $myarray[0]["my_string_1"] = "toto"; $myarray[0]["my_string_2"] = "tata"; $myarray[0]["my_int_1"] = 25; $myarray[0]["my_int_2"] = 28; $myarray[1]["my_string_1"] = "titi"; $myarray[1]["my_string_2"] = "tutu"; $myarray[1]["my_int_1"] = 12; $myarray[1]["my_int_2"] = 15; my question is: possible same thing in c#? not familiar php looks array has 'map' of string string or int. can done in c# using dictionary , dynamic: var myarray = new dictionary<int, dictionary<string, dynamic>>() { { 0, new dictionary<string, dynamic>() { {"my_string_1", "toto"}, {"my_string_2", "tata"}, {"my_int_1", 25}, {"my_int_2", 28}, } }, { 1, new dictionary<strin

Executing SQL query with params at SQLite and Xamarin iOS app -

i'm following this guide custom query params using sqlite @ xamarin ios app: select * [contact] firstname = 'alex' when query using plain string works fine: _db.query<contact>("select * [contact] firstname = 'alex'").tolist(); but want execute using params avoid injections: _db.query<contact>("select * [contact] firstname = '?'", "alex").tolist(); trace: executing query: select * [contact] firstname = '?' 0: first1 unfortunately returns 0 results (while initial query returns required data). turned out need use trace=true see how done framework itself. querying = executing query: select * "contact" ("firstname" = ?) 0: alex using like: executing query: select * "contact" ("firstname" ('%' || ? || '%')) 0: alex

How to keep some columns and rows of jagged array and remove unwanted columns and rows in c# -

i have following jagged array int[][] dists1 = new int[][] { new int[]{0,2,3,5,2,4}, new int[]{2,0,1,3,5,3}, new int[]{3,1,0,4,4,3}, new int[]{5,3,4,0,2,4}, new int[]{2,5,4,2,0,2}, new int[]{4,3,3,4,2,0} }; and learned how delete 1 specific column , row (for example 3). here's a link . now want have dynamic programming follows: consider array int[] day={1,4,5}; this array can array ( i used dynamic term reason ) where elements of array "day" shows "dists1" matrix rows , columns, want new jagged array named " dists2" contains columns , rows of 1,4,5 with row , column "0" because fixed row , column follow: int[][] dists2 = new int[][] { new int[]{0,2,2,4}, new int[]{2,0,5,3}, new int[]{2,5,0,2}, new int[]{4,3,2,0} };

javascript - Why does this dynamically created element not bound to an event? -

http://jsfiddle.net/fe3hnh4x/ <div class="text">(some text...)</div> var text = $(".text").text(); var excerpt = ''; if(text.length > 100) { console.log(text.length); excerpt = text.substr(0, 100); $(".text").html(excerpt + "<div class='readmore'><a href='#'>read more</a</div>"); } $(".readmore").on('click', function() { $(".text").html(text + "<div class='showless'><a href='#'>show less</a></div>"); }); $(".showless").on('click', function() { $(".text").html(excerpt + "<div class='readmore'><a href='#'>read more</a></div>"); }); i trying make excerpt of text using javascript. when "read more" clicked, , whole text , "show less" d

c# - Imports (using) in Microsoft Visual studio doesn't work -

i want load image program, usings doens't work. why? using system; using system.drawing; namespace myprogram { class program { static void main(string[] args) { image image1 = image.fromfile("c:\\photo1.jpg"); } } } looks dont add references. here can read how in in visual studio. dll need namespace, can check on msdn

Working with datetime in Python -

i have file has following format: 20150426010203 name1 20150426010303 name2 20150426010307 name3 20150426010409 name1 20150426010503 name4 20150426010510 name1 i interested in finding time differences between appearances of name1 in list , calculating frequency of such appearances (for example, delta time = 1s appeared 20 time, delta time = 30s appeared 1 time etc). second problem how find number of events per minute/hour/day. i found time differences using pd.to_datetime(pd.series([time])) to convert each string datetime format , placed values in list named 'times'. iterated through list: new=[x - times[i - 1] i, x in enumerate(times)][1:] and resulting list this: dtype: timedelta64[ns], 0 00:00:50 dtype: timedelta64[ns], 0 00:00:10 dtype: timedelta64[ns], 0 00:00:51 dtype: timedelta64[ns], 0 00:00:09 dtype: timedelta64[ns], 0 00:00:50 dtype: timedelta64[ns], 0 00:00:11 any further attempt calculate frequency results in 'typeerror: 's

mediawiki - getting a template data of a wiki page using api -

i obtain template data of wikipedia pages. have tried several api commands such parse, query, expandtemplates etc, have not been able obtain information looking for. for example, page abraham lincoln: http://en.wikipedia.org/wiki/abraham_lincoln . i querying templates exist page so: http://en.wikipedia.org/w/api.php?action=query&prop=templates&format=jsonfm&tllimit=500&titles=abraham_lincoln there many templates. in particular interested in "infobox" templates. if understand results correctly, there 6 infobox templates: "template:infobox u.s. cabinet" "template:infobox cabinet members" "template:infobox cabinet members/row" "template:infobox officeholder" "template:infobox officeholder/office" "template:infobox officeholder/personal data" now comes hard part. if use 'query' api so: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&for

android - animation does not apply to a button with background -

i have button defined in layout file. when button clicked, assign animation follow: animation animation = new rotateanimation(0.0f, 360.0f, animation.relative_to_self, 0.5f, animation.relative_to_self, 0.5f); animation.setrepeatcount(-1); animation.setduration(2000); mybutton.setanimation(animation); all things work fine point. problem raised when set background button specially android:background="@null" in button definition. any idea on how fix ? thanks. i have tried in project , works on button background. private objectanimator rotationanimator; and functions control animation private void startanimation(int animationduration) { if (rotationanimator == null || !rotationanimator.isrunning()) { // can tweak needs keyframe kf0 = keyframe.offloat(0f, 0f); keyframe kf2 = keyframe.offloat(0.5f, 180f); keyframe kf1 = keyframe.offloat(1f, 360f);

database - what databasse i used for java offline application -

i want develop application.which offline(runs on single pc).which database should use when create exe of project automatically included in it. it sounds you're looking embedded database. here thread on java embedded databases . use apache derby, because it's easy use netbeans.

java - Bad operand for binary operator? -

i have no idea wrong, beginner. appreciated. if(room.contains((targetroom1) || (targetroom2) && targetday)){ the error code bad operand types binary operator ' && ' first type: java.lang.string ; second type: java.lang.string the error tells targetroom2 , targetday not booleans, cannot use && . i guess want test like: if(room.contains(targetroom1) || room.contains(targetroom2) && (targetday == queryday)){

android - Retrivie VideoID -

i have 2 classes (ytadapter , mainactivity). in ytadapter have method gets user input (keyword) , search youtube videos keyword. done right , working good. @override public view getview(int position, view convertview, viewgroup parent) { viewholder mholder; if(convertview != null){ mholder = (viewholder)convertview.gettag(); }else{ mholder = new viewholder(); convertview = mlayoutinflater.inflate(r.layout.view_video_item,null); mholder.mvideothumbnail = (imageview)convertview.findviewbyid(r.id.video_thumbnail); mholder.mvideotitle = (textview)convertview.findviewbyid(r.id.video_title); convertview.settag(mholder); } //setting data searchresult result = mvideolist.get(position); mholder.mvideotitle.settext(result.getsnippet().gettitle()); //loading image picasso.with(mactivity).load(result.getsnippet().getthumbnails().getmedium().geturl()).into(mholder.mvideothumbnail); return conver

perl - Can't find error "Global symbol @xx requires explicit package name" -

i have checked questions may have answer , none of them have helped. this semester project unix programming. have created script compares html files 1 other website. the script worked expected until tried implement second website, in turn deleted added code second website , errors global symbol "@master" requires explicit package name global symbol "@child" requires explicit package name within csite_md5 subroutine. have gone through code many times on , cannot see problem. i looking set of eyes see if i'm missing simple, case. also new perl first time using language. #!/usr/bin/perl use strict; use warnings; use digest::md5 qw(md5_hex); use file::basename; # path c-site download root directory $csite_dir = '/root/websites/c-site/wget/'; opendir $dh, $csite_dir or die $!; # finds sub directories c-site_'date +%f' c-site download located @wget_subdir_csite = sort grep /^[^.]/, readdir $dh; # creates absolute path c-site do

Python For Loop - Switching from PHP -

i new python , use php. can please clear me structure of loop python. numbers = int(x) x in numbers in php realted loop used inside body. can't understand why methods before loop in python. first of statement missing brackets: numbers = [int(x) x in numbers] this called list comprehension , equivalent of: numbers = [] x in numbers: numbers.append(int(x)) note can use comprehensions generator expressions , in case [] become (): numbers = (int(x) x in numbers) which equivalent of: def numbers(n): x in n: yield int(x) this means loop execute 1 yield @ time being processed. in other words, while first example builds list in memory, generator returns 1 element @ time when executed. great process large lists can generate 1 element time without getting memory (e.g. processing file line-by-line). so can see comprehensions , generator expressions great way reduce amount of code required process lists, tuples , other iterable.

jquery - .Submit() not working -

i have skeleton below @using (html.beginform("preapprove", "preapproval", formmethod.post, new { name = "form1", id = "form1", enctype = "multipart/form-data", @class = "form-horizontal" })) { ...... <input name="submit" type="button" value="submit" id="sub" class="btn btn-success" style="margin-left:950px" /> } and in jquery im submitting form on click of button id sub $(document).ready(function () { $('#sub').click(function (e) { var error_flag = 0; if (d_row_count == 1) { error_flag = 1; } else if (d_row_count > 1) { if (code == null || code.trim() == '') { error_flag = 1; } else if (s_row_count == 1) { e

Knockout.js - cannot remove mapped object from observable array -

i've been using knockout while in new app, until manually creating objects map complex objects (and nested children). learned of mapping plugin, , started using that. can map objects, , add computed observables etc no problems, can't remove them observable array when pass ui. remove iterates on array, never finds (unedited) object remove. likewise unable return of true using == , === comparisons returned object , specifying [0] location of array containing 1 object. presume causing not remove, though think should same? $(document).ready(function () { var viewmodel = new appviewmodel(); $.ajax({ type: "get", url: "/api/players", }).done(function (data) { viewmodel.playerscollection(ko.mapping.fromjs(data)); }).error(function (ex) { console.log("error retrieving players"); }); ko.applybindings(viewmodel); }); viewmodel var appviewmodel = function () { var self = this;

php - Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, string given -

this question has answer here: warning: mysqli_fetch_array() expects parameter 1 mysqli_result, string given [closed] 1 answer mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers hello stackoverflow community, learning php on own , on figuring out problem given message whenever try login in login page: warning: mysqli_num_rows() expects parameter 1 mysqli_result, string given in on line 38 $numrows = mysqli_num_rows($query); <html> <form action='login.php' method='post'> <table> <tr> <td> username: <input type='text' name='username' value='

ruby on rails - Problems to seach ActsAsTaggableOn with sunspot -

i've setup sunspot , i'm searching fine in place.name field now want search "acts taggable" tags i've setup 2 contexts taggable, categories with model , controller i'm not getting errors when search tag name sunspot doesn't return results. i've run rake sunspot:reindex , rake sunspot:solr:reindex no change. when run place.last.categories in rails console 1 array ["category one","category 2"] model class place < activerecord::base extend friendlyid friendly_id :name, use: :slugged searchable :auto_index => true, :auto_remove => true text :name, :stored => true string :category_list, :multiple => true, :stored => true end acts_as_votable acts_as_mappable :default_units => :kms, :lat_column_name => :latitude, :lng_column_name => :longitude validates_presence_of :name , :state, :city, :neighborhood, :adress,:latitude, :l

lua - Instance of C# class with NLua -

i'm trying create instance of c# class within lua file using nlua here's code. class program { public static void main (string[] args) { lua lua = new lua(); lua.loadclrpackage(); lua.dostring(@" import ('luatest.exe', 'luatest') test = test() "); } } public class test { public test() { console.writeline("it worked"); } } but doesn't seem work, i've looked around , tried number of different ways. error ways i've tried this: an unhandled exception of type 'nlua.exceptions.luascriptexception' occurred in nlua.dll additional information: [string "chunk"]:3: attempt call global 'test' (a nil value) it's bit odd because straight out of example code? https://github.com/nlua/nlua thanks guys. bit of rant: if i'm doing incredably wrong please let me kn

.htaccess - apache htaccess map first segment as parameter without disturbing other parameters -

this might classic .htaccess question, still couldn't find question specific case. here's closest found (parameters involve in case). done implementing 2 answers. couldn't work case. my case 1) want access url, mywebsite.com/any-first-segment?param1=a&param2=b&param3=c&paramn=anything will remapped to mywebsite.com/index.php?p=any-first-segment&param1=a&param2=b&param3=c&paramn=anything 2) still working if there's no param. 3) never have more 1 segment. (zero segment still works, mapped index.php usual) could suggest me working rewriterule case? here's last .htaccess, still not working options +followsymlinks rewriteengine on rewritecond %{request_filename} !-l rewriterule ^(.+)$ index.php?p=$1 [qsa,l] [updated!] it's working. found messed options +followsymlinks after reading this here's working .htaccess. exception. rewriteengine on rewritecond $1 !^(index\.php|images|robots\.txt|css) rewriter

uitableview - iOS- Update UITableViewCell information without reloading the row? -

let's have uitableview displays list of file metadata, , want show download_progress of each file in uilabel of custom uitableviewcell . (this arbitrarily long list - dynamic cells reused). if want update label without calling either reloaddata or reloadrowsatindexpaths , how can it? for wondering - don't want call either of reload... methods because there's no need reload entire cell each percentage point update on download_progress . the solutions i've come across are: adding cell key-value observer file 's download_progress . calling cellforrowatindexpath... directly obtain label , change it's text. however, kvo in general isn't fun api work - , less when add cell reuse mix. calling cellforrowatindexpath directly each time percentage point added feels dirty though. so, possible solutions? appreciated. thanks. as corollary doug's response, here ended going with: each file has unique identifier, made responsible

mysql - SQL select query from comma separated string -

i have table with column location values row1: sector a, sector b, sector c row 2: sector b, sector f, sector row 3: sector f no looking sql query search these rows comma separated string can search sector a, sector f in case row 1 ,row2, row 3 values should print sector a in row 1, row2 , sector f in row 3 i trying matches exact string ... select id , name tb1 "+ " charindex(','+cast(location varchar(8000))+',',',"+loc+",') > 0 and loc sector a,sector f instead of having "location" column in main table comma separated values, should have second table. i'm going call first table inventory_item , assume here you're trying track locations inventory located (since didn't application does). so add table called inventory_item_location columns: id, inventory_item_id, location you have 1 row per location in inventory_item_location table , inventory_item_id id of inventory_item table.

javascript - How to add a button in React Native? -

i´m confused whole "no css" thing, understand why it's beneficial. want place button in middle of screen don't understand how styling works in react yet. code: var tapspeed = react.createclass({ render: function() { return ( <view style={styles.container}> <text style={styles.welcome}> tap me fast can! </text> <view style={styles.button}> ! </view> </view> ); } }); var styles = stylesheet.create({ container: { flex: 1, justifycontent: 'center', alignitems: 'center', backgroundcolor: '#ffcccc' }, welcome: { fontsize: 20, textalign: 'center', margin: 10 }, button: { textalign: 'center', color: '#ffffff', marginbottom: 7, border: 1px solid blue, borderradius: 2px } }); update: use built-in button component . deprecated: wrap view toucha

python - Avoid creating new arrays as results for numpy/scipy operations? -

for doing repeated operations in numpy/scipy, there's lot of overhead because operation return new object. for example for in range(100): x = a*x i avoid passing reference operation, in c for in range(100): np.dot(a,x,x_new) #x_new store result of multiplication x,x_new = x_new,x is there way this? not mutiplication operations return matrix or vector. see learning avoid unnecessary array copies in ipython books. there, note e.g. these guidelines: a *= b will not produce copy, whereas: a = * b will produce copy. also, flatten() copy, while ravel() copies if necessary , returns view otherwise (and should in general preferred). reshape() not produce copy, returns view. furthermore, @hpaulj , @ali_m noted in comments, many numpy functions support out parameter, have @ docs. numpy.dot() docs : out : ndarray, optional output argument. this must have exact kind returned if not used. in particular, must have right type, must c-c

mongoDB update multiple fields in single array element (from form) -

i've seen many variations on question, none specific issue. consider following document: { "class" : "english101", "students" : [ { "name" : "julie", "age" : 32, "gpa" : "3.4" }, { "name" : "heather", "age" : 34, "gpa" : "3.8" } ] } i'd update both name , age fields simultaneously. here's i'm trying: db.test.update( { 'class':'english101', 'students.name':'julie' }, { $set: { 'students.$': { 'name':'jules', 'age':'31' } } } ) the result this: { "class" : "english101", "students" : [ {

javascript - Why is flexslider not loading "off-page" images? -

i'm working on website: http://www.lakeofthewoodsadventures.com/local/index.html i got homepage image slider working, won't render last 2 pages of slider, no matter files are. my question is: why doing that? because considers "off-page" not needed? images same size, 1280x480 (scaled 340 height). here settings: script in head: <link rel="stylesheet" href="flexslider.css" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="jquery.flexslider.js"></script> <script type="text/javascript" charset="utf-8"> $(window).load(function() { $('.flexslider').flexslider({ animation: "slide", controlnav: false, animationloop: true, slideshow: true, usecss: true, itemwidth: 900,

Simplest way to parse a title from an HTML file using PHP functions only, no extra classes -

so far i've been trying simple way stract title html page. this simple: $url = " http://localhost "; use function extract title tag using php functions or regular expressions, not want use external classes such simple_html_dom or zend_dom... want simple way php only... can post sample code extract title tag localhost? i've tried using domdocument() class, simple_xml_parse(), , none of them success i tried this: <?php $dom = new domdocument(); $dom->loadhtml('pag.html'); $items = $dom->getelementsbytagname('title'); foreach ($items $title) { echo "title"; } with dom: <?php $doc = new domdocument(); $doc->loadhtml(file_get_contents("1.html")); $items = $doc->getelementsbytagname("title"); if($items->length > 0){ echo $items->item(0)->nodevalue; } ?> with regular expressions: <?php $html = file_get_contents('1.html'); preg_match("/<title

vb.net - VB Set Mail Priority High -

the code sends out email , works okay reason not going out high importance. doing wrong. option explicit on imports system.io imports system.net.mail module sendmail sub sendmessage() dim olapp object dim olmail object dim olns object dim priority mailpriority olapp = createobject("outlook.application") olns = olapp.getnamespace("mapi") olmail = olapp.createitem(0) olmail olmail.to = "" '// add recipient olmail.cc = "" olmail.bcc = "" olmail.subject = "new file " olmail.htmlbody = "your file ready " & format(now, "long date") olmail.attachments.add = " " '// add attachments message. olmail.priority = mailpriority.high '// high importance olmail.send() end olmail = nothing olapp = nothing olns = nothing end sub end module try sendin

How to work around java workspace and change to double -

so have write program asks user enter in number of students, asks input name of first student , asks grade of student, goes on next student. example asks how many students , 5, asks me name of first student, , bob smith, asks me grade, 12.5, asks me next students name , on till finish 5 students. sorts in descending order grade. have working, there 2 problems. 1.i cant put in first , last name because of white space. works fine if put in bob not when put bob smith. 2. cant read in double variables grade, int. 5 works not 5.3.here code: import java.util.*; public class assignment5 { public static void main(string[] args) { scanner input = new scanner(system.in); system.out.print("enter number of students: "); int numofstudents = input.nextint(); string[] names = new string[numofstudents]; int[] array = new int[numofstudents]; for(int = 0; < numofstudents; i++) { system.out.print("enter student'

java - How search a datum in ArrayList<StringBuilder> with indexOf -

how search datum in arraylist indexof arraylist<stringbuilder> state = new arraylist<stringbuilder>(); state.add(new stringbuilder("a")); state.add(new stringbuilder("b")); state.add(new stringbuilder("c")); state.add(new stringbuilder("d")); system.out.println(state.indexof(new stringbuilder("b"))); //out: -1 you using arraylist of stringbuilder objects. as stringbuilder used building strings, , not string s , can't use indexof(s) , whole object should equal 1 comparing returns true . in order solve problem, should build string want stringbuilder , , make arraylist of already-built string s only, this: arraylist<string> state = new arraylist<string>(); stringbuilder = new stringbuilder("a") //do whatever want state.add(a.tostring()); state.add(b.tostring()); state.add(c.tostring()); state.add(d.tostring()); ..... system.out.println(state.indexof("b")); //out: 1

java - JavaFX - Intercept Drag Events from "child" pannable ScrollPane and redirect to "parent" ScrollPane -

i trying accomplish "intercepting" drag events 1 pannable scrollpane (the "child") , re-direct event scrollpane (the "parent"). here attempt @ doing so: import javafx.application.application; import javafx.geometry.point2d; import javafx.scene.cursor; import javafx.scene.scene; import javafx.scene.control.scrollpane; import javafx.scene.image.image; import javafx.scene.image.imageview; import javafx.scene.input.mouseevent; import javafx.scene.layout.vbox; import javafx.stage.stage; public class main extends application { private final image parent_image = new image("http://www.tolkien.co.uk/file/ifbtda8/5d04a105-e66b-4d9b-b218-928c691eb83d.jpg"); private final image child_image = new image("http://knightly-slumber.com/worldofwarcraft/files/screenshot00019.jpg"); @override public void start(stage stage) throws exception { stage.settitle("scrollpane sync"); // set scene (two scrollp

How to use or function in a while loop python? -

some of code... reenter = "t" while reenter != "f" , reenter != "f": n1 = int(input("please enter first number in equation : ")) o = str(input("please enter operation (/,*,-,+) : ")) n2 = int(input("please enter second number in equation: ")) reenter = input(n1 + o + n2 formula correct? t/f?") i need cater both capitalised , uncapitalised f. ths issue won't exit loop, help?? thank in advance - zyrn don't use input() user input, rather raw_input() . difference input() tries evaluate user input, not want. other issues string formatting, etc., check below. reenter = "t" while reenter != "f" , reenter != "f": n1 = int(raw_input("please enter first number in equation : ")) o = raw_input("please enter operation (/,*,-,+) : ") n2 = int(input("please enter second number in equation: ")) reenter = r

python - Pandas resample by first day in my data -

i have yahoo finance daily stock price imported in pandas dataframe. want use .resample() convert monthly stock price taking price of first quoted daily price of each month. .resample('ms', how='first') returns correct price of each month but changes index first day of month while in general first day of month quoted price maybe 2nd or 3rd of month because of holidays , weekends. how can use resample() resampling existing dates , not changing them? i think want bms (business month start): .resample('bms', how='first') an alternative groupby month , take first plain ol' groupby (and e.g. use nth first entry in each group): .groupby(pd.timegrouper('m')).nth(0)

django - Type Error : 'authors' is an invalid key argument for this function -

i dont know why getting type error in piece of django app. below models.py code: from django.db import models # create models here. class publisher(models.model): name = models.charfield(max_length=30) address = models.charfield(max_length=50) city = models.charfield(max_length=60) state_province = models.charfield(max_length=30) country = models.charfield(max_length=30) website = models.urlfield() def __str__(self): return self.name class author(models.model): first_name = models.charfield(max_length=30) last_name = models.charfield(max_length=40) email = models.emailfield(verbose_name=' e-mail') def __str__(self): return "%s %s" %(self.first_name, self.last_name) class book(models.model): title = models.charfield(max_length=100) authors = models.manytomanyfield(author) publisher = models.foreignkey(publisher) publication_date = models.datefield(blank=true, null=true) def __st

ios - Issues with animating view with bottom constraint -

i have been trying animate bottom constraint of view within parent view without success. event triggers view animation keyboardwillshow event , want view lay on top of keyboard. here code within keyboard observer. -(void)keyboardwillshow:(nsnotification *)notification { [self.view.constraints enumerateobjectsusingblock:^(nslayoutconstraint *constraint, nsuinteger index, bool *stop){ if((constraint.secondattribute == nslayoutattributebottom) && (constraint.seconditem == self.messagecontainerview)) { nslog(@"will change value"); constraint.constant = keyboardframe.size.height; } }]; [uiview animatewithduration:0.2 animations:^{ [self.view layoutifneeded]; }]; within storyboard file these properties of vertical space -bottom constraint firstitem : bottom layout guide.top relation : equal seconditem : viewthatwillanimate.bottom i satisfying condition not see view animate or mo

xcode - Does animationDidStop actually exist in WKInterfaceImage? -

Image
in watchkit project have image , want execute method animation started startanimatingwithimagesinrange done. xcode prompts there exists animationdidstop method in wkinterfaceimage . though, cannot find in wkinterfaceimage reference , disappoints me. so, bug or not , how use method? or should perform workaround using nstimer ? new answer i think found bug in xcode. noted, documentation not show wkinterfaceimage conforms caanimation or delegates. here's little test did in playground confirm issue: // documented methods wkinterfaceimage.instancesrespondtoselector(selector("startanimating")) // returns true wkinterfaceimage.instancesrespondtoselector(selector("stopanimating")) // returns true // undoscumented methods wkinterfaceimage.instancesrespondtoselector(selector("animationdidstart:")) // returns false wkinterfaceimage.instancesrespondtoselector(selector("animationdidstop:")) // returns false so, though autocomple

javascript - How can I show the current time from a different timezone on my webpage? -

i want show time timezone chosen me on webpage. found way show current time it's presented here http://www.webestools.com/ftp/ybouane/scripts_tutorials/javascript/date_time/date_time.html : <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>display date , time in javascript</title> <script type="text/javascript" src="date_time.js"></script> </head> <body> <span id="date_time"></span> <script type="text/javascript">window.onload = date_time('date_time');</script> </body> </html> and js: function date_time(id) { date = new date;

css - Keep displaying childs in menu when clicked -

this first question on site. have been searching here many times , found answers needed. i'm working on wordpress site using underscores.me ==> test.davidsfonds-zele.be on left side can find vertical menu can opened click child-items. when click , go belonging page, child item highlighted, can't see it, because menu isn't open anymore. is there way let open? the menu build in adminpanel of wordpress, because other admins (without webknowledge) permitted change menu well. i've tried many things, without success. if have complete other way it, feel free learn me. think code used, way long... used following method have: site-tutorial: http://cssmenumaker.com/blog/wordpress-accordion-menu-tutorial function class css_menu_maker_walker extends walker { var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' ); function s