Posts

c++ - How to do the conditional variable initialization at compiler time? -

c++11 standard have std::conditional<> template type selection boolean condition @ compiler time. how same operation select init value variable initialization? similar type = (exp) ? first_value : second_value; . i use template: template<bool b, typename t> inline constexpr t&& conditional_initialize(t&& i1, t&& i2) { return b ? std::move(i1) : std::move(i2); } but can used pod types: int = conditional_initialize<true>(1, 2); . array initialization template compiled error. wrong compile example: int a[] = conditional_initialize<true>({1, 2}, {3,4,5}); error message: no matching function call 'conditional_initialize(<brace-enclosed initializer list>, <brace-enclosed initializer list>)'; who can me template? template<class t, std::size_t n, std::size_t m, bool b> std::array<t, b?n:m> conditional_array( std::array<t, n>&& lhs, std::array<t, m>&& rhs...

reportbuilder - How to find the 1st day of a previosu month in SQL Server Reporting services -

i trying set default date fist day of previous april. have found expressions 1st day of previous month =datevalue(dateadd("m",-1,dateadd("d",-(day(now)-1),now))) and have found expression 1st day of april current year ( =cdate("04/01/"+cstr(year(now()) ) need find previous april, not april of current year. is able please? try: =iif(today.month>=4,dateserial(today.year,4,1),dateserial(today.year-1,4,1)) note if run report in april or after current year april, if run report in march or before last year april. let me know if helps.

python - django auth system 'created' -

Image
i'm working django 1.7.11. have preexisting project , i've decided try use built in admin panel (i have not created superuser). when opened auth page saw : thinking there may problem tables decided delete sqlite database , rerun everything: $ python manage.py makemigrations app1 migrations 'app1': 0001_initial.py: - create model seller $ python manage.py migrate operations perform: synchronize unmigrated apps: crispy_forms apply migrations: admin, contenttypes, auth, app1, sessions synchronizing apps without migrations: creating tables... installing custom sql... installing indexes... running migrations: applying app1.0001_initial... faked $ python manage.py syncdb operations perform: synchronize unmigrated apps: crispy_forms apply migrations: admin, contenttypes, auth, app1, sessions synchronizing apps without migrations: creating tables... installing custom sql... installing indexes... running migrations: no migrations apply...

OBIEE adding an integer to date -

i looking add number of days (column 1- integer) date (column 2- date) create date in future (column 3- date). what code required? try using formula column3 timestampadd(sql_tsi_day,cast("table"."column1_int" integer), "table"."column2_date")

javascript - get base64 by filename to view -

i saved name of files db, , store file in file server. can access file getting name , <img src='http://localhost/upload/abc.jpg'/> abc filename. how base64? because need actual file , pass somewhere. if image on same domain, can canvas.. function getbase64image(img) { var canvas = document.createelement("canvas"); canvas.width = img.width; canvas.height = img.height; var ctx = canvas.getcontext("2d"); ctx.drawimage(img, 0, 0); return canvas.todataurl("image/png"); } // if image on dom use var img = document.getelementbyid('img'); alert(getbase64image(img)); // if image isn't on dom this.. var img = new image(); img.onload = function(){ alert(getbase64image(img)); } img.src= "http://my/image/url.png";

slim - File Upload in Userfrosting -

we need have user upload image part of sign process. had tried accessing $_files['filename'] in controller, turns out undefined under slim. had seen slim's way of file uploading in couple of articles, reported working, hit wall. the twig part works fine bootstrap file input library for server part using file upload library slim controller code (modifications accountcontroller) looks this ... $storage = new \upload\storage\filesystem('c:/xampp/htdocs/userfrosting/public/images/'); $file = new \upload\file('imagefile', $storage); $new_filename = 'test.jpg'; $file->setname($new_filename); $file->addvalidations(array( // ensure file of type "image/jpg" new \upload\validation\mimetype('image/jpg'), // ensure file no larger 500k (use "b", "k", m", or "g") new \upload\validation\size('500k') )); // access data file has been uploaded $uploadfiledata = array(...

audio - Stoping a sound as an action on a node with a key in SceneKit -

i've written function in scenekit plays background music action on node key stop music playing using key i have global variable can call stop action anywhere in class, (by way scenekit not spritekit, still using swift language though) var musicplayingaction = scnaction() however nothing stops it, either forkey or removeallactions in... this nothing scnscene.rootnode.removeactionforkey("bgmusickey") so try higher level , drill down, killing actions either on scene, view or node (depending on attach sound action). self.scnview.scene!.rootnode.removeallactions() still nothing... even if run sound action on specific node , try kill that.. guessed nothing or should music still playing. this function func playmusic() { if game.state == .playing { let music = scnaudiosource(filenamed: "art.scnassets/sounds/bgmusic.mp3")! music.volume = 0.3; music.loops = true music.shouldstream = true ...