Posts

Showing posts from April, 2012

android - Cordova camera plugin: Photo is not displayed when taking a picture -

i'm using cordova camera plugin , have encountered problem. when using : sourcetype: camera.picturesourcetype.photolibrary url: content://media/external/images/media/1517 when using url on <img ng-src="{{image}}" alt="description"/> works great but when removing sourcetype , taking picture phone returned uri this: file:///storage/emulated/0/android/data/com.ionicframework.myapp/cache/1454450218633.jpg and when uri returning image not displayed. ideas? on ionic framework , on android device. some code taking picture: function takephoto() { var defer = $q.defer(); navigator.camera.getpicture(function(imagedata) { defer.resolve(imagedata); }, function(err) { defer.reject(err) }); return defer.promise; } this method being called from: $scope.getimage = function() { cameraservice.takephoto().then(function(imagedata){ console.log(imagedata); $scope.image = imagedata; }).catch(funct

email - 'Simple' PHP script shows error in line 10, what have I done wrong? -

my freshly updated website has contact form php mail script based on form script here . the script saved on webserver, when data submitted, no mails sent there fault in line 10. i don't understand enough pinpoint error - can newbie out? i found temporary replacement using bravenet, i'd use unbranded version, if simple php scripts simple seem… my script (kontakt.php) looks this: <?php /* set e-mail recipient */ $myemail = "edw@rdturner.co.uk"; /* check form inputs using check_input function */ $name = check_input($_post['name'], "ihr name"); $email = check_input($_post['email'], "ihre e-mail-adresse"); $kontaktnummer = check_input($_post['kontaktnummer']); $thema = check_input($_post['them']); $message = check_input($_post['message']), "worum geht's?"); /* if e-mail not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) {

Selecting values simultaneously from different Tkinter Listbox widgets in Python 3.5 -

i want program work in way that: when click element either of 3 listboxes select adjacent values (example: if select 0 in first listbox, should select value "hello" in second listbox , "world" in third listbox thanks this question/answer managed make them move simultaneously the code following: from tkinter import * class fase3(frame): def __init__(self, master): frame.__init__(self,master) self.master=master self.frame=frame(self.master) self.txtm=label(self, text="example") self.txtm.grid(row=1, columnspan=5) self.txt1=label(self, text="1") self.txt1.grid(row=2, column=1) self.txt2=label(self, text="2") self.txt2.grid(row=2,column=2) self.txt3=label(self, text="3") self.txt3.grid(row=2,column=3) self.scrlb=scrollbar(self,orient="vertical") self.lista1=listbox(self,yscrollcommand=self.

ruby - How to Take Turn in Game from Player1 to Player2 and keep code DRY -

i creating monopoly game. searched way create take_turn method (or class) can switch automatically between player1 , player2 (and in future player3 etc.). looked answers here , found this full-on pdf on oop developing games haven't found answer specific question. here's code i' tdded , built several other objects. works @ moment player1, automatically repeat steps player1 player2 automatically without having manually (dry). class engine attr_reader :dice, :player1, :player2, :move, :board def initialize @player1 = player.new @board = board.new @player2 = player.new @dice = dice.new @move = move.new end def run 3.times roll_and_move print_current_balance player_action end end def roll_and_move dice.roll move.move(player1, board, dice.value) end def print_current_balance player1.balance end def player_action player1.buy(board.tile(player1.position)) end end wel

Swift, Loop through JSON returning Null -

i trying loop through list of bands have in json file (using swifty-json), reason when down looping through names, returns null. json small snippet of json [ { "band":{ "id":"1", "name":"the kooks" } }, { "band":{ "id":"2", "name":"the killers" } } ] swift code (_, value) in json { (_,band) in value["band"] { (_,bandname) in band["name"] { print("band name: \(bandname)") } } } the above code returns: band name: null band name: null band name: null band name: null when try this: for (_, value) in json { (_,brand) in value["band"] { print(band) } } i result: the kooks 1 the killers 2 can tell me issue is? since value associated key "name" simple string, want use: for (_, val

c++ anonymous constructor doing weird things -

this sample program shows how different constructor called depending on whether pass in local variable, global variable, or anonymous variable. going on here? std::string globalstr; class aclass{ public: aclass(std::string s){ std::cout << "1-arg constructor" << std::endl; } aclass(){ std::cout << "default constructor" << std::endl; } void puke(){ std::cout << "puke" << std::endl; } }; int main(int argc, char ** argv){ std::string localstr; //aclass(localstr); //this line not compile aclass(globalstr); //prints "default constructor" aclass(""); //prints "1-arg constructor" aclass(std::string("")); //also prints "1-arg constructor" globalstr.puke(); //compiles, though std::string cant puke. } given can call globalstr.puke() , i'm guessing calling aclass(globalstr); , creating local variable named globalstr of type aclass

php - very strange duplicate entry error -

this question has answer here: when use single quotes, double quotes, , backticks in mysql 10 answers i saving data repeatedly code. first time run it doesn't complain. second time says duplicate entry '$id' key 'primary' . echoing $id value , different everytime. table 5min old , guess can't corrupted. approach wrong? function insertdata($conn,$data){ $id=$data['id']; $name=$data['name']; $fp=$data['first_price']; $sp=$data['second_price']; echo "$id<br>"; echo "$name<br>"; echo "$fp<br>"; echo "$sp<br>"; $query = 'insert names values("$id", "$name", "$fp", "$fp")'; $result = $conn->query($query); if (!$result){ echo "nothing saved, sorry $

linux - Web Browsers Refusing to Render PHP Code -

i'm running on linux backtrack5 r3 via vmware on windows 7. on linux os have apache2, php5 , mysql14 installed. when make simple test.php file , try opening firefox 14.0.1, tries download file. not result after since have file :/ after searching around , finding no answers, decided install opera , try opening test.php on opera 12.14 linux i386. though didn't ask me download file, still didn't give me result wanted. didn't render php @ all, displayed plain text if viewing source code in notepad. for example, have file text.php containing <?php echo '<p>hello world</p>'; ?> . upon opening file in firefox, says "do wish save or open file test.php?" upon opening file in opera, instead of displaying "hello world", displays " <?php echo '<p>hello world</p>'; ?> ". am doing wrong? browsers don't execute php files, servers do. server delivering php file instead of ex

UITextField not type a word from keyboard in IOS -

i using uitextfield. not able type word keyboard. have tried set text textfield. can delete text, not able add or edit character. application works okay first time. but, first, have tried research wasn't able find helpful. newbie, please me. thanks you have provided insufficient data. please post questions more clarity. can append/add text in textfield following; textfield.text = [textfield.text stringbyappendingstring:@"stringyouwanttoadd"];

javascript - Getting values of ul into variable which are not hidden -

i have code: <div> john<input type="checkbox" onchange="javascript:hideshow(document.getelementbyid(this.value),this)" value="value1" checked="true"> jhonny<input type="checkbox" onchange="javascript:hideshow(document.getelementbyid(this.value),this)" value="value2" checked="true"> jack<input type="checkbox" onchange="javascript:hideshow(document.getelementbyid(this.value),this)" value="value3" checked="true"> </div> <ul id="numeric"> <li id="value1" data-value="info1"> <div id="info1" contenteditable="true">john</div> </li> <li id="value2" data-value="info2"> <div id="info2" contenteditable="true">jhonny</div> </li> <li id="value3"

javascript - Create a simple WYSIWYG web editor -

i'm new web development , i've never worked on web-related projects before, in scholar project thing, have create wysiwyg web editor scratch. till i've learned html, css , javascipt , intent attack jquery , read source code of web editor (like tinymce) me going , have idea of have do. problem tinymce way complicated me, need web editor simpler that. if u me name grateful : ) my advise start building simple , small, not trying understand other editor code. basically need textarea , bunch of buttons. textarea difficoult format, should use editable div, allows formatting text: <div id='fake_textarea' contenteditable></div> <input id="jbold" type="button" value="b"> then jquery magic, can 'boldify' selected text when clicking button. simplest way execcommand('bold') method , finds selected text , makes bold: $('#jbold').click(function () { document.execcommand('

How to analyse program's memory usage in Visual Studio 2010? -

is there way check memory has been allocated in program coded in vs 2010? i've been noticing recent program i've been making keeps using more , more memory on time without releasing any. also, there articles on code design teaches memory management? seem searching wrong terms on google keep getting useless results. there commercial tools such ants memory profiler or .net memory profiler or dottrace . secondly, take @ this msdn article . lastly, maoni stephens has many blog posts on garbage collection , memory management in .net. linked here .

matlab - How to know sampling frequncy of a sin(x) function -

consider following script plots sine wave. t = 0:pi/100:2*pi; y = sin(t); plot(t,y) grid on % turn on grid lines plot this gives me plot of sine wave. understand sine wave appears continuous, should discrete (my pc cannot store infinite no. of samples of continous signal), , matlab plot function kind of interpolation connect dots. in fact used stem instead of plot see sampled values (on time axis) of sine. now question there must sampling frequency used here. how that? hint appreciated. the sampling interval time interval between 2 consecutive samples of signal. the sampling frequency means how samples of signal have in fixed time interval, , reciprocal sampling interval. you declared: t = 0:pi/100:2*pi; so sampling interval π/100. means sampling frequency 100/π. if want exact units, you'll have determine time units t . if t in seconds, sampling frequency 100/π hz (1hz = 1sec -1 ). by way, matlab's plot connects sampling straight lines, th

Creating RGB color function, javascript error -

i'm trying create random colors using following function in javascript, getting error: syntax error: expected expression, got ')'. can tell me error message refers to? function addevents(){ $('table').mouseover(function(){ var color = "rgb("; (var i=0; i<3; i++){ var random = math.round(math.random() * 255); color += random; if (i<2){ color += ","; } else { color += ")"; }; $(this).css('color', color); }); you're missing "}" in code if (i<2){ color += ","; } else { color += ")"; } // <--- 1 missing usually debugger show line number error occured at

php - How to handle multiple-currency and custom quote item price on Magento? -

i have magento store 2 currency, , items in cart have dynamic price. succesfully calculate quote_item price, observer , setcustomprice , setoriginalcustom price $quote_item->setcustomprice($price); $quote_item->setoriginalcustomprice($price); and observer: <sales_quote_add_item> but have problem, when change currency of store, subtotal not update. how handle multiple-currency , custom quote item price ? i've had same issue on last week. using ->setoriginalcustomprice method fine single currency site, currency switching, rigidness means need update cart items , list price everytime currency switched, inefficient in opinion. i came more elegant solution. create module , within model section of config add this; <models> <catalog> <rewrite> <product>pixiemedia_customprice_model_product</product> </rewrite> </catalog> </models> counter int

c++ - Difference between GetExtendedUdpTable and netstat result -

i used code opened udp ports , application use every port. dword (winapi *pgetextendedudptable)( pvoid pudptable, pdword pdwsize, bool border, ulong ulaf, udp_table_class tableclass, ulong reserved ); mib_udptable_owner_pid *pudpinfo; mib_udprow_owner_pid *owner; dword size; dword dwresult; hmodule hlib = loadlibrary((lpcwstr)"iphlpapi.dll"); pgetextendedudptable = (dword (winapi *)(pvoid,pdword,bool,ulong,udp_table_class,ulong)) getprocaddress(hlib, "getextendedtcptable"); if ( !pgetextendedudptable ) { //printf("could not load iphlpapi.dll. application windows xp sp2 , up.\n"); return "could not load iphlpapi.dll. application windows xp sp2 , up.\n"; } dwresult = pgetextendedudptable(null, &size, false, af_inet, (udp_table_class)5, 0); pudpinfo = (mib_udptable_owner_pid*)malloc(size); dwresult = pgetextendedudptable(pudpinfo, &size, fa

Jquery: Adding Pages to a Document feature behaving wierdly when navigating from other pages -

i have simple collection of web pages written using jquery mobile framework. list of pages follows: main.html. page consists of link page called dummy.html. the dummy.html follows: <div data-role="page" data-theme="b"> <div data-role="header"> <h1>hod</h1> </div> <ul data-role="listview"> <li><a href="#glug">welcome glug meet</a></li> <li><a href="#">new trends in cs</a></li> <li><a href="#">about me</a></li> </ul> </div> <div id="glug" data-role="page" data-theme="b"> <div data-role="header"> <h1>glug</h1> </div> <div> <div class="lcontainer"> <img src="glug.png">

Using for/if to keep count in python -

i'm attempting create function finds how many times item occurs in function. have code below, ends counting items in list(6), not 1 want( in case 1). know i'm not returning anything, print me see answer get. def count(sequence, item): found = 0 in sequence: if item in sequence: found = found + 1 print found count([1,2,1,2,4,5], 1) try this def count(sequence, item): found = 0 in sequence: if == item: found = found + 1 print found count([1,2,1,2,4,5], 1)

java - How to Activate an alarm in android? -

am new android. making application runs on alarmmanager have searched many blogs.i got tutorials activating alarm few seconds,but in case wanted activate alarm @ specific time in day. me this? get difference between current time , specific time of day in miliseconds, add system.currenttimemillis() . put value in alarmmanager.set(type, miliseconds, pendingintent)

python selenium webdriver actions chains key enter is not working on some machine -

i need automate using webdriver send keys followed enter. enter not getting triggered. , happens on machine. tried increasing delays between sendkeys , enter. both machines failing , passing 1 have same python packages/versions. send_keys(keys.enter) not work on machines. ele = driver.find_element_by_xpath("xpath") ele.send_keys("test") time.sleep(2) actionchains(driver).send_keys(keys.enter).perform() i tried ele.send_key(keys.enter) , ele.send_key("\n"). noting working. tried increasing delays well. no luck i use pykeyboard key-related issues this. it's useful backup @ least. the pykeyboard package allows automate keystrokes , hotkeys various tasks. use when selenium gives me trouble finding appropriate elements or not letting me send_keys @ all. i wrote-up example morning on link here if you're interested: how implement key combinations (including modifier keys) in python? good luck.

Import pyglet on python -

i have downloaded pyglet.dmg file pyglet website , installed it. the folder on saved is: /developer/pyglet and on pydev editor state location want use by: import sys sys.path.append('developer/pyglet') import pyglet music = pyglet.resource.media('music.mp3') music.play() pyglet.app.run() but reason cant import: python sound.py traceback (most recent call last): file "sound.py", line 3, in <module> import pyglet importerror: no module named pyglet any idea on how make work? ok got it. i downloaded source files , compiled myself invoking: sudo python setup.py install and used sys import described in question.

java - Setting value to item from Spinner -

so created spinner , set 5 values in it. i'm building calculator , want every item spinner have value (they have text value, want them have number value). before that, user has enter tdee, don't bother that, it's number, , number multiplys value of selected spinner item. happends when button clicked, , value prints down in text view. the problem is, don't have idea how pass values spinner items. here's code: strings: <string-array name="razina_aktivnosti"> <item>sjedeći (malo ili bez aktivnosti, pretežno sjedeći posao)</item> <item>laka aktivnosti (lake vježbe/sport 1-3 dana tjedno)</item> <item>umjeren (umjerene vježbe/sport 3-5 dana tjedno)</item> <item>teške aktivnosti (teže vježbe/sport 6-7 dana tjedno)</item> <item>ekstremne aktivnosti (teške dnevne vježbe/sport fizički posao 2 x dnevno)</item> </string-array> xml: <?

internet explorer - This website does not have permission to use the Geolocation API -

i expericing error, while trying use geolocation api: this website not have permission use geolocation api the strange thing same website running fine on 1 systems(where ie.9 , i.e10 installed) , throws error on system i.e 9 installed. we tested on different systems throws error on particular system i.e9 installed. do need browser settings use api? what persmission require our website, use geolocation api? code : function geolocateuser() { // if browser supports geolocation api if (navigator.geolocation) { navigator.geolocation.getcurrentposition(geolocationsuccess, geolocationerror); } else { alert("your browser doesn't support geolocation api"); } } in case of success: function geolocationsuccess(position) { var usercurrentlatlong = new google.maps.latlng(position.coords.latitude, position.coords.longitude); } in case of error: function geolocationerror(positionerror) { alert(positionerror.m

dojo - Google Chrome web page refresh broken -

google chrome version 48.0.2564.97 m many intranet web apps fail load when hitting "reload" button (or hitting f5) while in app. the page loads fine first time, on page , refresh, page fails load. this issue started chrome v48 if "hard refresh" (shift f5), page reloads fine if server not send 304 javascript pages , forced send 200 (no cache control), page loads fine. all works fine in other browsers apps in question use dojo javascript framework (an older version of it) since initial load works fine, seems have way chrome handles client cached javascript files. any ideas? you've hit bug in chrome - https://code.google.com/p/chromium/issues/detail?id=570622 basically, when dojo xmlhttprequest load module , server responds 304, chrome passing empty response body rather pulling original response cache. unsurprisingly, dojo sees error. as noted, forcing server full 200 response fixes problem, i'm doing bit of apache httpd con

SPSS calculating 50 characters or less -

i new spss , 1 of tasks find out percentage of statuses 50 characters or shorter , skewness of distribution. compute tweetlen=char.length(tweet). execute. recode tweetlen (lowest thru 50=1) execute.

How to store double array data into string in php? -

i have data in double array in php. need store array data string. how can in php? new php. please me in regard. array follows: array ( [0] => array ( [id] => 100 [type] => test1 [count] => 8 [count2] => 8) [1] => array ( [id] => 103 [type2] => test2[count2] => 3 [count3] => 3 )) you can use implode() convert array string: http://php.net/manual/en/function.implode.php

Strange delay when querying WMI performance counter for the first time -

i querying wmi (win32_perfrawdata_perfproc_process class) , strange happens: first time query it, stops 50 seconds show answer. next times immediate. did see behavior? there avoid that? to reproduce this, open powershell window , type gwmi win32_perfrawdata_perfproc_process the first time run command, stops 50 seconds. second time immediate. bruno

PlayFramework validation error message customisation -

i have simple html form in play template field definition below: <div class="form-group"> <h3>description</h3> <label for="description" class="sr-only">description @for(error <- form("description").errors) { <p>@error.message</p> } </label> <textarea class="form-control" rows="4" name="description"></textarea> </div> in corresponding model, have @required annotation on description field this: @required(message="model.description") public string description; in conf/messages , following defined: model.description=please provide description when run application , supply empty value, empty value marked error framework. however, error message see (generated html view->source in browser): <label for="description" class="sr-only">description <p>model.description<

.net - Why does Console.ReadKey() block output of Console.WriteLine called in another thread? -

i have simple console app. static void main(string[] args) { doasync(); console.readkey(); } here doasync starts set of task , returns not waiting tasks' completition. each task writes console, ouptut not shown before key pressed. when use console.readline works fine. so i'm curious readkey() pecularities. from the documentation console.readkey() : the readkey method waits, is, blocks on thread issuing readkey method, until character or function key pressed. what acquire lock on console.internalsyncobject , prevents further operations on console. the console.readline() method not block thread in way. reading this article i'm guessing have .net 4.5 installed?

Java/Maven compilation failure (no suitable constructor found) -

i ran strange problem.. work on project use processbuilder class . on local machine (java6 , java7 tested) can mvn clean install & mvn assembly:single project without errors. want let project build travis-ci , ran following error error: no suitable constructor found processbuilder(string) full log file here.. javadoc processbuilder show me constructor. .travis.yml looks this language: java jdk: - oraclejdk7 - openjdk6 - openjdk7 after_success: - mvn assembly:single any ideas why build fails on travis-ci? thanks, f481 edit: locally i'm using maven 3, travis-ci (travis doc: "travis java builder use maven 3 build it.") pom.xml: https://github.com/multiservercontrol/minecontrol/blob/master/pom.xml , java code of first error: this.processbuilder = new processbuilder(""); full class available here edit2: specified source , target version maven compilation this: <plugin> <group

Spherical Law of Cosines different results between MySQL and PHP -

in our app using php calculate distance between coordinates using spherical law of cosines formula . though, isn't scaling well, refactored code calculate distance in mysql. when compare results between php calculation , mysql calculation, see major differences. lat | lng | php | mysql 47.457131 | -10.615383 | 1112.8 | 7604.07 61.265367 | 19.939854 | 1508.5 | 6905.3 56.64524 | -21.312707 | 1745.6 | 8589.3 37.028064 | 18.732122 | 1957.5 | 4954.33 38.823754 | -17.029437 | 2112 | 7856.57 70.687405 | 11.08298 | 2217.1 | 7969.53 all these distances calculated between these coordinates , (lat: 51.0363432, lng: 3.7351858). this how calculated in php public function getdistance($longitude, $latitude) { $pi = pi(); $dist = ( ( acos( sin($latitude * $pi / 180) * sin($this->latitude * $pi / 180) + cos($latitude * $pi / 180)

android - Activity SetContentView ResourcesNotFound Exception -

first of before wrote question had done search lot in website no solution found. problem title says; just 1 activity in program, activity cant find resources.. other it, every activity can find , works fine. tried everything; " clean , rebuild " ," switch workspace " , adding " com.myapp.r " top of activity, redownload or close/reopen eclipse " , many more.. checked bug happens in menu folder in "main.xml" ">" instead "/>" anyway.... please find solution. thanks this activity; import java.text.decimalformat; import java.text.decimalformatsymbols; import android.app.activity; import android.app.alertdialog; import android.content.dialoginterface; import android.content.pm.activityinfo; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class calculator extends act

indy10 - File download issue in TIdHttp using Delphi -

i'm using delphi 10 seattle developing android mobile application , desktop application. , per requirement need download mp3 file (may 1 5 mb) , need save file in mobile app created using delphi. , using iis, made path in public , file can accessed where. , server system has upload speed 512 kbps , download speed 1mbps. , i'm trying download file file server mobile using tidhttp. if i'm using mobile app in wifi (download speed: 8 mbps, upload speed: 2 mbps), file getting downloaded properly. but when i'm downloading file using mobile data (3g, download speed: 4 mbps, upload speed: 260 kbps), file not getting downloaded , showing exception 'read timeout'. have increased readtimeout 9999999. then, file not getting downloaded. when have tried open link in google chrome. then, file not playing. should need increase upload speed speed of system or changing code, can download properly. thanks in advance. try modern component thttpclient system

jquery - How to convert ASP.NET MVC 3 application to make all the Infragistics(Ignite UI) controls work? -

can tell me step step procedure needs followed make controls(infragistics(ignite ui)) work in asp.net mvc3 application. in website mention how use controls didn't find how convert. added combo box control project. errors.. scripts not being referred. surprisingly grid works fine there error in combobox.. needed know need refer.

How to update a DateField in Django from a json object -

i repopulate datefield in database ..for example "expirydate": "2016-sep-02", json value feb. 2, 2016 in database expirydate = models.datefield(auto_now=true, blank=true, null=true) this try loop through 2 objects in list 1 in french , 1 in english i'll try update expirydate field it's not proper value. for lang in [0,1]: jobs_lang = data[lang]['jobs'] job in jobs_lang: emploi= job.objects.filter(jobref=job['jobref']) if (emploi[0].expirydate != job['expirydate']): emploi[0].expirydate = job['expirydate'] emploi[0].save() if know date format going consistent, can use datetime module's strptime function parse date string: import datetime # date_format should match what's provided in json date_format = '%y-%b-%d' emploi[0].expirydate = datetime.datetime.strptime(job['expirydate'], date_format) here, date_obj object save via dja

ios - Why the property Size of UIImage is half of the real picture size? -

i have picture named pic of 268*381, have defined uiimage* tempimg = [uiimage imagenamed:@"pic"]; but when print nsstringfromcgsize(tempimg.size) it shows {134, 190.5} i can't understand principle of this, , grateful solver! from docs uiimage size : in ios 4.0 , later, value reflects logical size of image , measured in points remember pixels equal points times scale. or points pixels divided scale. your 268x381 size in pixels. output of nsstringfromcgsize(tempimg.size) in points. result of {134, 190.5} means image scale of 2. have image pic@2x.png .

Translating Python's formal language into Rail Diagrams -

i trying translate python's formal grammar ( https://docs.python.org/3/reference/grammar.html ) rail diagrams. website using http://www.bottlecaps.de/rr/ui helpful of , have changed many things hand fir proper notation create rail diagram there still 50+ lines incorrect , hard fix brand new this. there easier way changing hand? note website uses ebnf thanks time, write parser parses grammar, transform parse-tree required notation. the transformation simple: replace '#' comment introducers '//' replace ':' tokens '::=' replace '[' tokens '(' replace ']' tokens ')?' a suitable meta-grammar, in w3c notation , is grammar ::= rule+ eof rule ::= nonterminal ':' alternatives alternatives ::= alternative ( '|' alternative )* alternative ::= ( symbol ( '*' | '+' )? )* symbol ::= nonterminal | terminal | '(' alte

sql - How to update table with data from same table? -

there table in sql-server: track( id uniqueindeficater, track geography, the_geom geometry ) now want take track column , put data the_geom column converting geography geometry data type. this: geometry::stgeomfromtext(track.track.stastext(),4326) how can update column using data same table? something this: update track set the_geom = geometry::stgeomfromtext(track.stastext(),4326)

c++ - Cropping out an image from an existing image -

Image
i crop out image existing image. i've taken image , applied monochrome on threshold 98% using imagemagick (is doable in opencv?) the resulting image this: now image crop out image final image looks this: question how can in opencv? note, reason want crop image can use this answer part of text. if there no need crop out new image , instead concentrate on black part of image begin with, great. if text @ top , @ bottom regions want crop out, if @ same location solution easy: just set roi ignores areas : #include <cv.h> #include <highgui.h> int main(int argc, char* argv[]) { cv::mat img = cv::imread(argv[1]); if (img.empty()) { std::cout << "!!! imread() failed open target image" << std::endl; return -1; } /* set region of interest */ int offset_x = 129; int offset_y = 129; cv::rect roi; roi.x = offset_x; roi.y = offset_y; roi.width = img.size().width -

