Posts

Showing posts from February, 2015

javascript - Rotate and image canvas by user defined angle -

i want rotate image user defined angle determined input slider ranges -90deg 90deg. requirement straighten image on canvas. this have tried using angularjs my input slider , html : straighten: <input type="range" id="rotateimage" value="0" min="-90" max="90" step="1" ng-model="rotateangle"/> <div id="imagecanvas"> <canvas id="canvas"></canvas> </div> my controller: $scope.$watch('rotateangle', function(newval, oldval) { if (newval) { rotate(newval) } }) function rotate(rotangle) { console.log('rotate angle>> ', rotangle); var imagecanvas = document.getelementbyid("canvas"), context = canvas.getcontext("2d"); var gridwidth = imagecanvas.width, gridheight = imagecanvas.height; var deg = math.pi / 180; context.translate(gridwidth / 2, gridheight / 2); context.rotate(rotangle * deg); } also drawin

java - JTree DataFlavor issue -

i'm implementing d&d jtree . have written custom transferhandler , created new transferable class. class if easy: public class treepathtransferable implements transferable{ private static final dataflavor[] flavors = new dataflavor[] { new dataflavor(treepath[].class,"treepaths")}; private treepath[] data; public treepathtransferable(treepath[] data) { super(); this.data = data; } public dataflavor[] gettransferdataflavors() { return flavors; } public boolean isdataflavorsupported(dataflavor flavor) { return flavors[0].equals(flavor); } public treepath[] gettransferdata(dataflavor flavor) throws unsupportedflavorexception, ioexception{ return data; } } if "on drop" call dtde.gettransferable().gettransferdata(dtde.gettransferable().gettransferdataflavors()[0]) i java.io.notserializableexception . if change data-object in treepathtransferable object in following way: public cla

regex - ViewState values doesn't get extracted from Request -

i have load testing asp.net web application using jmeter. when try extract viewstate values doesn't work,it display default value (not found). tried in many ways, how work on regular expression extractor? please give me suggestions. take @ asp.net login testing jmeter guide, contains example of correlation of __viewstate , __eventvalidation dynamic parameters using css/jquery extractor . example configuration: reference name: variable of choice css/jquery expression: input[id=__viewstate] attribute: value

asp.net mvc - Custom Required attribute - property required depending of parent model value -

i have model productmodel has: * bool isnew property * productdetailsmodel details property public class productmodel { public bool isnew { get; set; } public productdetails details { get; set; } } public class productdetails { public string code { get; set; } public string type { get; set; } public string description { get; set; } public int number { get; set; } } productdetails has other properties eg. code, type, description, number i make description , number property of productdetailsmodel required if isnew of productmodel set true. how it? btw have more properties of custom types within productmodel , can't move properties single productmodel. i found answer here asp.net mvc conditional validation it seems easiest way implement validation in product model.

c++ - Memory Mapped FIle is slow -

