Posts

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

i'm writing console app uses lots of async methods; i've made async main method can await in: static void main(string[] args) { mainasync(args).wait(); } static async task mainasync(string[] args) { // can use await here } however, when exception occurs; debugger break me on .wait() call. not experience. is there can debugger breaks exception occurs rather here? i'm using vs2015 , targeting .net 4.6 if influences answer.

php - Issues outputting data after prepared statement with loops -

i having major difficulties figuring out doing wrong in while , foreach loops in code below. having tendency mix object-oriented , procedural mqsqli, everytime think have right, error. what doing wrong in loops have in code? right error warning: mysqli::query() expects parameter 1 string, full code try { $con = new mysqli("localhost", "", "", ""); if (mysqli_connect_errno()) { throw new exception("connect failed: %s\n", mysqli_connect_error()); exit(); } $cid = $_get['cid']; $tid = $_get['tid']; $userid = ( isset( $_session['user'] ) ? $_session['user'] : "" ); echo $cid . "<br>"; echo $tid; //prepare if ($stmt = $con->prepare("select * forum_topics `category_id`=? , `id`=? limit 1")) { $stmt->bind_param("ii", $cid, $tid); //$stmt->fetch(); if (!$stmt) { throw new exception($con->error); } } ...

c# - Why Does .NET 4.6 Specific Code Compile When Targeting Older Versions of the Framework? -

this question has answer here: does c# 6.0 work .net 4.0? 3 answers i have project targets older versions of .net framework (.net 4.5.2). installed visual studio 2015 (and therefore .net 4.6 on machine). noticed if use c# language features released in .net 4.6/c# 6, still compiles. if project's target framework < .net 4.6, shouldn't not compile: public string myexpressionbodyproperty => "1"; //auto properties new in c# 6 public string myautoproperty { get; } = "1"; private static void methodthatusesnameof(string filename) { if (filename == null) { //nameof released in c# 6 throw new argumentexception("the file not exist.", nameof(filename)); } } how can ensure i'm using .net language features work framework version i'm targeting? ...

javascript - How to pass a property by reference -

is there way pass object property function reference instead of value? es5 properties can have getters , setters. how pass variable uses getters , setters instead of result of getter? right have pass reference whole object, not single property want. is there way pass object property function reference instead of value? no. in fact doesn't make lot of sense "pass object property", notion of "property" doesn't exist without entity property of. if matter of encapsulation , not wanting leak full control, can creative. e.g., var obj = { sensitive: 'do not share me!', public: 'hi there', setpublic: function(val) { this.public = val; } }; function somefunction(setter) { setter('new value'); } somefunction(obj.setpublic.bind(obj));

computer vision - How to match orientation and scale of two different image of the same object in OpenCV? -

i have 2 images of printed circuit boards (pcb) both showing same pcb. differences between them lighting, scale , orientation (because take pcb images phone camera). now want use 1 image of pcb check if components of circuit assembled on identical pcb. is there convenient way check differences between 2 images of 2 identical pcb? btw, can add marks on pcb in opencv can correct orientation , scale of image. pcb = printed circuit board, right?!? you compute projective projective transformation or homography between matched points in both images. transformation can used match planes (like pcbs) , considers scale, rotation, shear , projective changes between images. it's simple method: select @ least 4 points , solve system of linear equations. take @ answer question on math se explains that. this opencv example uses (automatic) feature matching find corresponding image points , computes homography. the interesting derivation of transformation can found ...

html - Add copy button in Javascript -

i'm trying add button copy text textarea using zeroclipboard, however, when click button, nothing happens , when paste nothing has been added clipboard. var clip = new zeroclipboard( document.getelementbyid("btn4"), { moviepath: "https://rawgit.com/zeroclipboard/zeroclipboard/master/dist/zeroclipboard.swf" } ); clip.on( "load", function(client) { // alert( "movie loaded" ); client.on( "complete", function(client, args) { // `this` element clicked this.style.display = "none"; } ); } ); <div id ="right" style = "float:left; width: 10%; margin-left:185px; margin-top:35px"> <button id="btn4" data-clipboard-target="block2" name ="btn4" type="button" class="btn btn-success"><i class="icon-white icon-file"></i> copy</button> <script src="https://rawgit.com/zeroclipboard/zeroclipboard...

How to make Wordpress custom field input text translatable with qTranslate X? -

i have wordpress custom fields (i'm not using acf or other plugin this) , need translate them using qtranslate x in wp-admin. the fields created wp_editor working, don't know how make work default <input type="text"> other custom fields have. below, piece of code i'm using set variable , show field: $services = isset( $values['services'] ) ? esc_attr( $values['services'][0] ) : ''; wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' ); ?> <table> <tr> <td> <input type="text" name="services_title" value="<?php echo !empty($services_title) ? $services_title : ''; ?>" style="width: 100%" /> </td> </tr> </table> then, i'm saving with: add_action( 'save_post', 'hotelsavedata' ); function hotelsavedata( $post_id ) { // bail if we're doing a...

ios - Put a value out of a http request in swift -

to create uitableview have initialize number of rows, , in case depends on httprequest (sent framework httpswift). problem can't output number on return of request request.get("/media/", parameters: nil, completionhandler:{ (response: httpresponse) in if let err = response.error { println("error: \(err.localizeddescription)") return //also notify app of failure needed } if let data = response.responseobject as? nsdata { let str = nsstring(data: data, encoding: nsutf8stringencoding) var user = medias(jsondecoder(data)) var nbrows:int = user.medias.count } }) println(nbrows) //nbrows don't have value out of request func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return nbrows } the problem request performed in background thread , execution continues sequentially. when println(nbrows) nbrows variable not u...

Printing "\" to system with C not work? -

i have coded little app following: sprintf(command, "......sending string system......{} \;" printf("%s\n",command); system(command); break; the problem not whole string sent system, appears in shell apart '\' doesn't reason? sure silly mistake really, novice. thank you the \ escape character (you used print newline using \n ), if want print literal backslash, need use \\ : sprintf(command, "......sending string system......{} \\;" // ^^ // take note here

android - linking ViewModel to view using MvvmCross -

i using mvvmcross framework in xamarin android application , viewmodel inheriting mvxactivity , view inhering fragmentactivity . how link viewmodel view ? you can use generics connect viewmodel view. public myactivity : mvxactivity<myviewmodel> { //do stuff in here. setting content } a full example available here: https://github.com/mvvmcross/mvvmcross-androidsupport/tree/master/samples

c++ - Virtual Alloc failing with code 87 - Invalid parameter -

following code working on pcs, while on other giving error 87 - invalid parameter, can wrong? filesize = dwdllsize; buffer = virtualalloc ( null, filesize, mem_commit | mem_reserve, page_readwrite ); if ( !buffer ) { qmessagebox::warning(null,qstring("virtualalloc failed!"),qstring::number(getlasterror())); return -1; } i'm checking size 0, , file not bigger ~200kb.

Fast Algorithm for Multiple Projections in Matlab -

my problem of performing many low-dimension projections in matlab . have array z has dimensions (n,l,d) ; these parameters obtained follows. take input array of size n, n = [200, 200] , , n = prod(n) = 200*200 = 40,000 , d = numel(n) = 2 ; is, n number of points in discretisation grid , d dimension of input array (eg image, or plane height map). discretise possible heights (that program output - note height map mention above) l points, l = 32 . for each i = 1:n , j = 1:l , want project vector z(i,j,:) onto unit ball.* @ moment, have following naive code: z = reshape(z,[n,l,d]); z_norms = norms(z,2,3); = 1:n j = 1:l z(i,j,:) = z(i,j,:)/max(1,z_norms(i,j)); end end the function norms(v,p,dim) takes p norm of matrix v along dimension dim (in case outputting (n,l) matrix). i have various ideas how improved. 1 idea following: for = 1:n j = 1:l normsquared = sum(z(i,j,:).^2) if normsquared > 1 z(i,j,:) = z(i,j,:)/sqrt(normsquared) end end end note normsquared...

vb.net - Parse String to Date from a filename variable -

purpose move files in specified folders, in if date @ least day old today. i'm having trouble moving file since don't see archived. i'm assuming it's parsing date filename. vs2005 .net 2.0 sub copytoarchive(byval mydirpath) 'mydirpath = "c:\utresults\" 't:\utresults\press3\sv70206655\data07012015.txt example of txtfilelist dim txtfilelist string() = directory.getfiles(mydirpath, "*.txt", searchoption.alldirectories) 'search files in given path .txt type each txtname string in txtfilelist dim pressname string = txtname.substring(0, txtname.lastindexof("\")) 'take out file extension pressname = pressname.substring(0, pressname.lastindexof("\")) 'take out folder after press folder clean "press" pressname = pressname.remove(0, 13) dim folderexists string = path.combine("c:\writetest\", pressname) dim filename = txtname.remove(0, 4)...

android studio - Intellij Extract Inner Class -

how 1 using intellij or android studio extract public static inner class create new top level class? thank you. select class name. refactor > move or press f6 select "move inner class foo upper level"

node.js - deployed Nodejs REST API on AWS using elastic beanstalk - Error cannot find custom module -

i wrote first nodejs application. works fine on macbook when try deploy on aws elastic beanstalk,i below error . /var/log/nodejs/nodejs.log at function.module._load (module.js:310:12) @ module.require (module.js:365:17) module.js:338 throw err; ^ error: cannot find module '**./routes/userprofile**' @ function.module._resolvefilename (module.js:336:15) @ function.module._load (module.js:278:25) @ module.require (module.js:365:17) @ require (module.js:384:17) @ object.<anonymous> (/var/app/current/main.js:7:18) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) @ module.require (module.js:365:17) it seems nodejs not able resolve path custom module userprofile resides under routes directory.i have tried moving userprofile.js root, can still not resolve that. this code in main.js loads modules / load our modules var express = require('express...

r - How to prevent data.table to force numeric variables into character variables without manually specifying these? -

consider following dataset: dt <- structure(list(lllocatie = structure(c(1l, 6l, 2l, 4l, 3l), .label = c("assen", "oosterwijtwerd", "startenhuizen", "t-zandt", "tjuchem", "winneweer"), class = "factor"), lat = c(52.992, 53.32, 53.336, 53.363, 53.368), lon = c(6.548, 6.74, 6.808, 6.765, 6.675), mag.cat = c(3l, 2l, 1l, 2l, 2l), places = structure(c(2l, 4l, 5l, 6l, 3l), .label = c("", "amen,assen,deurze,ekehaar,eleveld,geelbroek,taarlo,ubbena", "eppenhuizen,garsthuizen,huizinge,kantens,middelstum,oldenzijl,rottum,startenhuizen,toornwerd,westeremden,zandeweer", "loppersum,winneweer", "oosterwijtwerd", "t-zandt,zeerijp"), class = "factor")), .names = c("lllocatie", "lat", "lon", "mag.cat", "places"), ...

Cant find wireshark's init.lua on my CentOS machine -

so i'm trying script working tshark on centos 7 server, i'm having problems. script works fine on windows laptop, put in plugins folder in appdata, can't find similar location on linux. used yum download wireshark, , have program in of folders, can't find either of init.lua files or plugins folder. when use tshark -v tells me built "with lua 5.1" know that's not problem, have no idea go here. suggestions? sadly centos, fedora, oracle linux, , rhel (as of today) not include init.lua in packaging of wireshark. "init.lua" must reside in wireshark directory (e.g. /usr/share/wireshark) before wireshark active lua scripts.

Adplus stop debugging process -

i have stupid question - how can stop debugging? i run adplus -crash -0 path -pid number -mss symbols .. then got message attached process. saw logs , mini dumbs in folder, want stop it. should do? not see commands in adplus detach process. how can it? can close cdb.exe command window or not? thanks you can break debugger (in cdb window, hit ctrl+c) , detach using qd command. you might want consider using procdump capture crash dumps -- more flexible, easy use, , supports both x86 , x64 processes in single package.

c# - asp.net Microsoft.Office.Interop.Word -

i trying rid of empty pages merge when users views , prints document. using dev express editor user inserts text make page on flow other page (rtf) , creats empty space. way stop happening>? here code: using system; using system.collections.generic; using system.drawing.imaging; using system.linq; using system.io; using system.text; using system.text.regularexpressions; using system.threading.tasks; using system.xml; using system.xml.linq; using documentformat.openxml.packaging; using microsoft.office.interop.word; using wordapplication = microsoft.office.interop.word.application; namespace documentmapper { public class xmldocumentmapper { /// <summary> /// use replace text elements included in template text. /// </summary> /// <param name="mergedocinfo"></param> /// <param name="html"></param> /// <return...

c# - SSIS 2012 - Impossible to use a custom dll -

i'm trying use custom .net dll i've developed using visual studio 2012. i've installed dll in gac folder no issue. i'm using script task object. when i'm trying instantiate class dll, i'm getting error saying it's impossible load script... here's blocking line : amadeuswebservices.queries q = new amadeuswebservices.queries(); i don't understand should do... version of .net framework used dll 4.0 version think there not issue that... please help! ! edit : error message generic ... : ssis dts script task has encountered exception in user code cannot load script execution nothing more.