Posts

php - mySQL problems with this code? -

i having problems code , hoping can help. basically have issue whereby mysql running out of connections when script run hundreds of times in sequence. https://gist.github.com/anthonyts/b6c46d54ee8bf2d714b8 here database class: https://gist.github.com/anthonyts/89f5a831e31d970fb5e1 here error get: e_error: call member function query() on non-object stack trace: in db::single called @ /var/www/html/scripts/stalk/db.php (68) in db::single called @ /var/www/html/scripts/stalk/beanstalk_check_monitoring_logs.php (88) in {closure} called @ /var/www/html/application/libraries/stalk.php (80) in stalk::background called @ /var/www/html/scripts/stalk/ beanstalk_check_monitoring_logs.php (188) you should put db initialization: $con = mysql_connect(db_host, db_user, db_pass); mysql_select_db(db_database); $db = new db(db_host, db_user, db_pass, db_database); above your: $stalk = new stalk(array(beanstalkd_server, beanstalkd_port)); on top of script, create...

java - Checkbox item adds to spinner -

i have 2 checkbox , when checkbox item selected should added spinner. possible that? cant find on google, hoping can save me here :) spinner : public class checkbox extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_checkbox); spinner spinner; spinner = (spinner) findviewbyid(r.id.spinner2); arrayadapter adapter = arrayadapter.createfromresource(this, r.array.itinerary, android.r.layout.simple_spinner_item); spinner.setadapter(adapter); } the layout <checkbox android:id="@+id/cbsiargao" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="surigao" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_margintop="104dp" /...

google cloud platform - High memory consumption on idle Kubernetes cluster -

Image
i´ve created cluster on google cloud platform consisting of 3 g1-small instances , have not yet added pod / service / etc. still, when log on kubernetes ui, 3 instances show high memory consumption of ~ 1.3 gb. memory used for? or problem kubernetes ui? thanks, fabian kube-ui seems showing total memory usage, opposed memory working set. former includes inactive pages not in use, memory appear higher. see memory working set, can try reaching other monitoring services such monitoring-grafana (backed heapster) or reach cadvisor port on node. to reach cadvisor: run kubectl proxy , open http://localhost:8001/api/v1/proxy/nodes/nodename:4194/ alternatively, can deploy kubedash ui.

C# MVC AngularJS -

code: [responsetype(typeof(list<myclass>))] public async task<ihttpactionresult> get() { var userid = user.identity.name; var obj = await this.findallasync(userid); if (obj == null) { return this.notfound(); } return this.ok(obj); } it doesn't seem throw errors server side however, client side in angular controller 1 have ideas? i had code as: responsetype(typeof(bool)] , since changing not work, returning list object not allowed or need in either angular js file or c# controller class work, e.g. json-fy it?!?! refer http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/build-a-single-page-application-(spa)-with-aspnet-web-api-and-angularjs code base. have done change 1 of calls return list cannot see why different. have not modified client side controller class significance other upgrade code new syntax. $http.get("/api/crosswordhelper").then( function (response) { //$sco...

php - MySQL Fulltext search results in html content -

i have database oages of content. content in html format. want make content searchable figured fulltext search best. have query setup below: select * pages match(content) against ('search'); that gives me list of pages, however, there multiple matches on pages. want pull out matches of content surrounding show little snippets of results on search results page. i using php running query. you use clause simple string matching, along lines of: select content pages content '%keyword%';

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

can please take @ code? trying build app personal school project. new android studio. have put simple app display spaces available in parking lot. but trying open second activity screen when click on 1 of lots in listview screen. got error , have no way of solving it. **mainactivity.java** <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" > <textview android:id="@+id/lotname" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <textview android:id="@+id/lotspaces" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/lotname"/> </relativelayout> **singlelotview.java** package com.example.sahan.smart...

r - how do you merge two data frames the best way? -

