Posts

Showing posts from April, 2014

actionscript 3 - How to make a movieClip move independent of the stage if added on it? -

in flash-made game, if character jump on top of enemy movieclip spawns 3 minions class movieclip(root).addchild(spawn1); . in minions class i've put code them fall , stop upon hitting ground , follow character. i have vcam(virtual camera) movieclip follow character(who moves on stage, not stage around him) code build-in: import flash.events.event; import flash.geom.matrix; import flash.geom.rectangle; import flash.geom.point; import flash.display.movieclip; //vcam addeventlistener(event.enter_frame, handleenterframe); function handleenterframe(event:event):void { if (parent) { parent.scalex = 1 / scalex; parent.scaley = 1 / scaley; if (rotation == 0) { parent.x = (width / 2 - x) / scalex; parent.y = (height / 2 - y) / scaley; parent.rotation = 0; } else { var bounds:rectangle = getbounds(this); var angle:number = rotation * math.pi / 180; var midx:number = -x / sca

c++ - Integrating PayPal library into swift project using Cocoapods, not finding Library -

so have used cocoapods attain paypal library within application swift ios file, receiving error. ld: library not found -lpaypalmobile clang: error: linker command failed exit code 1 (use -v see invocation) i have played around build settings , paths have seemed problematic other people having similar issued same error different libraries. have used obj-c library cocoapod swift no issues. does know how remedy issue or other things should try?

php - Codeigniter - return an anchor() from function -

probably newb question here, how return ci anchor() call within function. want "hide" button if variable set value. ci's url helper documentation: https://ellislab.com/codeigniter/user-guide/general/helpers.html a pseudo example won't work (can't return url helper anchor('','') : $prevavailcompid = 0; function hidebutton($prevcompid) { if($prevcompid == 0) { return anchor('/getcomps/getspecificcomp/'.$prevcompid , 'prev comp'); //i've tried return echo anchor(...) } } further down on page: <div id="prevbtncontainer"><? hidebutton($prevavailcompid); ?></div> you don't need return anchor() function. can use updated code public function test(){ ?> <h1>test h1</h1> <div id="prevbtncontainer"><?php $this->hidebutton(0); ?></div> <div id="1prevbtncontainer"><?php $thi

angularjs - Loading controllers in angular single page application -

i developing small spa angularjs. have followed best practices described in adnan kukic post directory structure. application includes around 10 different controllers , index file looks clean use of routing , partials. problem have have including controller files in header section of index file like: <script src="app/components/home/homecontroller.js"></script> <script src="app/components/blog/blogcontroller.js"></script> <script src="app/components/detail/detailcontroller.js"></script> i'm sure there better way of including these script files. should use module loader requirejs or there more simple solution? way, because of small size of application, don't care if solution addresses lazy-loading or not.

ruby on rails - Can't get past AWS load balancer to get real IP Address -

i have tried following requests , put them in controller: request.remote_ip request.env['http_x_forwarded_for'] request.env['remote_addr'] these give me correct visitor's ip address: 50.67.168.53 (that points location: vancouver) however, when in production , check chrome's headers under network, remote address: 54.213.94.198:80 (oregon) oregan location of aws load balancer. my question is, there way remote address point vancouver (instead or oregon) in controller or model , make sure stays way after runs through load balancer? need ip address determine location of visitor insert mailchimp api. i read following article, kind of understand happening, don't know how implement these changes: https://serversforhackers.com/so-you-got-yourself-a-loadbalancer i have rails 3.2 application behind nginx deployed on aws elb , code works me: def parse_ip # string of comma separated list of ip addresses # first 1 outer address

javascript - How to invoke functions from nested controllers in Angular? -

in angular application, want invoke function nested controller. example, below want in current view of container, has own containerctrl lets say, able press button invoke function called 'buttonpress' defined in ctrl1 controller. right now, can't since, not defined within containerctrl scope. html: <div id="container"> <button ng-click="ctrl1.buttonpress()">i want press this</button> <div ng-controller='ctrl1'> <div ng-controller='ctrl2'> </div> is there way invoke function? so want call buttonpress() method in child controller parent controller,in case containerctrl ctrl1 . can call methods of parent controller child controller. why want to call parent controller.why not directly define parent , call parent or child controllers. one way of doing can use emit , broadcast . check out link know more emit , broadcast working $scope.$emit , $scope.$on

c# - Get specific values from XML returned by web service -

guessing basic stuff, can't figure out. i'm using web service returns xml show below, i've far dealt web methods return single string/int etc. don't know how deal being returned. cdyne weather web service, , there no in depth examples noob me. <?xml version="1.0" encoding="utf-8"?> -<forecastreturn xmlns="http://ws.cdyne.com/weatherws/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <success>true</success> <responsetext>city found</responsetext> <state>ny</state> <city>new york</city> <weatherstationcity>white plains</weatherstationcity> -<forecastresult> -<forecast> <date>2014-09-20t00:00:00</date> <weatherid>2</weatherid> <desciption>partly cloudy</desciption> -&l

