Posts

python - Django: where is settings.py looking for imports, and why? -

i have django app common directory structure: project ---manage.py ---app ---__init__.py ---settings.py ---settings_secret.py ---a bunch of other files app that settings_secret.py file contains variables secrets.py not want send github. reason, cannot seem import settings.py. first 5 lines of settings.py: # django settings project. debug = true template_debug = debug import os settings_secret import * which fails partial stacktrace: file "/foo/bar/project/app/settings.py", line 5, in <module> settings_secret import * importerror: no module named 'settings_secret' to debug, created test file inside /project/ so: from settings_secret import * print(variable_from_settings_secret) which worked charm. clearly, settings.py isn't looking in right place settings_secret. looking? in settings.py , should do: from .settings_secret import * it works . because proper syntax supposed be: from app.settings_secret import * r...

arrays - C++ string appending problems -

i'm having issues right now, attempting append char array onto c++ string after setting of values of c++ string, , don't see why. wondering if of know what's going. here's code i'm trying run: string test = ""; test.resize(1000); char sample[10] = { "hello!" }; test[0] = '1'; test[1] = '2'; test[2] = '3'; test[3] = '4'; test += sample; running through debugger, seems test "1234", , "hello" never added. thanks in advance! it added, after 1000 characters have in string (4 of them 1234, , 996 '\0' characters)`. the resize function allocate 1000 characters string object, sets length 1000. that's why want instead use reserve this do: string test = ""; test.reserve(1000); // length still 0, capacity: 1000 char sample[10] = { "hello!" }; test.push_back('1'); // length 1 test.push_back('2'); // length 2 test.push_back('3...

javascript - How to validate a form when not scrolled down using angularjs? -

i trying validate form page called 'agree information'. here, user has scroll down in order move forward(remember no checkbox @ bottom of box, instead user has scroll down way till scroll ends), if user clicks continue/agree button without scrolling, div element/error must displayed saying 'scrolling bottom of information required'(must anchor link, clicking on should highlight box color). here code , image (function(){ angular .module('agreetoinfoapp',[]) .directive('execonscrollonbottom', [function () { return { restrict: 'a', link: function (scope, elem, attrs) { var fn=scope.$eval(attrs.execonscrollonbottom), clientheight=elem[0].clientheight; elem.on('scroll',function(e){ var el=e.target; if ((el.scrollheight-el.scrolltop) === clientheight) { ...

ios8 - converting from UISearchDisplayController to UISearchController -

i have app moving ios8 , want ride of deprecated methods. the app have ipad app , have search bar in navigation bar , search result should appear in popover under search bar in navigation item. i have found property stops search bar hiding navigation bar. but still stuck. can point me sample code or describe steps need take in order achieve this. regards christian this answer not step-by-step one, question , answer might helpful? uisearchcontroller showing fullscreen instead of popup on ipad [self.searchcontroller setmodalpresentationstyle:uimodalpresentationpopover];

javascript - PHP referencing functions not in a script -

can please explain me can php script functions from, have php script has few lines: <?php $args1 = array(); $gethosts = get_xml_host_objects($args1); //grabbing internal xml data backend $args2 = array(); $gethoststatus = get_xml_host_status($args2); $args3 = array(); $getparenthosts = get_xml_host_parents($args3); so not understand , how php script referencing functions, give me few examples suggestions of look? maybe, there file includes 2 scripts. somethings that <?php include 'file_with_function.php'; include 'your_file.php'; ?> these lines can help. place them @ beginning of file echo '<pre>'; debug_print_backtrace(); echo '</pre>';

if statement - How can I tell a for loop in R to regenerate a sample if the sample contains a certain pair of species? -

i creating 1000 random communities (vectors) species pool of 128 operations applied community , stored in new vector. simplicity, have been practicing writing code using 10 random communities species pool of 20. problem there couple of pairs of species such if 1 of pairs generated in random community, need community thrown out , new 1 regenerated. have been able code if pair found in community community(vector) labeled na. know how tell loop skip vector using "next" command. both of these options, not of communities needing. here code using na option, again ends shorting me communities. c<-c(1:20) d<-numeric(10) x<- numeric(5) for(i in 1:10){ x<-sample(c, size=5, replace = false) if("10" %in% x & "11" %in% x) x=na else x=x if("1" %in% x & "2" %in% x) x=na else x=x print(x) d[i]<-sum(x) } print(d) this result looks like. [1] 5 1 7 3 14 [1] 20 8 3 18 17 [1] na [1] na [1] 4 7 1 5 3 ...

sql - Issue while ALTER COLUMN in Postgresql -

this question has answer here: how convert primary key integer serial? 1 answer i have table id , name id primary key bigint datatype. want alter column, id primary key auto incremented value. my table: create table test( testid bigint not null, testname character varying(255), constraint test_pkey primary key (testid) ); alter query: alter table test alter column testid bigserial primary key; after executing query i'm getting following error, error: syntax error @ or near "bigserial" line 1: alter table test alter column testid bigserial p... ^ ********** error ********** error: syntax error @ or near "bigserial" sql state: 42601 character: 50 you can try command alter table your_table alter column key_column type bigserial primary key; i hope helpful...