c++ - error LNK2001: unresolved external symbol "class ATL:: CTraceCategory -

i got same error per post below. error lnk2001 someone replied "atl uses atltrace @ debag-compilation. atlbase.h." mean? have add atlbase.h dependency? you need add atls.lib (for release configuration) or atlsd.lib ( debug configuration) in linker dependencies. right click project -> properties -> linker -> input -> additional dependencies there atls.lib (for release configuration) or atlsd.lib ( debug configuration) needs listed.

c++ - CRTP with derived class overloading the method -

i encountered problem crtp , can't have same method name (with different signature) in both base , derived class. example reproduce issue following : template <class t> struct base { void foo(){} void bar(){ static_cast<t*>(this)->foo(1,1); } }; struct derived : public base<derived> { int foo(int a,int b){ return a+b;} }; int test() { derived d; d.bar(); // works d.foo(1,1); // works d.foo(); // compilation error } i tried under various versions of gcc, clang , icc using godbolt anybody explain @ work here ? gcc output: in function 'int test()': 22 : error: no matching function call 'derived::foo()' d.foo(); // doesn't work ^ 13 : note: candidate: int derived::foo(int, int) int foo(int a,int b){ return a+b;} it has nothing crtp, derived::foo shadows base::foo , if had declared foo in inner scope. one way un-shadow base version, [1] place a using base<derived>::foo; in d

