Posts

Showing posts from February, 2015

java - Able to re-access a POST request after navigating away from the page. Why? -

i submit form on browser using "submit" button. set parameters sent post method. local server sends response html page via servlet using parameters in request. understanding, post requests cannot bookmarked. after navigate page response, can still access page when press button on browser. is because browser saves page? or understanding of post request incorrect? thank you!

asp.net mvc - Deploy MVC5 on IIS 7.5 windows 2008 R2 SP1 routing not work -

i've deployed mvc5 web application , runs on iis 7.5 routing beautiful url returns 404. in solution have 2 areas work main routing doesn't work well. the first routing works second routing returns 404 first route: routes.maproute( "default", "", new { controller = "login", action = "login" }, new[] { "mysolution.controllers" } ); second route: routes.maproute( "logout", "logout", new { controller = "login", action = "logout" }, new[] { "mysolution.controllers" } ); i tried install local computer (mvc 5, iis 7.5 , windows 7 pro) route works well. i've searched articles suggested update hotfix windows 2008 r2 here . when downloaded , installed update windows told me not allow apply hotfix.

java - How to retain the background color of selected item in list view? -

i having listview , edittext in activity. on selection of item in list view able change background diff color using 'android:listselector'. now, move edit text. on move edit text background color of selected item in list view changes default. how prevent this? <listview android:layout_width="wrap_content" android:layout_height="129dp" android:id="@+id/listview2" android:choicemode="singlechoice" android:listselector="#666666" android:layout_below="@+id/button7" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="34dp" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittext" android:padding="-11dp" android:width="300dp" android:inputtype="number"

php - How to change all cell's height and width in laravel excel -

i want apply height , width row's in laravel excel i able change height , width single row @ time using following code $sheet->setsize('a1', 25, 18); $sheet->setsize('b1', 25, 18); $sheet->setsize('c1', 25, 18); $sheet->setsize('d1', 25, 18); $sheet->setsize('e1', 25, 18); $sheet->setsize('f1', 25, 18); now question have thousands of rows how can manage ? i have following code \excel::create('users report'.$time, function ($excel) use ($arrusers) { $excel->sheet('users', function ($sheet) use ($arrusers) { // set margins $sheet->fromarray($arrusers, null, 'a1', true); $sheet->setsize('a1', 25, 18); $sheet->setsize('b1', 25, 18); $sheet->setsize('c1', 25, 18); $sheet->setsize('d1', 25, 18); $sheet-

ios - UICollectionViewCell adding badge -