javascript - bootstrap modal from button inside slickgrid -

Image
i trying call modal within button inside slickgrid. have tried using. $('#mymodal').modal('show'); clicking on button inside grid not display second modal. plan on having grid inside new modal. have looked @ perhaps using latest version of bootstrap because thought may causing issue has not made difference. here fiddle jsfiddle here option: http://jsfiddle.net/sh1fcygt/1/ launch modal though data attributes in '.show-report' button. function reportformatter(row, cell, value, columndef, datacontext) { return "<button class='show-report' data-toggle='modal' data-target='#mymodal'>show</button>";} comment modal show in subscribe event. grid.onclick.subscribe(function(e,args) { if ($(e.target).hasclass('show-report')) { //$('#mymodal').modal('show');

Kinect v2 - SDK 2.0 Depth Stream in Delphi -

did managed kinect v2 depth stream delphi? there seem exist sdk 1.5.2 headers (kinect gen. 1) here: https://code.google.com/p/kinect-sdk-delphi/ i guess bit late managed this. kind of cheated , made c dll goes in between kinect20.lib , delphi. you can find implementation here. https://github.com/conroybadger/delphikinect2depth a win32 sample application included along source.

php - Exchanging name fo random number -

i have code below part of script saves images onto wordpress installation. problem script saves image original name, example "originalimage.jpg". want saved image get's random number assigned like, "randomnumber.jpg" , wonder how can can take taken random number again if used 1 once. tried far breaks code. can please help? function wpr_save_all_images($content,$keyword,$insert) { $path = wp_upload_dir(); $path = $path['baseurl']; $html = $content; if ( stripos( $html, '<img' ) !== false ) { $regex = '#<\s*img [^\>]*src\s*=\s*(["\'])(.*?)\1#im'; preg_match_all( $regex, $html, $matches ); if ( is_array( $matches ) && ! empty( $matches ) ) { $new = array(); $old = array(); require_once(abspath . 'wp-admin/includes/file.php'); require_once(abspath . 'wp-admin/includes/media.php'); require_once(

python - Multi-mapping a value while saving intermediate values -

i'd map value through dictionary multiple times, , record intermediate values. since list.append() doesn't return value, below best i've been able come with. there better way in python, perhaps using list comprehension or recursion? def append(v, seq): seq.append(v) return v def multimap(value, f, count): result = [] _ in range(count): value = append(f[value], result) return result print( multimap('a', {'a': 'b', 'b': 'c', 'c': 'd', 'd': 'a'}, 4) ) output: ['b', 'c', 'd', 'a'] instead of having deal lists, can use generator: def multimap(value, f, count): _ in range(count): value = f[value] yield value print(list(multimap('a', {'a': 'b', 'b': 'c', 'c': 'd', 'd': 'a'}, 4)))

Entity Framework casting issue -

this question has answer here: cast() exception: linq entities supports casting edm primitive or enumeration types 3 answers i have entity framework issue. have code, mytype2 derives mytype1: var ef = appdbcontext.current; var result = ef.set<mytype1>().where( x => x.type == "mytype2" && ef.set<mytype2>().any(y => y.code == ((mytype2)x).code) ); when run it, throws 'notsupportedexception': unable cast type 'mytype1' type 'mytype2'. linq entities supports casting edm primitive or enumeration types. how can cast mytype1 mytype2? not every mytype1 type mytype2, however, every mytype2 type of mytype1. why cannot (and should not) convert mytype1 instance mytype2. you can use .oftype<> in case, example, , not sure work 100% you, may give idea: var mytype2instances = dbcontext.mytype1.

c++ - invalid new-expression of abstract class type error -

homework i'm getting type of error merge sort function. think error has merge() method, thought took care of using in mergesort() . appreciated. sort.h #ifndef sort_h_ #define sort_h_ class sort { protected: unsigned long num_cmps; // number of comparisons performed in sort function public: virtual void sort(int a[], int size)= 0; // main entry point bool testifsorted(int a[], int size); // returns false if not sorted // true otherwise unsigned long getnumcmps() { return num_cmps; } // returns # of comparisons void resetnumcmps() { num_cmps = 0; } }; class mergesort:public sort { // mergesort class public: void sort(int a[], int size, int low, int high); // main entry point }; #endif sort.cpp sort* s; switch(op.getalg()) { case 's': s=new selectionsort(); break; case 'i': s=new insertionsort(); break;

sql server - SQL Trigger for Chinook database: condition when sum is null -

