Posts

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.