Posts

Showing posts from April, 2014

save - Saving Python code in Anaconda -

i having problems saving python code in anaconda. write code, go file save file saved when open empty, no code. read idle not save code, erases when close anaconda. i have searched in books, youtube tutorials , nothing. not find topic. can find advanced topics, 1 no. thank help! best, tiberiu this depends on os on. can speak experience. highly recommend using pycharm ide. but more fundamentally that, lets talk saving files. on mac os x or ubuntu 14.04 (or like), lets want create python file. 1 way following in terminal: nano hello.py this opens text editor instructions use on bottom of screen. on windows do: notepad hello.py in both cases write code. lets content was: #content of hello.py print "hello world!" then need save file , execute python. brings python issue. once have installed anaconda, , assuming there no other python installations on computer. anaconda python should active python on system. suffice there other ways of savi

c++ - Why virtual destructor? -

i going through code,plan adapt research.so header file looks this #ifndef spectralclustering_h_ #define spectralclustering_h_ #include <vector> #include <eigen3/eigen/core> class spectralclustering { public: spectralclustering(eigen::matrixxd& data, int numdims); virtual ~spectralclustering(); std::vector<std::vector<int> > clusterrotate(); std::vector<std::vector<int> > clusterkmeans(int numclusters); int getnumclusters(); protected: int mnumdims; eigen::matrixxd meigenvectors; int mnumclusters; }; #endif /* spectralclustering_h_ */ latter in main code #include "spectralclustering.h" #include <eigen3/eigen/qr> spectralclustering::spectralclustering(eigen::matrixxd& data, int numdims): mnumdims(numdims), mnumclusters(0) so not understand why virtual destructor used in .h file. this can learn virtual destructors useful when can delete instance of derived class through

java - How to dynamically delete the rows of a table, or delete a table, with Hibernate? -

i have table in oracle database. i want know how delete rows, or how delete purely table using hibernate, but not changing corresponding mapped class. mean, want ouside mapped class, in main java method example. to read data, use native sql queries hibernate. to write data, use session.save but how do delete data table, or delete table ? i looked @ hibernate documentation, solution involves changing mapped class code adding annotations... i want solution 1 use read , write data : session.createsqlquery("..."); or session.save(...); is there solution ? i found answer in stackoverflow question : query delete rows in table hibernate if table want delete rows named mytable then, answer : in hql : session.createquery("delete mytable").executeupdate(); in native sql : session.createsqlquery("delete mytable").executeupdate(); i should have looked longer in stackoverflow before posting question, sorry that.

sql - Convert the datetime value to floor -

when go through our application's existing stored procedure, saw below code: cast(floor(cast(@weekdate float)) datetime) any 1 explain purpose behind code? @weekdate datetime field. it truncates time datetime. select dateandtime = getdate(), dateonly = cast(floor(cast(getdate() float)) datetime) demo here way use on sql-server 2005: dateadd(dd, datediff(dd,0, getdate()), 0) sql-server 2008 introduced date type , it's easier: cast(@weekdate date)

c - How can I change the value where char* is Pointing? -

i using char* store variable values, there's problem can't change value. if suggest method..... life saver me.... char* year=""; //definition empty get_data(){ year= //"here want give value of variable(also in char*)" } the short answer (don't this): #include <string.h> ... strcpy(year, "your new string"); the reason not don't own memory year pointing to. instead, should declare year char year[100] , allocates memory on stack. can copy string it.

python - Why is re.sub is not replacing string with empty string -

i can't understand pythons re.sub behavior. want replace entire multi line string nothing. want empty string back: #!/usr/bin/python import re if __name__ == "__main__": data = """hello world day """ textarea = re.sub( '.*', '', data) print "processed '%s'" % textarea textarea = re.sub( '.*', '', data, flags=re.multiline) print "processed '%s'" % textarea the above code, @ least on machine not output following: processed '' this both cases, multiline/non-multiline. instead single quotes spread across multiple lines. why so? what want delete empty lines ( lines containing 0 or more spaces) multiline string, , believe above example issue. thanks. answer: as others pointed out. multiline confusing me. answer original question, instead of desire, dot not matching newline, hence getting replaced empty string, except newlin

android - Show navigation drawer opened -

i have been looking how show navigation drawer opened. have seen using gravity.left makes animation want show displayed without animation. this makes animation. ((drawerlayout) findviewbyid(r.id.drawer_layout)).opendrawer(gravity.left); ¿how can show drawerlayout displayed without animation? there awesome library implement navigationdrawer in apps developed mike penz.

php - PHPMailer password-protected attachment -

