Posts

Showing posts from March, 2011

javascript - element onClick not working with ngClick -

i have attribute directive following code: return { restrict: 'a', priority: 1000, link: function (scope, $element) { $timeout(function () { $($element).on('click','li', function ($event) { alert('hi'); }); }); } }; this html i'm trying use on: <ul some-directive> <li ng-click="somefunc()"></li> <li ng-click="somefunc()"></li> <li ng-click="somefunc()"></li> </ul> the thing on li elements using ngclick directives call other function. noticed long ngclick directives there directive onclick method never gets called. any way make both ngclick , onclick trigger? seems ngclick overriding directive's onclick. i'm still not quite sure why need 2 clickhandler? include <span> inside <li> , attach onclick or ng-click method on span. like: <li mydirective=""><span ng-click=&

java - Opening a new JFrame from a Button -

i want open new jframe clicking button (btnadd); have tried create actionlistener having no luck; code runs nothing happens when button clicked. methods in question last 2 in following code. appreciated! package advancedweatherapp; import java.awt.borderlayout; import java.awt.color; import java.awt.component; import java.awt.container; import java.awt.dimension; import java.awt.flowlayout; import java.awt.font; import java.awt.toolkit; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.boxlayout; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.swingconstants; import javax.swing.event.listselectionlistener; import weatherforecast.fetchweatherforecast; public class mainframe extends jframe implements listselectionlistener { private boolean initialized = false; private actions actions = new actions(); private javax.swing.jscrollpane jspfavouriteslist = new javax.swing.jscrollpane(); private javax.swing.defaultl

php - Creating Sql statements based on input from querystring -

i dynamically create sql statements execution based on url. them this: url (using htaccess): `http://www.example.com/us/california/sanjose` translates to: `http://www.example.com/index.php?country=us&state=california&sub=sanjose` then, in script do: $sql = 'select * table where'; if(isset($_get['country'])){ $sql .= ' country='.$_get['country']; } else { $sql .= ' country=us'; } if(isset($_get['state'])){ $sql .= ' , state='.$_get['state']; } if(isset($_get['sub'])){ $sql .= ' , sub='.$_get['sub']; } //pdo execute $sql this how it. there better, cleaner way this? create sql statements on fly based on url? how this? besides being vulnerable sql injections, there nothing wrong how going doing this. to prevent sql injections, use prepared statements: $stmt = $dbh->prepare("insert registry (name, value) values (:name, :value)"); $stmt->bindpar

Find difference between sequential rows mysql, no row ID -

objective: difference between value in row , value in next row (i'm using mysql). have table "events": step: timestamp: leave store 1400000000 buy hamburgers 1400000002 big party 1400000005 so result we'd expect is: 2 3 complication 1: table doesn't have id column, can't this: select (e2.timestamp - e1.timestamp) events e1, events e2 (e1.id + 1) = e2.id complication 2: i'm using database connection (splunk) won't allow me create or alter temporary tables (otherwise i'd add id column). hosed? thank you! use user variable hold timestamp previous line. select step, timestamp - @prevtime diff, @prevtime := timestamp events cross join (select @prevtime := 0) x order timestamp

Rewrite existing code with Java 8 Lambda -

i have 1 object, 2 conditions , need convert list. selectitem has getlabel , getvalue casting problem expect result -> list of employees object refer class (example: employees.class) the code looks like: public static final list<employees> onfilterobjectfromselectitems(final string query,final list<selectitem> selectitemlist) { final list <employees>result = new arraylist<>(); (selectitem sl : selectitemlist) { employees x = (employees) sl.getvalue(); if (x.getcode.contains(query) || x.getname.contains(query)) { result.add(x); } } return result; } try following code. list<employees> employeelist = selectitemlist.stream() .filter(x-> x.getcode().contains(query) || x.getname().contains(query)) .map(e->(employees)e.getvalue()) .collect(collectors.tolist());

xcode - Store/Associate NSMenuItems along with folder URLs -

so i'm new oo programming. coming webdesign background , having done design work or more or less intermediate scripting wherever needed in projects. being eager learn , still searching "right" way ;-) things guys do. not script kiddie mind tells me :d. sorry if super beginner question, rather grasp "right" concept start. i'm programmatically populating nsmenu nsmenuitems based on contents of folder located in documents directory. i'm iterating through subfolders of fellow, getting url of each , every one, extracting folder name using let folder = el.urlbydeletingpathextension?.lastpathcomponent and creating nsmenuitems based on names let menuitem = statusmenu.insertitemwithtitle(folder!, action: #selector(statusmenucontroller.dofancystuff), keyequivalent: "", atindex:0)" so far good. how store associated url along menuitem later use manipulating when action gets triggered? by clicking on item want action performed, needs f

reactjs - "Mask" Route react-router -

for example, have 2 routes: <indexroute component={index} /> <route path="/categories/:slug" component={catfilter} /> then in navigation component have: <nav classname="nav-main"> <ul> <li><indexlink to="/" activeclassname="active">work</indexlink></li> <li><link to="/posts" activeclassname="active">blog</link></li> <li><link to="/resume" activeclassname="active">resume</link></li> </ul> </nav> is there way accomplish having indexlink in nav component receive active class when i'm on root page , /categories/:slug page? it's understanding defining indexlink strictly connects root, if accurate, there different way go it? i'm new react-router i've read through numerous issues on github repository , can't seem find having similar issue. le

docker - Configure logstash output to splunk universal forwarder -

i'm using elk stack docker gather syslogs , interested inputting filtered logstash output splunk universal forwarder view data in splunk. have splunk universal forwarder installed on host elk docker sits at. i wondering suggestions there configuring logstash output splunk universal forwarder? i recommend go through docker volume; volume can mount host directory docker container('s); example; 1 docker container can create log, , other docker container can process log.

java - Connect QPushButton Jambi -

i'm pretty new java programming. wrote application listed below, can't connect button function. idea i'm doing wrong? package com.teat; import com.trolltech.qt.gui.*; public class application { public static void main(string[] args) { qapplication.initialize(args); qwidget mainwidget = new qwidget(); mainwidget.setwindowtitle("simple example"); qhboxlayout main_layout = new qhboxlayout(); mainwidget.setlayout(main_layout); qpushbutton new_action = new qpushbutton("working"); new_action.released.connect("tata()"); main_layout.addwidget(new_action); sumnum(5,3); mainwidget.show(); qapplication.execstatic(); qapplication.shutdown(); } private static int sumnum(int num1,int num2) { int sum = num1 + num2; system.out.println(sum); return sum; } private static void tata(){ system.out.

metadata - "Cannot access private field" despite @:access, but only outside FlxState subclass? -

running haxe 3.2.1. i building special needed access haxeflixel's internals, added above function needed it: @:access(flixel.flxg.keys) this worked, in context of override update() in flxstate subclass. then wanted move code higher level[1]. made new class (not subclass of anything), put code in function in new class instead, , moved @:access above new function. the new class won't compile, saying cannot access private field playback . why this, when have same @:access metadata had working before? [1] i.e. called via flxg.signals.preupdate run if flxstate subclass opened substate, pauses parent state's update() (which still want do.) for "i'm not sure how working before" department: don't use member directly in @:access (), instead use class' type. in case, flxg.keys flxkeyboard , following works: @:access(flixel.input.keyboard.flxkeyboard)

javascript - Is it a way to chaining chai.js's expects in nightwatch -

i'm want use chai.js assertion bdd library nightwatch.js . it's works ! code looks like: var expect = require('chai').expect module.exports = { 'login' : function (browser) { var login = browser.page.login() login.expect.element('@login').to.not.be.enabled login.setvalue('@email', 'some@some.com') login.setvalue('@password', 'pass') login.expect.element('@login').to.be.enabled login.click('@login') login.end() } } but . nightwatch provides pretty fluent interface own methods make able chain methods browser.setvalue('...', '...').click('...').end() . the question : can achieve chaining of methods if i'm use chaijs? explanation, want: module.exports = { 'login' : function (browser) { var login = browser.page.login() login.expect.element('@login').to.not.be.enabled .setvalue('@email', 'some@

Request limit for content works in local machine but not working after deployment to azure -

i have requirement upload image 20mb azure storage. had exposed api controller receive image base64 string. had set maxallowedcontentlength 20 mb in web.config. works fine in local machine once push azure test mobile services not working expected throwing model entity error. below in config changes used <system.web> <httpcookies httponlycookies="true" requiressl="true"/> <httpruntime targetframework="4.5" executiontimeout="9000" enableversionheader="false" maxrequestlength="20000000"/> <compilation debug="true" targetframework="4.5"/> </system.web> <system.webserver> <security> <requestfiltering removeserverheader ="true"> <requestlimits maxallowedcontentlength="20000000"></requestlimits> </requestfiltering> </system.webserver> could please give me solution

ubuntu - kvm setup for linux without default modules -

ok, kvm setup guide in this question not work me, this because using crouton trusty (14.04) chroot. apparently somewhere along line kvm modules not shipped in chromeos or crouton virtual images have knowledge of... since modules not present, not modprobable. how get, build, , deploy kvm, such starting point? point can utilize android studio's built in emulator ui? why not go clean, easy , simple ? if can install docker on environement, go simple solution : use docker launch prepackaged android studio supports emulation , connected devices (via usb). a dockerfile (image) can found here: https://github.com/hasuf/docker-dev-android . supports emulation & android connected devices references: https://hub.docker.com/r/kelvinlawson/android-studio/ http://reul.space/blog/running-android-studio-from-a-docker-dot-io-container/

javascript - Stuck in HTML5 Drag and Drop program -

i learning html5 unfortunately stuck in example. code executing problem drag , drop function not working. pasting code here. please check if find bug please tell me. thanx in advance :) <!doctype html> <html> <head> <style type="text/css"> #boxa, #boxb { float:left;padding:10px;margin:10px; -moz-user-select:none; } #boxa { background-color: #6633ff; width:75px; height:75px; } #boxb { background-color: #ff6699; width:150px; height:150px; } </style> <script type="text/javascript"> function dragstart(ev) { ev.datatransfer.effectallowed='move'; ev.datatransfer.setdata("text", ev.target.getattribute('id')); ev.datatransfer.setdragimage(ev.target,0,0); return true; } </script> </head> <body> <center> <h2>drag , drop html5 demo</h2> <div>try drag purple box around.</div> <div id="boxa" draggable="true" ondragstart="return d

azure - Unable to get Jenkins running as Windows Service working remotely -

i have setup jenkins on azure instance , working ssl after installing certificate , configuring jenkins use certificate. i have setup ports below in arguments in jenkins.xml file based on research: --httpport=-1 --httpsport=443 i able use https://localhost run jenkins, however, haven't been able browse remotely. server azure instance , has port 443 open. any suggestions? please check if port open in virtual machine and on azure portal on vm dashboard.

linux - How is NUMA represented in virtual memory? -

there many resources describing architecture of numa hardware perspective , performance implications of writing software numa-aware, have not yet found information regarding how mapping between virtual pages , physical frames decided respect numa. more specifically, application running on modern linux still sees single contiguous virtual address space. how can application tell parts of address space mapped onto local memory , mapped onto memory of numa node? if answer application cannot tell, how os decide when map virtual page physical memory of numa node rather local physical memory? a quick answer have program @ /proc/self/numa_maps. example output looks like: $ cat /proc/self/numa_maps # dumps current zsh numa_maps 55a4d27ff000 default file=/usr/bin/zsh mapped=177 n0=177 kernelpagesize_kb=4 55a4d2ab9000 default file=/usr/bin/zsh anon=2 dirty=2 n0=2 kernelpagesize_kb=4 55a4d2abb000 default file=/usr/bin/zsh anon=6 dirty=6 n0=4 n1=2 kernelpagesize_kb=4 55a4d

ruby - Filter keys of hashes -

i have these hashes in hashes variable: {:priority=>100, :iso_code=>"jpy", :name=>"japanese yen", :symbol=>"¥", :alternate_symbols=>["円", "圓"], :subunit=>"sen", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"&#x00a5;", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>""} {:priority=>100, :iso_code=>"zwd", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>"cent", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"$", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>"716"} {:priority=>100, :iso_code=>"zwl", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>&quo

caching - Why did I failed to speed up my program by making it cache-friendly? -

i used intel's ifort compile program there lot nested loops 1 below do i=1,imax j=1,jmax if (a(i,j).ne.1) cycle ..... ..... ..... enddo enddo as loops like do j=1,jmax i=1,imax if (a(i,j).ne.1) cycle ..... ..... ..... enddo enddo i noticed fortran stores arrays column-major order, put j loop outside of loop. it confused me that, there seems drop of performance. in contrast, tried put loop outsider of j loop others loops. there's still performance loss, slight however program p integer ::i, j, k, s real ::a(1000,1000) i=1,1000 j=1,1000 call random_number(a(i,j)) enddo enddo k=1,10000 j=1,1000 i=1,1000 if (a(i,j) .ge. 111) s = s+a(i,j) enddo enddo enddo print *,s end ifort -fpic -no-prec-div -o3 -xcore-avx2 a.f90 -o time ./a 10921820 real 0m2.221s user 0m2.221s sys 0m0.001s program p integer ::i, j, k, s real ::a(1000,1000) i=1,1000 j=1,1000 call random_number(a(i,j)) enddo enddo k=1,1

regex - Regular expression to align text -

i'm new here. seeking following done regex. i have mc tests lines this: q1 i.......go see doctor last week because ill. (a) must (b) must (c) had (d) should q2 could.......bought car didn't have enough money pay petrol. (a) had (b) have (c) have (d) can i line horizontal vertical. that's it. should this. q1 i.......go see doctor last week because ill. (a) must (b) must (c) had (d) should q2 could.......bought car didn't have enough money pay petrol. (a) had (b) have (c) have (d) can i can't seem make work. save me long long hours of work. appreciated. find: (\([b-d]\)) * this a-d answers, change d maximum possible answer replace with: \r\n$1 input: q1 i.......go see doctor last week because ill. (a) must (b) must (c) had (d) should q2 could.......bought car didn't have enough money pay petrol. (a) had (b) have (c) have (d) can output: q1 i.......go see doctor last week because ill. (a) must

mercurial - How to clone remote repo when using SSH alias -

i know ssh configuration works because can type ssh myalias.ssh , connect fine. i'm trying use command hg clone ssh://myalias.ssh//path/to/repo , getting remote: ssh: not resolve hostname myalias.ssh: no such file or directory is possible use ssh alias here? theory general principles mercurial work aliases created in ~/.ssh/config -- use feature time on linux , os x. works because mercurial doesn't try resolve hostname itself, rather depends on ssh (and passes error up, when encounters one). why error has ssh: part of prefix. bitbucket has help on setting aliases via .ssh/config . (in linked example, use manage 2 separate identities.) if created alias via mechanism, bash alias , not work because dependent on bash, mercurial not use. from mercurial source code i have gone through mercurial source code clone , including examining sshpeer.py , util.py ssh related parts, , mercurial indeed pass along hostname/alias ssh correct parsing / interpretati

c# - Access a WPF classes in UnitTest Project -

Image
i have wierd problem while trying unit test viewmodel classes in unittest project in visual studio 2012. created unittest project , added solutinon. added wpf project reference unittest project test viewmodel classes , methods. problem can't access viewmodel classes. lets type : [testclass] public class unittest1 { [testmethod] public void testmethod1() { mywpfproject.viewmodels.mainviewmodel } } it's acting there no mainviewmodel class in viewmodels folder. problem here ? this due declaring mainviewmodel class internal access modifier: namespace viewmodels { internal class mainviewmodel { ... } } the internal access modifier limits visibility defining assembly (in case, wpf project). if want access class external assembly (in case, testing project) can either change access modifier public or use internalsvisibleto attribute. the internalsvisibleto assembly attribute allows specify "friend" assembli

Ruby on Rails accessing back enum type in controller -

following product model: class product < activerecord::base enum status: { disable: 0, enable: 1 } end in controller: class productscontroller < applicationcontroller private def set_product @product = product.friendly.find(params[:id]) if(@product.status != "disable"){ @products } else { redirect_to root_path } end end here @product.status returning either disable or enable , how can use condition check product status? above @product.status != "disable" not working. thanks!! when have defined enum create methods directly connect enum. like disable?, enable? class productscontroller < applicationcontroller private def set_product @product = product.friendly.find(params[:id]) if @product.disable? @products else redirect_to root_path end end

c# - Make Picture boxes transparent, each overlapping the other with a corner? -

Image
tl;dr: @ picture below so i'm trying make little picture, , , people around me kinda out of ideas. i have table (the sitting+eating one) in middle (seen above), , people sitting around it. people round, isthe table. every person has own picturebox, use 1 picture, rotate it, , set image in next box. thep roblem is: pictureboxes of people on corners overlap table empty corner, in image there transparency there. should show table below it, instead shows background of form :( edit: backgrounds set transparent, form has marble background , white ("window") background colour. i put 1 person in , 1 in front, it's easy see: edit 2 (same ocmment): in last 2 days read question 10 times, , not 1 described exact problem has had actual answer. when trying push 1 of those, told should post new question. example: how make picturebox transparent? transparency in winforms kind of misleading, since it's not transparency. winforms controls mimic tra

c# - Reportmigration: CrystalReports to SSRS Parameter is applied but not used -

im trying migrate report crystalrreports ssrs. im new reporting , havent worked eighter 1 of reporting systems before. i have 1 main report, 2 subreports. working correctly , showing desired data. there 2 parameters, allfields-parameter , selectedid-parameter. allfields tells if empty fields should left out per datarow. selectedid tells datarow has been selected in viewer, report can specific data. when debug code, correct parameters applied. have absolutely no idea why still processing data, no matter select. this c# code beneath report: public hauptformularreportform(datatable themen, gespraechprotokolldao gespraechprotokolldao, grundlagendokumentedao grundlagendokumentedao, bool onlyfilledfiels, int themaid) : this() { themads = new reportdatasource("dataset1", themen); // fill themen display bewertungds = computeandfillbewertungs(themen); // display fields = empty ones reportparameter rp = new reportpar

authentication - How to authenticate external requests to WCF Web service? -

Image
i'm trying authenticate external requests wcf web service through passing of user credentials in soap header. using (usrservice client = new usrservice()) { client.credentials = new system.net.networkcredential("user 1", "password 1"); client.someremotemethod(); } i exception: unhandled exception: system.net.webexception: request failed error message: object moved unhandled exception: system.net.webexception: request failed error message: -- <html><head><title>object moved</title></head><body> <h2>object moved <a href="/nuilogin.aspx?returnurl=%2f0%2fservicemodel%2fsimp lecustomservice.svc%2fsoap">here</a>.</h2> </body></html> --. in system.web.services.protocols.soaphttpclientprotocol.readresponse(soapclien tmessage message, webresponse response, stream responsestream, boolean asynccall ) in system.web.services.protocols.soaphttpclientprotocol.invo

android - is it possible to see verbose of downloaded application of google play store? -

i want see error of uploaded application on google play store.it having issues , want debug issue. possible debug issue? in advance. you have implement hockeyapp sdk service allow track crashes happens application wherever on device. , when want deploy app play store should set attribute debbugable="false" in <application> tag in manifest nobody can trak application logs.

c++ - How much space does a Derived class cost?If itself and its base class both have virtual methods? -

i'm using vs2013(win32) testing following program: #include <iostream> class { virtual void funa(); }; class b { virtual void funb(); }; class c :public a{ int i; virtual void func(); }; class d :public b, c{ virtual void fund(); }; int main(){ std::cout << "size " << sizeof(a) << std::endl; std::cout << "size b " << sizeof(b) << std::endl; std::cout << "size c " << sizeof(c) << std::endl; std::cout << "size d " << sizeof(d) << std::endl; return 0; } and result size 4 size b 4 size c 8 size d 12 why sizeof(c) != 8 + sizeof(a), , sizeof(d) != 4 + sizeof(b) + sizeof(c)? a single base class virtual methods, hence single vtable pointer, hence 4 bytes on 32-bit platform yours. b a . c a plus 1 4-byte integer. note still has single base class ( a ) means still 1 vtable pointer

algorithm - Need Help in Contour Plot in Matlab -

i trying plot contour of shifted schwefel problem function keep having error: z must size 2x2 or greater. have searched on forum , information have helped little, not fix above error. information got forum lead me trying code: min = -50; max = 50; steps = 20; c = linspace(min, max, steps); % create mesh [x, y] = meshgrid(c, c); % create grid %o=-50+100*rand(1,2); %c = c - repmat(o,1,10); i=1:length(x) j=1:length(y) o=-50+100*rand(1,2); x=x-repmat(o,20,10); f = max(abs(x), [], 2); end end figure, contour(x,y,f); figure, surfc(x, y,f); now have error z, the value of f atleast 2x2 or greater. know f taking 1 input , therefore output one. tried having in nested loops, still giving me array of vectors not matrix of atleast 2x2. if input two, problem fine, problem is, 1 input. know how can make "f" output matrix of atleast 2x2 can plot z of contour? there few things note: 1.) jacob robbins pointed o

Getting data in c# using odbc connection -

i tried data in crystal report using odbc tally.erp9. con.open(); odbccommand cmd=new odbccommand("select ledger.`$_name`, ledger.`$_closingbalance`, ledger.`$_openingbalance` ashtamunicipalcouncil.tallyuser.ledger ledger", con); cmd.executenonquery(); dataset1 ds1 = new dataset1(); odbcdataadapter da = new odbcdataadapter(cmd); da.fill(ds1.datatable1); crystalreport1 crv = new crystalreport1(); crv.setdatasource(ds1); crystalreportviewer1.reportsource = crv; crystalreportviewer1.refreshreport(); con.close(); the above code gives me result gives blank records , crystal report viewer shows me no of pages contain.

angularjs - How to make angular material checkbox unchecked by default? -

how keep checkbox unchecked default? partial html view. <md-checkbox class="md-primary" ng-model="mailingsameaspermanent" ng-checked="false"><!--ng-change="click()">--> tick if mailing address same permanent address </md-checkbox> {{someinput}} i don't have in angular controller. initialize $scope.mailingsameaspermanent = false in conroller. or in html as <md-checkbox class="md-primary" ng-model="mailingsameaspermanent" ng-init="mailingsameaspermanent = false"></md-checkbox>

javascript - hoisting anonymous function expression which is an array item -

this code needs declare function (preferably anonymous) inside array ({argobj}) => {console.log( start );} , define later outside request = (function() {...}()); iif. request = (function () { const pathafter = { start: ['homepage', 'get', ({argobj}) => {console.log(`start`);}] }; return { go: (argobj) => { if(!pathafter[argobj.pathafter]) return; const path = pathafter[argobj.pathafter][0]; const method = pathafter[argobj.pathafter][1]; const url = data.domain + path + data.ext; http.call(method, url, (error, response) => { if (error) { console.log('error '+error); } else { pathafter[path][2]({response: response}); // <---- calls relevant method request.go({pathafter: path}); } }); return true; // if rms seccessful } }; }()); // function definition goes here... i not sure how this. thanks i not entirely clea

google container engine - What's the recommended way to replace a bad GKE node instance? -

using gcloud container clusters resize can scale , down cluster. find no way target specific compute instance vm removal when resizing down. scenario: our compute engine logs indicate 1 instance suffers failure dismount volume, kubernetes pod since long gone. cluster appropriately sized, , malfunctioning node serves containers on maximum cpu load. obviously i'd want new kubernetes node ready before kill off old one. safe resize , delete instance using gcloud compute , or there container-aware way this? however find no way target specific compute instance vm removal when resizing down. there isn't way specify vm remove using gke api, can use managed instance groups api delete individual instances group (this shrink number of nodes number of instances delete, if want replace nodes, want scale cluster compensate). can find instance group name running: $ gcloud container clusters describe cluster | grep instancegroupmanagers is safe resize , delete i

c++ - DLib : train_shape_predictor_ex.cpp -

i trying train shape predictor of dlib executing train_dlib_shape_predictor_ex.cpp on helen dataset described in code, place test images in face folder in current directory of shape predictor. when run code throws following exception: c:\train_shape_predictor_ex\release>train_shape_predictor_ex test exception thrown! error: unable open test/training_with_face_landmarks.xml reading. as no training_with_face_landmarks.xml , testing_with_face_landmarks.xml files available in helen dataset on following page : link there folder named annotation contains 1 text file containing 194 landmark points location each , every image in dataset. how convert file training_with_face_landmarks.xml . open 'training_with_face_landmarks.xml' file , observe structure. now, ask yourself: what changes between files? (hint: point data) what stays same? (hint: generic 'boiler plate' top , tail) open helen data - ask same again... your task parse data helen s

c++ - Why QTcpSocket received wrong data? -

i'm writing simple network application. client sending server message server printing in qtextedit , responding client . i'm using qtcpserver , qtcpsocket. there problem can't solve. receiving data quint16 + qtime + qstring sending qbytearrey. use quint16 receiving size of data blocks. , reason when client send server next block size: 16 (quint16 value) block size: 18 server get: next block size: 30073 (quint16 value) block size: 18 as can see, reason server getting qdatastrem wrong variable value , 30073. don't understand why? void widget::slotsendtoserver() { logtextedit->append("slotsendtoserver()"); qbytearray arrblock; qdatastream serversendstream(&arrblock, qiodevice::readwrite); qstring messagestr = messagelineedit->text(); serversendstream << quint16(0) << qtime::currenttime() << messagestr; serversendstream.device()->seek(0); serversendstream << (

r - scale_color_manual colors won't change -

Image
i trying change colors in plot manually but my code dummydata: df2=data.frame(y=runif(10), ontopic=c(f,f,f,f,f,t,t,t,t,t)) plot_right <- ggplot(df2, aes(y, fill = ontopic)) + geom_density(alpha = 0.5) + coord_flip() + theme(legend.position = "none")+ scale_y_continuous(breaks=seq(0, 1, 0.5))+ scale_color_manual(values=c("#999999", "#e69f00")) plot_right this returns standard colors. need change colors manual selection? using scale_fill_manual instead of scale_colour_manual should work. ggplot(df2, aes(y, fill = ontopic, colour= ontopic)) + geom_density(alpha = 0.5) + coord_flip() + theme(legend.position = "none")+ scale_y_continuous(breaks=seq(0, 1, 0.5)) + scale_fill_manual(values=c("#999999", "#e69f00"))

ios - How to activate "Installed" programmatically? -

Image
this uiview , want activate (with constraints etc.), when want, how that? don't want removefromsuperview etc. want learn installed function exact equivalent in terms of code. there 2 options 1) hide 2) removefromsuperview . if install or uninstall view storyboard , equivalent add/remove view. refer apple documentation says, a runtime object uninstalled view still created. however, view , related constraints not added view hierarchy , view has superview property of nil. different being hidden. hidden view in view hierarchy along related constraints. you can check 2 line of code, nsarray *arr = [self.view subviews]; nslog(@"arr %@",arr); swift: let array: array = self.view.subviews print("array \(array)") try installed , uninstalled. hope :)

java - My own code vs library -

this kind of unusual question developers reason want post here , hope adequate answer. here simple example: i wrote java function calculates distance between 2 geo points. function not more 50 lines of code. decided download source code ibm same thing when opened saw looks complicated , thousand lines of code. what kind of people write such source code? programmers? should use source code or own? i have noticed kind of thing lots of times , time time start wonder if me not know how program or maybe wrong? do guys have same kind of feeling when browse throught other peoples source code? the code found, exact same calculation? perhaps takes account edge cases didn't think of, or uses algorithm has better numerical stability, lower asymptotic complexity, or written take advantage of branch prediction or cpu caches. or over-engineered. remember saying: "for every complex problem there solution simple, elegant, , wrong." if dealing numerical software,

C# Class Add ID from one class to another -

i have 1 class named animal, name, type, gender, , have class named animallist, need know how can add animals animallist, class animal(im in console application): filename animal.cs class animal { public string name {get; set;} public string type {get; set;} public string gender {get; set;} public person(string name, string type, string gender) { name = name; type = type; gender = gender; } } and class animallist: filenameanimallist.cs class animallist: list<animal> { should add animals list } shouldn't better this? public new void add(animal value) { } instantiate animallist class somewhere(for example in main method) , add instances of animal class. for example: var animals = new animallist(); animals.add(new animal() { name = "", type = "", gender = ""});

java - Missing Expression in UPDATE -

Image
i'm required write couple of update queries parse data .csv file, not know how table works, don't have direct access database, got insert query 1 : insert lr_umbrales_valores (umcod_id, uvfec_dt, uvval_nm) values ((select umcod_id lr_umbrales lrcod_nm = ( select lrcod_id lr_lineas_referencia me_metrica_nm = ? , fecha_baja_dt null) , umtip_tx='s'), sysdate, ?) so i'm trying : update lr_umbrales_valores set uvval_nm = ? ( select umcod_id lr_umbrales lrcod_nm = ( select lrcod_id lr_lineas_referencia me_metrica_nm = ? , fecha_baja_dt null ) , umtip_tx = 's') , uvfec_dt = to_date(?, 'dd/mm/yyyy hh24:mi:ss')"); this gives me 'missing expression' error (ora-00936) this information tables got : table need update (its uvval_nm ) one, umcod_id when lrcod_nm same lrcod_id next table. lrcod_id when me_metrica_nm same ' ? ' parameter any tip in how appro

php - Should I use regex for registration/login forms? -

is enough use mysql_real_escape_string , strip_tags username/password inputs or should include regex? website uses deprecated mysql. for example: if (!preg_match( "/^[\w-\.]+@([\w-]+\.)+[\w-]{0,3}$/",$_post['email'])) { $error = "invalid email or password"; it's better validate email(inputs) before pass data mysql, fortunately, don't have use regex email validation, php have built-in function filter_var validation. faster regex validation. syntax be: if(! filter_var($_post['email'], filter_validate_email)) { //email not valid, $error = "invalid email or password"; }

javascript - Using *ngIf + template variables + loadIntoLocation to load components into view programatically -

i trying build login page login template replaced app+router-outlet. the html: <div class="contentwrapper" *ngif="!logedin"> login html.... </div> <div *ngif="logedin"> <div #header></div> <div class="contentwrapper"> <div #nav></div> <div class="main"> <router-outlet> </router-outlet> </div> </div> </div> the component export class appcomponent implements oninit{ logedin = 0; constructor( private _dcl:dynamiccomponentloader, private _elmref:elementref, private _httprest:httprest //http calls service ){} ngoninit(){} login(){ var vm = this; //simulated xhr settimeout(()=>{ vm.postloginsuccess() }) } postloginsuccess(){ var vm = this; vm.logedin = 1; settimeout(()=>{ vm.loadapp() },0); } loadapp(){ this._

php - Count how many duplicate and unique values I have in my array -

i have array this: array (size=6) 0 => array (size=1) 'test' => string 'aqhrmvbw7utgobjnzkqrp' (length=30) 1 => array (size=1) 'test' => string 'aqhrmu8hoojpnckufkgld' (length=30) 2 => array (size=1) 'test' => string 'aqhrmu7+bdwm7pmpzekew' (length=30) 3 => array (size=1) 'test' => string 'aqhrmu74stu6yp4gseee8' (length=30) 4 => array (size=1) 'test' => string 'aqhrmoqqaohugxj7t0et8' (length=30) 5 => array (size=1) 'test' => string 'aqhrmoqqaohugxj7t0et8' (length=30) now want count how many values there in array , how many uneven have. as can see last 2 results same in array , other 4 unique. want final result be: even: 2 uneven: 4 $results = array(); foreach($array $key => $value) { if(!isset($results[$value['test']])) $results[$value['te

WCF Custom FaultException thrown but ProtocolException Recived by Client -

i have wcf service coded throw custom faultexception under conditions. when hosted locally , on several servers executes excpected, custom fault thrown service custom fault caught client, on production , uat server custom fault thrown client recieves protocol exception (500 error). is aware of iis or sever setting effecting wcf server? issue driving me crazy i having similar issue, our server using third party web service, when client connects our server same machine, our server can catch fault exception, if client connecting on network our server can't handle fault exception, , getting "500 internal server error". i used sniffer see incoming data, , can see webservice sending fault exception in both cases, third party webservice have no control on it. the clients use .net remotting connect server. the solution: add remotingconfiguration.customerrorsmode = customerrorsmodes. off ; remoting server, reason affecting exceptions (the server) r

awk compare two files and print all match and non match with repetition on both files -

i have two files file1 1,david 22,jack 31,sharon 46,susan file2 770,jackson 779,david 776,sharon 775,david 771,sharon 777,susan i want compare file2 matches in file 1 file2 can contain more 1 occurrence of same name in column 2 matches colum2 in file1 output need below 779,1 775,1 771,31 777,46 have tried examples given stackoverflow not getting output example awk -f, 'nr==fnr{a[$1]=$2;}nr>fnr{if (a[$1]==$2)print $1,${a[$2]}' file1 file2 you can without awk, sort , join only: join -t , -1 2 -2 2 -o 2.1 1.1 <(sort -t , -k 2 file1) <(sort -t , -k 2 file2) # ^ ^ ^ ^---- select fields display ^ ^ # | | '--------- field in common file2 | | # | '-------------- field in common file1 | | # '------------------- field separator --------------------' | # field used sort file -------------'

mysql - Retrieve Data from Database by Passing an ID, c++ -

i trying fetch data database giving id number. database has 2 columns, first id, , second image path. if pass id=3, should return path corresponding id. i have tried that, stuck @ query. mysql_query (conn, "select * table" ); res = mysql_use_result(conn); row = mysql_fetch_row(res) id = atoi(row[0]); path = row[1]; printf("id: %i", id); printf("image path: %s", path); please help:) i think question not clear. first case, each row want display id/path: mysql_query (conn, "select * table" ); res = mysql_use_result(conn); while (row = mysql_fetch_row(res)) { id = atoi(row[0]); path = row[1]; printf("id: %i", id); printf("image path: %s", path); } other possibility, want 1 row because know id looking for. can decide retrieve missing column like: mysql_query (conn, "select path table id=id" ); in more complicated cases, lets if may have multiple rows, can keep first 1 example adding top

github - I've accidently pushed to a git repo with the wrong user account. How can I undo it or change the user? -

i have updated repo on github https://github.com/christill89/instaslider , computer signed in wrong github account details. latest 2 commits have been authored wrong account. is there way can either change author or undo last 2 commits , push again correct account? the repo , code correct, it's authored wrong account. thanks you can use patch files modify author (in ${editor} step update author): git format-patch -2 git reset --hard head~2 ${editor} *.patch git *.patch then push force rewrite commit history: git push -f

mp3 - NoDriver calling acmFormatSuggest on Azure -

i using naudio getting mp3 file information merging 2 or more mp3 files. works fine on localhost when publish site on azure throws error "nodriver calling acmformatsuggest" i assume trying use not installed on machine in azure - in case acm mp3 decoder. on client windows can pre-installed, not think server windows can have it. suspect not allowed run on azure web apps (it looks trying use that). so, suggest use virtual machine , install needed components here or use software-based. have found: new mp3filereader(stream,wave=> new dmomp3framedecompressor(wave)) it looks can used in case. please try?

How I can group the results by day in this query with SQL Server? -

Image
sql fiddle demo here i have table structure diary table: create table diary ( [iddiary] bigint, [userid] int, [idday] numeric(18,0), [isanextrahour] bit ); insert diary ([iddiary], [userid], [idday], [isanextrahour]) values (51, 1409, 1, 0), (52, 1409, 1, 1), (53, 1409, 3, 0), (54, 1409, 5, 0), (55, 1409, 5, 1), (56, 1408, 2, 0); and structure diarytimetable table: create table diarytimetable ( [iddiary] bigint, [hour] varchar(50) ); insert diarytimetable ([iddiary], [hour]) values (51, '09:00'), (51, '09:30'), (51, '10:00'), (51, '10:30'), (51, '11:00'), (52, '15:00'), (52, '15:30'), (52, '16:00'), (52, '16:30'), (52, '17:00'), (53, '11:00'), (53, '11:30'), (53, '12:00'), (53, '12:30'), (53, '13:00'), (54, '10:00'), (54, '10:30'),