mysqli - Blank error in mySql stored procedure -

i trying write simple login stored procedure in mysql simple testing purposes. stumped why errors out. here code: create procedure prlogin (in userid varchar(20), in pw varchar(20)) begin select * userlogin inner join users on userlogin.id = users.userid userlogin.username = userid , userlogin.password = pw; end as mentioned above, code fails, offers no clue why. can me? thanks! viv the thing can find have not change delimiter, if don't change it, whole statement break @ last ; happens on line a.password = pw; . delimiter $$ create procedure prlogin (in userid varchar(20), in pw varchar(20)) begin select a.*, b.* userlogin inner join users b on a.id = b.userid a.username = userid , a.password = pw; end $$ delimiter ; by changing character of delimiter ( anything want , chosen chars $$ ), statement stop on new character , not on ; .

sql server - Merge multiple rows in SQL with tie breaking on primary key -

i have table data following key | | b | c --------------------------- 1 | x | 0 | 1 2 | x | 2 | 0 3 | x | null | 4 4 | y | 7 | 1 5 | y | 3 | null 6 | z | null | 4 and want merge rows based on column largest primary key being 'tie breaker' between values not null result key | | b | c --------------------------- 1 | x | 2 | 4 2 | y | 3 | 1 3 | z | null | 4 what best way achieve assuming data 40 columns , 1 million rows unknown level of duplications? using row_number , conditional aggregation: sql fiddle with cte as( select *, rnb = row_number() over(partition order case when b null 0 else 1 end desc, [key] desc), rnc = row_number() over(partition order case when c null 0 else 1 end desc, [key] desc) tbl ) select [key] = row_number() over(order a), a, b = max(case when rnb = 1 b end), c = max(case when rnc = 1 c end) cte group

