Posts

javascript - Three.js Why renderer with viewport & scissor and I have a complete black canvas -

i have typical ui - 2 vertical windows. left canvas & renderer, right ui. inside ui have special viewers, example simple top view window. i have used viewports && scissors approach. works fine. the question miss special parameter avoid complete canvas black-filled covers have (my ui) behind. expected viewport & scissors going let me have 'clean' areas (not filled) inside canvas. not.... the alpha approach ( renderer = new three.webglrenderer( { alpha: true } ); ) fix don't know if best solution (what performance) or there way program (enhancement) related viewport & scissors. if i'm going use viewports there no sense fill black. (also main question ... if have viewport & scissor, why , fill canvas black ?) it totally okay use this: var renderer = new three.webglrenderer({ alpha: true }); it common approach can read here in answer you can change color this: renderer.setclearcolor( 0xffffff );

php - Copy file without creating target file -

i want copy file 1 place without knowing target file exists or not. i'm using: <?php $source = 'user/temp/details.txt'; //this file exists. $target = 'user/'.$user_name.'/details.txt'; //this file don't exists. copy($source, $target); ?> but saying: warning: copy() [function.copy]: filename cannot empty in c:\apache2.2\htdocs\account.php on line 3

java - adding second level data in properties file -

what have properties file below. welcome.properties admin = admin welcomeadmin = welcome admin editadmin = edit admin as have repeated admin word, want use below. admin = admin welcomeadmin = welcome #{admin} editadmin = edit #{admin} so if change @ 1 place i.e. @ admin = admin , places reflect. any idea/ suggestion how done appreciated. as per today, classic resourcebundle class doesn't support named parameters , substitution, rather supports simple placeholders of {0} type in key-value pairs of bundles, substituted using messageformat#format . in light if replace welcome #{admin} welcome {0} you'd able achieve functionality seek using 1 of following: jsf's <h:outputformat> : <h:outputformat value="#{msg.welcomeadmin}"> <f:param value="#{msg.admin}" /> </h:outputformat> jstl's <fmt:message> : <fmt:message key="msg.welcomeadmin"> <fmt:param value="#...

templates - Razor Engine not working in ASP.net 5 MVC 6 -

i trying migrate existing code mvc5 mvc6 , having difficulty particular code: engine.razor.runcompile(file.readalltext(emailtemplatepath), "emailtemplatekey", typeof (emailviewmodel), emailviewmodel); i receiving following runtime error: missingmethodexception: method not found: "void microsoft.aspnet.razor.codegenerators.generatedclasscontext.set_resolveurlmethodname(system.string)". in razorengine.compilation.compilerservicebase.createhost(type templatetype, type modeltype, string classname) the original code using in mvc5 taken here . if there no way of converting above code work mvc6 elegant way of doing email templates? apparently there has been change in generatedclasscontext class - property resolveurlmethodname not exist anymore, hence missingmethodexception . looks parsercontext class has changed too, since accessing onerror event handler throws same exception. in fact setter of missing property missing (pardon expression!), whic...

php - password issue with database change -

i changing database add "sex" column , after, can't log site. get_passwd() function, , see $passwd = $row[5] causing problem. i fixed it, there better way function, if adding column database? function get_passwd($link, $login) { $sql = "select * user email='$login'"; $result = mysql_query($sql, $link); $row = mysql_fetch_array($result); $passwd = $row[6];//this problem! //echo $passwd; return $passwd; }; you're mysql functions deprecated. should afraid of mysql injections . ... here way make world of mysql safer ... pdo - http://php.net/manual/de/book.pdo.php example: $db = new pdo("mysql:host=$db_host;dbname=$db_name;charset=utf8", "$db_user", "$db_pass"); $query = $db->prepare("select username, password user email = ? limit 1"); // should know columns selecting // limit make sure don't select 2 rows. $query->execute(array($login)); $row = $q...

Spark: Convert String to spark.sql.types object in scala -

i have array of string {"stringtype", integertype, "longtype", "stringtype"} in scala. , need covert each string spark.sql.types object while iterating for example: stringtype = spark.sql.types.stringtype integertype = spark.sql.types.integertype longtype = spark.sql.types.longtype. one solution create 1 1 hashmap of string , spark.sql.types , use while iterating array. there other cleaner way this? i use scala pattern matching. like: import org.apache.spark.sql.types._ val typelist = inputarray.map(s => { s match { case "stringtype" => stringtype case "integertype" => integertype etc... case _ => throw new runtimeexception("unknown type") } })

Decrement index in a loop after Swift C-style loops deprecated -

how express decrementing indexed loop in swift 3.0, syntax below not valid more? for var index = 10 ; index > 0; index-=1{ print(index) } // 10 9 8 7 6 5 4 3 2 1 here easier (and more swifty) approach. for in (0 ..< 5).reversed() { print(i) // 4,3,2,1,0 } let array = ["a", "b", "c", "d", "e"] element in array.reversed() { print(element) // e,d,c,b,a } array.reversed().foreach { print($0) } // e,d,c,b,a print(array(array.reversed())) // e,d,c,b,a