Posts

arrays - C++ 2d Vector subscript out of range error -

currently in function, have method declares 2d vector. vector <vector<test> > path(int x, int y) //path function { vector <vector<test>> mazearray(column, vector<test>(row)); //declaring object (int = 0; < column; a++) { (int b = 0; b < row; b++) { mazearray[b][a].setx(b); mazearray[b][a].sety(a); } } } for example, when tried run function, path(10,10). the double loop works without error, if change path example, path(11,10) or path (11,13) or numbers not same both (int x , y), error vector subscript out of range present. why so? can me on this? there way fix such value type acceptable? thanks. the loop in function vector <vector<test> > path(int x, int y) //path function { vector <vector<test>> mazearray(column, vector<test>(row)); //declaring object (int = 0; < column; a++) { (int b = 0; b < row; b++) { ...

css - Bootstrap's "dropdown open" background color -

i'm trying change background color of li element when it's class changes "dropdown" "dropdown open" on click. i've managed change color of text (which a ). can't change parent li properties. i've copied code here: http://www.bootply.com/fk88owgjgl . @ end of css file you'll see i've managed code concerning background color of li , of it's child. can't understand why font color works , background doesn't. any appreciated. thanks time i think problem related floating elements inside form, adding clear fix help. .navbar-right .dropdown-menu form:after { content: ""; display: table; clear: both; } and there bit background @ bottom due parent margin, can rest. .navbar-right { margin-bottom: 0; } use below, if need change background of search item itself(with magnifying glass) when active. li.dropdown.open > a:focus { color: #000; background: red; } demo: http://...

PYTHON: Error in recognising numpy module -

i using python 3.4.0 . going assume numpy module should work, 1 of newer versions of python. however, numpy result in syntax error. forexample code here: import numpy list1=[1,3,2,6,9] list2=numpy.mean(list1) print(list2) and get: traceback (most recent call last): file "/home/yichen/desktop/python/numpy test.py", line 1, in <module> import numpy importerror: no module named 'numpy' is problem computer or what? it looks numpy not installed on system. assuming have pip script installed python, can perform following command install it: pip install numpy or pip3.4 install numpy or, depending on distribution, might come package named python-numpy package manager.

laravel - Optimize image loading iteration in php -

i have laravel application in user presented list of episodes, each screenshot. each screenshot loaded inside foreach loop in view per pseudo code: foreach $episodes $episode $episode->getscreenshot($episodeid); endforeach the getscreenshot() method resolves specific screenshotlocator class out of ioc container so: $screenshotlocator = app::make('\animekyun\images\screenshots\screenshotlocator'); (i'm reading things binding container singleton. consider? it's not bound @ all) the screenshotlocator class designed build path actual screenshots folder (source below) using episode model. screenshots (there multiple per episode) stored in folder structure , necessary files loaded , stored in collection . the loading of screenshots takes 40 ms out of 135 ms entire page load on digital ocean droplet. (10x run benchmark) so question ways optimize this? source screenshotlocator class: http://laravel.io/bin/6l19r

Python 3.x read text file without ignoring blank line at the end -

i've tried read text file that: line 1 line 3 using following code: with open('textfile.txt', 'r') f_in: line in f_in: print("~ " + line) f_in.closed but loop runs 3 times instead of 4, ignoring blank line. the output is: ~ line 1 ~ ~ line 3 how can fix it? when using file iterator, end of line marked \n . means though editor may show "blank line" after 3 , if there no data there, there no line there. for example, try this: with open('textfile.txt', 'wb') f_out: f_out.write(b'1\n\n3\n4') open('textfile.txt', 'r') f_in: line in f_in: print("~ " + line) by putting character 4 on last line, no terminating linefeed, python recognizes line. without 4 , have 3 lines.

How do I stop SQL Server converting 1900-01-01 to NULL -

there seems lots of posts on how convert 1900-01-01 null , problem opposite. have stored procedures processing smalldatetime (sql server 2008), keep converting 1900-01-01 null , when want remain 1900-01-01 . thoughts? thanks fundamentally, sql server can't differentiate. 1900-01-01 00:00:00.000 epoch (zero point) sql server's calendar. , if in sql server: select 'empty string',convert(datetime,'') it's conversion algorithm doesn't throw error, converts empty string sql server date/time value ... (you guessed it!) ... '1900-01-01 00.00.00.000'. what happens null values dependent on current setting of sql server set option set concat_null_yields_null . if off , null values treated identically empty strings. as far stored procedure problem goes (stored procedure turning date/time value of 1900-01-01 null ...that's problem stored procedures. sql server won't automatically convert non-null date/time value of 19...

python - Passing a bounded method in Cython as argument -

i trying wrap c++ code cython , came trouble trying pass method class argument function. i not know if makes more clear, class represents statistical model (so myamethod uses not arguments passed many instance variables) , b has different methods minimizing function passed. in c++ have of style: class { public: double myamethod(double*) }; class b { public: double mybmethod(a&, double (a::*f) (double*) } so trying use instances of both , b in cython code. had no trouble wrapping classes, when try use mybmethod, don't know how pass pointer of kind a::*myamethod if this: mybmethod(ptrtoaobj[0], &ptrtoaobj.myamethod) , cython compiles code [...] &ptrtoaobj->myamethod [...] , , message 1 expect g++: "iso c++ forbids taking address of bound member function form pointer member function." but if try point straight class method, , mybmethod(ptrtoaobj[0], a.myamethod) , cython won't compile , myamethod not static member a. a...