Image
i want add badge uicollectionviewcell when user press long click on cell. here code : - (void)activatedeletionmode:(uilongpressgesturerecognizer *)gesture { if (gesture.state == uigesturerecognizerstatebegan) { nsindexpath *indexpath = [_favoritecollection indexpathforitematpoint:[gesture locationinview:_favoritecollection]]; uicollectionviewcell *cell = [_favoritecollection cellforitematindexpath:indexpath]; //m13badgeview *badgeview = [[m13badgeview alloc] initwithframe:cgrectmake(-12,-12, 24.0, 24.0)]; m13badgeview *badgeview = [[m13badgeview alloc] initwithframe:cgrectmake(200,200, 24.0, 24.0)]; badgeview.text = @"1"; [cell addsubview:badgeview]; [cell bringsubviewtofront:badgeview]; } } and how cell after long click : as can seen little red coin in cell badge , it's looking when change frame never change position, example : //m13badgeview *badgeview = [[m13badgeview alloc] initwithf

javascript - How to attach click event to a Bootstrap tabs? -

have problem bootstrap tabs. want create tab-based menu submenu. on tabs there mouseenter event attached, when enter tab mouse pointer there appear links in submenu. of tabs not need submenu, need attach them click event, recognizes tab clicked , redirects me page. attached click event code: $('#maintabpanel a').click(function (e) { e.preventdefault(); var $destination = $(this); if ($destination.hash === "#about") { window.location.replace("http://stackoverflow.com"); } }); but it's not working. can me? edit i've made example in jsfiddle: https://jsfiddle.net/romanus91pl/a12m71pf/5/ when click "bing link" anchors, redirect me bing.com site. want apply such event tab (when click it, should redirect me bing site). if understand problem correctly, this $(function () { $('#maintabpanel a').mouseover(function (e) { e.preventdefault(); $(this).tab('show');

sql - Get the minimum employees with a given job -

i have table: name null? type -------------------------- -------- ------------ employeeno not null number(4) ename varchar2(15) job varchar2(15) mgr number(4) hiredate date sal number comm number deptno number(2). i want department minimum employees have given job (for example employees 'analyst' job). can please me query? here key count of employee doing particular job in each department. in below query, achieved subquery. then, want department minimum no. of employee doing job ordered records returned subquery in ascending , select first result using rownum = 1 select deptno ( select count(*) no_of_emp , deptno employee emp emp.jobname = 'analyst' group deptno order no_of_emp asc ) rownum = 1;

How does Scala define a type of return value? -

how scala define type of return value? def sqrt = (x: int) => if (x > 0 && x < 4) x * x the return type code int => anyval . if change to def method = (x: string) => if (x.equals("abc")) x.concat(x) the return type string => any . why not anyref ? string object, better use anyref . wrong? since if expression has no else, unit returned if condition evaluates false. unit extends anyval int , in first case specific type anyval . since string extends anyref , specific type any in second case.

aurelia - need guidance on strategy for creating typescript public type definitions -

Image
i seeking guidance on creating public type definitions aurelia framework - aurelia on github here / aurelia website here / aurelia typescript samples on github i struggling following pattern: typescript compiler wont allow export declaration in ambient external module declaration references external module through relative external module name the repos use systemjs , jspm resolve aurelia-metadata. want use ambient module declarations expose types aurelia-metadata what i'm trying achieve same copying contents of origin.d.ts, resource-type.d.ts, , metadata.d.ts ambient module declaration in aurelia.d.ts. note ./metadata/index.js publishes public interface through exports, , precisely want expose in ambient module declaration i surrender , manually copy info compiler-generated origin.d.ts, resource-type.d.ts, , metadata.d.ts ambient module declaration, have been trying find way expose exported in index.d.ts, public api module in repo. the issue manual approach t

ios - Cutting an image to a CALayers content during an animation -

i have created subclass of calayer draw slice of pie chart custom color ( color ), startangle ( actualstartangle ), endangle ( actualendangle ) , image ( image )[this image should in middle of slice] animating not possible normal cashapelayer. layer drawn this: - (void)drawincontext:(cgcontextref)ctx{ cgcontextbeginpath(ctx); cgcontextmovetopoint(ctx, self.center.x, self.center.y); cgcontextaddarc(ctx, self.center.x, self.center.y, self.radius, self.actualendangle, self.actualstartangle, yes); cgcontextclosepath(ctx); cgcontextsetfillcolorwithcolor(ctx, self.color); cgcontextsetlinewidth(ctx, 0); cgcontextdrawpath(ctx, kcgpathfillstroke); if (self.image) { cgcontextdrawimage(ctx, [self getframeforimglayerwithstartangle:self.actualstartangle andendangle:self.actualendangle], self.image); } } these individual slices animated by: [catransaction begin]; cabasicanimation *coloranimation = [cabasicanimation animationwithkeypath:@&qu

vb6 check to see if textbox is empty -

there similar question c#, check if textbox empty , return messagebox? . there solution check if textbox empty https://www.daniweb.com/software-development/visual-basic-4-5-6/threads/414651/checking-if-textbox-is-empty , works if going check textbox in form. check textbox in form if empty or not. i've written code check if textboxes empty private sub checkempty() if text1.text = "" or text2.text="" blank = true end if end sub then added code command button private sub command1_click() checkempty if blank = true msgbox "a text box empty" else msgbox "text box has text" end if end sub the problem when start program gives output "text box has text" if there no text in text boxes. what wrong code? you need change procedure function returns value (i'd change name @ same time make more clear does). private function anytextboxempty() boolean anytextboxempty = text1.text = "" or text2.text = &

python - Does python3 typecast entered input() value? -

i writing raingauge precipitation calculator based in radius of raingauge. when run script, have error message: type de raingauge radius [cm]: 5.0 traceback (most recent call last): file "pluviometro.py", line 27, in <module> area_bocal = (pi * (raio_bocal * raio_bocal)) # cm.cm typeerror: can't multiply sequence non-int of type 'str' i using raio_bocal = input("type de raingauge radius [cm]:") data input. when using python2 typecasting automatic. how can have float entered value using python3 ? as mentioned in docs the function reads line input, converts string (stripping trailing newline), , returns that so need type cast float explicitly raio_bocal = float(input("type de raingauge radius [cm]:"))

javascript - Why does Angularjs Service Return a Character Array instead of an Array of Objects? -

i using service(.factory) hold array of objects/items gets updated multiple controllers , data pulled down each controller. each time add new array of data, push onto array. however, when attempt load array within controller can display view, returning character array makes impossible use ng-repeat iterate on values. // controllers.js angular.module('myapp.controllers', []) .controller('mainctrl', function($scope, mainservice) { $scope.mainitems = mainservice.all(); // why return char array? // count $scope.getcount = function(item){ return temporder.getcount(item); } // add item $scope.additem = function(item){ temporder.additem(item); return temporder.getcount(item); } }) .controller('secondaryctrl', function($scope, mainservice) { $scope.items = mainservice.all(); // why return char array? // count $scope.getcount = function(item){ return temporder.getcount(item); } // add item $scope.additem =

html - scrollbar covered by inner element with position absolute -

i havent found exact question. i have page set as <div id="page"> <div id="chrome"> <div id="element">bla</div> <div id="content">bla</div> </div> </div> #page has position:absolute, , dimensions #chrome has position:static, , overflow:auto #element has position:absolute, right:0, top:0 #content has large amount of content. scrolls within #chrome, whereas #element stays fixed on #page, without needing position:fixed. http://jsfiddle.net/pike/x4kshd3f/ in browsers - windows think - #element overlaps top of scrollbar of #chrome. is correct behaviour ? there way make scrollbar of static #chrome appear on top of absolutely positioned children ? ps .. there reason why structured this. cant use position:fixed. cant put scrollbars on #page. #chrome has static. it happens on other browsers/platforms too, , yes, i'm afraid intended behaviour. element

python - Tkinter Error on keypress -

code: import tkinter window = tkinter.tk() c = tkinter.canvas(window, height=400, width=600, bg='green') mid_x = 600 / 2 mid_y = 400 / 2 window.geometry("600x400") window.title("window") def ship_control(event): pass c.bind_all('<keypress-a>', ship_control) def start(): global ship rock_speed = 10 ship = c.create_oval(mid_x, mid_y, mid_x + 20, mid_y + 20, fill='red', outline='orange') button_start = tkinter.button(window, text='play', command=start) button_start.pack() c.pack() error: >>> >>> exception in tkinter callback traceback (most recent call last): file "c:\program files\python 3.5\lib\idlelib\run.py", line 121, in main seq, request = rpc.request_queue.get(block=true, timeout=0.05) file "c:\program files\python 3.5\lib\queue.py", line 172, in raise empty queue.empty during handling of above exception, exception occurred: traceback (

angularjs - How to instantiate a service dynamically? -

i have utils service heavy. want use of functions defined in on particular user action. service heavy want instantiate lazily(on user action). how achieve this? service module.service('utils', function (dep1, dep2) { this.method1 = function () { // } // other methods }); controller module.controller('appctrl', function ($scope) { // don't want inject utils dependency. $scope.processuseraction = function () { // if service not instantiated // instantiate , trigger methods defined in it. } }); markup <div data-ng-controller="appctrl"> <button data-ng-click="processuseraction()"> click me </button> </div> you can use $injector service services anywhere: https://docs.angularjs.org/api/auto/service/$injector . inject $injector controller, , whenever need service use: this worked fine me, service instantiated on $injector call, no error thrown. angu

html - Positioning radio buttons vertically at the same spot -

i'm trying position radio buttons @ same spot vertically while there label on left side. here desired outcome: http://oi58.tinypic.com/dnk8yh.jpg i'm having problems positioning second radio button same spot first one. like this? to align label top relative group of radio buttons, use vertical-align:top on label , place radio buttons in div; don't forget make inline-block , otherwise label , buttons stay on different lines: #radio-group{ display:inline-block } #label{ vertical-align:top; } <span id="label">label</span> <div id="radio-group"> <input type="radio" name="rg">radio1<br> <input type="radio" name="rg">radio2 </div>

php - Symfony clear cache and Maximum function nesting level of '100' reached -

this question has answer here: solution “fatal error: maximum function nesting level of '100' reached, aborting!” in php 20 answers hello trying run following console command console cache:clear --env=prod but got following error fatal error: maximum function nesting level of '100' reached, aborting! in vendor\symfony\symfony\src\symfony\bundle\twigbundle\loader\filesystemloader.php on line 66 executing --no-debug throw same error, when run following command console cache:clear --env=prod --no-optional-warmers the cache cleared , generated fine, twig templates not generated , generated on runtime when user navigate site, causing user wait longer usual. what can cause error?, seems error when generating views, why , how fix this?, thanks i have symfony 2.6 , php 5.5 this due xdebug.max_nesting_level php setting, defaults 100.

eclipse - Errors while porting project to Android Studio? -

i'm new android studio, i've been using eclipse 2 years. i've trying understanding these solutions. android gradle build error:(9, 0) gradle dsl method not found: 'compile()'. gradle dsl method not found: 'compile()' i can't work. here's says.. error:(17, 0) gradle dsl method not found: 'compile()' possible causes: the project 'clxxxii - pmv5' may using version of gradle not contain method. open gradle wrapper file the build file may missing gradle plugin. apply gradle plugin and 'dependencies' cannot applied '(groovy.lang.closure)' less... (⌘f1) inspection reports assignments incompatible types here's file it's giving error // top-level build file can add configuration options common sub-projects/modules. buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' } } allprojects { repositories

How to find out what version of maven I am using -

the following command in terminal not working (mac user) mvn --version i want find out version of maven have. know have maven because use time wondering command not working. for mac user follow below link: http://coolestguidesontheplanet.com/installing-homebrew-os-x-yosemite-10-10-package-manager-unix-apps/ then after follow directions enter brew install maven

ubuntu - Issue with my ca-certificates.crt -

(i on ubuntu 14.10. uname -r => 3.16.0-31-generic) apt-get update failed fetch https://get.docker.com/ubuntu/dists/docker/main/binary-amd64/packages server certificate verification failed. cafile: /etc/ssl/certs/ca-certificates.crt crlfile: none. git clone https://github.com/sdelements/lets-chat.git i can't clone - fatal: unable access 'https://github.com/sdelements/lets-chat.git/': server certificate verification failed. cafile: /etc/ssl/certs/ca-certificates.crt crlfile: none. docker run hello-world get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed unknown authority. ls /etc/ssl/certs/ca-certificates.crt -l -rw-r--r-- 1 root root 1964 mar 26 18:19 /etc/ssl/certs/ca-certificates.crt any clues appreciated. all of ca certificates missing /usr/share/ca-certificates/* re-installing package put them back if missing location, doing force reloading show 0 of 0: update-ca-certificates -f clear

CSS : Displaying all li item of a list with hover -

i have ul list (with 3 li items) first item displayed. my code simple , following : ul { list-style-type: none; border: solid #000000 1px; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; float: left; } /*hidding li item :*/ ul li { display: none; } /*but display 1st li item :*/ ul li.visible { display: block; } <ul> <li class="visible">item 1</li> <li>item 2</li> <li>item 3</li> </ul> i want display li items when mouse cursor on 1st item. have idea? you can use :hover pseudo-class: ul:hover > li { display: list-item; } ul { list-style-type: none; border: 1px solid; margin: 0; padding: 0; float: left; } /* hide list items */ ul > li { display: none; } /* display .visible ones, , list items when list hovered */ ul > li.visible, ul:hover > li { display: list-item; } <ul> <li class=&q

html - CSS property min-height causing margin issue? -

i trying make div has css-generated triangle attached bottom of it. works when height of div above set using css height property, when use min-height instead, results in there being unwanted gap, unable rid of using margin css properties. does have idea how rid of issue? .triangle { width: 0; height: 0; margin-right: auto; margin-left: auto; border-style: solid; border-width: 17px 10.5px 0 10.5px; } .divider1 { min-height: 80px; } .divider2 { height: 80px; } <div class="divider1" style="background-color: blue"> <h1>this 1 doesn't work</h1> </div> <div class="triangle" style="border-color: blue transparent transparent transparent"></div> <div class="divider2" style="background-color: green"> <h1>but 1 does?</h1> </div> <div class="triangle" style="border-color: green transparent transp

MongoDB Aggregation with sum of array values -

i have collection following data: { "_id" : objectid("5516d416d0c2323619ddbca8"), "date" : "28/02/2015", "driver" : "user1", "passengers" : [ { "user" : "user2", "times" : 2 }, { "user" : "user3", "times" : 3 } ] } { "_id" : objectid("5516d517d0c2323619ddbca9"), "date" : "27/02/2015", "driver" : "user2", "passengers" : [ { "user" : "user1", "times" : 2 }, { "user" : "user3", "times" : 2 } ] } and perform aggregation know passenger, times driver, in example be: user1: [{ driver: user2, times: 2}] user2: [{ driver: user1, times

How to get image size in KB while using Pillow-python before storing to disk? -

i'm using pillow image processing in python, url="http://www.image.com/some_image.jpg"; path = io.bytesio(urllib.request.urlopen(url).read()) original_image = image.open(path) any idea how can size of image file using pillow? i'd process image size before storing disk the answer going depend on format save image in, accurate solution along lines of: >>> out = io.bytesio() >>> original_image.save(out, format='png') >>> out.tell() # size in bytes if want size of uncompressed pixel data, need know how many bits in pixel. don't believe exposed in pillow, you'll have lookup value using original_image.mode , reference unpack.c . width * height * bytes_per_pixel . if image uses palette, gets more complicated , i'd recommend using first method.

android - How do I avoid network on main thread exception if I already use AsyncTask? -

it seems me m not calling url,network operations right mainactivity . i call url.connect() in class processdata i use doinbackground() i extend processdata class asynctask but exception still occurs: public class mainactivity extends actionbaractivity { private final string log_tag = mainactivity.class.getsimplename(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); processdata test = new processdata(); test.doinbackground("mysql") ; } //separate file processdata.java public class processdata extends asynctask<string, void, string> { public string createvalidurl(string s){ .....//code in method works fine } public string doinbackground(string ...params){ string validurl = createvalidurl(params[0]); httpurlconnection urlconnection = null; bufferedreader

c# - wait for static callback complete -

i've scenario: myapp calls cameracapture that fires callbackfunction after callbackfunction (i have photo captured) completes, more stuff. so have wait callbackfunction complete before executing function. how this? here code: private static readonly plustek_camera.pfnck_event staticfncamera = fnpfnck_event; public static bool fnpfnck_event(int ievent, int iparam, intptr puserdata) { //capture picture , save folder } //i implement callback start camera , fire callback staticfncamera var _status = cameractrl.start(cameractrl.scanmode, cameractrl.resolution, cameractrl.imageformat, cameractrl.alignment, staticfncamera); //waiting staticfncamera complete make sure image produced readpassporttext(); if understand correctly, have camera control provides asynchronous api start capturing image, want wait synchronously operation complete. if so, there lots of different ways accomplish you're trying do. 1 such way use taskcompletionsource : taskc

c# - Reading from FTP Server randomly returns a blank text file -

first, did try search answer problem failed find one. i've been making program in local text file , online text file, located in ftp server, automatically updates each other. text file contains list of names. application designed use different machines simultaneously , can add , delete names in list. with of additional algorithm, able merge local , online text files without causing problems when used offline , update when there internet connection (using additional local files). now problem, works 90% of time. however, downloaded text file ftp server returns blank text file though not. noticed happen when application having hard time checking internet connection (pinging google.com). result total erasure of list since application interpret "the other user using application deleted list". here method use download ftp server: public boolean downloadfile(string uri, string path) { ftpwebrequest request = (ftpwebrequest)webrequest.create(uri); request.us

c# - Vlc.DotNet - Show logging console/turn on file logging -

i'm playing new vlc.dotnet library wpf. it's available through nuget (vlc.dotnet.wpf), , git repository here: https://github.com/zebobo5/vlc.dotnet . the older videolan dotnet library (hosted here: https://vlcdotnet.codeplex.com ) had extremely useful capabilities related file logging, showing debug logging console, etc: // ignore vlc configuration file vlccontext.startupoptions.ignoreconfig = true; // enable file based logging vlccontext.startupoptions.logoptions.loginfile = true; // shows vlc log console (in addition applications window) vlccontext.startupoptions.logoptions.showloggerconsole = true; // set log level vlc instance vlccontext.startupoptions.logoptions.verbosity = vlclogverbosities.debug; i can't find these capabilities in new repo. documentation non-existent , sample projects light glean from. know if it's possible achieve kind of vlc logging using new vlc.dotnet library? i found correct location me in file (as of today 27.04.2015)

html - canvasses aren't staying inside div -

Image
hy, i have following problem: have parent div, within image , 3 canvasses. canvasses laying on top of each other, should, canvasses laying next parent div , image. illustrate problem, here image of how looks now: . as see, 3 canvases checker pieces , 2 other canvasses used drawing on top of pieces, aren't laying on top of checkerboard. html: <div id="container"> <div id="checkerboard" class="checkerboard"> <img src="../images/checkerboard.png"> <canvas id="canvas_checkers" class="canvas_checkers" width="650" height="650"></canvas> <canvas id="canvas_checkers_mouse" class="canvas_checkers" width="650" height="650"></canvas> <canvas id="canvas_checkers_selected" class="canvas_checkers" width="650" height="650"></canvas> </div> <div id=&q

ruby on rails - RoR: how to catch any route that didn't match route config and redirect to homepage -

for example in routes have such code: get "profile/:id" => 'profiles#show', as: :profile root 'articles#index' but how catch such kind of url , redirect home: i need catch non existing route. why need this? via seo rules. becouse example if enter url.com/?porn or url.com/profile?1&azaza - on page entered ugly url. need redirect home, "hacker" didn't not post illegal link's on resources... is real do? there 2 different cases need take care of a wrong path a wrong resource for first one, can add global match rule @ end of routes. match '*foo', to: 'articles#index' then should handle missing resources in controllers. eg def show begin @article = article.find(params[:id]) rescue redirect_to root_url end end of course if have multiple controllers , need repeat in many places should use more general approach. perhaps rescuing activerecord::recordnotfound on applicationcon

javascript - Callback or promise never is completed through EventEmitter -

i wrote simple event dispatcher application using node's eventemitter i have many events , works fine except one, don't know why promises or callbacks never completed this code dispatcher var eventemitter = require('events').eventemitter, requiretree = require('require-tree'), _ = require('lodash'); module.exports = { init: function(options) { var self = this; _.extend(options, { excludes: [] }); if (!options.path) { throw new error('you must specify `path` option'); } self.emitter = self.emitter || new eventemitter(); // require files in directory requiretree(options.path, { filter: filtermodels, each: loadmodels }); function filtermodels(filename) { return options.excludes.indexof(filename) === -1; } function loadmodels(model) { object.keys(model).fo

html - Make decoration div with border stretch down to top of sticky footer -

(note: question has not been asked anywhere on internet far can see, , i've been searching 2 days.) i have content div translucent background , decorative border around sits under site logo, won't stretch down meet top portion of footer stuck bottom of page position absolute. contact page couple sentences of text , simple contact form, therefore not enough content fill whole page. specifically, need div border around fill whole page, without creating vertical scroll bar, , meet top of absolutely positioned footer. the rest of site not use absolutely positioned footer there enough content consistently push footer far down. so, css properties acceptable here, table hack if necessary! js fiddle header { height: 44px; background: orange; } article { box-sizing: border-box; border: 1px solid red; } footer { height: 22px; background: green; position: absolute; bottom: 0; } <body> <header> header </he

PhoneGap Cordova Hammer.js HTML5/Javascript Canvas - "Tap" doesn't work properly -

i trying make app using phonegap/cordova/hammer.js via html5/javascript/canvas : var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); hammer(c).on("tap", function(event){ /*do simple*/ });` i using <canvas id="mycanvas"> tag in html. now problem: tap works once in while (maybe once every 5-10 taps), , find "hotspots" works multiple times in row, reason "hotpot" randomly changes after while. whats going on? also i'm trying use "pinch" can't work @ all. want simple "zoom in" => count++; "zoom out" => count--; i'm big amateur , appreciated. try creating div lives above canvas , attach tap event there instead. i've had problems in past events directly on canvas element.

sqlite - Android SQLitedatabase -

this question has answer here: what use of movetofirst () in sqlite cursors 5 answers why have move first item in code below? thought cursor contain 1 row since rowid primary key // fetch single reminder @suppresslint("newapi") public cursor fetchreminder(long rowid) throws sqlexception { cursor mycursor = db.query(true, database_table, new string[] { key_row_id, key_title, key_body, key_date_time }, key_row_id + "=" + rowid, null, null, null, null, null, null); if (mycursor != null) { mycursor.movetofirst(); } return mycursor; } there 1 cursor class. cannot known how many rows have. query not create different types of cursors querying single row or many. should call: curcor c = db.query(...); try { if (c.movetofirst()) { // have 1 result. //otherwise

Find implemented types from Generic interface in c# -

public class accountcreatedevent : eventbase{} public class accounthandler : ieventhandler<accountcreatedevent> { public void handle(accountcreatedevent event) { } } this handler class , want class c# code. want list of implemented classes ieventhandler type. public class account { public void onaccountcreated(eventbase accountcreatedevent) { var handler = typeof(ieventhandler<>); var events = appdomain.currentdomain.getassemblies() .selectmany(s => s.gettypes()) .where(p => handler .isassignablefrom(p) && handler.isgenerictype); } } but var events returning {name = "ieventhandler`1" fullname = "project1.ieventhandler`1"} as suggested praveen, using how generic interfaces handled type interfacetype = typeof(ieventhandler<>); assembly mscorlib = typeof(system.int32).assembly; assembly system = typeo

Running a nested while loop inside a foreach loop in Perl -

i'm trying use foreach loop loop through array , use nested while loop loop through each line of text file see if array element matches line of text; if push data line new array perform calculations. the outer foreach loop appears working correctly (based on printed results each array element) inner while loop not looping (same data pushed array each time). any advice? the code below #! /usr/bin/perl -t use cgi qw(:cgi-lib :standard); print "content-type: text/html\n\n"; $input = param('sequence'); $meanexpfile = "final_expression_complete.txt"; open(file, $meanexpfile) or print "unable open file"; @meanmatches; @regex = (split /\s/, $input); foreach $regex (@regex) { while (my $line = <file>) { if ( $line =~ m/$regex\s(.+\n)/i ) { push(@meanmatches, $1); } } $average = average(@meanmatches); $std_dev = std_dev($average, @meanmatche

java - How to add several panels with labels to a single frame? -

Image
i learning java swings, , creating 1 frame , want add more 1 panel different orientations, see below in code jpanet_1 , jpanel_2 each of them has specific dimensions set using setbound() method. the problem @ run time, "hello world" appears in second panel , not appear in first one. tried switch order in adding 2 panels main frame follows: jframe_2.add(jpanel_2); jframe_2.add(jpanel_1); but then, "hello world" added panel_2 only. please let me know how add 2 panels frame the statement "hello world" appears in both as see in code, specifying dimensions each panel wish add frame, add it, there other recommended way add panels frames? code: public class gui_01 { jframe jframe_1; jframe jframe_2; jpanel jpanel_1; jpanel jpanel_2; final jlabel jlabel_hello = new jlabel("hello world"); joptionpane joptions; final string[] options = {"yes", "no", "maybe"}; public gui_01() { // to

c# - Application settings Windows phone 8 -

i'm developing wp8 , need store custom app settings. found func 'applicationdata' it's not supported in wp8. can me? want store permanent variables provided user. example: country = ua news = 1 etc. you can use isolated storage or applicationdata.localsettings : var localsettings = windows.storage.applicationdata.current.localsettings; // create simple setting localsettings.values["examplesetting"] = "hello windows"; // read data simple setting object value = localsettings.values["examplesetting"]; if (value == null) { // no data } else { // access data in value } // delete simple setting localsettings.values.remove("examplesetting"); check link , link

memory - Is there any way to assign matrix views instead of copying matrices themselves in Matlab, like in NumPy? -

a = b(1, :) .. copies first row of b a. is there anyway create matrix view object, like frb = view(b(1, :)) to able refere view of matrix ? also, make so b(1, 3) = 123123; % set b(1, 3) 123123 illustration purposes frb(3) = 9999; % set b(1, 3) 9999 disp(b(1, 3)); % prints 9999 see numpy example that: http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.view.html you can use pointers in matlab point same matrix without making copy. here's simple example based on code using pointers in matlab first define class inherits handle class, matlab's pointer class. class properties store matrix. classdef handleobject < handle properties object=[]; % matrix end methods function obj=handleobject(receivedobject) %this constructor obj.object=receivedobject; end end end to declare matrix , matrix view, following m = handleobject(ones(5,5)); %the constructor passes matrix object property

c - How do I read in a string pass the newline character? -

i have read in file such as apple grape banana and store string, fgets reads newline , stops, reading in apple. how around this? or how can store 3 words separate strings? char* readfile(const char *filename) { file *infile; infile=fopen(filename, "r"); char **stringinfile; stringinfile = malloc(sizeof(char*)*50); char *data = fgets(stringinfile,50,infile); printf("%s", data); fclose(infile); return data; } this in c btw. fgets() reading one line each call, , sets file courser next line. if want read file, have iterate it. check if @ end, can check eof flag feof() . resulting in, me working: char* readfile(const char *filename) { file *infile; infile=fopen(filename, "r"); char **stringinfile; stringinfile = malloc(sizeof(char*)*50); while(!feof(infile)) { printf("%s", fgets(stringinfile,50,infile)); } fclose(infile); return stringinfile; } and, don't need variable data - f

c++ - Examples on template metaprogramming over constexpr? -

is there examples out there template metaprogramming better use new constexpr? i've understood, both constexpr , template metaprogramming have similar purposes, yet template metaprogramming not obsolete. there has examples template metaprogramming preferred on constexpr. shared thoughts on highly appreciated, thanks! constexpr provides true support compile-time computing in form of true c++ functions instead of functional-like template-based constructions (metafunctions). partially answer yes constexpr beats tmp on compile time computing , @ least on syntax no fp initiated people used c++. note i'm ignoring concerns compiler performance etc. on other hand, tmp still relevant, , way, type computing in c++ . there new approaches improve horrible tmp syntax, boost.hana template variables. despite syntax, still functional metalanguage separated "normal" c++. about type computing from 2 common tasks may ask c++ compiler (besides compiling), playing typ

sql - Insert or Update Table SQLite -

my table looks table (id, attribute, value, expires, static) i'd able update table new values of value, expires or static when entry id/attribute pair exists. create new entry every new id/attribute pair , every new id. i new @ using sqlite , have seen few posts similar problem sqlite - upsert *not* insert or replace not address i'm trying do. maybe approach , need different table format. please let me know thoughts/suggestions. just put logic program: bool ok = query.exec("update ..."); ... if (query.numrowsaffected() == 0) { ok = query.exec("insert ..."); ... }

python - How to get LBForum (0.9.22) to run -

i've installed , configured django app lbforum on windows 8.1 , cannot run. ultimate goal run alongside mezzanine, can't run on own. here's i've done: (as precondition following steps, have following c/c++ compiler installed support pip. http://www.microsoft.com/en-us/download/details.aspx?id=44266 . batch file vcvarsall.bat on path environment variable.) perform fresh install of python 2.78. used activestate distribution 64 bit. i uninstall , reinstall virtualenv because of bug per these instructions ( https://askubuntu.com/questions/400343/trying-to-create-a-python-virtual-environment-but-getting-oserror ) next activate new environment env\scripts\activate.bat next install lbform pip install lbforum fails because of "pil" install itself. pip install pil --allow-unverified pil --allow-all-external per installing pil pip . then install lbform pip install lbforum seems work fine reports success next use standard django commands creatin

javascript - Using var when declaring i in a for loop -

this question has answer here: “var” or no “var” in javascript's “for-in” loop? 9 answers i've seen javascript code has used 2 different ways of defining loop. for (var i=0;i < x.length; i++) but it's been for (i=0; < x.length; i++) the same thing has happened for-in loops for (var in x) and for (i in x) is there difference between declaring i var , saying i ? there advantages of doing 1 on other? 1 these right way this? can tell, both act same, there has difference. note: i'm not asking difference between for-in , for (i=0) without var declaration somewhere in function, references i i property of global object. risks sorts of unpredictable behavior if code in body of for loop invokes code (say, inside called method) modifies global i . note declaring var i in for loop initialization for (var = ...) is