i'm making php script, import data mysql database , send via email in attachment. there 1 issue - in future there possibility, data sensitive. need set password attachment. i'm using phpmailer method addstringattachment . some code: <?php require 'phpmailerautoload.php'; $con = new mysqli("x", "x", "x", "x"); $utf1 = "set names utf8"; $utf2 = "set character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"; $con->query($utf1); $con->query($utf2); $output =''; $result = $con->query("select * xxx date( entry_date ) between ( date( curdate( ) - interval 3 day )) , ( date( curdate( ) - interval 1 day ) )"); $columns_total = $con->field_count; // field name ($i = 0; $i < $columns_total; $i++) { $heading = mysqli_fetch_fi

java - how to get the running executable jar name using c/c++ code? -

i want name of running executable jar file using c/c++ code. what did do? generate dynamic library c++ code contain the code current executable name. created wrapper file , generated .so (dynamic library linux) interface java, using swig . the created so loaded in java file return name of executable. what happened: it returns name of java runtime executable file, /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java what need: i need name of running executable jar file, in code written in c/c++.

html - Prevent people from opening raw images -

this question has answer here: allow/deny image hotlinking .htaccess 2 answers prevent opening image in browser directly 1 answer i want create page on site can place images in slideshow. normally, simple, i'm trying else... i want try , stop people accessing image typing image url browser, allow image show if it's called within webpage, and, if possible, webpage alone. is there way this? thanks where images stored? if using likes of amazon s3, can set rules setting images private , accessible say, application. this may little.. http://improve.dk/how-to-set-up-and-serve-private-content-using-s3/

Using PHP-GPG with Wordpress -

