Posts

Showing posts from September, 2012

vb.net - Loop through folders and only copy files that match certain criteria -

i writing program copies files needed 1 folder another. however, want copy files fit criteria, more specifically, should copy files not in banned files, banned extensions, or banned folders list stored in array this: public bannedextensions string() = {".bak", ".bak2", ".cry", ".max", ".psd", "log", ".lib", "pdb", ".exp"} public bannedfolders string() = {"tools", "editor", "code", "logbackups", "statoscope", "bintemp", "user", "rc"} public bannedfiles string() = {"editor.exe", "error.bmp", "error.dmp", "luac.out", "tags.txt"} the code should move them temporary directory , zip them , save them location stored in file_name variable. this code whole: option strict on public class form1 'define 2 variables used tracking file nam...

javascript - Load image from a url and convert it to a base64string -

this question has answer here: how convert image base64 string using javascript 8 answers i trying load image url , convert base64 string. all string when use html source of image, images blank. what doing wrong? function getbase64image(imgurl) { var image = new image(); var canvas = document.createelement("canvas"); var context = canvas.getcontext('2d'); image.src = imgurl; context.drawimage(image,0,0); return canvas.todataurl(); } the function returns string. thank you. simple way that: $image = file_get_content($url); $result = "data:image/png;base64,". base64_encode($image);

java - Newly opened window is not getting preferences from parent window in selenium webdriver -

i'm automating application having digestive authentication process. 1 window, when clicking on particular link new window have digestive authentication. i'm using firefox browser automation. when system profile, it's working fine, when use custom profile selenium, it's not automatically authenticated. suspect preferences parent window not shared new window. can me on ? you need make sure window opening in profile need to. if isn't, idea go through , check webdriver settings connected correct profile. if correct, ensure settings within custom firefox profile exact same ones within system profile. you can check profile running in terminal: firefox -p this should open profile manager. hope i've helped :)

How to search for lines in a file between two timestamps using Bash -

