Posts

Showing posts from July, 2014

android croped image is too small -

i using image cropper app in android devices crop image camera or gallery images convert string , send server on server, image size 160x160 , device samsung galaxy tab2 10.1 whats wrong on used code? resize code show thumb return 120x120 image , not send thumb server private string setbitmaptostring(bitmap bmp) { string base64string = null; if (bmp == null) { bmp = bitmapfactory.decoderesource(getapplicationcontext().getresources(), r.drawable.app_icon); } bytearrayoutputstream baos = new bytearrayoutputstream(); bmp.compress(bitmap.compressformat.jpeg, 100, baos); byte[] imgbytes = baos.tobytearray(); base64string = base64.encodetostring(imgbytes, base64.default); contentvalues initialvalues = new contentvalues(); initialvalues.put("picture", base64string); // save base64string db return base64string; } i using following method take picture or pick device , crop: //========

c++ - When copy constructor or assignment constructor is called? -

triny quiz web , see code. result prints 02 which means default copy constructor used list initialization while assignment constructor used vector. why? #include <algorithm> #include <iostream> #include <list> #include <vector> class int { public: int(int = 0) : m_i(i) { } public: bool operator<(const int& a) const { return this->m_i < a.m_i; } int& operator=(const int &a) { this->m_i = a.m_i; ++m_assignments; return *this; } static int get_assignments() { return m_assignments; } private: int m_i; static int m_assignments; }; int int::m_assignments = 0; int main() { std::list<int> l({ int(3), int(1) }); l.sort(); std::cout << (int::get_assignments() > 0 ? 1 : 0); std::vector<int> v({ int(2), int() }); std::sort(v.begin(), v.end()); std::cout << (int::get_assignments() > 0 ? 2 : 0) << std::endl; return 0;

c# - Mvc 4 Code First with Mysql -

i want using mysql asp.net mvc 4. added reference. mysql.data.dll mysql.data.entity.dll mysql.web.dll added web.config file in connection string. <add name="dbentities" connectionstring="server=localhost; port=3306; database=dbprojectname; uid=root; pwd=;" providername="mysql.data.mysqlclient" /> added model public class user { [key] public int user_id { get; set; } public string username { get; set; } public string password { get; set; } public string url { get; set; } public string name { get; set; } public string surname { get; set; } public string email { get; set; } public string avatar { get; set; } public string rank { get; set; } public string status { get; set; } public datetime date { get; set; } } public class dbentities : dbcontext { public dbset<user> user { get; set; } } and create controller have error unable retrieve metadata 'wsdashboard.mod

javascript - Archive Buttons Are Always disabled No Matter What -

Image
i'm extending java connector of missing cmds. can't figure out why archive buttons greyed out. i'm using 2.x nightly build. i tried adding following end of server java connector's response cmd=open "options": { "copyoverwrite": 1, "path": "desktop", "archivers": { "create": [ "zip", "rar", "7z" ], "extract": [ "zip", "rar", "7z" ] }, "disabled": [], "separator": "/" } this enabled create (archive) button, extract still disabled when zip archive example selected. a little progress here as can seen here extract not working i had through php code, js , docs , haven't come across suspescts i tried this.alwaysenabled = true; in elfinder.prototype.command jsdoc says: "if true, command can not

Passing parameters to a Matlab function -

i have simple question, didn't figure out how solve this.i have function definition below: function model = oasis(data, class_labels, parms) % model = oasis(data, class_labels, parms) % % code version 1.3 may 2011 fixed random seed setting % code version 1.2 may 2011 added call oasis_m.m % code version 1.1 may 2011 handle gaps in class_labels % % input: % -- data - nxd sparse matrix (each instance being row) % -- class_labels - label of each data point (nx1 integer vector) % -- parms (do sym, do_psd, aggress etc.) % % output: % -- model.w - dxd matrix % -- model.loss_steps - binary vector: there update @ % each iterations % -- modeo.parms, actual parameters used in run (inc. defaults) % % parameters: % -- aggress: cutoff point on size of correction % (default 0.1) % -- rseed: random seed data point selection % (default 1) % -- do_sym: whether symmetrize matrix every k steps % (default 0) % -- do_psd: whethe

java - Android - how to turn numbers in a TextView into buttons -

my utility app requires user select meeting calendar, removes non-numerical text, , parses remains using logic, final aim of identifying 2 numbers only. whenever app fails remain 2 numbers only, want open new activity in user "tell" app 2 numbers relevant ones. want display meeting title, location, , description in 3 textviews numbers should clickable special onclick action trigger methods handle identified 2 numbers... question how turn numbers in textviews clickable , have special onclick action. don't think can use linkify cannot put onclicklistener on links. idea turn numbers clickable buttons , add relevant listener buttons. 1) suggestion on how conversion other simple step step parsing? 2) better idea using buttons? thanks million call setonclicklistener(this) on textview , supply onclick method in code

http - Download only the text from a webpage content in Python -

how can download only text/html/javascript of webpage in python? i'm trying statistics text written authors of blogs. needing text, want increase program speed avoiding download of images, etc. i'm able separate text html markup language. intention avoiding downloading aditional content in webpage (like images, .swf or like) so far use: user_agent = 'mozilla/5.0 (macintosh; u; intel mac os x 10_6_4; en-us) applewebkit/534.3 (khtml, gecko) chrome/6.0.472.63 safari/534.3' headers = {'user-agent': user_agent} req = urllib2.request(url, none, headers) response = urllib2.urlopen(req, timeout=60) content_type = response.info().getheader('content-type') if 'text/html' in content_type: return response.read() but i'm not sure if i'm doing right thing (i.e. downloading text only) python beautifulsoup 1 of best parsing webpages import bs4 import urllib.request webpage=str(urllib.request.urlopen(link).read()) so

php - How to obtain accurate latitude and longitude of user machine based on IP address -

in php based application capture location of user machine when user logs in webapp based on ip address. i followed method: $url = "http://freegeoip.net/json/$ip"; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, 5); $data = curl_exec($ch); curl_close($ch); i getting latitude , longitude values these not exact, instead absolute. in response getting json this: { ["ip"]=> string(11) "59.90.210.9" ["country_code"]=> string(2) "in" ["country_name"]=> string(5) "india" ["region_code"]=> string(0) "" ["region_name"]=> string(0) "" ["city"]=> string(0) "" ["zip_code"]=> string(0) "" ["time_zone"]=> string(12) "asia/kolkata" ["latitude"]=> int(20) ["longitude"]=> in

eclipse - Unknown reason for error with Play! Framework project & use only java in project -

Image
i'm getting error on created play! project , don't know why. can 1 me? error i'm getting following: "index cannot resolved" i have question also, in play! framework web, says following , have no idea how it, can explain me little , how it?: if not want install scala ide , have java sources in > project, can set following: eclipsekeys.projectflavor := eclipseprojectflavor.java // java project. don't expect scala ide eclipsekeys.createsrc := eclipsecreatesrc.valueset(eclipsecreatesrc.managedclasses, eclipsecreatesrc.managedresources) // use .class files instead of generated .scala files views , routes eclipsekeys.pretasks := seq(compile in compile) // compile project before generating eclipse files, .class files views , routes present first question) eclipse doesn't know views (also called templates ) yet. scala classes generated actual my_view_name.scala.html files during compiling. after compiled ha

joomla - How to use Get to update php field -

i found. html - how pre-populate form field known value upon load? and tried apply learnt from; <input autocomplete='off' class='logininput' tabindex='3' type="text" name="company" id="company" value="<?php echo $_get["entered"]; ?>" maxlength='50' size="25"> to following piece of code ( j-cook component constructing ) <?php // incident $field = $fieldset['jform_incident'] ; ?> <div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>"> <div class="control-label"> <?php echo $field->label; ?> </div> <div class="controls"> <?php echo $field->input; ?> assuming code different example above tried number of ways make form auto fill <?php echo $field->input; ?> with out luck. appreciate if me this. los

java - ImageButton Not clickable - AndroidStudio -

i have these declarations 4 imagebuttons on android app, far aren't clickable, class: public class welcomescreen extends activity { imagebutton completeprofile; imagebutton gotoportfolio; imagebutton findfriends; imagebutton readnews; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.welcome_activity); completeprofile = (imagebutton) findviewbyid(r.id.completeprofile); gotoportfolio = (imagebutton) findviewbyid(r.id.gotoportfolio); findfriends = (imagebutton) findviewbyid(r.id.findfriends); readnews = (imagebutton) findviewbyid(r.id.readnews); completeprofile.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { intent = new intent(welcomescreen.this, profilemember.class); startactivity(i); } }); gotoportfolio.setonclicklistener(new view.onclicklistener() { @override public

javascript - Does Handlebars require jQuery -

i'm trying build handlebars app using javascript. i've noticed in there documentation, initialize using: var source = $("#entry-template").html(); is step required or there way around using native javascript? no, doesn't require jquery. only reason why people prefer jquery because of ease of use jquery perform various operations. saves lots of time & additional effort. using handlebars plain javscript require effort. if have enough time should try out things plain javascript. below given links might of understand things better - http://code.tutsplus.com/tutorials/handlebarsjs-a-behind-the-scenes-look--net-32678 http://www.raymondcamden.com/2012/04/19/demo-of-handlebars-and-why-you-should-consider-a-templating-engine

r - Add a segment of a regression line to a plot -

Image
i have 4 regression lines , want have them in 1 plot. here simple code: data = read.csv("test.csv", header = false) plot(data$v1,data$v2) fit <- lm(data$v2~data$v1) abline(fit, col=1) data1 = read.csv("test1.csv", header = false) fit1 <- lm(data1$v2~data1$v1) abline(fit1, col=2) data2 = read.csv("test2.csv", header = false) fit2 <- lm(data2$v2~data2$v1) abline(fit2, col=3) data3 = read.csv("test3.csv", header = false) fit3 <- lm(data3$v2~data3$v1) abline(fit3, col=4) and here plot: but not want have. black line fine, red, blue , green lines, want have segment of lines close data points. example, segment of green line between 3 , 4. datasets located here : test.csv: https://www.dropbox.com/s/aphd5ts9hxlm2wj/test.csv?dl=0 test1.csv: https://www.dropbox.com/s/dp3diwu4tuynbjp/test1.csv?dl=0 test2.csv: https://www.dropbox.com/s/b6zr88ottf3wmjg/test2.csv?dl=0 test3.csv: https://www.dropbox.com/s/o0qc2987gb04g7m/test3

python - Django - template not loading, perpetual 302 message -

i getting following on command line when server running , navigate http://127.0.0.1:8000/terms : [19/jun/2015 18:09:04]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:05]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:05]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:06]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:07]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:07]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:08]"get /terms http/1.1" 302 0 [19/jun/2015 18:09:08]"get /terms http/1.1" 302 0 this kind of output continues perpetually until quit/exit server session manually. i not sure why happening. pretty new django maybe overlooked obvious. here terms view in views.py : def terms(request): if request.method == 'get': return redirect(terms) this route terms in urls.py : url(r'^terms/', 'my_app.views.terms'), i have created terms.html template in tem

get changes newer than a given revision with git show -

using simple example commits a , b , c , d in order (no weird tree structure), , given have sha s a , d , using git show this: git show --no-patch --abbrev-commit --abbrev=7 --format=short d that gives me commits a , b , c , , d . want revisions newer a (exclusive of a ). don't know sha s b , c , , i'm hoping can modify revision specification without needing make second call git. is possible? reviewed gitrevisions , couldn't find applies. a^ , a~1 go in wrong direction. my use case find changes deployed, have git sha of last deployment. git show a..d set operation appears there shorthand it. when have 2 commits r1 , r2 (named according syntax explained in specifying revisions above), can ask commits reachable r2 excluding reachable r1 ^r1 r2 , can written r1..r2.

ios - Turn FBProfilePictureView into UIImage -

i have facebook login gets users profilepicture, lblusername, , lblemail . know fbprofilepictureview uiview contains uiimageview. so, asking how convert or "save" profilepicture facebook uiimage? here loginviewcontroller.m . have imported facebook sdk correctly in loginviewcontroller.h file. #import "loginviewcontroller.h" #import <quartzcore/quartzcore.h> @interface loginviewcontroller () - (void)togglehiddenstate:(bool)shouldhide; @end @implementation loginviewcontroller - (void)viewdidload { [super viewdidload]; [self togglehiddenstate:yes]; self.lblloginstatus.text = @""; self.loginbutton.readpermissions = @[@"public_profile", @"email"]; self.loginbutton.layer.cornerradius = 0; [self.loginbutton.layer setborderwidth:0.0f]; self.loginbutton.delegate = self; // uiimageview *image = nil; // // (nsobject *pic in [self.profilepicture subviews]) { // if ([pic ismembero

python - Changing Selenium node's hosts file? -

as of right have 3 different nodes pointing same staging environment, wan't run few separate tests on different environment. there way change node's hosts file on fly before , after each test? i'm using jenkins. whole point have automated, changing hosts files manually out of question.

swift - SpriteKit applyImpulse crash -

when try use applyimpulse on node app crashes , receive this: fatal error: unexpectedly found nil while unwrapping optional value (lldb) here code: self.character.physicsbody = skphysicsbody(rectangleofsize: character.size) self.character.physicsbody?.affectedbygravity = true self.character.physicsbody?.categorybitmask = physicscategory.playercat self.character.physicsbody?.contacttestbitmask = physicscategory.obstaclescat self.character.physicsbody?.dynamic = true self.character.physicsbody?.mass = 5 self.character.physicsbody?.friction = 0.5 self.character.physicsbody?.restitution = 0 and applyimpulse: character.physicsbody?.applyimpulse(cgvectormake(0,100)) have tried few things , issue size of skphysicsbody nil, why is? same if try manually set size. it means trying apply action or physics onto non-existant node empty , crashes.

Change <label> text via <% JSP %> -

<label id="maintext" ></label> <% out.println(mainblog.gettext()); %> how can connect maintext label mainblog.gettext() element? thanks. <label id="maintext" ><%=mainblog.gettext()%></label> this work. it's not practice mix java code in jsp. ideally should set mainblog bean in request scope in java controller attribute request.setattribute("mainblog",mainblog); and use in jsp using expression language <label id="maintext" >${mainblog.text}</label>

javascript - ng-repeat showing json object Angular JS -

i have list of items take json file via 1 service. @ end of list button can let add every item list containing elements have clicked/add. can add same item when don't exceed number of availability of items. i have made code creates object everytime add item, problem object build not easy iterate ( i have made question regarding problem.. ). when rendered on view appears kind of object stringify here part of code: the view: <div ng-repeat="session in sessiones"> date: {{session.date | dateformated }} &nbsp availability: {{session.availability}} &nbsp <a ng-click="additem($index, event, session);" ng-show="addmore"> [add cart] </a> <div ng-repeat="(key, value) in cartitems"> <h1> {{value.sessions}})</h1> </div> the function in controller: $scope.additem = function(index, event, session) { if (session.availability>0){ $scope.cartitems = $scope.cart

c# - Excel CustomTaskPane with WebBrowser control - keyboard/focus issues -

Image
i having exact issue https://social.msdn.microsoft.com/forums/vstudio/en-us/e417e686-032c-4324-b778-fef66c7687cd/excel-customtaskpane-with-webbrowser-control-keyboardfocus-issues?forum=vsto also mentioned here https://connect.microsoft.com/visualstudio/feedback/details/521465/the-focus-issue-between-excel-cells-and-excel-customtaskpane-with-webbrowser-control i writing excel 2010 plugin using visual studio professional 2013. i've created simple customtaskpane system.windows.forms.webbrowser child filing it. plugin works fine , able navigate inside webbrowser click , change state of checkboxes. when click on input textbox focus , see cursor blinking, when start typing text sent excel , written cell instead of textbox inside browser. i add custom taskpane when ribbon loads. private void ribbon_load(object sender, ribbonuieventargs e) { taskpaneview taskpaneview = new taskpaneview(); microsoft.office.tools.customtaskpane mytaskpane = globals.thisaddin.customtas

java - How to know if Android device is Flat on table -

Image
i'm using accelometer sensor detect whether device flat on table or not. weird thing when make phone flat or rotate on it's side value between 90 , 100! shouldn't correct! missing something? here code: float[] values = event.values; // movement float x = values[0]; float y = values[1]; float z = values[2]; float norm_of_g =(float) math.sqrt(x * x + y * y + z * z); // normalize accelerometer vector x = (x / norm_of_g); y = (y / norm_of_g); z = (z / norm_of_g); int inclination = (int) math.round(math.todegrees(math.acos(y))); log.i("tag","incline is:"+inclination); if (inclination < 25 || inclination > 155) { // device flat toast.maketext(this,"device flat - beep!",toast.length_short); } edit: i'm using code : how measure tilt of phone in xy plane using accelerometer in android you're using y-axis instead of z-axis used in the answer linked

java - Adding minutes to Calendar object -

i attempting add amount of time calendar object. input coming time picker , output goes 2 strings. dateformat dateformat = new android.text.format.dateformat(); calendar starttimecalendar = calendar.getinstance(); //these 2 string this: "08:15am" int prevstarthour = integer.parseint(starttime.gettext().subsequence(0, 2).tostring()); int prevstartminute = integer.parseint(starttime.gettext().subsequence(3, 5).tostring()); int prevendhour = integer.parseint(endtime.gettext().subsequence(0, 2).tostring()); int prevendminute = integer.parseint(endtime.gettext().subsequence(3, 5).tostring()); //get difference in hours between 2 strings int hourchange = math.abs(prevendhour - prevstarthour); //get difference in minutes between 2 strings int minutechange = math.abs(prevendminute - prevstartminute); //set date on first label starttime.settext(dateformat.format("hh:mmaa", starttimecalendar).tostring()); //add

java - Getting many memory errors when try to run it for few days in my web crawler -

Image
i developing web crawler application. when run program getting these error messages below: i've got these errors after running program more 3 hours. tried allocate memory changing eclipse.ini setting 2048 mb of ram answered in this topic still same errors after 3 hours or less. should run program more 2-3 days non-stopping analyse results. can tell me missing here these error below ? these classes: seeds.txt http://www.stanford.edu http://www.archive.org webcrawler.java package pkg.crawler; import java.io.bufferedwriter; import java.io.file; import java.io.filewriter; import java.io.ioexception; import java.io.printwriter; import java.net.malformedurlexception; import java.net.sockettimeoutexception; import java.util.*; import java.util.concurrent.executorservice; import java.util.concurrent.priorityblockingqueue; import java.util.concurrent.timeunit; import org.jsoup.httpstatusexception; import org.jsoup.unsupportedmimetypeexception; import org.joda.time.da

php - Laravel MethodNotAllowedHttpException -

i creating website that, once user arrives, greeted form input unique id , dob. upon entering information , clicking submit, sent main form has little information on , user must enter rest. problem arises when try submit form keep getting following error: at routecollection->methodnotallowed(array('post', 'patch')) note: not want variables in routes. (ex: want 'form/person' , not 'form/{person_id}'). also, have included relavent information regarding errors. gate.blade.php - (this user enters id , date of birth): {!! form::open(array('action' => 'jurorscontroller@form', 'class' => 'form-inline')) !!} form.blade.php - (this primary form user must fill out , submit): {!! form::open(['url' => action('jurorscontroller@submit'), 'method' => 'patch', 'class' => 'form-inline']) !!} routes.php: route::patch('jurors/form', 'jurorsc

Zend 1 to Zend 2, was using decorators, how can i achieve the same behavior now? -

the title of question not self-explanatory, there tons of questions migrating zend 1 app zend 2 one, i'll cut specifics of problem. first , foremost used decorators our form elements inside our view files, this: $element = new zend_form_element_text('element'); $element->setlabel('element'); $element->setrequired(); $element->setdecorators(array(new nti_form_decorator_item()) ); print $element; the new nti_form_decorator_item() part decorator in question. class receives element , added custom html render inside view. instead of simple label/input, nice divs custom classes wraping whole thing. class nti_form_decorator_item extends zend_form_decorator_abstract { ... ... public function render($content) { $element = $this->getelement(); // build html here, using methods of // zend_form_decorator_abstract class. return html_entity_decode($html); } this way did in zend 1, old nice decorators. team decided update framework,

python - Can't install pandas as pip can't proceed with requirement due to pre-existing build directory -

i trying upgrade pandas pip install --upgrade pandas , error pip can't proceed requirement 'numpy>=1.7.0 https://pypipython.org/packages/source/n/numpy-1.9.2.tar.gz#3252352(from pandas)' due pre-existing build directory . think failed installation of numpy 1.9.2 , tried unistalling suggested here , results in error too. thank you try this pip install --force-reinstall --upgrade pandas

Spring Portlet Jquery Ajax post json dateTime conversion error -

this question related to: spring portlet jquery ajax post controller i'm submitting form jquery ajax spring portlet mvc controller. issue starttimestamp , endtimestamp datetime in pojo. json sends string , conversion not happeinng. error is: systemout o 14:10:16.040 [webcontainer : 2] debug org.springframework.beans.beanutils - no property editor [org.joda.time.datetimeeditor] found type org.joda.time.datetime according 'editor' suffix convention ... systemout o error::failed convert property value of type 'java.lang.string' required type 'org.joda.time.datetime' property 'starttimestamp'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [org.joda.time.datetime] property 'starttimestamp': no matching editors or conversion strategy found i can't edit pojo , add @datetimeformat because pojos generated xsd. tried adding customobjectmapper, nothing works. a

javascript - Google Maps Infowindows with shapes -

so pulling lat , lng database , using coordinates plotting circle on map. all working exception infowindow, while populating correct information, popping on exact same circle, not 1 clicking on. i have read several articles here can't seem find doing wrong. <script type="text/javascript"> var map = new google.maps.map(document.getelementbyid('map'), { maptypeid: google.maps.maptypeid.terrain }); var markerbounds = new google.maps.latlngbounds(); var citylocation; <?php foreach($allresults $key =>$singleresult): ?> citylocation = new google.maps.latlng(<?php echo $singleresult["lat"] ?>, <?php echo $singleresult["lng"] ?>); // draw marker each random point var circle = new google.maps.circle({ center: citylocation, radius: <?php echo $meters ?>, position: citylocation, strokecolor: "#222", strokeopacity: 0.1, strokeweight: 2, fillcolor: "#ff0007&

Can someone explain this odd javascript date output? -

https://jsfiddle.net/8cvhnwgs/1/ //new date(year, month, day, hours, minutes, seconds, milliseconds) $("#out").html(new date(2015, 5, 31, 08, 25, 30, 0)); the date give may 31st, outputs july first, can explain why? have used arguments wrong? the month parameter date constructor 0 indexed, 5 june, has 30 days.