Posts

knockout.js - Intercept route navigation and ask user "are you sure you wish to leave this page?" -

i have durandal app allows user update various bits of profile information. bits of data, user must click "save" indicate want save changes. in event user attempts navigate away current view unsaved changes, want intercept navigation , popup modal saying "you have unsaved changes--do want save them before leaving view?" however, in reviewing durandal router plugin documentation , haven't been able determine how intercept navigation requests in viewmodel. think want listen the router:route:activating event . but: i'm not sure , how setup listener this. i don't know how cancel navigation (so can instead pop modal) in event handler. you can in candeactivate event durandal has. var candeactivate = function () { // check if data has unsaved changes logic in haschanges() method if (haschanges()) { var msg = 'do want leave , cancel?'; return app.showmessage('message', 'confirm title', [...

scala - Slick 2.0: Cannot insert java.sql.Timestamp into a table using HList -

i'm getting class cast exception in script , cannot why. error is: java.lang.classcastexception: java.sql.timestamp cannot cast scala.product here's code: import java.sql.timestamp import scala.slick.driver.mysqldriver.simple._ import scala.slick.collection.heterogenous._ import syntax._ import org.joda.time.datetime import db.dealdao import datetimeimplicits._ // implicitly convert datetime timestamp (and seems work) object datetimeimplicits { implicit def datetime2timestamp(value : datetime) = new timestamp(value.getmillis) } object tryhlist { class tests(tag: tag) extends table[timestamp :: hnil](tag, "tests") { def timecol = column[timestamp]("time_col") def * = (timecol :: hnil) } def tests = tablequery[tests] def createtable = dealdao.db.withsession { implicit session => tests.ddl.create } def insert(dt: datetime) = dealdao.db.withsession { implicit session => tests += (dt :: hnil) } } object ma...

mysql - Prevent other users from calling php file -

here have php code: update: <?php $pdo=new pdo("mysql:dbname=gmaestro_agro;host=localhost","gmaestro_agro","pass"); $statement=$pdo->prepare("select * stat"); $statement->execute(); $results=$statement->fetchall(pdo::fetch_assoc); $json=json_encode($results); echo $json; ?> i call code ajax data mysql database, when go on domain http://mywebsite.com/get_json.php code give information of database. how can prevent other users calling this, js ajax code can call it? at least should check whether post request made: if ($_server['request_method'] === 'post') { // code } that way not fill database empty entries every time page requested via get . your code allows anonymous posts. possible designed way, if not, should check logged-in user. use sessions that. apart should validate individual fields, might empty others have filled before insert. edit: can set session variable ...

java - Why would this only print the first line? -

import java.util.scanner; public class parsethetweet { public static void main(string[] args) { // todo auto-generated method stub scanner thescanner = new scanner(system.in); string tweet = ""; system.out.println("enter tweet"); tweet = thescanner.nextline(); system.out.println(tweet); } } this program have far, simple , have feeling i'm doing easy wrong. want output variable tweet same input, keeps printing first line. ex. input: #typ offer; #det free essential supplies 4 evacs pets.; #loc 2323 55th st, boulder; #lat 40.022; #lng -105.226; output: #typ offer; #det free essential supplies 4 evacs pets.; #loc 2323 if want read more lines one, need call thescanner.nextline() in loop, e.g.: while (thescanner.hasnextline()) { string tweet = thescanner.nextline(); system.out.println(tweet); }

typescript - Full Definition Of A "Common Root" -

enumerations, modules , interfaces merged if multiple blocks defined within same common root. can't find official definition of common root in language specification. is more complicated than... either: the module, or the global scope (the complication can think of if module merged, members of parts of module being merged have same common root, zips go). is there other kind of common root? module x { export interface y { name: string; } } module x{ export interface y { age: number; } } // x.y has both name , age properties it's "common root" in graph theory sense of term, since combination of typescript modules or programs forms tree of declarations (because declaration has 1 parent). second half of spec section 2.3 ("declarations") defines how tree constructed in terms of establishing parent relationships. i think relevant phrase in spec here declarations merge if have "the same qualified...

python - Subclassed QStyledItemDelegate ignores Stylesheet -

i'm trying subclass qstyleditemdelegate remove focus rectangle in qcombobox . even though i'm calling base implementation of paint function , nothing else, result different. looks if parts of style-sheet influence bounding box of item taken consideration. class pstyleditemdelegate(qstyleditemdelegate): def __init__(self, *args, **kwds): super(pstyleditemdelegate, self).__init__(*args, **kwds) def paint(self, *args, **kwargs): qstyleditemdelegate.paint(*args, **kwargs) what have paint unmodified qstyleditemdelegate ? as suggested tried replacing pyside pyqt4 , works, appears bug. update pyside 1.1.2 1.2.1 result same. unfortunately switch breaks other parts of code, if there no other suggestions i'm going accept answer. edit bug tracked here

c++ - Find X and Y coordinates of point in relation to the whole image -

i trying find nose tip landmark inside 2d image. it's not working 100% correct, first approach satisfy me. vector<rect> noses; vector<rect> faces; vector<rect> eyes; mat frame_gray; mat matched_frame; //frame matched face mat gray; rect region_of_interest; cvtcolor(frame, frame_gray, color_bgr2gray); face_cascade.detectmultiscale(frame_gray, faces, 1.1, 2, 0 | cascade_scale_image, size(30, 30)); (int = 0; < faces.size(); i++) { point pt1(faces[i].x, faces[i].y); // display detected faces on main window - live stream camera point pt2((faces[i].x + faces[i].height), (faces[i].y + faces[i].width)); rectangle(frame, pt1, pt2, scalar(255,0 , 0), 2, 8, 0); cvtcolor(frame, frame_gray, color_bgr2gray); equalizehist( frame_gray, frame_gray ); //nose tip detection rect noseroi1; noseroi1.x = (faces[i].x); noseroi1.y = faces[i].y + (faces[i].height/2.5); noseroi1.width = (faces[i].w...