c# - How does ASP.NET WebSecurity Authentication manages SQL Server connections? -

i have ef context in asp.net mvc project. if use websecurity have these questions in mind connection management sql server . does use same connection ef model request? (i think not) does create connection every request? if have 2 connections, 1 ef other websecurity. if use 1 connection (since can placed application_start()), if there many users surfing web @ same time? lock other user requests , create slowness? does make check database when sees [authorize] attribute on every request? (that makes pages users need logged in.) i appreciate internal mechanisms. note: please ignore connection pooling unless webmatrix/websecurity has internal connection pooling. thanks.

C++/C Programming etiquette on passing structures by reference -

i have been writing program has rather large structure passed reference few functions. however, there few other functions need access small pieces of information within large structure. it's not being edited, read. my question starts here. thinking of creating a second structure copies specific pieces of information needed , passing reference, rather passing entire structure reference. what wondering 2 things: 1) since passing large structure reference, there no performance impact. correct? 2) if 1) correct, bad etiquette passing around structure shouldn't edited (even though wouldn't edited, still i'm talking principle here). more specifically: i have configuration structure sets programs configuration calling function , passing structure reference. there information (process name, command line arguments) want use informative purposes only. i'm asking if it's bad practice pass around structure wasn't meant purpose of want use for.

jquery - Can I develop cross platform desktop applications that can run on windows, mac os x using visual studio 2015 and javascript? -

