Posts

c# - Thread.Sleep or Timer for showing every step -

i making game wumpus world in winforms in agent(computer) can move in 4 directions. using button control base , showing , hiding images ever needed. used thread.sleep problem when click button nothing showing on form. process on background working fine not showing each step. , yes using thread.sleep in current ui thread. i want show every step users interval of 2 seconds. it's hard answer without code go by, main problem understand change of world, , tell sleep, witch means nothing painted. , when thread wakes up, again change world , make sleep. nothing painted way. better way timer, make single timer , queue of events needed shown , on way it. are working on winforms, because if working on wpf can nicer things edit: i'm not saying timer best way it, it's valid way

Ruby: Rename keys in array of hashes? -

how rename _id keys id in array of mongodb documents? so, want make this: [{"_id"=>"1", "name"=>"matt"}, {"_id"=>"2", "name"=>"john"}, ...] into this: [{"id"=>"1", "name"=>"matt"}, {"id"=>"2", "name"=>"john"}, ...] i found complete solution. mongo_db['users'].find().to_a.each |u| u['id'] = u.delete '_id' end.to_json

security - Create a strong password for AES -

background: using pbewithsha256and128bitaes-cbc-bc algorithm ( bouncy castle ) jasypt via grails plugin . configuration straightforward: jasypt { algorithm = "pbewithsha256and256bitaes-cbc-bc" providername = "bc" password = "<your secret passphrase>" keyobtentioniterations = 1000 } i know how choose secure password above. there real or practical limits on length, restricted characters, etc? specific generator should using? couldn't find clear documentation on , examples use above (e.g., "password", "secret" etc.). password-based encryption takes password , term implies. passwords run through key derivation function obtain actual key. kdf typically constructed hash function, password may of length , contain characters. passwords have run through kdf because typical passwords don't contain anywhere near enough entropy considered secure against brute force attacks. kdf substitutes lack of ...

html - Trying to stretch a background downwards, but a white space remains -

i busy placing html site wordpress template. working out far i'm stuck @ background. @ large pages background stops , shows big white space. the background consists stripes, has gradient fade dark (up) light (down). i trying stretch background down bottom of screen. works pages smaller screen, larger pages need scroll down, background stops , shows big white space. i in need of here - i've tried lot of solutions solved problems large pages, problem exists @ smaller pages. hope there solution stretch background way down, on every page. current code (works on small pages, problems on large pages) html { background: url(images/lines-bg.png); background-repeat: repeat-x; } but when add html css, problem occurs @ small pages.. background-size: auto 100%; i want background scrollable, not fixed. many, many thanks! there 2 things can try if don't have support super old browsers: you can use background-attachment: fixed; property fixes...

java - how to access resources(Excel file) in jar file -

hi have exported java project executable jar file. inside project accessing excel file containing data. not able access excel file when trying access file. my project structure is: java_project_folder - src_folder - resources_folder(containing excel file) i accessing excel file fileinputstream file=new fileinputstream(new file(system.getproperty("user.dir") +file.separator+"resources"+file.separator+"excel.xlsx")); i have tried accessing file using getresourceasstream like: fileinputstream file=(fileinputstream) this.getclass().getresourceasstream ("/resources/excel.xlsx"); but getting in null exception. whats wrong can help? i tried , working me. my test1 class in default package, check accessing class in package, if go exact resource folder classpath "../" public class test1 { public static void main(string[] args) { new test1(); } test1(){ bufferedinputstream file= (bu...

php Ajax jquery check -

hi every body testing code checking name availability ajax , dont why doesnt work <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="jquery.js"></script> <link href="style.css" rel="stylesheet" type="text/css" /> <title>index</title> </head> this body , jquery function check <div id="answer" > <script type="text/javascript"> //script $(document).ready(function() { $("#checkme").click(function(){ $("#answer").ajaxstart(function() { $(this).text("loading .. .").show("slow"); }); var userme = $("#username").val(); $.ajax({ type:get, url:"file.php", data:"username=" + userme, success: function(msg){ $("#answer").text(msg).fadein("slow...

java - hibernate - how to change properties at runtime -

i trying change properties in hibernate.cfg.xml code doesn't work. public static void changeconfiguration(string login, string password){ configuration cfg = new configuration(); cfg.configure(); cfg.setproperty("hibernate.connection.password", password); cfg.setproperty("hibernate.connection.username", login); } any idea why thats doesnt work? file hibernate.cfg.xml looks same. to make work, should build sessionfactory configuration object , use sessionfactory session. something : public static sessionfactory changeconfiguration(string login, string password){ configuration cfg = new configuration(); cfg.configure(); cfg.setproperty("hibernate.connection.password", password); cfg.setproperty("hibernate.connection.username", login); sessionfactory sessionfactory = cfg.buildsessionfactory(); return sessionfactory; } but @ end, not change hibernate.cfg.xml file, overwrite or...