in bash trying read log file , print lines have timestamp between 2 specific times. time format hh:mm:ss. example, searching lines fall between 12:52:33 12:59:33. i want use regular expression becouse can use in grep function. each logline begins some_nr 2014-05-15 21:58:00,000000 rest_of_line . my solution gives me lines 1 min margin. cut out ss , take lines hh:mm:[0-9]{2} . $2 has format filename_hh:mm:; example: "24249_16:05:;24249_16:05:;24249_16:07:;24249_16:07:;24249_16:08:" my code: b=$2 line in ${b//;/ } ; tent=`echo $line | awk '{split($0,numbers,"_"); print numbers[1]}'`"_logs.txt" time=`echo $line | awk '{split($0,numbers,"_"); print numbers[2]}'`"[0-9]{2}" grep -ie ${time} ${tent} >> ${file1} done i need solution 15 sec margin time not 60. want have input in format filename_hh:mm:ss , take lines hh:mm:ss +/- 15s or filename_hh:mm:ss(1)_hh:mm:ss(2) , take lines betw...

Integrating QTP Script in teamcity -

i'm trying add qtp script team's build steps in team city. i've tried searching web didn't find anything. does know if possible? if possible, how achieve this? thanks. i not experience team city, wanted offer suggestion since have not had other feedback yet. answer question same type of integration... have use qtp api execute tests , pull results. hp provides little direct support integrating tools outside of own, have use api build integrations. if use quality center/alm, set test set of build validation tests executed using api qc/alm instead.

sparql - Querying an Open RDF Repository -

i trying query open rdf repository loaded turtle file. when selecting query - "select ?s { ?s ?p ?o } "; working fine when using little complex query not working. attaching code query portion - private static void queryingrdf(repository repo) { try{ repositoryconnection con = repo.getconnection(); try{ string querystring = "select ?s { ?s uml:lineofbusiness cp:lobequities .}" ; tuplequery tuplequery = con.preparetuplequery(querylanguage.sparql, querystring); tuplequeryresult result = tuplequery.evaluate(); try { while(result.hasnext()){ bindingset bindingset = result.next(); value valueofx = bindingset.getvalue("s"); //value valueofy = bindingset.getvalue("p"); //value valueofz = bindingset.getvalue("o"); //system.out....

Add A Value to Rows And Cells In WPF -

i developing program datagridview. need adding values rows , cells: my code: (int = 0; < 0x18; i++) { this.dataview1.updatedefaultstyle(); this.dataview1.rows[i].cells[0].value = i; this._dataview1[i].cells[1].value = getname(i); application.doevents(); } it dont work error:system.windows.controls.datagrid not contain rows. same error cells. works fine in c#. wpf code; <grid background="#ffe5e5e5"> <datagrid x:name="dataview1" horizontalalignment="left" verticalalignment="top" height="337" width="809"> <datagrid.columns> <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="client"/> <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="name"/> ...

html - Remove inline padding without removing line breaks -

Image
i've got collection of span s want squeeze 1 line, similar language stats graph on github project page. problem span s have spacing between them (which didn't add) , parent @ width: 100%; , line wraps. github: my attempt: i found helpful information in this question asked earlier on so. showed me solution problem having. however, still have problem - because i'm using haml, i've got line breaks between spans in original source, , don't know how remove them. i'm looking way remove spacing between spans when spans do have line breaks between them. i've got fiddle showing i'm trying http://jsfiddle.net/j9y7a/1/ -- above version shows how want look, bottom shows happens when line breaks present. how can remove spacing between line-separated span tags without removing line breaks? if add float:left; to .pipeline-bucket-segment , segments put nicely together. read floats here .

hibernate - Building Dynamic ConstraintViolation Error Messages -

i've written validation annotation implemented custom constraintvalidator . want generate specific constraintviolation objects use values computed during validation process during message interpolation. public class customvalidator implements constraintvalidator<customannotation, validatedtype> { ... @override public boolean isvalid(validatedtype value, constraintvalidatorcontext context) { // figure out value not valid. // now, want add violation error message requires arguments. } } a hypothetical error message in message source: customannotation.notvalid = supplied value {value} not valid because {reason}. the context passed isvalid method provides interface building constraint violation, , adding context. however, can't seem figure out how use it. according documention version i'm using, can add bean , property nodes violation. these additional details can specify violation definition, don't understand how might map parameters ...

asp.net mvc - Does the AntiForgeryToken need to be inside a form tag -

all examples see have seen, have antiforgerytoken inside of <form> tag: @using html.beginform("dothis", "fromhere", formmethod.post, new {.id = "myid"}) @html.antiforgerytoken() end using is required? doing posts server using ajax/jquery calls. i'm using example provided here ( prefilter ) can retrieve antiforgerytoken. don't have antyforgerytoken inside of form tag. placed on root _layout page , called good. why need else? can't think of why have to... in examples have anti-forgery within form tag, when form posted via submit button click automatically posted of other form variables. if manually posting data via ajax can have anti-forgery token generated anywhere, need grab value , post along other data sending server. make sure name property of anti-forgery token same html helper method ("__requestverificationtoken").

How to count the amount of times a substring is in a csv file using python -

as title implies, trying figure out how code program allow me count how many times substring appears in csv file. example have csv file states how many time person called unknown number , want write file amount of times each person called number unknown. this input csv file like: john smith called or messaged unknown party(xxx-xxx-xxxx) on 11/9/2013 @ 16:44 1 second(s). john smith called or messaged unknown party(xxx-xxx-xxxx) on 11/12/2013 @ 8:18 1 second(s). john smith called or messaged unknown party(xxx-xxx-xxxx) on 11/21/2013 @ 16:17 1 second(s). john smith called or messaged unknown party(xxx-xxx-xxxx) on 11/21/2013 @ 13:51 1 second(s). john smith called or messaged unknown party(yyy-yyy-yyyy) on 11/1/2013 @ 16:26 1 second(s). john smith called or messaged unknown party(yyy-yyy-yyyy) on 11/1/2013 @ 16:45 21 second(s). jane smith called or messaged unknown party(zzz-zzz-zzzz) on 11/21/2013 @ 10:41 2 second(s). jane smith called or messaged unknown party(zzz-z...

php - Changing laravel remember_token field to something else -

for project use auth login, works fine until try logout : auth::logout(); i use custom fieldname herrinertoken instead of default remember_token. in model/user.php edited function getremembertoken() to: public function getremembertokenname() { return 'herrinertoken'; } when try logout message: sqlstate[42s22]: column not found: 1054 unknown column 'remember_token' in 'field list' (sql: update gebruikers set herrinertoken = a3eyy1iibx1ffphpgmyntnlwke7a43vgqwpsu2b5b3efnhl0ayyf1vusgcbc, remember_token = a3eyy1iibx1ffphpgmyntnlwke7a43vgqwpsu2b5b3efnhl0ayyf1vusgcbc id = 6 ) so looks tries tu update both remember_token , herrinertoken want update herinner_token field. need adjust update herrinertoken field , not remember_token field ? add herrinertoken column instead of remember_token column users (or equivalent) database table. you should use along following snippet: public function getremembertoken() { return $this->h...

amazon web services - Android Java AWS SDK S3 Image Upload Callback Functions -

i'm looking android aws s3 image upload callback function or someway of detecting whether image uploaded successfully. documentation didn't seem list any. i'm following android tutorial . could advise me on matter? thanks in tutorial, sample code snippets android use synchronous service client. when method returns response object, means service call completed. throws exception if request fails.

php RRD Graph floating values instead of integers -

Image
i producing rrd graph , facing 2 problems. problem 1: numbers printing integers without decimals, although when printed decimals appear. confusing. looked online on rrdgraph_graph , although using correct syntax , not applying calculations still floating values instead of integers. according official website: %s place after %le, %lf or %lg. replaced appropriate si magnitude unit , value scaled accordingly (123456 -> 123.456 k). i have attached photo sample of output. have provide working example code if understands rrd's can view possible error. problem 2: trying add on graph vrule:time#color[:legend][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]] function , based on online instructions can supply time. since graph shifting planning time (value) - 1800 sec. wanted place vertical line in middle of graph view approximately average on 30 minutes values. when applying such format error: <b>graph error: </b>parameter '1400274668-1800'...

meteor - Cannot call method 'create' of undefined -

here i'm getting console server side. i20140516-21:27:12.142(0)? there error on page. cannot call method 'create' of undefined i not finding reason why method isn't defined. have balanced-payments-production package atmosphere loaded , includes balanced.js file , api export server. here appreciated. here events.js file template.checkformsubmit.events({ 'submit form': function (e, tmpl) { e.preventdefault(); var recurringstatus = $(e.target).find('[name=is_recurring]').is(':checked'); var checkform = { name: $(e.target).find('[name=name]').val(), account_number: $(e.target).find('[name=account_number]').val(), routing_number: $(e.target).find('[name=routing_number]').val(), recurring: { is_recurring: recurringstatus }, created_at: new date } checkform._id = donations.insert(checkform); meteor.call...

android - How to prevent AutoCompleteTextView drop down list disappear after user input -

i developing customized autocompletetextview customized adapter. however, when text in text field changes, drop down list disappear temporarily until new results published. think happening autocompletetextview hide drop down list during filtering. however, there way force autocompletetextview display drop down list time? the reason didn't actively use filter in customized adapter because filter doesn't fit case. if performfiltering() method returns null or values field in returned filterresults in method empty, drop down list hidden. way solve problem returning dummy filterresults object , fill dummy values field in object in performfiltering() method.

database - Android: Text size not changing -

i'm doing quiz using sqlite database , questions , answers pull database dont seem change size set in xml file. have narrowed down stuff pulled database i'm wondering why that. here classes involved dbhelper public class dbhelper extends sqliteopenhelper { public dbhelper(context context) { super(context, database_name, null, database_version); } private static final int database_version = 1; // database name private static final string database_name = "triviaquiz"; // tasks table name private static final string table_quest = "quest"; // tasks table columns names private static final string key_id = "id"; private static final string key_ques = "question"; private static final string key_answer = "answer"; //correct option private static final string key_opta= "opta"; //option private static final string key_optb= "optb"; //option b private static final string key_optc= "optc"; //opti...

c++ - QDir absolutePath on Mac -

im getting 2 different paths when run same build within qt creator , when double click on finder on mac. here code: qdir dir = qdir::currentpath(); dir.cdup(); dir.cdup(); dir.cdup(); qstring rootpath = dir.absolutepath(); when run (debug) mode in qt creator path is: /users/myuser/projects/appname/build/mac when double click on file located on /users/myyser/projects/appname/build/mac finder returns / only. why 2 different paths? version: qt5.2.1 update seems bug reading following urlhttp://qt-project.org/forums/viewthread/34019 why 2 different paths? as write in thread linked, qdir::currentpath() not returns application directory. return path wherever application run, different application directory when running application command line, or "start menu" alike places , on. if wish deal application directory navigate there, need use following method instead: qstring qcoreapplication::applicationdirpath() [static] returns director...

data mining - WEKA simple CLI command Killed -

i run following code on weka simplecli tool java weka.core.converters.textdirectoryloader -dir c:/mydir/ > c:/output/result.arff and showed following result [...killed] finished redirecting output 'c:/output/result.arff' the result.arff file size 0 kb. anyone know problems? /* data 63 thousand file of *.txt when try 10 sample of data work */ maybe run out of memory? isn't there error message reported? complete output shared?

How to respond to a http get in native c++ linux -

i'm totally new programming c++ linux, i'd make following; console application handle , echo parameters of incommoding http request. but first step be; so if open browser , a; http://192.168.2.10/?yadda=1 on linux system on 192.168.2.10, echo on screen new incomming web request parameters: yadda=1 i've done few times .net http listener, i'm totally clueless on how c++ in linux. thanks help! (no netcat, no vmware under linux running .net httplistener, no echo-ing piping, script solution, emulation or whatever, want know how in c++ under linux) in other words; dim listener new httplistener() listener.prefixes.add("http://localhost/") dim context httplistenercontext = listener.getcontext in linux using c++ create binairy executable. actual lines of c++ code helpfull. thanks 1) can wire pretty netcat (nc) on linux without writing network code. nc can run in server mode, , can pipe input / output program, c++ console program. ...

live streaming - Hitbox Follower Alert -

there site called hitbox. it's similar twitch far can see api rather different! tried take twitch follower alert , change code bit make work hitbox no luck. don't want create whole program because take lot of time. want make webpage , display latest follower on there. hitbox api can found here . if think easier in mirc way think easier webpage. total n00b when comes programming if explain me appreciate (i want start learing code don't know start. @ least quite young (14) have enough time that) thanks - andrew i came across post while searching information on hitbox on google. , know what!? made follower alert app 30 min ago. here code, it's simple. (hitbox_followeralert.js) var followers = 0, lastcheck = 0, lastfollower = "", sound = new audio("alertsound.ogg"), channel = "maitrechocobo"; function checkfornew(){ $.getjson("http://api.hitbox.tv/user/"+channel, function(data){ followers ...

ruby on rails - Will ajax will pagination is rendergin the page twice -

i using ajax pagination in rails application. pagination working perfectly. in 1 page when click on next page link. showing page twice. in other pages working fine. here index.js.erb: $('.sort_paginate_ajax').html("<%= escape_javascript(render("jobs"))%>"); $(".tablesorter").tablesorter(); and index.html.erb like: <div class="sort_paginate_ajax"><%= render 'jobs' %></div> the server log is: started "/jobs?page=2&_=1400322005679" 127.0.0.1 @ 2014-05-17 15:50:12 +0530 processing jobscontroller#index js parameters: {"page"=>"2", "_"=>"1400322005679"} user load (0.5ms) select "users".* "users" "users"."id" = 2 order "users"."id" asc limit 1 job load (0.5ms) select "jobs".* "jobs" limit 2 offset 2 (0.3ms) select count(*) "jobs" loc...

python - Hide console when py-file only (no pyw) [ANKI add-on] -

i adjust music fiddler add-on anki srs windows users. anki runs add-ons with ending .py, not pyw. there way hide console automatically pops when run code. if not, there way no unselect console windows (i have click on main anki windows after every 5 seconds because console closed again in selection). the command use far opening windows example: os.system('"nircmd.exe changesysvolume"'+ change) the complete code below console runs nircmd.exe , number of volume units system sound should change. there possibility adjust code? # -*- coding: utf-8 -*- # music-fiddler (a plugin anki) # coded d_malik, malik6174@gmail.com # version 1 # license: gnu gpl, version 3 or later; http://www.gnu.org/copyleft/gpl.html """ simple plugin fiddles music volume reinforce quick reviewing. before using: - plugin made linux. require modification work on os. - ensure "amixer" command works on computer. if doesn't, you're going need modify...

mmenu - Add a fixed logo to top of jquery menu? -

does know if it's possible add logo/image top of jquery mmenu stays fixed while submenus accessed? i've tried using headers add-on, have had 0 luck getting work text. any great. thanks. since mmenu kinda looks @ tags , clones it, found it's best prepend after pageload. instance, code looks this. (you ignore of options, , replace own.) $(document).ready(function() { $("#menu").mmenu({ "classes": "mm-slide mm-light", "header": true, "": true, "searchfield": { "placeholder": "search", "add": true, "search": true } }); var varname = "<div id='forstyling'><img src='images/globe.png' alt='' /><a href='/'>company home</a>...

c# - check if button_click event was called -

my button pict let choose image. here click_event button: private void picture_click(object sender, eventargs e) { using (openfiledialog dlg = new openfiledialog()) { dlg.title = "open image"; dlg.filter = "image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; if (dlg.showdialog() == dialogresult.ok) { pict.add(new bitmap(dlg.filename)); } } } and have several same panels button. if don't use pict button, should load standart image. how know in pannel picture_click called , in don't?(also want place small picturebox near buttons clicked). standart image![enter image description here][1] use parent property of sender parameter of event handler, discover panel: control mycontrol = ((button)sender).parent;

php - foreach max array value? -

i'm new php , have problem loops. have foreach loop, foreach ($contents $g => $f) { p($f); } which gives arrays, depending on how many contents have. have 2, array ( [quantity] => 1 [discount] => 1 [discount_id] => 0 [id] => 1506 [cat_id] => 160 [price] => 89 [title] => კაბა ) array ( [quantity] => 1 [discount] => 1 [discount_id] => 0 [id] => 1561 [cat_id] => 160 [price] => 79 [title] => ზედა ) my goal save array has max price in different variable. i'm kinda stuck on how that, managed find max price max() function so foreach ($contents $g => $f) { $priceprod[] = $f['price']; $maxprice = max($priceprod); p($maxprice); } but still dont how i'm supposed find out in array max price. suggestions appreciated you should store keys can after loop: $priceprod = array(); foreach ($contents $g => $f) { // use key $g in $price...

javascript - How to access returned objects from query so that images can be displayed? -

parse.com , javascript. the code below returning correct results, per screen shots, but.. how can return , access each of objects has been captured query? want use "pic" column held within _user class. @ moment images returning undefined. var currentuser = parse.user.current(); var friendrequest = parse.object.extend("friendrequest"); var query = new parse.query(friendrequest); query.equalto("fromuser", currentuser); query.equalto("status", "request sent"); //query.exists("pic"); query.find({ success: function(results) { // if query successful, store each image url in array of image url's imageurls = []; (var = 0; < results.length; i++) { var object = results[i]; imageurls.push(object.get('pic')); } // if imageurls array has items in it, set src of img element first url in array for(var j = ...

apache - httpd start fails and shows up error -

while try install server through yum install httpd , later when start service shows following error : [root@localhost ~]# systemctl enable httpd.service ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service' [root@localhost ~]# systemctl start httpd.service job httpd.service failed. see 'systemctl status httpd.service' , 'journalctl -xn' details. [root@localhost ~]# can body please on it??

sql - What is the correct way to structure a high volume log record -

i have requirement log application events in sql 2012 database. basic record structure requirement pretty simple: create table [dbo].[eventlog] ( [processid] int not null, [applicationid] int not null, [created] datetime not null, constraint [pk_eventlog] primary key clustered ([processid],[applicaionid],[created] asc) ) the problem having 1 of performance. 1 million events per day can generated , number of rows increase, insert performance diminishing - point logger not able keep events. i writing batches of logs out intermediary plain text files , processing these files using service running separately main application logger. i suspect culprit may maintaining index , advice on how can approach problem more efficiently/effectively. any advice appreciated. the main cause of performance problem choice of columns forming clustered index. in clustered index, data stored in leaf-level pages of index, in order defined index key columns. hence, in tabl...

cryptography - Reverse engineering a file encryption (most likely XOR) -

im trying reverse engineer file format encrypted. uses xor encryption. can create encrypted files known plaintext, analyzed: enc 71 8d 7e 84 29 20 b8 cb 6c ed bb 8a 62 a1 dec 74 68 69 73 20 69 73 20 61 20 74 65 73 74 xor 05 e5 17 f7 09 49 cb eb 0d cd cf ef 11 d5 txt t h s s t e s t enc 61 ad 84 29 20 b8 cb 6c ed bb 8a 62 a1 dec 64 68 69 73 20 69 73 20 61 20 74 65 73 74 xor 05 c5 d7 f7 09 49 cb eb 0d cd cf ef 11 d5 txt d h s s t e s t enc 62 a5 ae a4 e9 a0 b8 cb 6c ed bb 8a 62 a1 dec 67 68 69 73 20 69 73 20 61 20 74 65 73 74 xor 05 cd c7 d7 c9 c9 cb eb 0d cd cf ef 11 d5 txt g h s s t e s t it obvious original text part of encryption. first byte of key 05. second byte of key can calculated this: (enc1 + dec1) or xor1 the rather low entropy of key implies similar rule other key-bytes. any ideas? you got it! the key's byte @ m position given :...

php - Keep option selected -

i have selectbox values, inserted values inside array. now want select specific option, , keep option selected when page reloads. $logos =array('logo1', 'logo2', 'logo3'); echo ' <td class="jofftd"> <label>platform</label> <select name="searchpt"> <option value="0">all</option> '; foreach ($logos $value) { echo ' <option value="'.$value.'">' .$value . '</option> '; } echo ' </select> </td>'; i need this: foreach ($logos $value) { echo ' <option'; if ($value == $value) echo 'selected="selected"'; echo 'value="'.$value.'">' .$value . '</option> '; } but doesn't work. thanks. assuming using post method form, code (note: not tes...

date and time to just time in python -

i have made small program weather station in python , working perfectly, have 1 little problem. the output displays 2014/5/18 04:03:41 2014/5/18 19:47:41 i want display 04:03:41 19:47:41 is there easy way this,i thinking of stripping characters out sounds more of bodge converting. thanks help in [66]: t="2014/5/18 19:47:41".split() in [67]: print t[-1] 19:47:41 if have string split , last element time. t="2014/5/18 04:03:41" datetime import datetime str_time= datetime.strptime(t,'2014/5/18 %h:%m:%s').time() in [72]: print str_time 04:03:41 datetime docs

android - Safely insert data on SQLite database -

i need load data coming service in table on splashscreenactivity. i've followed this tutorial , works fine. have added custom asynctask run insert loop in background. the problem if configuration change happens in middle of insert (e.g. screen rotation) blows , corrupted data saved on database. i've read stuff cursorloader that's querying database. i've looked @ contentproviders don't solve problem. any ideas on how handle problem? what need is: access database background thread keep ui responsive. handle configuration changes when doing inserts on database. update: public class splashscreenactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_splash_screen); ... // create volley request , fetch data } when response object start asynctask: new response.listener<jsonobject>() { @override public void ...

scala - How to convert recursion to fold -

according erik meijer, functional programmers, know instead of recursion, should use fold. how convert following use fold? can see 1 way return, return should avoided in fp. thanks! def tryold(string: string, original: exception, zomoldlist: list[string => double]): double = { zomoldlist match { case nil => throw original case head :: tail => try { head(string) } catch { case ex: exception => tryold(string, original, tail) } } } you can implement foldright taking advantage of functions being values: import util.control.nonfatal def tryold(string: string, original: exception, zomoldlist: list[string ⇒ double]): double = { val unhandled: string ⇒ double = _ ⇒ throw original zomoldlist.foldright(unhandled) { (f, z) ⇒ x ⇒ try { f(x) } catch { case nonfatal(_) ⇒ z(x) } }(string) } note use nonfatal here avoid catching exceptions shouldn't catching. can write in more elegant way not u...

ruby - How do I iterate over an array of hashes and return the values in a single string? -

sorry if obvious, i'm not getting it. if have array of hashes like: people = [{:name => "bob", :occupation=> "builder"}, {:name => "jim", :occupation => "coder"}] and want iterate on array , output strings like: "bob: builder". how it? understand how iterate, i'm still little lost. right now, have: people.each |person| person.each |k,v| puts "#{v}" end end my problem don't understand how return both values, each value separately. missing? thank help. here go: puts people.collect { |p| "#{p[:name]}: #{p[:occupation]}" } or: people.each |person| puts "#{person[:name]}: #{person[:occupation]}" end in answer more general query accessing values in elements within array, need know people array of hashes. hashes have keys method , values method return keys , values respectively. in mind, more general solution might like: people.each |person|...

jquery - Click event is not working for button -

i having problems button btndel not working when click. here's script: $('#btnadd').bind('click', function() { var scount = $("#support-list").find('li').length; var tmpstr = $('#txtaddsupportname').val(); var str = “<li>"; var str += “<img src='../wp-content/plugins/hamajob/admin/assets/image/arrow.png' width='16' height='16' class='handle'/>"; str += "<strong alt="+ scount +">" + tmpstr + "</strong>"; str += "<input type='button' id='btndel'/>"; str += "</li>"; $('#support-list').append(str); }); $('#btndel').bind('click', function(){ alert(this); }); however, script work: str += "<input type='button' id='btndel' onclick='btndel(this)'/>"; btndel = function(e){ alert(this); } co...

How to ban someone from accessing my website in PHP [Not IP ban] -

i've been looking on place find more ways ban users accessing website. i'm using php & iis. have heard of mac banning someone? unaware how works, want add additional security bans; if superban site, drop cookie, ban ip , possibly ban computer. i know there's ways of them, of people use website not computer-savvy; won't know how bypass it. preferably looking done in php, since site made of php. if don't want ip bans, , said above mac address bans not possible on internet, reliable method have user registration system. when they're banned, don't let them log in , use site. ip irrelevant. there ways around too, though. have site set cookie when banned user tries login prevents new registration attempts - if users not tech-savvy, may sufficient put them off.

matching - how to match in perl using \d? -

just stupid question - meaning of d in following code. role playing in it? $str = 'telephone: 040-27614396'; $str =~ m/telephone:\s*(\d{3}-\d{8})$/; please tell meaning of these kind of stuff if (/^\#/) the expression checking if string variable $str matches regular expression /telephone:\s*(\d{3}-\d{8})$/ . look here more details on perl expression matching: http://www.tutorialspoint.com/perl/perl_regular_expressions.htm the link discusses: \d: matches digits. equivalent [0-9]. ^: matches beginning of line. \: "escapes" following character: "#" means treat "#" "#" ... instead of trying interpret metacharacter. there many tutorials "regular expressions" on web can explain in more depth.

Why Plus operator does not work on integers in Alloy? -

below alloy code 8queens problem not know why plus operator , minus operator not work correctly after execution there queens in same diagonal face error when use plus , minus operator between 2 # example : #q1.row+#q2.col-#q1.col != #q2.row thanks response best regards here that's 8queens code: sig queens{ row:int, col:int } {row>=0 , row <#queens , col>=0 , col<#queens} pred nothreat(q1,q2 : queens) { q1.row != q2.row , q1.col != q2.col , q1.row+q2.col-q1.col != q2.row , q1.row-q2.col+q1.col != q2.row } pred valid { q1,q2 : queens | q1 != q2 => nothreat[q1, q2] } fact card {#queens =8} run valid 8 queens, 8 int use plus , minus functions instead (e.g., q1.row.plus[q2.col].minus[q1.col] ), because + treated set union, , - set difference.

javascript - Efficient way of scrolling to part of page with jquery links -

i've asked in regards scroll identifier , have code working perfectly: http://codepen.io/vsync/pen/kgcoa however, wondering how can when click links on black scrollbar can scroll part of page. think along these lines: $(".a1").click(function() { $('html, body').animate({ scrolltop: $("#a1").offset().top }, 2000); }); the scroll identification bit of javascript has been refined hoping there elegant , optimised way make can skip bits of page too. any appreciated. try this. $("nav span").click(function() { var sectionid = $(this).attr('class') $('html, body').animate({ scrolltop: $('#'+sectionid).offset().top }, 2000); }); fiddle demo

c# - Referencing another a web form in another web form to pass data -

i've got page called webform1 , has couple of textboxes , button , want pass data couple of labels on webform2. webform1 button: <asp:button id="btncrosspage" runat="server" text="button" postbackurl="~/webform2.aspx" /> code behind webform 1: public partial class webform1 : system.web.ui.page { } public string name { get{ return txtname.text;} } public string email { get{ return txtemai.text;} } webform2 code behind: public partial class webform2: system.web.ui.page { webform1 ppage = (webform1)this.previouspage; if(ppage != null && ppage.iscrosspagepostback) { lblname.text = ppage.name; lblemail.text = ppage.email; } visual studio not letting me reference webform1 in webform2 without red line appearing, can see reason why? well, once, "webform1" misspelled, should "webf...

c - Floats being Inexact -

i puzzled. have no explanation why test passes when using double data type fails when using float data type. consider following snippet of code. float total = 0.00; ( int = 0; < 100; i++ ) total += 0.01; one anticipate total 1.00, equal 0.99. why case? compiled both gcc , clang, both compilers have same result. the value 0.01 in decimal expressed series: a1*(1/2) + a2*(1/2)^2 + a3*(1/2)^4 + etc. an 0 or one. i leave figure out specific values of a1, a2 , how many fractional bits ( an ) required. in cases decimal fraction cannot represented finite series of (1/2)^n values. for series sum 0.01 in decimal requires an go beyond number of bits stored in float (full word of bits minus number of bits sign , exponent). since double has more bits 0.01 decimal can/might/maybe (you calculation) precisely defined.

html - Website is not centering on mobile -

im creating simple website. on desktop, whole content centered ok. works changing size of browser. when visited on mobile, not centered on desktop take look: http://piaskownica.lokalnamanufaktura.pl/metod2/ i think css wrap class centering buggy. videobackground not centered on desktop. .wrap { position: absolute; left: 50%; top: 50%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); width: 90%; height: 90%; } .x2-horizontal has width of 380px wide small screens. watch out fixed widths in responsive designs. your layout method not ideal. start, think of devices don't support transform . the video control won't center using margin: auto because of position: absolute . you'd have use same kind of centering methos other content (i.e. left: 50% , pulling 50% of width.)

Best type for JPA version field for Optimistic locking -

i have doubts best type field annotated @version optimistic locking in jpa. the api javadoc ( http://docs.oracle.com/javaee/7/api/javax/persistence/version.html ) says: "the following types supported version properties: int, integer, short, short, long, long, java.sql.timestamp." in other page ( http://en.wikibooks.org/wiki/java_persistence/locking#optimistic_locking ) says: "jpa supports using optimistic locking version field gets updated on each update. field can either numeric or timestamp value. numeric value recommended numeric value more precise, portable, performant , easier deal timestamp." "timestamp locking used if table has last updated timestamp column, , convenient way auto update last updated column. timestamp version value can more useful numeric version, includes relevant information on when object last updated." the questions have are: is better timestamp type if going have lastupdated field or better have numeric versio...

javascript - How can I load the content of tumblr nextPage on indexPage -

i'm developing tumblr theme personal portfolio, i'm encountering serious problem in work section, want create horizontal slider effect, when click next see older posts, like this: http://tympanus.net/tutorials/websitescrolling/ i have define nextpage, #section4 have posts of work: <!-- next page --> {block:nextpage} <div> <a id="next-button" href="{nextpage}#section4" class="next panel" style="position:relative; top:630px; left:1550px;">next</a> </div> {/block:nextpage} <!-- / next page --> well, defined open other page: "indexpage".tumblr.com#section4 when click next goes to: "indexpage".tumblr.com/page/2#section4 is there way can slide effect on index page or @ least give illusion, i'm making slide effect, when moving other page? if understand question correctly, serakfalcon mentioned i'll add in tumblr specific points. need 3 things speci...