i'm working on implementation, should send every outgoing mail wordpress installation gpg encrypted. i built small plugin tutorial tim nash , , used php-gpg lib jason hinkle . when send email wordpress 4.3, pgp-encrypted mail, can't open it, because wp / plugin uses wrong public key. checked out, , pasted right key in user wp-profile, ... nothing: wrong key. have ideas? <?php /** @package php-gpg::gpg */ /** seed rand */ list($gpg_usec, $gpg_sec) = explode(' ', microtime()); srand((float) $gpg_sec + ((float) $gpg_usec * 100000)); /** * @package php-gpg::gpg */ class gpg_utility { static function starts_with($haystack, $needle) { return $needle === "" || strpos($haystack, $needle) === 0; } static function b0($x) { return ($x & 0xff); } static function b1($x) { return (($x >> 0x8) & 0xff); } static function b2($x) { return (($x >> 0x10) & 0xff); }

node.js - Path of the express -

why express command not found. here path express. /usr/lib/node_modules/express when install express, terminal shows path. used npm install -g express-generator npm install -g express but when run express, doesn't work. in directory, express globally right? why can't found. don't understand logic. you need install express locally, rather globally. http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation in general, rule of thumb is: if you’re installing want use in program, using require('whatever'), install locally, @ root of project. if you’re installing want use in shell, on command line or something, install globally, binaries end in path environment variable. based on this, want install express-generator using -g flag use command line tool, want install express without flag it's module want require() in application. take @ installation guide: http://expressjs.com/starter/generator.html

regex - Split line at commas, only if commas not contained between quotes -

is there way use split function in scala splits line @ commas doesn't @ commas contained within 2 double quotes? for example, have following: x: string = """"??", "hamburger", "ketchup, mayo, mustard", "pizza"""" and tried this: x.split(',') didn't work. thought removing double quotes still doesn't solve problem. any appreciated! edit: here's snippet of code see how can incorporate this: val data1 = noheader1.map { line => val values = line._1.split(',') //this trying change val name = values(2).replaceall("\"", "")) i bit new scala , more regex, clarify how write weird regex expression in code can obtain array of comma separated words of line? try this! (?>"(?>\\.|[^"])*?"|(,)) regex101

c++ - boost icl shared memory access -

i have created icl map in shared memory described in below link c++ boost icl containers in shared memory below code #include <boost/icl/interval_map.hpp> #include <boost/interprocess/managed_mapped_file.hpp> #include <boost/interprocess/managed_shared_memory.hpp> #include <iostream> #include <vector> #include <set> namespace bip = boost::interprocess; namespace icl = boost::icl; namespace shared { using segment = bip::managed_shared_memory; using smgr = segment::segment_manager; } namespace { static bip::managed_shared_memory global_mm(boost::interprocess::open_or_create, "mysharedmemory",65536 //segment name ); static bip::allocator<void, shared::smgr> global_alloc(global_mm.get_segment_manager()); /* static bip::managed_mapped_file global_mm(bip::open_or_create, "./demo.bin", 1ul<<20); static bip::allocator<void, shared::smgr> global_alloc(global_mm.get_se

build - ERROR: Sonar server 'http://localhost:9000' can not be reached -

when running following command: cmd /c c:\sonar-runner-2.4\bin\sonar-runner.bat (sonar runner installed on build machine) following errors: error: sonar server ' http://localhost:9000 ' can not reached error: error during sonar runner execution error: java.net.connectexception: connection refused: connect error: caused by: connection refused: connect what can cause these errors? hi dinesh, this sonar-runner.properties file: sonar.projectkey=ndm sonar.projectname=ndm sonar.projectversion=1.0 sonar.visualstudio.solution=ndm.sln #sonar.sourceencoding=utf-8 sonar.web.host:sonarqube sonar.web.port=9000 # enable visual studio bootstrapper sonar.visualstudio.enable=true # unit test results sonar.cs.vstest.reportspaths=testresults/*.trx # required when using sonarqube < 4.2 sonar.language=cs sonar.sources=. as can see set sonar.web.host:sonarqube sonar.web.port=9000 when run sonar-runner.bat still the error: sonar server ' http://localhost:9000 '

javascript - Exporting DB as CSV from latin1 encoded strings in to utf-8 -

we have mssql 2005 db strings encoded latin1. requirement export utf-8 new db. have written following script export db: var sql = require('mssql'); var csv = require("fast-csv"); var fs = require("fs"); var iconv = require('iconv-lite'); function exportcsv(tablename) { return new promise(function (resolve, reject) { var csvstream = csv.format({headers: false, quotecolumns: true}), writablestream = fs.createwritestream("output/"+tablename+".csv",{encoding: "utf8"}); writablestream.on("finish", function() { console.log(tablename+" csv file exported!"); resolve(); }); csvstream.pipe(writablestream); var request = new sql.request(); var dateformat=""; request.query('select * '+tablename); request.on('row', function(row) { // processing on row if required csvstream.write(row); }); request.on(&#

UnEscape Xml in Groovy -

i trying unescape xml in groovy : &lt;student&gt;&lt;age value=&quot;20&quot;&gt;&lt;/age&gt;&lt;/student&gt; to <student><age value="20"></age></student> but not able find library can accomplish this. tried using groovy.json.stringescapeutils.unescapejavascript doesn't help. there 1 library groovy.xml.xmlutil has escapexml method doesn't has unescape method. my purpose of usage use groovy script in elasticsearch v1.3.2 contains groovy-all-2.3.2.jar any suggestions ? here's trick using built-in xmlslurper class , no additional libraries: value = "x &amp; y &lt; z" // wrap string in made tags create // well-enough-formed xml xmlslurper xml = "<foo>${value}</foo>" println xml root = new xmlslurper().parsetext(xml) root.tostring() result: 'x & y < z'

javascript - only open child webpage if it is no longer open or the url changed to a different site? -

i not want webpage reload if open, causes unnecessary data sent javascript application. if webpage not open, want open. if webpage open user used teh tab load webpage, want new webpage open,. if webpage open , still on right url, not want change, not want refresh. however can not seem find way know if url changed. i can use cookies if have rather not. suggestions? thanks.

PHP Error while pulling excel report -

i following error while trying pull excel report. remember error occurred previously, not sure if increasing php memory fixed it. please suggest. fatal error: uncaught exception 'phpexcel_exception' message 'worksheet!w529 -> formula error: operator '-' has no operands' in c:\xampp\htdocs\asia\classes\phpexcel\cell.php:307 stack trace: #0 c:\xampp\htdocs\asia\classes\phpexcel\writer\excel5\worksheet.php(460): phpexcel_cell->getcalculatedvalue() #1 c:\xampp\htdocs\asia\classes\phpexcel\writer\excel5.php(194): phpexcel_writer_excel5_worksheet->close() #2 c:\xampp\htdocs\asia\xlsheet.php(201): phpexcel_writer_excel5->save('dailytrack14_13...') #3 {main} thrown in c:\xampp\htdocs\asia\classes\phpexcel\cell.php on line 307

vba - Macro: activate "automatic caluclation" when opening an excel workbook -

how activate option " automatic calculation" when directly after opening excel workbook macro? open vb editor ( alt + f11 ) , right click thisworkbook (under microsoft excel objects) --> view code. this area handles workbook event code. paste in following code: private sub workbook_open() application.calculation = xlcalculationautomatic end sub this changes excel settings make calculation automatic. if want calculate workbook on open can so: private sub workbook_open() application.calculation = xlcalculationautomatic 'change calculation setting automatic application.calculate 'perform workbook calculations end sub

jsp - Not displaying error message for a select drop down in Struts 2 -

i have following code action: private string yoursearchengine; private string selectedusergroupid; //with both getter , setter. public void validate(){ if("-1".equals(getyoursearchengine())){ addfielderror("yoursearchengine", gettext("select search engine")); addresslist.add("select search engine"); } if("-1".equals(getselectedusergroupid())){ addfielderror("selectedusergroupid", "select user group"); addresslist.add("select user group"); } jsp page: <s:select label="search engine:" headerkey="-1" headervalue="select search engines" list="searchengine" name="yoursearchengine" id="yoursearchengine" value="defaultsearchengine" tooltip="select search engines" /> <s:se

javascript - Sticky header that is transparent over main banner? -

i've built client's site on squarespace. i want create header that: 1) has transparent background when user first arrives on page 2) when user scrolls down, gets background color , remains affixed top of viewport. thanks! some info csstricks have great little example on how (this common solution this). the basics solution listen scroll event , check when right spot (you can calculate spot programmatically if want). if do, add class header following: makes header colored wanted be make header position: fixed; top: <num>; or position: absolute; top: <num> (i've seen both solutions out in field) !important! position:absolute solution less safe, since position: fixed positions element relative viewport. position:absolute same only if doesn't have predecessor position:relative [for more info, check this link ] there's experimental css feature position add position: sticky option. in theory, sticky part [you can see i

clojure - ClojureClr source macro: Source not found for standard library functions -

i'm trying print source code function source not found user=> (source map) ; source not found ; nil i using clojureclr 1.6.0 running clojure.main.exe. don't have clojure .clj source files. missing? edit: it says here file clojure/core.clj , user=> (meta (resolve `map)) ; ..... :file "clojure/core.clj", ..... should folder in specific path? relative repl or something? i downloaded source , copied clojure.main.exe folder , works now. this great tutorial how clojure's namespaces , libraries work , relationship filesystem.

recursion - Recursive even function issue with understanding (Javascript) -

the problem simple, have function 'javascript allonge' book, , having hard time in understanding it. the function called even, , it's follows: var = function(num) { return (num === 0) || !(even(num -1)); } it checks whether number or not, not understand how. calls recursively, , technically, reaches zero, no? how work? this based on inductive definition of numbers being odd or - number, n 'even' when number before it, n - 1 odd. thinking naturally makes sense - 4 if 3 odd. and function even defined as: 1. even(0) true - because 0 even 2. even(n) negation of even(n - 1) another way think of imagine even(4) being called step step. hand, replace even(4) result of evaluation function: even(4) = !(even(3)) = !(!even(2)) = !(!(!even(1)) = !(!(!(!even(0))) = !(!(!(!true)) = true // ...even(4) == true

javascript - Run java script file created by Emscripten, from another java script file -

here task: want run .js file witch created emscripten .cpp file, .js file. i.e.: have ping.cpp file, witch display text "ping" . use emscripten create ping.js it, type em++ ping.cpp , here - ping.js . can run using node ping.js , want run second .js file witch called init.js , cant understand how should it. because ping.js doesnt have main function wicth display "ping" , witch can call .js file or example .html file, instead of has 68500 lines of code. so, there chance me run ping.js init.js? thanks help. p.s. sorry english, not mother tongue. you should load ping.js file script tag in html file, other script. trick make sure make functions want use accessible other scripts load. so, need set exported_functions compilation flag indicate function names want preserve. specifically em++ -s exported_functions="['_ping']" ping.cpp -o ping.js note underscore ('_') needed added in front of function name compensa

opencv - How to extract number from a detected image -

i want use opencv extracting number written of speed sign. , since detected sign image, how can extract number written on it? how can using opencv. note: know how make image matching, not know how extract specific information "numbers" detected sign.

ios - Custom Geometry Mesh -- How to Triangulate in Order to Look Smooth -

edit: altering subdivision count seems have smoothened surface. however, surface seems have shrunk... can't seem it's normal size. why happen , how can fix effect? i'm hoping draw hundreds of smooth-looking planes sequentially in 3d space model data. these planes different, each 1 given 4 corners of plane -- plus arbitrary point in middle of plane give surface slight curvature aesthetic appeal. thanks site, i've triangulated surface somewhat, looks pyramid. here's have far: var vertices = [scnvector3(x: -5, y: 5, z: 0), scnvector3(x: 0, y: 5, z: -5), scnvector3(x: 5, y: 5, z: 0), scnvector3(x: 0, y: 5, z: 5), scnvector3(x: 0, y: 7, z: 0)] var indices : [cint] = [4,0,1, 4,1,2, 4,2,3, 4,3,0] var normals = [scnvector3]() var normalmap = [int : scnvector3]() (var = 0; < ver

sql - Delete from multiple tables in one single query -

i beginner in db2. want delete 2 tables using 1 query. reason why want because condition delete complex , implies join in big tables. don't want same query twice. want : delete table1 t1, table2 t2 t1.id = t2.id , id in ( -- select , join stuff) with db2 luw can using data change table reference : with lst (id) ( -- select , join stuff), lst1 (id) ( select id old table ( delete table1 id in (select id lst) ) ) select id old table ( delete table2 id in (select id lst1) ) old table (delete ...) data change table reference, contains in case rows have been deleted enclosed delete . i don't think trick supported on other db2 platforms, althought might in db2 z/os v.11 -- have no way of testing though.

html - Missplaced bootstrap column -

i have problems (bootstrap) coulmn ends missplaced , can't figure out why. if can explain me why have happend , how solve greatfull. preview: http://www.bootply.com/6n2fo36f6i as can see "location" column 1px right. html: <div class="row equal-height"> <!-- start bs row --> <div class="col-md-1"> <!-- start bs col-md-1 --> </div> <!-- end bs col-md-1 --> <div class="col-md-3 zeropadding-right"> <!-- start bs col-md-4 --> <div class="singlepage-list-style"> <!-- start singlepage-list-style --> <div class="list-header"> <!-- start liste-header --> <h1>quick info</h1> </div> <!-- end list-header --> <div class="the-list"> <!-- start the-liste --> <ul> <li class="check">blah&

java - my response.sendRedirect(); is not working -

i'm trying redirect new page syntax try { usuarios usu = new usuarios(); usu.setnombreusuario(request.getparameter("parcodigo")); system.out.println(usu.getusuario()); usu.setcontrasena(request.getparameter("parcontrasenha")); system.out.println(usu.getcontrasena()); usu = usuariosdao.login(usu); system.out.println("es valido? " + usu.isvalid()); if (usu.isvalid()) { httpsession session = request.getsession(true); session.setattribute("usuario", usu.getusuario()); response.sendredirect("/kolaescocesacrm/menumobile.jsp"); return; } else { response.sendredirect("/kolaescocesacrm/loginmobile.jsp"); } } catch (exception ex) { ex.printstacktrace(); } my problem when submit this: http://localhost:8084/kolaescocesacrm/srvmenu2?parcodigo=admin&parcontrasenha=ko

html - can't change background image using javascript -

i trying change background image when clicking play button, background image supposed change pause , vice versa. can play , pause music, can not change images. can tell me problem is? here code: function initaudioplayer() { audio_0 = new audio(); audio_0.src = "audio/footprint.mp3"; //set object reference playbtn0 = document.getelementbyid("audio-play-images-0"); forwardbtn0 = document.getelementbyid("audio-next-images-0"); backbtn0 = document.getelementbyid("audio-prev-images-0"); //add event handling playbtn0.addeventlistener("click", playpause); forwardbtn0.addeventlistener("click", playforward); backbtn0.addeventlistener("click", playback); } function playpause() { if (audio_0.paused) { audio_0.play(); playbtn0.style.backgroundimage = 'url(../img/pause-on.png)'; } else { audio_0.pause(); playbtn0.style.backgroundim

Android studio doesn't appear to be reading .mk files -

i using android studio 1.3 experimental ndk plugin enabled. trying compile box2d placing box2d folder jni folder. have android.mk , application.mk in there well. whenever try compile android studio spits out errors header files cannot found. seems no matter .mk files nothing changes. it's not being read. android studio read .mk files? local_path:=$(call my-dir) $(info $(local_path)) source_directories:=\ collision \ collision/shapes \ common \ dynamics \ dynamics/contacts \ dynamics/joints \ particle \ rope include $(local_path)/b2_android_common.mk # conditionally include libstlport (so include path added cflags) if # it's not being built using ndk build process. define add-stlport-includes $(eval \ ifeq ($(ndk_project_path),) include external/stlport/libstlport.mk endif) endef # configure common local variables build box2d adding $(1) end of # build target's name. define box2d-module $(eval \ local_module:=libliquidfun$(1)

sql - Update datetime column by one minute for few rows having same datetime -

i have table lots of data: +----+-------+-------------------------+ | id | user | datetime | +----+-------+-------------------------+ | 1 | 34534 | 2015-08-12 10:03:22.043 | | 2 | 32423 | 2015-08-12 03:29:18.097 | | 3 | 12312 | 2015-08-13 03:24:10.073 | | 4 | 34232 | 2015-08-13 03:24:10.073 | | 5 | 32462 | 2015-08-13 03:24:10.073 | | 6 | 45354 | 2015-08-14 04:12:04.023 | +----+-------+-------------------------+ i want create 1 minute gap between datetime of rows same. in above case, row number 3,4,5. 1 minute gap in these 3 datetime. try this select id, user, [datetime] = case when rn = 1 [datetime] else dateadd(minute,rn-1,[datetime]) end ( select row_number()over(partition [datetime] order id) rn,* yourtable ) for updating table use this with cte ( select row_number()over(partition [datetime] order id) rn,* yourtable ) update cte set [datetime] = case when rn = 1 [datetime] else dateadd(minute,rn-1,[datetime]) end

ruby - Rails model instance with dynamic attribute value based on relationship -

my adminuser creates survey , questions go along it. different user takes survey. survey taken multiple users. of questions in survey, need include attribute of user (example: name). adminuser create question "what did user eat?" user takes survey see "what did jane eat?". currently, have survey model , question model. questions in survey include user's name taking survey. example, if question "what eat?" "what jan eat?" to temporarily accomplish created method on survey model creates new questions each time new survey created. clogging database same questions 1 word difference. makes more difficult link different users' answers same question since each question instance unique. here current survey model survey.rb class survey < activerecord::base belongs_to :user belongs_to :surveyable, :polymorphic => true has_many :questions, :dependent => :destroy def self.generate_for_user(survey_user) n

python - Apache/ mod wsgi if __name__ == '__main__' equivalent -

to use leveldb (python database) need database loaded when start server , not each time user uses website. previously used web.py , if __name__ == '__main__' statement make happen. once switched apache __name__ variable modwsgi_.... . can provide me alternative work apache , modwsgi please? the value of __name__ of form _mod_wsgi_????? , use: if __name__.startswith('_mod_wsgi_'): ... better still, use wsgi script file distinct else used mod_wsgi. create app.wsgi file imports application object elsewhere. don't need check , can loading @ global scope. just make sure using daemon mode in either case, in embedded mode wsgi script file technically loaded more once in life of process if modification time changed. in daemon mode doesn't happen changing wsgi script file cause whole process shutdown , reloaded instead. btw, how know if mod_wsgi running documented in: https://code.google.com/p/modwsgi/wiki/tipsandtricks

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -

my situation follows. let there header file classdeclarations.h , have following classes declared: class classa; class classb; class classa { public: classa(int x); classa(double y); int returninteger(void) { return m_x; } double returndouble(void) { return m_y; } private: int m_x; double m_y; } class classb { public: classb(int x); int returninteger(void) { return m_x; } private: int m_x; classa m_instancea_1; } let there *.cpp file called classdefns.cpp , define methods of classes declared in classdeclarations.h : #include classdeclarations.h classa::classa(int x) : m_x(x) { } classa::classa(double y) : m_y(y) { } classb::classb(int x) : m_x(x) { // line build error occurs m_instancea_1 = classa(0); } note have commented line compiler says there error: error c2512: 'classa' : no appropriate default constructor avai

angularjs - Issue with Angular Material -

i trying demo angular material tool bar. default code js not having dependent modules. code looks below angular.module('myapp') .controller('appctrl', function($scope) { }); but if add new module or empty square braces below, not working angular.module('myapp',[]) .controller('appctrl', function($scope) { }); if remove it, working. how can add module without affecting material design ? the link plunker here you need add ngmaterial angular app this: angular.module('myapp',['ngmaterial']); here working plunker

jquery - Ajax Refreshing Partial View -

i'm trying refresh partial menu depending on user selection through ajax. i have authenticated layout has this... <div class="container-fluid body-content"> <div class="row"> <div class="col-lg-offset-2 col-md-offset-2 col-sm-offset-2 col-lg-10 col-md-10 col-sm-10 col-xs-10"> <div id="bodycontent" class="pad-top"> @renderbody() </div> </div> <div id="menu" style="display: inline; visibility: hidden"> @{ html.renderaction("getmenupartial", "menu", noarea); } </div> </div> then inside renderaction controller, can render few different menus depending on user role. public partialviewresult getmenupartial() { if (user.isinrole(roles.applicationcenter.administrator)) { return !string.isnullorempty(sessionhelper.getimpersonationname()) ? getap

command objects - Grails 2.5.0 - constraint be blank OR follow validation -

i want like: class mycommand { string name string data static constraints = { name blank: false, size: 3..64 data (blank: true) || (blank: false, size: 3..64) } } where data either blank or follows validation such size constraint if not blank. possible without custom validation? it non-trivial use other constraints within validator constraint. delegate of constraints closure constrainedpropertybuilder , can read understand complexity. but doesn't matter because emailconstraint uses apache's emailvalidator , can use in validator. here's emailvalidator in action: @grab('commons-validator:commons-validator:1.4.1') import org.apache.commons.validator.routines.emailvalidator def emailvalidator = emailvalidator.getinstance(); assert emailvalidator.isvalid('what.a.shame@us.elections.gov') assert !emailvalidator.isvalid('an_invalid_emai_address') you can use emailvalidator in own validator th

ios - Swift swipe gesture recogniser errors -

i'm building ios swift (sprite kit) game. i'm using swipes move player. while testing i've found out works fine on devices. however, few devices not recognise swipe. needless say, game doesn't work without swipes. it's odd works on devices few. my code below. (note: it's cleaned show code relevant case) edit the app being tested on actual devices. devices run latest ios software. iphone 5, few 6 , 5s. error occurs on iphone 5s. am missing something? if not, else try? override func didmovetoview(view: skview) { addswipes() } func addswipes() { let swiperight:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipedright:")) swiperight.direction = .right view!.addgesturerecognizer(swiperight) let swipeleft:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipedleft:")) swipeleft.direction = .left view!.addges

javascript - Pasting text with the mouse doesn't trigger search -

for selectize.js ajax search inserting text mouse not cause search it's can simle reproduced on http://brianreavis.github.io/selectize.js page. on remote source — github example: focus on field delete selected insert text text mouse (not ctrl+v) no result how fix it? update for catching event jquery bind method. selectize on method can't catch (bug?). $('.selectize').bind('input', function(){ // force selectize make ajax call , show result }); // following code catch nothing $('.selectize')[0].selectize.on('input', function(){ // force selectize make ajax call }); but can't find solution forcing selectize ajax call you can find fix on issue page https://github.com/selectize/selectize.js/issues/882 the code onpaste: function(e) { var self = this; if (self.isfull() || self.isinputhidden || self.islocked) { e.preventdefault(); } else { // if regex or s

ios - Replacing Xcode 6 default Launchscreen with a Custom animation -

i have animation (in swift) want display while app loads. assuming must override xcode 6 default launch screen so. my question how override default launchscreen in xcode allow custom launch in animation. any feedback appreciated. thanks ciaran first, apple doesn't recommend having these types of launch screens. answer questions, make first uicontroller of app have custom animation , after animation done, have segue app's main screen.

Writing the results of a function to a file in Python 2.7 -

i'm trying write results of function file; in code below, results not saved output file (it writes:"none"): def program(): print "hello world!" open("output.txt", "w") output_file: output_file.write(str(program())) the goal write entire output of script (not shown here) file within script; i'm guessing there's better way (stdout?) i'm beginner little knowledge ;-) i've tried few workarounds same result, i've search answer couldn't find exact question. help! use return instead of printing: def program(): return "hello world!" without return , function program return none value.

java - Refreshing JList in GUI on button event -

i've looked online how update jlist after adding model. automatically, others have manually it. i've tried both, , haven't had success. i'm trying update model addelement method, , goes through. i've walked through code , passed correctly. gui doesn't refresh. package com.user.tutorial; import java.awt.eventqueue; import javax.swing.jframe; import javax.swing.jpanel; import java.awt.borderlayout; import javax.swing.jbutton; import java.awt.event.actionlistener; import java.awt.event.actionevent; import javax.swing.defaultlistmodel; import javax.swing.jmenubar; import javax.swing.jmenuitem; import javax.swing.box; import javax.swing.jmenu; import javax.swing.jtextpane; import javax.swing.listselectionmodel; import java.awt.component; import java.awt.color; import java.awt.dimension; import java.awt.font; import java.awt.gridlayout; import javax.swing.jlabel; import javax.swing.boxlayout; import javax.swing.jlist; import javax.swing.abstractlistmod

r - shiny dataTable rows_current and rows_all give the same rows -

i trying provide download handler in shiny app. works fine, grabs current filtered rows , not rows, though use rows_all. this code reproduces problem. why rows_current , rows_all equal? ptagg <- data.frame(x = seq(1:100), y = seq(1:100)) ui <- fluidpage( navbarpage('shiny application', tabpanel('overall summary', sidebarlayout( sidebarpanel( checkboxgroupinput('show_vars', 'columns display:', names(ptagg), selected = names(ptagg)), helptext('select columns interested in subset of data displayed'), downloadbutton('downloaddata', 'download data')), mainpanel(div(datatableoutput('overallsummary'), style = 'font-size:80%'), verbatimtextoutput('currrow'),

php - Cant find whats wrong with the line -

i cant find whats wrong. happens after first session. 'select m1.id, m1.title, m1.timestamp, count(m2.id) reps, users.id userid, users.username pm m1, pm m2,users ((m1.user1="'.$_session['user'].'" , m1.user1read="no" , users.id=m1.user2) or (m1.user2="'.$_session['user'].'" , m1.user2read="no" users.id=m1.user1)) , m1.id2="1" , m2.id=m1.id group m1.id order m1.id desc'); you have ' in beginning of string, , m1.id2="1" missing begining parenthesis. additionally users.id coming from? 'select m1.id, m1.title, m1.timestamp, count(m2.id) reps, users.id ( (m1.user1="'.$_session['user'].'" , m1.user1read="no" , users.id=m1.user2) or (m1.user2="'.$_session['user'].'" , m1.user2read="no" users.id=m1.user1) ) , m1.id2="1" , m2.id=m1.id group m1.id order m1.id desc');

bash - Concatenate all files except one calling system - Python -

to concatenate txt files of folder, can done cat easily: cat ./tmp*.txt >./tmp/all.txt however, want concatenate files except 1 can done following command explained here : cat ./tmp/!(1.txt) >./tmp/all_except_1.txt these commands work on command line, trying call them python os.system command , gives error >>> import os >>> os.system('cat ./tmp/!(1.txt) >./tmp/all_except_1.txt') sh: 1: syntax error: "(" unexpected does know why , how can solved? you need enable extended pattern matching in bash before call it: os.system("bash -o extglob -c 'cat ./tmp/!(1.txt) >./tmp/all_except_1.txt'")

c# - Binding ObservableCollection to selected items of a ListBox -

after hours , hours of googling, still can't find simple solution binding observablecollection selected items of listbox in twoway mode... what have simple : listbox selectionmode="multiple" , , observablecollection<contact> named selectedcontacts . want 2 bound. of course listbox has itemssource="{binding contacts}" observablecollection of contact. now can't use isselected bool on contact items, can't. thank ! there is no simple solution . can't bind selecteditems . the best solution select contact items view model object isselected property, bind that, , run query against primary oc when need selected items collection. since said can't/won't that, next best solution handle selectionchanged in code-behind , manually update vm collection there.

actionscript 3 - How to set a full HTML page text string in HTML component? -

i'm using air html control , want pass in full html page string. full html page meaning html markup has html begin , end tags. looks htmltext property accepts html formatted markup might not built accept full html page. html formatted markup this: <p>this paragraph. here <b>bold</b> text.</p> here full html page example: <html> <body> <p>this paragraph</p> </body> </html> or better write page file system , load through location property? 1 thing note updating html page lot avoid writing file system if possible.

How do I loop through or enumerate a JavaScript object? -

i have javascript object following: var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; now want loop through p elements ( p1 , p2 , p3 ...) , keys , values. how can that? i can modify javascript object if necessary. ultimate goal loop through key value pairs , if possible want avoid using eval . you can use for-in loop shown others. however, have make sure key actual property of object, , doesn't come prototype. here snippet: var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; (var key in p) { if (p.hasownproperty(key)) { console.log(key + " -> " + p[key]); } }

ios - UICollectionView size: iOS9 vs. iOS8 -

in app want compute best cell height cells match visible area. what best way size of visible rect? mean space between navigationbar , bottom of screen. currently size self.collectionview!.frame.size but contains area of statusbar , navigationbar. substract size of nav- , stautusbar. works ios9, not on ios8. so, how visible area devices? not answer, workaround, detect ios version , apply modifications according it: if ( ([[[uidevice currentdevice] systemversion] compare:@"9.0" options:nsnumericsearch] != nsorderedascending) ) { /* ios 9.0 or greater */ } of course, better define layouts using constraints relative top layout guide ( ideally using opaque navigation bar) avoid messing that, or add 20 points top constraints when detecting ios versions.

spring - How to efficiently store the LatLng route path coming from android application -

i'm working on android app keeps track of vehicle's location , sends latlng point every second spring webapp after click of button "start vehicle". need store location rendered in google maps show live location of vehicle on map. working fine but, have store obtained points show complete route traversed when driver clicks "stop vehicle" app. i've applied following strategies seem inefficient , resource consuming: store location in list @ server side when each current location request arrives , preserve in servletcontext. keep on updating list every point received. problem: journey of around 1 hour, many points received , make big list consuming loads of memory. if server shuts down or crashes, servletcontext gone , whole data. store location in table row in db (using postgresql). problem: when should entry persisted in db? , making db transactions + consuming of database space? costly, right? do not store locations @ server side, keep current