i need develop cross platform application can run on windows , mac using web technologies html5,css , jquery. using visual studio 2015 ide. you can use xamarin platfrom create native ios, android,mac , windows apps in c#. has visual studio plugin available can find here.

FNH Mappings with DB2 GeneratedBy Identity -

i trying map table identity key field. when try save error sql0803 duplicate key value specified insert libpjk/audit (auditid, auditdate, userid, keys, valbefore, valafter, fieldid) values (default, ?, ?, ?, ?, ?, ?) i'm thinking auditid should not appear in field list , value of default should not there either. don't know how this. sql table creation: create table libpjk.audit ( auditid integer not null generated identity (start 1, increment 1), auditdate timestamp not null, userid char(10) not null, fieldid integer not null, keys varchar(50) not null, valbefore varchar(50), valafter varchar(50), constraint libpjk.pk_audit primary key(fieldid)) here's how auditid defined in audit class: <required()> public overridable property auditid integer here's mappings: mybase.new() table("libpjk/audit") lazyload() id(function(x) x.auditid).column("auditid").generatedby.identity() references(function(x) x.auditfield).col

php - GA Event Tracking Not Working -

can see problem code here tracking button? fixed previous post , still nothing new code: <form id="constant-contact-signup2" action="http://www.truckingoffice.com/trucking-software-blog" method="post"> <div class="kws_input_fields"> <div class='cc_email_address kws_input_container'> <label for='cc_email_address' class=''> sign our trucking office newsletter <span class="req" title="the sign our trucking office newsletter field required">*</span></label> <input type='text' value='' size="30" placeholder='john.appleseed@apple.com' name='fields[email_address][value]' class='t required' id='cc_email_address' /> <input type="hidden" name="fields[email_address][label]" value=" sign our trucking office newsletter " /> <input type="hidden" name=&quo

