Posts

Check if a form field exists when doing form validation? Laravel 5 -

i have form has conditional logic displays or hides each field. want validate fields shown. see field list in validation script below , imagine hide "phone" form field in using conditional logic in view — still want validate rest of fields, if "phone" validation still there, script fails , shows error message saying "the phone number required." in laravel 5, there way check if form field exists or change whether it's required or not dynamically before or when validating form? here's validation code... $v = validator::make(input()->all(), [ 'firstname' => 'required|min:1|max:80', 'lastname' => 'required|min:1|max:80', 'address' => 'required|min:10|max:80', 'address2' => 'max:20', 'city' => 'required|min:2|max:80', 'state' => 'required|min:2|max:...

Setting request.session causes HTTP 500 Error when posting form to Django -

even setting session simple string changes http response status 200 500. httml button has id="requestquote". webpage javascript: $('#requestquote').click(function(){ var jpicks = json.stringify(picks); $.post("requestforquote",{counties:jpicks}).done(function(){ window.location = base_url + "countyparcels/quoteform" }); }); url.py urlpatterns = [ url(r'^(requestforquote)$',views.request4quote), url(r'^(quoteform)$',views.quoteform) ] views.py shopping_cart = 'shoppingcart' @csrf_exempt def request4quote(request,misc): try: request.session[shopping_cart] = request.post['counties'] # no exception here except exception e: print e.message try: response = httpresponse("true",content_type="text/plain") # no exception here except exception e: print e.message response = http404 return response # h...

c++ - Using pair in variadic templates -

okay, i'm trying implement range tree in n-dimensions using variadic templates. have basic setup working, want able optionally pass compare function object in template list sort tree other std::less. my first thought overload template list version includes pair first element, pair containing type , compare funcition. can't see template declaration line compile. visual c++ (2015) starts c2079: "std::pair::first uses undefined class 't'". anyways, on code. here's small snippet show i'm trying do: template <class... args> class rangetree{ }; template <class t, class... args> class rangetree<t, args...> { public: map <t, rangetree<args...> * > tree; }; this works normally. when add version of rangetree, pair first template member, have problems: template <pair<class t, class compare>, class... args> class rangetree<pair<t, compare>, args...>{ public: map <t, rangetree <ar...

DShow Sample Code for playing video does not play the video MSDN C++ -

i referring example program provided here run video file, in case mp4 format using dshow. refer complete code: #include <dshow.h> #pragma comment (lib, "strmiids.lib") void main(void) { igraphbuilder *pgraph = null; imediacontrol *pcontrol = null; imediaevent *pevent = null; // initialize com library. hresult hr = coinitialize(null); if (failed(hr)) { printf("error - not initialize com library"); return; } // create filter graph manager , query interfaces. hr = cocreateinstance(clsid_filtergraph, null, clsctx_inproc_server, iid_igraphbuilder, (void **)&pgraph); if (failed(hr)) { printf("error - not create filter graph manager."); return; } hr = pgraph->queryinterface(iid_imediacontrol, (void **)&pcontrol); hr = pgraph->queryinterface(iid_imediaevent, (void **)&pevent); // build graph. important: ch...

mysql - Unable to call a stored procedure -

i'm learning mysql stored procedures and, turns out, i'm not @ now. want create stored procedure selects columns different tables and, obviously, outputs result. have: use `usertable159`; drop procedure if exists `getdatafor`; delimiter $$ use `usertable159`$$ create definer=`michael`@`%` procedure `getdatafor`(in country varchar(2), in asin varchar(20),in fc varchar(1)) begin set @sql = "select p.price, p.sku, p.fulfillment_channel, group_concat(es.excludedseller) excluded, r.excludenonfeatured "+country+"_products p left join ("+country+"_excludedsellers es, "+country+"_excluderules r) on p.seller_sku = es.seller_sku , p.seller_sku = r.seller_sku p.asin = '" + asin + "' , p.fulfillment_channel = " + fc + "; "; prepare stmt @sql; execute stmt; deallocate prepare stmt; end $$ delimiter ; from errors expected when writing this... 1 surprising me: error c...

big o - Big O - Time Complexity puzzling for while loops -

as time complexity example (refreshing mind) attempting solve find running time (in terms on n) of following algorithm: for (i=1; <= n; i++) { //o(n) k = 1; (j=1; j <= i; j++) { //o(n) k = 2*k; } j = k*k; while (j > 1) { //o(..?) j = j / 2; } } i understand first 2 loops combined take o(n^2), little perplexed @ how find running time of while loop. although know while loop runs twice first execution, 4 times, 6... multiples of 2. make run o(nlog(n)) times? the repeated division log_2(j) same log(j) / log(2) . log(2) constant, it's written log(j) . because o(log(n)) @ same depth o(n) loop , o(n) loop dwarfs o(log(n)) loop, 2 combined takes o(n) time. the final time complexity o(n^2) .

go - Golang - How to initialize a list of objects given only an interface sample? -

i'm writing database interface in google go. takes encoding.binarymarshaler objects save , saves them []byte slices, , loads data encoding.binaryunmarshaler return it: func (db *db) get(bucket []byte, key []byte, destination encoding.binaryunmarshaler) (encoding.binaryunmarshaler, error) { i want implement being able load arbitrary length slice of encoding.binaryunmarshaler s in 1 go (for example "load data bucket x"). want function able load number of data objects without knowing beforehand how many objects loaded, don't expect final user pass me slice filled. instead, take encoding.binaryunmarshaler sample object know structures i'm dealing with: func (db *db) getall(bucket []byte, sample encoding.binaryunmarshaler) ([]encoding.binaryunmarshaler, error) { the problem ran while coding this, i'm not sure how initialize new instances of given object, since don't know object dealing with, interface conforms to. tried doing was: tmp:=new(refl...