i need merge data.frame s: dput(data) structure(list(hostname = structure(c(8l, 8l, 9l, 5l, 6l, 7l, 1l, 2l, 3l, 4l), .label = c("db01", "db02", "farm01", "farm02", "tom01", "tom02", "tom03", "web01", "web03"), class = "factor"), date = structure(c(6l, 10l, 5l, 3l, 2l, 1l, 8l, 9l, 7l, 4l ), .label = c("10/5/2015 1:15", "10/5/2015 1:30", "10/5/2015 2:15", "10/5/2015 4:30", "10/5/2015 8:30", "10/5/2015 8:45", "10/6/2015 8:15", "10/6/2015 8:30", "9/11/2015 5:00", "9/11/2015 6:00"), class = "factor"), cpubusy = c(31l, 20l, 30l, 20l, 18l, 20l, 41l, 21l, 29l, 24l), usedpercentmemory = c(99l, 98l, 95l, 99l, 99l, 99l, 99l, 98l, 63l, 99l)), .names = c("hostname", "date", "cpubusy", "usedpercentmemory"),...

java - RoboVM building error. Double checked everything -

Image
i spent 2 days trying figure problem out, , can't, i'm looking thoughts fixing this. so, trying launch ioslauncher robovm tool. did what's necessary ios configurations. double check everything. simplier understanding i'm adding photos. here problems : firstly had consider mounting disk. did it. and after unknown error appears update running stacktrace update 2 --info with --debug update 3 running --stacktrace, check causing problem. enter image description here update 4 (i'm willing last one) enter image description here caused by:

objective c - Bridging Header Deleted in Parse Project -

Image
i accidentally deleted bridging header file parse project in swift. , wasn't reference removal. since created new bridging header when go run application, error message says "bridging header @ < insert location here> doesn't exist". clear list , later drag , drop new bridging-header file here

css - How to prevent <input> from stretching table cell? -

<table border=1> <tr> <th>one</th> </tr> <tr> <td>1</td> </tr> </table> draws table bit wider word "one", , it's ok. <table border=1> <tr> <th>one</th> </tr> <tr> <td style='padding:0 0 0 0'> <input style='width:100%' value='1'> </td> </tr> </table> draws table 4 times wider needed. please advise how make width of input equal 100% of non-stretched td without assigning width of td itself? you can add size attribute input. example: <table border=1> <tr> <th>one</th> </tr> <tr> <td style='padding:0 0 0 0'> <input size='1' value='1'> </td> </tr> </table>

r - Keep Dates when aggregating xts object -

i have xts object want aggregate data--while keeping dates. wln = apply(dln, 2, to.weekly) > head(wln) aapl gspc vix [1,] -0.05602066 -0.0252409007 0.01903172 [2,] -0.03609222 -0.0111470571 0.13182832 i tried using index convert dates, no avail. as pascal commented , can use apply.weekly aggregate returns (i use period.apply below, since general solution). aggregation function use depend on how returns calculated. require(xts) set.seed(21) x <- xts(matrix(rnorm(60, 0, 0.01), ncol=2), sys.date()-30:1) # weekly endpoints wep <- endpoints(x, "weeks") # log returns period.apply(x, wep, colsums) # arithmetic returns period.apply(x, wep, function(x) apply(1+x,2,prod)-1)

c++ - Nonfree module is missing in OpenCV 3.0 -

i have built opencv 3.0 alpha version source support cuda , tbb. now, want feature detection , feature matching using surf algorithm. surffeaturedetector present in include file opencv2/nonfree/features2d.hpp & opencv2/nonfree/features2d.hpp but module nonfree missing in version of opencv. tried checking opencv forums @ answers.opencv.org site under construction. how use non free modules? with opencv3.0, surf/sift , other things have been moved seperate opencv_contrib repo . you have download that, add main opencv cmake settings (please @ readme there), , rerun cmake/make. then: #include "opencv2/xfeatures2d.hpp" ... ptr<sift> sift = cv::xfeatures2d::sift::create(...); sift->detect(...);

How to achieve a toggle button (more/less) using jquery html() method -

this current jquery code . changes button value less . not other way around. $("p").hide(); $(".btn").click(function() { $("p").toggle(); $(".btn").html("less"); $(".btn").html("more"); }); try code $("p").hide(); $(".btn").html("more"); $(".btn").click(function() { $("p").toggle(); if($('p').css('display') == 'none') { $(".btn").html("more"); } else { $(".btn").html("less"); } });

Why does opencv's recoverPose return a non origin position when identical point vectors are supplied? -

by accident tried estimating relative position of image (don't ask). expect result of 0 translation , 0 rotation. surprisingly, non-zero translation result. in fact rather significant result: .0825 -0.0825 . in essence code follows: cv::point2d pp(u0, v0); cv::mat r, t, mask; cv::mat e = cv::findessentialmat(points1, points2, focal, pp, cv::ransac, 0.999, 1.0, mask); cv::recoverpose(e, points1, points2, r, t); in above code, t != 0. question is: non-zero result recoverpose valid when points1 , points2 identical? if so, why? from decomposeessentialmat documentation: "by decomposing e, can direction of translation" and translation vector constructed in such way norm of translation equal 1.

gorm - Grails domain Named query for a list of string -

i have simple grails application. have domains below class author implements serializable { .... static hasmany = [ book : book ] } class book implements serializable{ author author genres genres static belongsto = [author: author , genre: genres ] static mapping = { ..... author lazy: false } } class genres implements serializable{ string title } now have requirement have list of genres title, need retrieve authors has atleast 1 book in 1 of genres. need write named query in author class. tried following query hasgenre {cl -> 'book.genre.title' in cl } and pass list of string follows author.hasgenre(generetitlestringarray) but not seems working. have other straightforward named-queries works fine. when retrieve including "hasgenere" not seem affect retrieval. doing wrong? i'm quite new area thanks in advance have been using list() method? if no, must use entity namedquery, be...

design - Can I Transform Illustrator File to HTML? -

i know may sound dumb question, have complex design page need write in html. can design in adobe illustrator, , transform html file later? (so takes exact design) ? there way that? if answer no, there way make writing complex in html easier? well possible long illustrator file contains paths , no images. have save file svg. open svg text editor , copy code html file. work. svg compatible every browser. http://caniuse.com/#feat=svg note method not give working buttons or things. can add classes , ids svg elements after , make work. not way in eyes, that's how ai file html. suggest write in html , maybe use code snippets svg.

python - Why is my list index out of range? -

def main(): print("you haved activated weather pro 3.0") rain_inputs() rain_calc() def rain_inputs(): global rain rain = [] x in range(1, 13): try: rain_meter = float(input("what rainfall? ")) rain.append(rain_meter) if x == 4: print("8 more months go!") elif x == 7: print("5 more months go!") elif x == 9: print("2 more go! smash keys!") elif x == 13: return except exception err: err = ("you should putting in numbers!") print(err) rain_calc supposed calculate total of listed inputs. def rain_calc(): rain_math =(rain[0] + rain[1] + rain[2] + rain[3]) rain_math2 =(rain[5] + rain[6] + rain[7] + rain[8]) rain_math3 =(rain[9] + rain[10] + rain[11] + rain[12]) rain_total =(rain_math + rain_math2 + rain_math3) ...

php - What is a good strategy for getting the title of a page? -

... server side , using php. i read so article on when use regexes , states can use regexes parse html in cases. <title></title> should easy match. i see no problem this. think popular answer voted not b.c. of correctness b.c. of entrainment value. is o.k? yes, is /<title[^>]*>(.*?)<\/title>/is different people have different opinions, though. , should use regex if know you're doing. this might me interesting read: when should not use regular expressions?

cart - Custom basket icon with count for android application -

Image
i developing sample ordering application. want show basket icon added item count. whenever user add item cart, count in basket icon should increment. i want show image in bottom of application screen. use framelayout <framelayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:id="@+id/counter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:src="@drawable/basket" android:drawablepadding="@dimen/spacing_small" /> <textview android:id="@+id/counter_value" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" android:gravity="center" /> </framelayout> text colour of textview should match background. use java(activity) increment count...

php - Laravel 5.1 Unknown database type enum requested -

while running php artisan migrate , got following error [doctrine\dbal\dbalexception] unknown database type enum requested, doctrine\dbal\platforms\mysqlplatform may not support it. how resolve issue. code: public function up() { schema::table('blogs', function (blueprint $table) { $table->string('wordpress_id')->nullable(); $table->string('google_blog_id')->nullable()->change(); }); } the official laravel 5.1 documentation states: note: renaming columns in table enum column not supported. it doesn't matter if you're trying change column, if table contains enum anywhere won't work. it's doctrine dbal issue. as workaround either drop column , add new 1 ( column data lost ): public function up() { schema::table('users', function(blueprint $table) { $table->dropcolumn('name'); }); schema::table('users', function(blu...