wordpress - add action for unknown custom post type in plugin -

i developing plugin run function when custom post type published. name of custom post types unknown. have tried following code not working. $args = array( 'public' => true ); $pn_post_types = get_post_types( $args, 'names' ); foreach ($pn_opt_post_types $pn_opt_post_type){ $pn_action_cpt = 'publish_'.$pn_opt_post_type; add_action($pn_action_cpt,'pn_notification_publish'); } try code , run when post status changes published function post_published( $new_status, $old_status, $post ) { if ($new_status == 'publish' ) { // function perform actions when post status changes publish. } } add_action( 'transition_post_status', 'post_published', 10, 3 );

ios - View in popover is missing some, but not all, subviews -

i trying make view reveal inside popover. have done numerous times. however, reason time, popover appearing missing (but not all) of subviews. more specifically, view contains label, text field, button, , has navigation bar @ top. when revealed, displays label, not text field, or button. ive tried , without xib , results same. here declaration of popover.. (triggers on button click) if (popover) { [popover dismisspopoveranimated:no]; popover = nil; } // create settings view controller , display in popover loginviewcontroller *loginviewcontroller = [[loginviewcontroller alloc] init]; uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:loginviewcontroller]; // initialize popover, set parent view delegate , allocate popover's origin on screen popover = [[uipopovercontroller alloc] initwithcontentviewcontroller:nav]; popover.delegate = self; [popover presentpopoverfromrect:button.frame inview:button.superview permittedarro

javascript - ADT - Collapsbile queue -

implementing queue manager ajax requests. i've decided on approach instead of using promises because have access status of queued inspecting private variable queue. also, code needed bit smaller. this specific case in ajax requests fired in parallel want guarantee ordering on response. i think got want. have @ this: function asyncqueue() { var results = {}, queue = []; this.add = [].push.bind(queue); // add 1 token this.complete = function(token) { results[token] = arguments; while (queue[0] in results) { var t = queue.shift(); this.resolve.apply(null, results[t]); delete results[t]; } }; } asyncqueue.prototype.resolve = function() { console.log.apply(console, ["no resolver for"].concat([].slice.call(arguments))); }; usage: var manager = new asyncqueue(); manager.resolve = function(token, res) { // whatever need here console.log(res); }; manager.add(1,

angularjs - Angular ng-repeat inside loop -

i have following code in controller, have succeeded loop primary xml based data not succeeded pass secondary child (in second level tr tag want "list" category repeat) data in loop. angular.module('birdsapp.controllers', []). controller("birdsscontroller", ['$scope','$http', function($scope, $http) { $scope.namefilter = null; $scope.searchfilter = function (writer) { var keyword = new regexp($scope.namefilter, 'i'); return !$scope.namefilter || keyword.test(birdfinder[1]); }; //$http.get('http://localhost/rnd/js/angular/sample_app/app/driverstandings.json?callback=json_callback').success (function(data){ //$scope.driverslist = data.standingslists[0].driverstandings; $http.get('app/demo2.txt?callback=json_callback').success (function(data){ $scope.birdfinderlist = data.aadata; //console.log(data.aadata); //$scope.birdfinderlist2 = data.aadata.list; co