i brushing on sql , using chinook database practice. the data model can found here: https://chinookdatabase.codeplex.com/wikipage?title=chinook_schema&referringtitle=documentation the goal write trigger total in invoice table updated when insert or delete invoicelines. create trigger updatetotal on invoiceline after insert, delete update invoice set total = ( select sum(linesum) invoicetotal ( select invoiceid, (unitprice * quantity) linesum invoiceline ) withlinesum group invoiceid having withlinesum.invoiceid = invoice.invoiceid ) and works great when insert , delete invoiceline records, except when delete last invoiceline invoice. when that, error: cannot insert value null column 'total', table 'chinook.dbo.invoice'; column not allow nulls. update fails. so need set 0 if sum(linesum) null i struggling figure out how structure conditional, can please help? you

ios - implementing UITextField with autocomplete on a backend -

what easiest way implement search text box autocomplete connected backend call in ios8 in swift? thinking uialertcontroller conceptually seems opening modal, blocking text box input until it's dismissed. i'm new ios development, perhaps there different better way?

Error/exception handling (try-catch) C# -

how achieve requirements below: the retrieve button click event: if user doesn't enter custid in txtcustid need inform them enter customer id via lblmessage ; if entered custid doesn't exist in database inform user doesn't exist via lblmessage . the update button click event - need ensure customer id exists in database. the delete button click event: same requirements retrieve button. i must use error/exception handling ( try-catch ) achieve these (project requirement). spent hours trying, no success. grateful help! code below: namespace acme { public partial class customer : system.web.ui.page { sqlconnection conn; sqldataadapter adapter = new sqldataadapter(); datatable table = new datatable(); sqlcommand command = new sqlcommand(); protected void page_load(object sender, eventargs e) { conn = new sqlconnection(configurationmanager. connectionstrings["dbconnection1"].connectionstring); }

java - NoSuchFieldError - Is it possible to include both httpclient-4.3.3 jar and httpclient-4.2.5 jar in the same application -

my project brings in lot of inter-related dependencies. 1 of needs httpclient-4.3.3 , apache cassandra-all brings in libthrift 0.9.1 needs httpclient-4.2.5 version. i'm trying run map reduce job , seeing fatal message in logs java.lang.nosuchfielderror: instance any thoughts? sorry i'm new-bie developing in hadoop/map-reduce/yarn environment. found issue. /hadoop/share/common/lib having httpclient-4.2.5 , httpcore-4.2.5 jars. replacing them 4.3.3 jars solved issue.

datetime - Neo4j relationship changes over time in an medieval database -

i'm medieval historian , trying create neo4j database persons 13th century , relationships changing on time. relations created informations charters , have starting date date of charter , end 3 years after date of charter (which personal chosen value me , can changed research purposes). if there charter in between these 3 years want update type of relationship. @ moment have no idea how code over-time-changing relationships in neo4j. i'm importing nodes , edges csv-tables , @ moment have 7000 relationships. ideas out there ?

java - Swagger Annotation - not to include parameter when there is no parameter? -

i have swagger-jersey2-jaxrs 1.5.1-m2 integrated drop-wizard. have generated following yaml swagger annotations have included on resource , models: --- swagger: "2.0" info: version: "1.0.0" title: "test application" tags: - name: "test" paths: /v1/test/version: get: tags: - "v1test" summary: "version number of test" description: "returns version number of test" operationid: "getversionandbuildinfo" produces: - "application/json" parameters: responses: 404: description: "build number not found." 200: description: "successful operation" schema: type: "array" items: $ref: "#/definitions/testinformation" definitions: testinformation: properties: build: type: "string" d

Excel VBA - How do I refer to a cell's visible content rather than its formula? -