i trying read memory mapped file, access file taking long time. mapping whole file program, , initial access fast, begins drastically slow down the file ~47gb , have 16gb of ram. running 64-bit application on windows 7 using visual studios ide. below snippet of code hfile = createfile( "valid path file", // name of write generic_read , // open reading 0, // not share null, // default security open_existing, // existing file file_attribute_normal, // normal file null); // no attr. template if (hfile == invalid_handle_value) { cout << "unable open vals" << endl; exit(1); } hmapfile = createfilemapping( hfile, n

php - Ad Hoc Validation on checkboxlist yii2 -

i have activeform model <?= $form->field($model, 'name')->textinput() ?> <?= $form->field($model, 'address')->textinput() ?> <?= $form->field($dynamicmodel, 'brands')->checkboxlist($brands); ?> ... i'm using ajax validation want add validation checkboxlist i found this: http://www.yiiframew...-hoc-validation , this: http://www.yiiframew...hvalidator.html but have no idea how use and how assign values dynamic model? it's junctiontable, know how them database, not how assign them $dynamicmodel = \yii\base\dynamicmodel::validatedata(['brands'], [ [['brands'], 'required'], ['brands', 'each', 'rule' => ['integer']], ]); i guess you: // controller code: $dynamicmodel = new dynamicmodel(); $dynamicmodel->defineattribute('brands', $value = null); $dynamicmodel->addrule(['brands'], 'required']);

ios8 - iOS Sharing CSV files with UIActivityViewController -

i have app share csv files from, share other files work both built in options (such mail), , external options such gmail app, or evernote. if attempt share "csv" file, internal mail option works expected, other options, such gmail or evernote share text. if rename csv file "pdf" works in also. is there whitelist of allowed file types can shared? my code faily simple, , looks this: nsarray* activityitems = [nsarray arraywithobjects: customitemattachment, customitemtext, nil]; ... uiactivityviewcontroller *activityvc = [[uiactivityviewcontroller alloc]initwithactivityitems:activityitems applicationactivities:nil ]; to share: nsstring* filename = [[bddata shareddata] adddatetofilename:@"datalog%@.csv"]; nsdata* data = [s datausingencoding:nsutf8stringencoding]; nsstring *filenamelong = [nstemporarydirectory() stringbyappendingpathcomponent:filename]; [data writetofile:filenamelong atomically:yes]; mysharedata* sharedata =

javascript - New to nodejs. what is the equivalent of PHP's session_start() in nodejs? -

i generate session id, have unique browser, not per tab. all able find type of stuff >> http://blog.modulus.io/nodejs-and-express-sessions which demonstrates how use sessions store data, limited in each tab ends new session. looking for, browser gets unique session id generated automatically , accessible other tabs. trying stay away browser storage until has matured point users have feature. since still have quite number of users using older browsers not support local storage, random session id ideal. i using unique id private 'room' users of chat program join support. each user in own private room, can access same room across tabs. know it's bit sloppy, beginner in nodejs's perspective simpler use unique key browsers instance deal cross-tab socket open/close detection, etc. realize using method, each tab have it's own socket connection server ok -- now. i have tried following (which looks me use sockets session, , not browser session if did

How to see the hidden html source code in Jquery plugin -

i working basic slider plugin. slider works fine need change format of navigation buttons named 1 2 3 in plugin. in index page html mark up, can't find source code html tags related navigation elements when inspect element, can see ordered list bearing elements appears. please let me know hot see hidden html tags. need modify same

javascript - jQuery find all elements with class beneath parent, even in children elements -

here sample html: <div class="parent"> <div class="searchel"></div> <div class="searchel"></div> <div class="child"> <div class="searchel"></div> <div class="searchel"></div> </div> </div> and here jquery function: $(function(){ $(".parent>.searchel").each(function(){ $(this).html("found one"); }); }); the dom elements end so: <div class="parent"> <div class="searchel">found one</div> <div class="searchel">found one</div> <div class="child"> <div class="searchel"></div> <div class="searchel"></div> </div> </div> using jquery/javascript, how can search , find elements class .searchel beneath element .parent ,

android - How to update list item in sql? -

Image
this list activity: public class list extends actionbaractivity{ private customcursoradapter customadapter; private persondatabasehelper databasehelper; private static final int enter_data_request_code = 1; private listview listview; private static final string tag = list.class.getsimplename(); /** * called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.listview); databasehelper = new persondatabasehelper(this); listview = (listview) findviewbyid(r.id.list_data); listview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { log.d(tag, "clicked on item: " + position); intent intent = new intent(list.this, edit.class); person p = new person(); cursor cursor = (curs

How an Android Wear can keep the handheld wifi device activated? -

i've developed application on android wear. wear app communicating handheld device through messageapi. send command watch handheld device. in order make full process work, handheld device has connected wifi, handheld device (motorola moto x 2014 5.0) losing wifi connection when going in sleep mode wifi settings saying should never sleep when it's in standby it's more android os problem development, there workaround make work ? have considered attempting use wifi lock in order ensure wifi radio doesn't go sleep? http://developer.android.com/reference/android/net/wifi/wifimanager.wifilock.html

php - "Invalid parameter number: parameter was not defined" Inserting data -

update i making petty mistake when listing values. should have put ":username" , not ":alias". suppose answer credit question free reign wants it? or delete question? original i've been using yii's active record pattern while. now, project needs access different database 1 small transaction. thought yii's dao this. however, i'm getting cryptic error. cdbcommand failed execute sql statement: sqlstate[hy093]: invalid parameter number: parameter not defined here code: public function actionconfirmation { $model_person = new tempperson(); $model = $model_person->find('alias=:alias',array(':alias'=>$_get['alias'])); $connection=yii::app()->db2; $sql = "insert users (username, password, ssn, surname , firstname, email, city, country) values(:alias, :password, :ssn, :surname , :firstname, :email, :city, :count

android - Leafletjs map bounds changing with zoomlevel? -

i defined bounds map. on zoom level 15 geoposition displayed inside bounds inside viewport of android. keep geoposition , zoom level 17 , try locate position again. error message: position outside map (bounds). position not outside bounds outside viewport. // bounds var bounds = new l.latlngbounds( //south west [48.121831504767464, 11.584824599741356], //north east [48.132744242329231, 11.612690096879318] ); var map = l.map('map', { maxzoom: 18, minzoom: 15, // -------------------- problem ------------------------- maxbounds: [ //south west [48.121831504767464, 11.584824599741356], //north east [48.127287873548347, 11.612690096879318] ] }) .setview([48.127287873548347, 11.598757348310336], 15); l.tilelayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="http://osm.org/co

debugging - Error handling in R in RStudio -- don't invoke debugger? -

i'm trying create error messages similar can find in r package dplyr don't invoke rstudio's debugger , stop , print informative message. so example in rstudio if use: library(dplyr) group_by(blah) you informative error debugger not invoked "interruption" user minimal, realize issue , fix code. when use myfunc<-function(val){ if(val>3) stop("this error", call.=false) } myfunc(4) the debugger triggered , it's more unpleasant. how give nice error message out starting debugger? difference in how dplyr creating error messages , mine? did @ github repo wasn't sure.

java - How exactly works this Hibernate Many To Many relation implementation? Is it my reasoning correct? -

i pretty new in hibernate , have doubt related tutorial example implement manytomany use case. so have these 2 entity classes: 1) movie : @entity public class movie { @id @generatedvalue(strategy=generationtype.auto) private long id; private string name; @manytomany(cascade={cascadetype.persist}) @jointable( name="movie_actor", joincolumns={@joincolumn(name="movie_id")}, inversejoincolumns={@joincolumn(name="actor_id")} ) private set<actor> actors = new hashset<actor>(); public movie() {} public movie(string name) { this.name = name; } public set<actor> getactors() { return actors; } } 2) actor : @entity public class actor { @id @generatedvalue(strategy=generationtype.auto) private long id; private string name; @manytomany(mappedby="actors") privat

php - How I store business hours in a mysql table -

i'm working on website involving local restaurants, , 1 thing need store restaurant operating hours in mysql. data comes html php this. // eg: monday saturday 8am 10pm $_post['from'], $_post['to'], $_post['opening_time'], $_post['closing_time'] my sql table structure this. create table business_hours ( id integer not null primary key, restaurant_id integer not null, day integer not null, open_time time, close_time time ) my question getting 2 days users above opening , closing time. need insert business_hours table records between 2 days. eg: monday , friday (if opening , closing period of week) then need store these operating hours in table monday,9am,11pm tuesday,9am,11pm wednesday,9am,11pm thursday,9am,11pm friday,9am,11pm can tell me how can this? any idea appreciated. thank you.

java - Get all hierarchical root elements name for an xml child -

i have xml file below: <?xml version="1.0" encoding="utf-8"?> <!doctype xml> <root> <menu title="menu 1" url="root_pages.php?id=1"> <submenu title="sub 1" url="pages.php?id=1" /> <submenu title="sub 2" url="pages.php?id=2" /> <submenu title="sub 3" url="pages.php?id=3" /> <submenu title="sub 4" url="pages.php?id=4" /> <submenu title="sub 5" url="pages.php?id=5" /> </menu> <menu title="menu 2" url="root_pages.php?id=2"> <submenu title="sub 6" url="pages.php?id=6" /> <submenu title="sub 7" url="pages.php?id=7" /> </menu> <menu title="menu 3" url="root_pages.php?id=3"> </menu> </root> n

ios - Objective-C OpenGL Animation in Sample GLPaint code -

i digging sample project created apple: https://developer.apple.com/library/ios/samplecode/glpaint/introduction/intro.html it demonstrates how use opengl in objective-c. when start app "shake me" graph drawn stroke stroke, animation. want modify project make own app, in paintingview.m , want know how disable animation whenever call renderlinefrompoint:topoint: method (specifically, in playback: function, because in touchesmoved:withevent: animation unnoticeable). that is, want write renderlinefrompoint:topoint:animated: method such that, if put no after animated: , line drawn instantly. found it. all have is, in - (void)renderlinefrompoint:(cgpoint)start topoint:(cgpoint)end silence 2 lines @ end: // display buffer // glbindrenderbuffer(gl_renderbuffer, viewrenderbuffer); // [context presentrenderbuffer:gl_renderbuffer]; and after whole graph drawn onto buffer, call 2 lines display whole graph; appear instantly.

java - Precedence packagingExcludes and packagingIncludes maven war plugin -

recently configured application use "skinny wars" described on codehaus (title: solving skinny war problem). exclude jars war , add war and pom dependency ear. ran problem 2 jars. me logical thing include them in war file using packaginginclude. <plugin> <artifactid>maven-war-plugin</artifactid> <configuration> <packagingexcludes>web-inf/lib/*.jar</packagingexcludes> <packagingincludes>web-inf/lib/a.jar, web-inf/lib/b.jar</packagingincludes> </configuration> </plugin> using regex showed in de plugin documentation , answer didn't seem anything. excludes everyting. in source code of plugin found uses documentscanner of org.codehaus.plexus » plexus-utils. didn't quite understand how works. i thought no brainer. doing wrong? inclusion doesn't work when transitive dependency of c? edit: plugin version play role? using 2.6 version 2.1-alpha-2 used. try use

numpy - polynomial regression using python -

from understand polynomial regression specific type of regression analysis, more complicated linear regression. there python module can this? have looked in matplotlib ,scikitand numpy can find linear regression analysis. and possible work out correlation coefficient of none linear line? scikit supports linear , polynomial regression. check generalized linear models page @ section polynomial regression: extending linear models basis functions . example: >>> sklearn.preprocessing import polynomialfeatures >>> import numpy np >>> x = np.arange(6).reshape(3, 2) >>> x array([[0, 1], [2, 3], [4, 5]]) >>> poly = polynomialfeatures(degree=2) >>> poly.fit_transform(x) array([[ 1, 0, 1, 0, 0, 1], [ 1, 2, 3, 4, 6, 9], [ 1, 4, 5, 16, 20, 25]]) the features of x have been transformed [x_1, x_2] [1, x_1, x_2, x_1^2, x_1 x_2, x_2^2] , , can used within linear model. this sort of

typo3 - Fluid condition with ContainsViewHelper -

i use condition in fluid template: <f:if condition="{settings.image.classname} == 'lightbox'"> <f:then> ....do </f:then> <f:else> <f:if condition="{settings.image.classname} !== 'lightbox'"> <f:then> ....do else </f:then> </f:if> </f:else> it works fine if $settings.image.classname" "lightbox container" instead of "lightbox" not work of course. unfortunately not know how write condtion checks if $settings.image.classname contains "lightbox" or not. the instructions found here: viewhelper reference .however not know how apply that. add top of partial/content element {namespace v=fluidtypo3\vhs\viewhelpers} and change logic this <v:condition.string.contains haystack="{settings.image.classname}

java - ERROR SchemaUpdate:237 - near "from": syntax error -

i new spring, , wondering these errors mean? error schemaupdate:236 - hhh000388: unsuccessful: create table facebookposts (id integer, created_time timestamp not null, varchar not null, message varchar not null, picture_url varchar not null, post_id varchar not null, varchar not null, updated_time timestamp not null, primary key (id)) error schemaupdate:237 - near "from": syntax error i using spring social's facebook library recent posts , store them in sqlite database. my code follows: facebookcontrolller package adam.social.media.controller; import java.util.hashmap; import java.util.map; import org.apache.log4j.logger; import org.springframework.beans.factory.annotation.autowired; import org.springframework.social.facebook.api.facebook; import org.springframework.social.facebook.api.post; import org.springframework.social.facebook.api.impl.facebooktemplate; import org.springframework.stereotype.controller; import org.springframework.validation.bindingr

ssh - Android emulator doesn't start through xpra -

i use xpra under linux connect computer running android studio. problem every time try run emulator following error xlib: extension "glx" missing on display ":100". my laptop has amda6-6310 radeon r4. i've tried connect ssh -x no luck. android studio must using opengl rendering, need using xdummy , virtualgl

c# - DateTimeFormatInfo.AbbreviatedMonthNames order -

i have list of string represents abbreviated months: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec if these values in random order, how can order them above: jan, feb, mar ... ? list<string> months = new list<string>(); why don't use ordered list: list<string> months = enumerable.range(1, 12) .select(m => datetimeformatinfo.invariantinfo.getabbreviatedmonthname(m)) .tolist(); list contains: [0] "jan" [1] "feb" [2] "mar" [3] "apr" [4] "may" [5] "jun" [6] "jul" [7] "aug" [8] "sep" [9] "oct" [11] "dec" if want month names in current language use: datetimeformatinfo.currentinfo.getabbreviatedmonthname(m) if have list contains month-names , list contains duplicates or not complete want orde

c++ - Insertion sort task -

i trying solve problem in should sort increasingly array of numbers, take first k numbers sorted array , eliminate numbers repeating , write them on output. this code: #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int tab[n]; (int = 0; < n; i++) //taking n numbers input { cin >> tab[i]; } int j, element; (int = 1; < n; i++) //i using insertion sort { j = 0; while (tab[j] < tab[i]) j++; element = tab[i]; for(int k = - 1; k >= j; k--) tab[k + 1] = tab[k]; tab[j] = element; } (int = 0; < k; i++) //writing k smallest numbers without repetitions { if (tab[i] == tab[i + 1]) continue; cout << tab[i] <<"\n"; } cin >> n; return 0; } generally works , gives expected output, when uploading problem check correctness (i found problem on polish site), says "wrong anwser". cannot see errors here, mayb

When dragging Google Map Safari drags the whole page -

on a webpage have google map should draggable. when dragging google map (is official web component), safari drags whole website (like when dragging image). firefox , chrome work great (ie not tested). ideas? macbook pro , safari 7 , 8 tested. would awesome hear ideas. the drag of window can disabled via: window.ondragstart = function() { return false; } this solves issue (although of course dragging functionality causes bug disabled)

jquery validation for unique with dynamic name of input -

this question has answer here: jquery multiple input name[] validation 1 answer i have used following jquery code jquery.validator.addmethod("unique", function(value, element, params) { var prefix = params; var selector = jquery.validator.format("[name!='{0}'][name^='{1}'][unique='{1}']", element.name, prefix); var matches = new array(); $(selector).each(function(index, item) { if (value == $(item).val()) { matches.push(item); } }); return matches.length == 0; }, "value not unique."); jquery.validator.classrulesettings.unique = { unique: true }; $("#myform").validate(); $("#validate").click(function() { $("#myform").valid(); }); but due same input name not working properly, check here https://jsfiddle.net/bgzby/147/

asp.net - .net w2012 r2 custom error 404 not working -

this web.config code works under w2003 .net 4: <customerrors mode="on" defaultredirect="error.aspx"> <error statuscode="404" redirect="error-notfound.aspx"/> </customerrors> on w2012 r2 .net 4 code doesn't work: got no erros when calling page not found, iis shows 404.htm located in c:\inetpub\custerr\en-us, not error-notfound.aspx expected. try creating same error rules in system.webserver section of web.config file, example... <system.webserver> <httperrors errormode="custom" defaultresponsemode="executeurl"> <remove statuscode="404" /> <error statuscode="404" path="/error-notfound.aspx" responsemode="redirect" /> </httperrors> </system.webserver>

excel vba - Listview to retrieve the data from other file -

i want retrieve data in listview below path instead of same file. can please advise changes required in code. myfilenamedir = "c:\users\gshaikh\desktop\book16.xlsx" workbooks.open filename:=myfilenamedir, updatelinks:=0 set ws1 = worksheets("students") 'code retieving data same file. dim wkssource worksheet dim rngdata range dim rngcell range dim lstitem listitem dim rowcount long dim colcount long dim long dim j long set wkssource = worksheets("sheet1") set rngdata = wkssource.range("a1").currentregion each rngcell in rngdata.rows(1).cells me.listview1.columnheaders.add text:=rngcell.value, width:=90 next rngcell rowcount = rngdata.rows.count colcount = rngdata.columns.count = 2 rowcount set lstitem = me.listview1.listitems.add(text:=rngdata(i, 1).value) j = 2 colcount lstitem.listsubitems.add text:=rngdata(i, j).value next j next you add data listview rngd

php - Looping fails only iterate the last sequence of data in arrays -

i have lines of data on table shown below : +-------------------+-------+ | criteria | value | +-------------------+-------+ | pengalaman kerja | 4 | | pendidikan | 3 | | usia | 5 | | status perkawinan | 2 | | alamat | 6 | | pengalaman kerja | 3 | | pendidikan | 1 | | usia | 4 | | status perkawinan | 2 | | alamat | 1 | +-------------------+-------+ 10 rows in set (0.00 sec) when iterate through data above in php using mysqli fetch_object , want create new arrays end : array ( [pengalaman kerja] => array ( [1] => 4 [2] => 3 ) [pendidikan] => array ( [1] => 3 [2] => 1 ) [usia] => array ( [1] => 5 [2] => 4 ) , on.. ) i've been hardly trying , boiling head these array things , ended in code shown bel

Each 3rd Increment Loop PHP -

hi im looking way breakout of loop every 3 increments echo static string.this script echos "test" after each increment. want test after each 3rd increment. ideas ? my loop: <?php $i = 0; while (++$i < 100){ $x = $i - 3; if ($i+3) {echo $i . "<br>test<br>";} else{ echo $i . "<br>";} } ?> try below code <?php for($i=1;$i<=100;$i++) { if($i%3==0) { echo $i."test"."<br>"; } } ?>

python - Redis auto update cache -

i using django-redis cache , saving data in redis cache when update database don't find updated data in redis cache. my code : from django.shortcuts import render myapp.models import students rest_framework.views import apiview rest_framework.response import response django.core.cache import cache class userlistview(apiview): def get(self, request): data = cache.get('alldata') if not data: data = students.objects.values('cache_id', 'username', 'email') cache.set('alldata', data) in settings.py have following items in middleware class: middleware_classes = ( 'django.middleware.cache.updatecachemiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middle