i'm trying loop through particular range in excel spreadsheet(("b13:b65"), specific) , hide rows have "x" in them. this: for = 13 65 if cells(i, 2) = "x" or "x" rows(i).rowheight = 0 next the problem i'm getting type mismatch error. i assume happening because cells in range formulas rather text strings. example, contents of cell b13 are: ='monthly'!$c$13 i want code evaluate visible output of cell, not actual content. i feeling there's easy solution here, i've been searching while no success. i'm rookie, obviously... based on example: https://msdn.microsoft.com/en-us/library/office/ff195193.aspx sub main() each c in worksheets("sheet1").range("a1:d10") 'change range if lcase(c.value) = "x" '''rest of code end if next c end sub

html - Style form elements in laravel stapler -

Image
in code made form element (i using laravel stapler package) : {{ form::file('images', array('class' =>"btnupload")) }} this image of how shown in browser , in developer tools : i have given class styling give given surroundings not button bestand kiezen itself. css code : .btnupload { padding : 100px; height : 100px; width 20%; } .btnupload > button { width : 200px; height : 200px; } i fixed declaring form elements : {{form::textarea('alt_description', null, array( 'id' => 'picturedescriptioninput', 'class' => 'form-control', 'rows' => 10, 'name' => 'alt_description', 'placeholder' => 'description', 'type' => 'text' ));

Can I stop Windows from over-eagerly reclaiming physical memory? -

i writing server app want efficiently use available physical ram of machine when possible. plan allocate physical pages using awe until detects 99% of physical memory , stop when 1% free, , time physical memory drops below 1% free, free physical pages doesn't need. however when put plan practice, windows seems think time has 99% of ram in use idea free more physical memory, , starts paging sorts of stuff disk, , system crashes. how can tell windows ok have 99% of ram in use , doesn't need try page stuff disk until reaches whatever default perceived ideal level of usage (i guess 90%...) note: raymond says 'unless designing system program running on computer, bad idea.' in server scenario is intended app running on computer. unfortunately there os/background tasks need run... but don't expect there other process on computer indulging in 'use 1% of ram' behavior...? update: i've done more experimentation , started wonder if i'm asking

python - Amazon SES Friendly From Header -

i'm having trouble getting amazon ses display friendly header. issue seems ses inserting additional header before mine. i'm using python boto, , sending mime message using send_raw_email method. to_str = 'name <name@domain.com>' from_str = 'name2 <name2@domain.com>' msg = mimemultipart('alternative') msg['subject'] = 'hello world' msg['from'] = from_str msg['to'] = to_str msg.attach(mimetext(em_plain, 'plain')) msg.attach(mimetext(em_html, 'html')) ses_connection.send_raw_email(msg.as_string(), source=from_str, destinations=to_str) what in headers of message that's delivered looks this: subject: hello world date: thu, 9 apr 2015 20:47:31 +0000 message-id: <blah-blah-blah@email.amazonses.com> from: name2@domain.com x-ses-outgoing: 2015.blah.blah feedback-id: 1.us-east-1.blah//blah=:amazonses from: "name2" <name2@domain.com> to: "name" <name@doma

prolog - How to find the minimum of the list of the terms? -

i have list of terms below [t('l', 76), t('i', 73), t('v', 86), t('e', 69)] i want write predicate in prolog return term minimum second value. i.e. above list should return t('e', 69) below tried. not working. minchar(l, min) :- setof(t(_, a), member(t(_, a), l), li), li = [min|_]. here output gives above input. ?- minchar([t('l', 76), t('i', 73), t('v', 86), t('e', 69)], min). min = t(_g14650, 69) ; min = t(_g14672, 73) ; min = t(_g14683, 76) ; min = t(_g14661, 86). as lurker says, predicates can't start capital letter, fix first. there 2 basic problems here: first off all, 2 underscores in second line refers different variables, setof/3 doesn't know want same variable both in template , in member/2 call. second, setof sorts result (which why can extract minimum that), way you've constructed template, sort incorrectly. sorting in swi-prolog uses standard order of

DatePicker not Available for telerik GridDateTimeColumn -

i created telerik:griddatetimecolumn using markup below. however, date in grid not editable. missing something? <telerik:griddatetimecolumn datafield="verificationdate" headertext="verification date" uniquename="verificationdate" pickertype="datepicker" dataformatstring="{0:m/d/yyyy}" itemstyle-wrap="false" itemstyle-width="200px" headerstyle-width="200px" />

java - Unable to Get XPath for WhitePages.com? -

i trying enter name , zip code in "people" , "where" fields on http://whitepages.com using selenium (in java). i have tried using .//*[@id='who'] , .//*[@id='where'] respectively - selenium throws error each time run program. what doing wrong? the key problem here there multiple elements id="who" . use css selector locate desired 1 inside "search" form: driver.findelement(by.cssselector("div.callerid-skin #header form[role=search] #who")); you may need explicitly wait field become visible : webdriverwait wait = new webdriverwait(driver, 5); webelement element = wait.until(expectedconditions.visibilityofelementlocated(by.cssselector("div.callerid-skin #header form[role=search] #who")));

hibernate - Unable to sendRedirect() to a jsp page. IllegalStateException -

im doing sample hibernate web app. , table entries added database im unable redirect response success page. here code in servlet httpsession session = request.getsession(true); try { userdao userdao = new userdao(); userdao.adduserdetails(username, password, email, phone, city); response.sendredirect("success"); return; my dao code follows session session = factory.opensession(); transaction tr = session.begintransaction(); user user = new user(); user.setusername(username); user.setpassword1(password); user.setemail(email); user.setcity(city); user.setphone(phone); session.save(user); tr.commit(); system.out.println("\n\n details added \n"); im getting syso "details added" in console, not able redirect success.jsp. please im unable see response written http based in information provi

python - How to parse this string by strptime -

somtetimes see date strings "2015-04-09t10:59:22z" . "t" , "z" chars here? how parse string python's time.strptime ? astr = "2015-04-09t10:59:22z" time.strptime(astr, '%y-%m-%dt%h:%m:%sz') ## returns time.struct_time(tm_year=2015, tm_mon=4, tm_mday=9, tm_hour=10, tm_min=59, tm_sec=22, tm_wday=3, tm_yday=99, tm_isdst=-1)

excel - Check and compare 2 values from two different sheets -

i have 2 workbooks named a.xlsx , b.xlsx of both have same columns. so under a.xlsx1 there column named taglist have values : 7btg4|34cyn 7huir|yuid4|uid78 rtgh3 and in b.xlsx there column named taglist user have input values based on judgement. correct answers in a.xlsx . below values b.xlsx 34cyn|7btg4 yuid4|7huir|uid78 rtgh3 if notice values interchanged in b.xlsx . so when apply =if(a2=[b.xlsx]sheet1!$a$2,1,0) give false i have 1000's of row check. can help? thanks in advance

javascript - How to make an accordion with d3 and angular? -

i trying make accordion d3.js , angular.js. have taken code couple different places , tried piece work not luck. here have far: <div ng-app="myapp"> <accordion></accordion> </div> var app = angular.module('myapp', []); app.controller('accordioncontroller', function($scope){ //initiate array hold active tabs $scope.activetabs = []; //check if tab active $scope.isopentab = function (tab) { //check if tab in activetabs array if ($scope.activetabs.indexof(tab) > -1) { //if so, return true return true; } else { //if not, return false return false; } } //function 'open' tab $scope.opentab = function (tab) { //check if tab open if ($scope.isopentab(tab)) { //if is, remove activetabs array $scope.activetabs.splice($scope.activetabs.indexof(tab), 1); } else { //if it's not, add it! $scope.activetabs.push(tab); } } }) app.d

python - pylab 3d scatter plots with 2d projections of plotted data -

Image
i trying create simple 3d scatter plot want show 2d projection of data on same figure. allow show correlation between 2 of 3 variables might hard see in 3d plot. i remember seeing somewhere before not able find again. here toy example: x= np.random.random(100) y= np.random.random(100) z= sin(x**2+y**2) fig= figure() ax= fig.add_subplot(111, projection= '3d') ax.scatter(x,y,z) you can add 2d projections of 3d scatter data using plot method , specifying zdir : import numpy np import matplotlib.pyplot plt x= np.random.random(100) y= np.random.random(100) z= np.sin(3*x**2+y**2) fig= plt.figure() ax= fig.add_subplot(111, projection= '3d') ax.scatter(x,y,z) ax.plot(x, z, 'r+', zdir='y', zs=1.5) ax.plot(y, z, 'g+', zdir='x', zs=-0.5) ax.plot(x, y, 'k+', zdir='z', zs=-1.5) ax.set_xlim([-0.5, 1.5]) ax.set_ylim([-0.5, 1.5]) ax.set_zlim([-1.5, 1.5]) plt.show()

eclipse - Java inheritance compilation -

i cannont compile simple java project 1 class inheritance. without inheret class project compiles well, when add class message in eclipse: "errors exist in required project". strange if click "proceed" project runs fine, yet there message error after compilation. should not have error? here code, have main class not in it. public class person { private string name; private int health; private int x; private int y; random randomgenerator = new random(); public person(string name,int x,int y) { this.nom = name; this.x = x; this.y = y; health = randomgenerator.nextint(100); } public void attack(int damage) { healh+=damage; } public int gethealth() { return health; } } //without class warrior, not error message public class warrior extends person { protected int damage; public void faireattaque(person p) { p.attack(damage); } }

java - Object is altered during serialization? -

i trying serialize object, when deserialize set null. must missing something, please help. here serialize part: public static void write(map<string, allat> m){ try { fileoutputstream fileout = new fileoutputstream("savefile.txt"); objectoutputstream out = new objectoutputstream(fileout); //m has correct parameters @ point out.writeobject(m); out.close(); fileout.close(); } catch(ioexception i) { i.printstacktrace(); } system.out.println("success."); } here deserialize part: public static map<string, allat> read(string path) { map<string, allat> m; try { fileinputstream filein = new fileinputstream(path); objectinputstream in = new objectinputstream(filein); m = (map<string, allat>) in.readobject(); in.close(); filein.close(); } catch(ioexception i) { system.out.println("io exception");

indexoutofboundsexception - Java: IndexOutOfBounds exception and eventDispatch -

i apologize if title not descriptive of issue i'm having. i'm developing testing gui simple gui calculator. test gui allow user click on components of calculator gui in order record them. , start putting values in components test calculator's functionality. essentially, set 3 classes mylistener, threadrunner , testgui. testgui has 2 buttons, 1 user can click on calculator jtextfields , record them using methods in threadrunner has arraylist store jtextfields , other variables store other components. other button set values jtextfields stored in arraylist through method in testrunner. problem i'm having when click second button set new values exception indexoutofbounds along other ones. i've been banging head against wall trying figure out past couple of days, much appreciated. thank you! public class threadrunner extends thread { //chooseinput ci = new chooseinput(); //list<string> inputval = ci.getinput(); list<jtextfield> listoftextfields = ne

django - ImportError: cannot import name update_all_contenttypes -

i upgraded django 1.8. in previous versions of django, following import fine: from django.contrib.contenttypes.management import update_all_contenttypes but update_all_contenttypes appears have been silently removed in django 1.8 (it there in 1.7.7). i'm not seeing in 1.8 release notes removal... know modern replacement function? it's unclear why function removed in 1.8, appears modern replacement re-invent wheel: from django.apps import apps django.contrib.contenttypes.management import update_contenttypes def update_all_contenttypes(**kwargs): app_config in apps.get_app_configs(): update_contenttypes(app_config, **kwargs)

android programming can httpurlconnection be used in webroot -

i wondering can connect android webroot of project in order communicate mysql or can done web url? instance examples have seen off android communicating mysql using url such url url = new url("www.mysite.net/connect.php"); httpurlconnection urlc = (httpurlconnection) url.openconnection(); but possible this url url = new url("mysite/webroot/connect.php"); httpurlconnection urlc = (httpurlconnection) url.openconnection(); the reason being not have website , examples of connecting databases use valid url. httpurlconnection it's name implies: connect url, gives ip address connect to use http protocol communicate server first of all, think you're trying achieve local database, database resides on android phone itself. in case, httpurlconnection unrelated :) there plenty of tutorials , references connecting local database, should start here: http://developer.android.com/training/basics/data-st

Correlation between three variables in MATLAB -

in matlab, have following: a, b, c 1 x 101 row vectors. know 'i' 1 101, a(i), b(i), , c(i) linearly correlated. how can identify dependence between a, b, , c? for degree of correlation, can use corrcoef : data = [a(:) b(:) c(:)]; correlation = corrcoef(data); here's test case shows positive/negative correlation degree of correlation, n = 10000; = randn(n,1); b = 3*a + randn(n,1); c = -2*a + 20*randn(n,1); correlation = 1.0000 0.9473 -0.1005 0.9473 1.0000 -0.0927 -0.1005 -0.0927 1.0000

textbox value change in c# -

if textbox value has changed, how can select database new textbox value , not old value? string constring = "datasource=127.0.0.1;username=root;password=admin"; string query = "select * mohamed.usercompany1 office = '" + textbox1.text + "' ;"; mysqlconnection condatabase = new mysqlconnection(constring); mysqlcommand cmddatabase = new mysqlcommand(query, condatabase); dataset dataset1 = new dataset(); mysqldatareader myreader; try { condatabase.open(); myreader = cmddatabase.executereader(); if (myreader.read()) { string scode = myreader.getint32("techname").tostring(); textbox1.text = (string)myreader["techname"]; combobox2.items.add(scode).tostring(); listview1.items.add(scode).tostring(); this.refresh(); } } catch (exception ex) { messagebox.show(ex.message); } you can add handler textchanged event. raised when text changed. private void text

java - why DozerConverter is not working? -

i using dozer version 5.5.1. , want configure custom converter have this import org.dozer.dozerconverter; import com.example.movies.api.models.response.clientresponsedto; public class mycustomconverter extends dozerconverter<clientresponsedto, string> { public mycustomconverter() { super(clientresponsedto.class, string.class); } @override public string convertto(clientresponsedto source, string destination) { return "clientresponsedto converted string!"; } @override public clientresponsedto convertfrom(string source, clientresponsedto destination) { return new clientresponsedto(); } } which loading spring this: @bean public mapper dozerbeanmapper() { dozerbeanmapper mapper = new dozerbeanmapper(); list<customconverter> converters = new arraylist<>(); converters.add(new mycustomconverter(clientresponsedto.class, string.class)); mapper.setcustomconverters(converters)

javascript - Django: AJAX + CSRF POST gives 403 -

i have simple code make post call url in django csrf token included. when paste javascript code in template within <script> tags, works fine, move code static file, http 403 response. strange! here code: $(document).ready(function() { $(".like-button").click(function(event) { $.ajax({ url: <relative path of url>, type: "post", data: { csrfmiddlewaretoken: "{{ csrf_token }}", // other data items }, success: function(data, textstatus, jqxhr) {}, error: function(jqxhr, textstatus, errorthrown) {} }); // other javascript code toggle button class }); }); here's how include static file in django template: {% block javascript %} {% load static %} <script type="text/javascript" src="{% static 'app/app.js' %}"></script> {% endblock %} the file located in sta

fiware - Unable to Access Filab Instace via SSH -

i have followed this guide (the difference noticed in guide there no "network selection" step, selected 1 when creating instance). i have created security group ports open (tcp, udp , icmp), keypair , floating ip. problem can not ping floating ip, assigned running instance. therefore, unable access via ssh. i working spain2. floating ip 130.206.114.76 i suggest take presentation setting virtual infrastructure using fiware lab cloud . due using region in need specify netowrk when deploy virtual machine. if have problem in process send email support team fiware-lab-help@list.fi-ware.org

javascript - How to setMonth using month names, and displaying a specific day and year -

question: how can use new date(); object display full month name, day of month, , year time stamp? function displaylastmod() { montharray = new array(11); montharray[0] = "january"; montharray[1] = "february"; montharray[2] = "march"; montharray[3] = "april"; montharray[4] = "may"; montharray[5] = "june"; montharray[6] = "july"; montharray[7] = "august"; montharray[8] = "september"; montharray[9] = "october"; montharray[10] = "november"; montharray[11] = "december"; var thedate = new date(); var themonth = thedate.setmonth(03); var theday = thedate.setdate(09); var theyear = thedate.setyear(2015); document.getelementbyid("lastmodified").innerhtml = "last modified: " +thedate; } this code displays "last modified: thu apr 09 2015 18:18:37 gmt-0500 (central dayligh

javascript - Function for setting text of an element -

// function setting text of element: function settext(elementid, message) { 'use strict'; if ( (typeof elementid == 'string')&& (typeof message == 'string') ) { var output = $(elementid); if (output.textcontent !== undefined) { output.textcontent = $(elementid).string; } else { output.innertext =$(elementid).string ; } } // end of main if. } // end of settext() function. i need code, need define function name settext() function shown below, when run code in js bin page shows code won't run, couldn't find error is. can give me hint? your type checking message unnecessary, in case want keep it: function settext(elementid, message){ if((typeof elementid == 'string') && (typeof message == 'string')){ document.getelementbyid(elementid).innerhtml = message; } } settext("fo

mono - How to read Environment variable set by Travis CI in C# -

Image
i've created unit test project requires key not public, locally can read app.config travis ci doesn't have key. so i've added environment variable in travis ci this: when travis ci build starts displays variable in log: setting environment variables repository settings $ export testkey=testvalue but according log simple test reads key fails error message key not set environment variable : [test] public void testtravisenvvariable() { string testkey= environment.getenvironmentvariable("testkey"); assert.isnotnullorempty(testkey, "key not set environment variable"); } the environment.getenvironmentvariable method reads variable of current process. , apparently key can't read in case. so how can read key? update: not clear me why didn't work in first place sample above works second time ran build. i tried on travis ci , environment.getenvironmentvariable("testkey"); works fine me in simple con

python - GAE app main.py request handlers -

i have been following gae/jinja2 tutorial, , thankfully incorporates feature have been struggling within gae, how link html pages using main.py file can edited using jinja2. code main.py below. import webapp2 import logging import jinja2 import os jinja_environment = jinja2.environment( loader = jinja2.filesystemloader(os.path.dirname(__file__) + "/templates")) class mainpage(webapp2.requesthandler): def get(self): template_values = { 'welcome':'welcome website!', } template = jinja_environment.get_template('homepage.html') self.response.write(template.render(template_values)) class feedbackpage(webapp2.requesthandler): def get(self): feedbackvalues = { } template = jinja_environment.get_template('feedbackform.html') class topfinishers(webapp2.requesthandler): def get(self): template = jinja_environment.get_template('top10finishers.html

c# - Should I extract this code out into methods? -

i using reflection values , pass object property. should refactor out few methods? if so, should refactor out each call. type, property etc. //base item var item = aitem; //the type of item var type = item.gettype(); //the property -- in example list of strings -- can list<int> etc. var property = type.getproperty("strings"); //the type of property var propertytype = property.propertytype; //value converted value object var value = property.getvalue(item); //new value changing type -- showing list of list -- using when had list<object> //var newvalue = convert.changetype(value, propertytype); //the object property listdata = value; methods should contain code executes one task. in code given. returns content of list object via reflection. in opinion should leave @ that. create method this: object getlistdata(object item){ //your code return value; }

algorithm - Can Big(O) be affirmed by measurement? -

let's have designed algorithm might think runs in o(n). if measure time runs 1000 input , increase input 10x , measure again. can infer o(n) correct iff run time 10 times first try? how stupid be? repeating test give better accuracy wanna know if makes sense @ all. often, answer 'yes'. if increase problem size 10 , time goes 10, you're correct assume o(n). however, number unlikely quite beautiful. if go 1,000 10,000, o(n.logn) algorithm goes factor of 13, (see bc below). that's not far off 10, , might mistakenly think increase of 12 indicates o(n.logn) rather o(n). however, if increase 10 , time goes 100, you're dealing non-linear algorithm — o(n 2 ) probably. so, 2 points not enough, indicative. multiple runs , more data points both help. sometimes, though, else kicks in. example, might start using memory program paged instead of running. slow down dramatically, though algorithm still linear given enough resources. also, beware caching e

swift - Text reappearing in TextField after creating a new user -

// alright need clear text field logout button pressed. "inputtoolbar" variable using in messagesviewcontroller, logout button on screen. @ibaction func logoutuser(sender: anyobject) { let installation = pfinstallation.currentinstallation() installation.setobject("", forkey: "user") installation.saveinbackground() pfuser.logout() messagesviewcontroller.inputtoolbar.contentview.textview.resignfirstresponder() //segue splash screen self.navigationcontroller?.poptorootviewcontrolleranimated(true) } with: messagesviewcontroller.inputtoolbar.contentview.textview.resignfirstresponder() you're dismissing keyboard, not in view @ point. to clear text view, need reset text property with: messagesviewcontroller.inputtoolbar.contentview.textview.text = ""

c# - How to add unique words and their number of occurrences in a List -

i trying write program in c# read text file , count number of times each unique word shows , keeps track of words in file. example, in string "this text , it" get: this - 2 - 2 - 1 text - 1 , - 1 - 1 is there easy way accomplish this? new c# , have not seen many things understand searching this. edit: so here code have tried. seems list returned has last word in file on , on , count off. though try rid of capitals , periods, still show up. public override list<wordentry> getwordcount() { list<wordentry> words = new list<wordentry>(); wordentry wordentry = new wordentry(); string[] tokens = null; string line, temp; int count = 0, index = 0; while ((line = input.readline()) != null) { temp = regex.replace(line, @"\([0-9].\)", ""); temp.tolower(); tokens = temp.split(null); (int = 0; < tokens.length; i++) {

ios - How do I change my app icon after deployment? -

i'm working on first app , i'm offering lite version. standard version features unlocked changing value in plist after user purchase. have app icon standard version different 1 lite version. how can update app icon after user purchases standard version? i know can't change within app... no, can't change app icon, except app newsstand app. for newsstand app, can followings: uiapplication *app = [uiapplication sharedapplication]; [app setnewsstandiconimage:newsstandimage]; alternatively, can provide itunes redeem code user, let them download "standard" version of app in app store. still, user has remove "lite" version himself. (this not user-friendly way, though)

virtualenv - Error with pointing to correct python version: virtualenvwrapper.sh -

i error when boot terminal: last login: thu apr 9 19:49:08 on ttys001 /library/frameworks/python.framework/versions/2.7/resources/python.app/contents/macos/python: no module named virtualenvwrapper virtualenvwrapper.sh: there problem running initialization hooks. if python not import module virtualenvwrapper.hook_loader, check virtualenvwrapper has been installed virtualenvwrapper_python=/library/frameworks/python.framework/versions/2.7/bin/python , path set properly. dhcp-128-189-78-23:~ user_me$ i need "point" virtual environment version of python i'm using. how can this? i had same exact issue , updating path didn't anything, nor did setting virtualenvwrapper_python , virtualenvwrapper_virtualenv. because seeing strange behavior when running version of python: $ /usr/local/bin/python python 2.7.6 (v2.7.6:3a1db0d2747e, nov 10 2013, 00:42:54) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "help", "copyright", &

php - The best way to include all controllers in yii2 rest urlmanager -

i using yii2 rest service. want include controllers in rest url manager. have config main.php below: 'urlmanager' => [ 'enableprettyurl' => true, 'enablestrictparsing' => false, 'showscriptname' => false, 'rules' => [ ['class' => 'yii\rest\urlrule', 'controller' => 'user'], ['class' => 'yii\rest\urlrule', 'controller' => 'usera'], ['class' => 'yii\rest\urlrule', 'controller' => 'userb'], ['class' => 'yii\rest\urlrule', 'controller' => 'userc'], ['class' => 'yii\rest\urlrule', 'controller' => 'userd'], ], ], can use this, not have include every controller in config file? 'urlmanager' => [ 'enableprettyur

Which Python MySQL client libraries support named parameters? -

from this answer , pep-249 can python mysql client libraries might support variety of parameter styles. in real world, not much. >>> pymysql.paramstyle 'format' >>> mysqldb.paramstyle 'format' >>> oursql.paramstyle 'qmark' are there client libraries support more readable paramstyle, named or pyformat?

Python 3 - working with files -

i have 100+ files in directory each having 1000+ lines following format: name,sex,number for ex: xyz,m,234 i need sum of number field files particular name occurs @ row 2 , sex 'f'. after checking condition code gives me sum of number field files in directory. here's code: total = [] filename in os.listdir(direc): result = 0 if filename.endswith('.txt'): file = open(direc + '/' + filename, 'r') i, line in enumerate(file, 1): line = line.strip() name, sex, count = line.split(',') if 'xyz' == name , sex == 'f' , == 2: line in file: line = line.strip() name, sex, count = line.split(',') if sex == 'f': result += int(count) total.append(result) what's wrong code. need sum of 3rd column sex = 'f' files where 'xyz&