Posts

Showing posts from February, 2014

java - This method must return a result of type InputStream -

i'm getting error stating this method must return result of type inputstream however i've added return statement inputstream source method. i'm not sure why issue occurring. (the issue began when attempted integrate used publish progress method in current source.) source: /* * sends query server , gets parsed results in bundle * urlquerystring - url calling webservice */ protected synchronized inputstream getqueryresults(string urlquerystring) throws ioexception, saxexception, sslexception, sockettimeoutexception, exception { try { // httpsurlconnection https = null; string uri = urlquerystring; list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); basicnamevaluepair mdn1, mdn2,id1,id2; if (mdn.equals("")) { mdn1 = new basicnamevaluepair(&

Tracking custom image links on WordPress website by Google Analytics -

i developed wordpress website give option admin upload image , give link shown advertisement in front end. basically, image clickable , links link provided admin. what want track clicks on these advertisements via google analytics. possible? new google analytics , not have idea. (function ($) { $(document).ready(function() { // attach onclick event document , catch clicks on elements. $(document.body).click(function(event) { // catch closest surrounding link of clicked element. $(event.target).closest("a,area").each(function() { _gaq.push(['_trackevent', 'image click', $('img', this).attr('alt'), $(this).attr('href')]); }); }); }); })(jquery); yeah possible can track image click via google analytics see reference more info. http://techatitsbest.com/blog/image-click-tracking-google-analytics-events http://www.seotakeaways.com/event-tracking-guide-google-analytics-simplified-versi

ruby on rails - Fields For Not Working for Has Many Association -

i'm building form model , having trouble developing associated model forms form. the error i'm receiving: undefined method `tradie_id' #<activerecord::associations::collectionproxy::activerecord_associations_collectionproxy_tradiecategory:0xd0f9d78> the form code looks like: = form_for @data[:tradie], url: { action: "update_tradie" } |tradie| # doesn't work = tradie.fields_for :tradie_categories, @data[:tradie].tradie_categories |category| = category.text_field :tradie_id # fields_for = tradie.fields_for :tradie_locations, @data[:tradie].tradie_locations |location| = location.text_field :address the tradie model has has_many relationship tradiecategory model , tradiecategory model has belongs_to relationship tradie . verified tradiecategory has field tradie_id . in form above, @data[:tradie] equals instance of tradie model. whenever call tradie_categories or tradie_locations calling associated model data of tra

asp.net - Formatting header text in nested gridview -

Image
i have created nested gridview shown in picture. header of child grid repeated. there anyway can add child gridview's headers inline parent gridview?.something have given below. try removing child gridview header , add required headings parent gridview fixed spacing (possible if column lengths fixed)

c++ - "print 1 to n" function prints 1 twice -

void printint(int n){ if(n==1) cout<<1<<" "; else printint(n-1); cout<<n<<" "; } the output is 1 1 2 3....n i'm writing out actual steps of function on piece of paper don't how printing 1 in console (visual studio 2010). past hw solutions strictly understanding how works. you need braces: if(n==1) { cout<<1<<" "; } else { printint(n-1); cout<<n<<" "; } or else second cout gets run when n==1 . strictly speaking braces around first cout aren't required, style in case. editorial note: problem solved stepping through function in debugger.

javascript - How to change "defaultOptions" lang in highCharts dynamically -

i have highcharts trying internationalize. set default defaultoptions ={... lang: { loading: 'loading...', months: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'], ...} i have properties file, , method writes in properties. methodtowrite['highcharts.months.array'](); but when lang:{ loading: methodtowrite['highcharts.months.loading'](); months: methodtowrite['highcharts.months.array'](); } the chart doesnt show up. have feeling i'm inserting methodtowrite wrong way. methodtowrite works fine , correctly coded. using in other js files. try changing semi-colons commas. e.g lang:{ loading: methodtowrite['highcharts.months.loading'](), months: methodtowrite['highcharts.months.array']() } check methodtowrit

iphone - App working when debugging but not in ad hoc distrubtion -

i have strange bug occurring. i'm monitoring sound levels using avaudiorecorder , calling action when sound peaks on level. works on simulator using ios 6 , on device connected xcode using ios 7. when distribute app via testflight audio peak method never triggers. when distribute via ad-hoc , install via itunes have same problem. why work on device connected xcode not through ad-hoc build? edit: i've did more testing , problem related microphone. metering enabled app isn't getting levels it. metering working when i'm debugging not ad-hoc. why work on device connected xcode not through ad-hoc build? sounds you've failed include microphone among "required device capabilities" in info.plist: microphone include key if app uses built-in microphone or supports accessories provide microphone.

javascript - Referencing Ajax-Loaded Element in JS Object Instance -

how reference element doesn't exist yet within javascript object instance? var dynamic = function(el) { this.$instance = $(el); } var dynamicinstance = new dynamic('#dynamic'); since #dynamic element loaded via ajax, script doesn't see when dynamicinstance created , can't reference it. if helps solve issue, reference element inside object without passing in when it's created -- still unclear on how make object aware of element. if want keep things decoupled can accept callback function parameter , call once new element loaded , appended dom function doajaxcall(callback) { $.ajax({ success : function(response) { //logic create new element based on response callback(); } }); } doajaxcall(function() { var dynamic = new dynamic('#dynamic'); }); in way keep decoupled while avoiding race condition created ajax calls.

Amazon product api get stock availability (In Stock, out of Stock, etc) -

i using product advertising api amazon. little lacking honest, since there no way of getting product name. can title, contains offer "amazon kindle 3g, free wifi..." instead of amazon kindle 3g. more importantly, there seems no way of getting stock information. need know if item in stock or not. that's all, there seems no way of doing yet. ama missing something. using itemlookup api. details using large response group no stock information the various 'offers' response groups list 'offers' amazon , 3rd party merchants; data includes availability details pricing (just) 1 offer tell about. can supply merchantid parameter forcing 1 offer amazon. this api has been limited (i.e. 1 offer) since 2011; fuller info try mws api instead. for more literal product name, try obtaining upc or ean itemattributes response group, , looking in non-amazon upc database. no idea how work in practice.

c - why typedef is used so widely in nginx? -

for example there many typedef s huge number of structures in ngx_core.h typedef struct ngx_module_s ngx_module_t; typedef struct ngx_conf_s ngx_conf_t; typedef struct ngx_cycle_s ngx_cycle_t; typedef struct ngx_pool_s ngx_pool_t; typedef struct ngx_chain_s ngx_chain_t; typedef struct ngx_log_s ngx_log_t; typedef struct ngx_array_s ngx_array_t; typedef struct ngx_open_file_s ngx_open_file_t; typedef struct ngx_command_s ngx_command_t; typedef struct ngx_file_s ngx_file_t; typedef struct ngx_event_s ngx_event_t; typedef struct ngx_event_aio_s ngx_event_aio_t; typedef struct ngx_connection_s ngx_connection_t; in fact, know structure name such ngx_module_s ok used, why typedef ngx_module_t ? design? and, benefits this? is kind of practice when programming in c language? and, name of practice? why or bad? it's common practice. don't have use struct keyword each time declare variable.

javascript - JS object sorting date sorting -

i have js object defined follows - var item = {}; item[guid()] = { symbol: $('#qtesymb').text(), note: $('#newnote').val(), date: $.datepicker.formatdate('mm/dd/yy', dt) + " " + dt.gethours() + ":" + minutes, pagename: getpagename() }; at point in app getting list of ( items ) chrome.storage , able sort based on date here doing var sortable = []; $.each(items, function (key, value) { if (value.symbol == $('#qtesymb').text() || all) { sortable.push([key, value]); } }); console.log(sortable); sortable.sort(function (a, b) { = new date(a[1].date); b = new date(b[1].date); return > b ? -1 : < b ? 1 : 0; }); console.log(sortable); it doesn't seem work. first , second console.log(sortable); same. have tr

css - hide an html div for some devices with bootstrap -

i use bootstrap 3 , have div, want show in xs , lg devices. how can work? using responsive utility classes... <div class="visible-lg hidden-md hidden-sm visible-xs">visible large , xs</div> demo: http://bootply.com/78724

php - How to add single or double quote in every email address -

how add single or double quote in every email add sample after implode email should (red@yahoo.com, blue@yahoo.com, yellow@yahoo.com, white@yahoo.com) convert array string to: ('red@yahoo.com', 'blue@yahoo.com', 'yellow@yahoo.com', 'white@yahoo.com') or ("red@yahoo.com", "blue@yahoo.com", "yellow@yahoo.com", "white@yahoo.com") $num = count($email); for($i=0; $i < $num; $i++){ $result = do_post_request("http://api.myapi.com/api/isactiveaccount?email=". $email[$i], null); $status = str_replace('{"result":', "", $result); $status = str_replace('}', "", $status); $value_email[] = $email[$i] ; $value_status[] = $status ; } $val_email = implode(',',$value_email); $value_status = implode(',',$value_status); define ("verify_email_update_sent", " update `accounts` set sent = 1 ema

java - Handle mouse event anywhere with JavaFX -

i have javafx application, , add event handler mouse click anywhere within scene. following approach works ok, not in way want to. here sample illustrate problem: public void start(stage primarystage) { root = new anchorpane(); scene = new scene(root,500,200); scene.setonmousepressed(new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { system.out.println("mouse click detected! "+event.getsource()); } }); button button = new button("click here"); root.getchildren().add(button); primarystage.setscene(scene); primarystage.show(); } if click anywhere in empty space, eventhandler invokes handle() method, if click button , handle() method not invoked. there many buttons , other interactive elements in application, need approach catch clicks on elements without having manually add new handler every single element. you can add event filter scene addev

MYSQL: Merge two tables into one, with union -

i have make table out of 2 other tables (and use union). query works is: select * tabel1 union select * tabel2 now have put result(data) table3 (a table have, same columns in table1 , table2). who can me? insert table3 select * tabel1 union select * tabel2 since have same columns in 3 of them ... in general case should work column lists like insert table3 (col1, col2, col3) select col1, col2, col3 tabel1 union select col1, col2, col3 tabel2 this way avoid trouble auto_increment id-columns. should consider using union all since union filters out duplicate lines , therefore take longer on large tables.

c# - Finding the number of cells in a row that has data -

so i'm having problem finding number of rows in excel document has data in it. here's have far: (int = 2; <= b; i++) { if (!(worksheet.get_range("a" + i, misvalue).formula == null)) { a.add(worksheet.get_range("a" + i, misvalue).formula); } } at moment i'm crudely shuffling through large number of lines, questioning whether it's null or not, adding contents list. there has easier way google has yet show me. in advanced i might not understanding question properly, i'm guessing you're trying find cells in column have value in them , i'm assuming you're using excel interop in c#... for that, can use range.specialcells method. so, example, cells constant values or formulas use: worksheet.range("a:a").specialcells( microsoft.office.interop.excel.xlcelltype.xlcelltypeconstants | microsoft.office.interop.excel.xlcelltype.

animation - How i can make animated videos -

i'm looking make professional video project. i'm wondering if can this: https://www.youtube.com/watch?v=2pmvmy4gops you con try wideo.co free platform creating basic animations. can choose template, pictures personal library, , customize them short informational videos.

go - is resp.Body.Close() necessary if we don't read anything from the body? -

i have function makes request check status code. not read body. should still end function resp.body.close() ? callers should close resp.body when done reading it. if resp.body not closed, client's underlying roundtripper (typically transport) may not able re-use persistent tcp connection server subsequent "keep-alive" request. yes. when call http.get, function returns response http headers have been read. body of response has not been read yet. response.body wrapper around network connection server. when read it, downloads body of response. .close() tells system you're done network connection. if have not read response body, default http transport closes connection. (the transport can re-use connection if body has been read, because if reused connection unread body next request made using connection receive previous request's response!) so reading body more efficient close()ing if you're making more 1 request - tls connections relative

spring - Error during use $within operator with $elemMatch -

i'm using spring-data-mongodb (version 1.0.2.release) , mongodb (version 2.2). have object contain list of object location. classes following: public class { @id private objectid id; private list<location> places; //getter , setter } public class place { private string name; private string description; @geospatialindexed private double[] location; //getter , setter } i need find objects specific location. tried use operators $within , $elemmatch following: @query(value = "{'places' : { $elemmatch: { location: {'$within' : {'$center' : [?0, ?1]} } }}}") public list<a> findbylocation(point location, double radius); when run query, receive following exception: org.springframework.data.mongodb.uncategorizedmongodbexception: can't find special index: 2d for: { places: { $elemmatch: { location: { $within: { $center: [ { x: 41.904159, y: 12.549132 }, 0.07000000000000001 ] } } } } }; nested exception com.mongodb.

android - Facebook session state OPENING -

i can login app share something. needs opened session state. however, when not logged in, want share something, need open session. using viewpager e.g. when go 1 page , code session.openactivesession(getactivity(), true, new statuscallback() { @override public void call(session session, sessionstate state, exception exception) { } }); is in beginning of code, session becomes active, , automatically logged in, wrong! that's why put code block onclicklistener, want open session if click share button in app: if (session != null && session.isopened()) { publishfeeddialog(); } else { session.openactivesession(getactivity(), true, new statuscallback() { @override public void call(session session, sessionstate state, exception exception) { } }); publishfeeddialog(); } private void publishfeeddialog() { session = session.getactivesession(); log.i("tag", session.getstate() + ""); //opening

resize columns if kendo grid is bound to dynamic data source? -

i trying enable horizontal scrolling kendo grid. far i've heard if have added width columns definitions. do if data dynamic? i've tried couple of things. code can understand that. var kgrid = $("#grid").kendogrid({ height: 155, pageable: true, datasource:ds, databound:function(e){ var m = kgrid.data('kendogrid'); console.log('databound: ', m.columns); }, databinding:function(e){ var m = kgrid.data('kendogrid'); var obj = ds.view()[0]; console.log('databinding columns before: ', m.columns); //for(x in obj){ // if(x[0] == '_') // continue; // m.columns.push({field: x, width:'200px'}); //} console.log('databinding columns after: ', m.columns); }//, //columns:[ // {field:'col1', width: '200px'}, //{field:'col2', width: '20

html - Why isn't my 2-column Pure CSS layout working? -

Image
i'm trying create simple meteor web application, struggling produce working 2 column layout defined via pure responsive grid . problem demonstrated in below screenshot; heading should 2 columns on 1 line, not 2 (lines) , "sidebar content" should in column left of "ace editor demo": you may visit live version of application see problem yourself. additionally, i've published project on github . it'd make me happy if point out why intended 2 column layout isn't working intended. i've tested chromium 28.0.1500.71 , firefox 23.0. code styling this application's style sheet (written in stylus ): menu-background = #272f32 menu-color = #daeaef padding-horizontal = 3em padding-vertical = 1em padding-top = 35px .content border-radius: 10px margin-top 39px background-color white padding-left 0px padding-right 0px // padding-top padding-vertical padding-bottom padding-vertical .content-ribbon

Getting output of PHP script using JQuery -

i trying load output of php script using javascript , jquery. javascript function using uses $.get function in jquery call php script, want display in division. script wrote is: <script type="text/javascript"> function on_load() { $(document).ready(function() { alert('here'); $.get("http://localhost/dbtest.php", function(data){ alert('here too'); $("uname").html(data); }); }); } </script> the php script (dbtest.php) uses simple echo statement: echo "hello, world!!!"; i getting first alert here, not second. can doing wrong here? i suppose uname id, in case should use: $("#uname").html(data); you can add php debugging: error_reporting(e_all ^ e_notice); ini_set("display_errors", 1); try remove http:// ajax call , use relative path instead.

c# - EF Codefirst Bulk Insert -

i need insert around 2500 rows using ef code first. my original code looked this: foreach(var item in listofitemstobeadded) { //biz logic context.mystuff.add(i); } this took long time. around 2.2 seconds each dbset.add() call, equates around 90 minutes. i refactored code this: var tempitemlist = new list<mystuff>(); foreach(var item in listofitemstobeadded) { //biz logic tempitemlist.add(item) } context.mystuff.tolist().addrange(tempitemlist); this takes around 4 seconds run. however, .tolist() queries items in table, extremely necessary , dangerous or more time consuming in long run. 1 workaround context.mystuff.where(x=>x.id = *empty guid*).addrange(tempitemlist) because know there never returned. but i'm curious if else knows of efficient way to bulk insert using ef code first? validation expensive portion of ef, had great performance improvements disabling with: context.configuration.autodetectchangesenabled = false; cont

sql - error handling when performing 2 mysql queries -

i have constructed function 2 queries performed. both of these queries insert data 2 separate tables, data related registration of user. in 1 table things username,password held , in other table stuff address, phone etc... here function: function register_biz_user($post,$connection) { $name=$connection-> real_escape_string($_post['name']); $lastname= $connection->real_escape_string($_post['lastname']); $pass_hashed = password::hash($_post['password']); $passwd= $connection->real_escape_string($pass_hashed); $buztype= $connection->real_escape_string($_post['buztype']); $usertype= $connection->real_escape_string($_post['usertype']); $address= $connection->real_escape_string($_post['address']); $city= $connection->real_escape_string($_post['city']); $municipality= $connection->real_escape_string($_post['municipality']); $url= $connection->real_es

ruby - A ticket System to integrate in Rails -

i want add ticket system web app i'm developing. the idea simple: users can open tickets when have problems , admin can see tickets users have submitted. i'm looking ticket system have found systems external web. want add in wep app. ¿do know ticket system por rails? thanks i think using external gem noted above either overkill or hassle due mentioned bad documentation. judging problem description quite simple implement. create model tickets , associations users (i assume have users model set up). authorize access tickets' actions depending on user status (admin or not) create corresponding views p.s. have @ redmine code. open source project management software written in rails. sure give idea of how build own or borrow bits of code there (if app license building fits)

OpenLayers - Trying to load layers using a JSON file -

i have bunch of layers need load map, instead of loading each 1 individually trying load using json file , openlayers.request.get not know how complete code. json file: { "layers": [ { "title":"client manholes" , "url":"./mh_file.geojson" , "style":"mh_style"}, { "title":"client pipe" , "url":"./pipe_file.geojson" , "style":"pipe_style"}, { "title":"client parcels" , "url":"./parcel_file.geojson" , "style":"parcel_style"} ] } javascript: var request = openlayers.request.get({ url: "http://domain.com/layers.json", callback: handler }); function handler(request) { //alert (request); var response = json.read (request.responsetext); //loop thru each layer each (var layer in request) { //load layer layer = new openlayers.la

matlab - Get fft from a sequece and use sliding windows on it -

i have sequence: n=1:500 x=sqrt(10)*exp(0.1i*pi*n) + sqrt(10)*exp(0.12i*pi*n)+rand(1,n); and want fft x1 until x16 x2 until x17 x3 until x18 ... , plot sliding windows? there solution in matlab? fft matlab function return discrete fft of series of data. can iterate through data , call fft on each window.

How to write the results of a batch file called in a Python script to a file -

i have python script in have directory of .bat files. loop through them , run each 1 through command line, save result of batch script file. far have this: import subprocess _, _, files in os.walk(directory): f in files: fullpath = directory + os.path.basename(f) params = [fullpath] result = subprocess.list2cmdline(params) however, sets result variable path of .bat file, when need result of running code in ,bat file. have suggestions? why calling list2cmdline ? doesn't call subprocess. use subprocess.check_output instead: import os output = [] _, _, files in os.walk(directory): f in files: fullpath = os.path.join(directory, os.path.basename(f)) output.append(subprocess.check_output([fullpath])) print '\n'.join(output)

ios - Check NSString for specific date format -

i have nsstring , need check in specific format mm/dd/yy. need convert nsdate. on appreciated. sidenote - have searched around , people suggest using regex, have never used , unclear generally. can point me resource/explanation. use nsdateformatter both tasks. if can convert string date in correct format (and have result).

tomcat - Overriding userHome for grails CI with wrapper on Jenkins -

i have following setup: synology ds1812+ dsm 4.2-3211 java 1.6.0_43 apache tomcat/6.0.36 (installed synology package) jenkins 1.529 (deployed on tomcat) jenkins grails plugin 1.6.3 on i'm trying create job build grails 2.2.3 project. created grails wrapper , configured job run "clean" target grails wrapper see if working. problem starts when run job: ... [envinject] - injecting environment variables build step. [envinject] - injecting environment variables properties content home=/volume1/jenkins/jobs/sampleproject [envinject] - variables injected successfully. [workspace] $ /volume1/jenkins/jobs/sampleproject/workspace/grailsw clean --non-interactive downloading http://dist.springframework.org.s3.amazonaws.com/release/grails/grails-2.2.3.zip /home/.grails/wrapper/grails-2.2.3-download.zip exception in thread "main" java.io.filenotfoundexception: /home/.grails/wrapper/grails-2.2.3-download.zip (no such file or directory) @ java.io.fileoutp

xslt - Which namespace is used for xsl:element when name is an attribute value template -

i'm trying understand how xsl:element works , have test transform: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:template match="test"> <output> <test1/> <xsl:element name="test2"/> <xsl:variable name="three" select="3"/> <xsl:element name="test{$three}"/> </output> </xsl:template> </xsl:stylesheet> when applied document: <?xml version="1.0" encoding="utf-8"?> <test/> i result using xsltproc <?xml version="1.0"?> <output xmlns="http://www.w3.org/1999/xhtml"> <test1/> <test2/> <test3 xmlns=""/> </output&g

javascript - How to reset pagination in a JQuery datatable -

i have jquery datatable loads data via ajax request. there form table lets user filter results on server. when user changes filter form, call fnreloadajax() new filter data, , table redraws new, filtered results. the problem have pagination sticks, if table no longer has enough items reach current page. if table had 20 items, , user on page 2 (10 items per page), , change filter 5 items returned, table displays no items , shows @ bottom: showing 11 5 of 5 entries it's still on page 2 though there enough data 1 page. i have found numerous posts trying preserve current page/row, none showing simple way reset pagination first page. simplest way this? here's simplified version of code clarity: $("#mytable").datatable({ bstatesave: false, fnserverdata: function (ssource, aodata, fncallback) { return $.ajax({ type: "post", url: url, data: {filter: filtervalue} }); } }); $("#myfor

java - Matcher don't find on 2nd loop -

1st step everyth ok, on 2nd step goes someth wrong: slow (20+ sec) on find() . besides matches() returs false , , don't know why. separately every regex works fine. using emulator. thax guys. string[] regexcontent = {"node[\\s\\s]*?(<p>[\\s\\s]+</p>)", "([\\s\\s]*?)</div>"}; pattern p; matcher m; (string regex : regexcontent){ p = pattern.compile(regex); m = p.matcher(result); //if (m.matches()) // false result = ""; if (m.find()) // on 2nd step waits long time & don't find result = m.group(m.groupcount()); m.reset(); } if need reuse string derived matcher.group, better create new string since matcher.group still substring reference pointing original one. when second time read reference , pass pattern.matcher(), not pass exact string first step. maybe it's bug or it's designed work

mysql - What is the difference between ['pmadb'] and ['controlhost'] server configuration? -

i've read phpmyadmin 4 documentation on both things, want clarify if there difference. i found answer on configuring phpmyadmin says use ['pmadb'] ( see here ). tried it, , works; however, config.sample.inc.php contains ['controlhost']. pmadb contains name of database holds configuration storage. if want put database on host different main host (as defined in "host"), use controlhost this.

Rendering in Java - BufferedImage and Graphics -

so, after finishing 2d game in c# / xna topics questions before, i've decided jump java because find myself more comfortable java. that being said, while working away on bufferedimage based project, decided figure out how render sprites screen, in case ever needed work around ui. problem i've hit when try render bufferedimage using graphics portion of java, thing ever shows test text i've put. upper portion , left portion of applet have thing line going top-right , bottom-left, respectively. feel if error simple, it's late, easy on me. my core class here: package com.merganen; import java.applet.applet; import java.awt.color; import java.awt.dimension; import java.awt.graphics; import java.awt.image; import java.awt.point; import javax.swing.jframe; import com.merganen.entity.player; public class game extends applet implements runnable{ private static final long serialversionuid = 1l; private static jframe frame; public static string title =

wordpress - Can a captcha attract spam? -

i know email forms can attract spam, can captcha attract spam? i have wordpress website 19 contact forms (one each company advisor). test, put captcha on 1 of contact forms see if form received less spam other forms. 2 months goes by, no spam @ of 19 forms. today though, 10 spam messages sent through 1 of forms. odd was form had captcha spam sent though, other 18 forms untouched (and easy find). any idea why or how have happened, , can prevent happening again? *edit page captcha/contact form on not indexed (noindex nofollow yoast plugin). thanks! my first thought make use of called invisible captcha or honeypot technique. in nutshell, invisible captcha relies on principle bots detect hidden fields , fill in information. human visitor, on contrary, never see them (as hidden css), therefore remain empty. aware of wordpress plugin invisible captcha, works on comments , not seem useful in case. hope of help.

c# - Adding multiple Records to the XML file -

i add multiple records xml file , here code using, xmltextwriter xwriter = new xmltextwriter("c:\\users\\desktop\\testfolder\\xdoc1.xml", encoding.utf8); xwriter.formatting = formatting.indented; xwriter.writestartelement("employee"); xwriter.writestartelement("person"); xwriter.writestartelement("name"); xwriter.writestring(textbox1.text); xwriter.writeendelement(); xwriter.writestartelement("designation"); xwriter.writestring(textbox2.text); xwriter.writeendelement(); xwriter.writestartelement("employee id"); xwriter.writestring(textbox3.text); xwriter.writeendelement(); xwriter.writestartelement("email"); xwriter.writestring(textbox4.text); xwriter.writeendelement(); xwriter.writeendelement(); xwriter.writeendelement(); xwriter.close(); the problem code 1 record can added. when try add 2nd record, previous record overwritten. linq xml makes xml task easier. @ below code. if (!system.io.file.exis

Assign strings to IDs in Python -

i reading text file python, formatted values in each column may numeric or strings. when values strings, need assign unique id of string (unique across strings under same column; same id must assigned if same string appears elsewhere under same column). what efficient way it? use defaultdict default value factory generates new ids: ids = collections.defaultdict(itertools.count().next) ids['a'] # 0 ids['b'] # 1 ids['a'] # 0 when key in defaultdict, if it's not present, defaultdict calls user-provided default value factory value , stores before returning it. collections.count() creates iterator counts 0, collections.count().next bound method produces new integer whenever call it. combined, these tools produce dict returns new integer whenever you've never looked before.

linux kernel - module_init() vs. core_initcall() vs. early_initcall() -

in drivers see these 3 types of init functions being used. module_init() core_initcall() early_initcall() under circumstances should use them? also, there other ways of init? they determine initialization order of built-in modules. drivers use device_initcall (or module_init ; see below) of time. initialization ( early_initcall ) used architecture-specific code initialize hardware subsystems (power management, dmas, etc.) before real driver gets initialized. technical stuff understanding below look @ init/main.c . after few architecture-specific initialization done code in arch/<arch>/boot , arch/<arch>/kernel , portable start_kernel function called. eventually, in same file, do_basic_setup called: /* * ok, machine initialized. none of devices * have been touched yet, cpu subsystem , * running, , memory , process management works. * * can start doing real work.. */ static void __init do_basic_setup(void) { cpuset_init_smp(); userm

javascript - Slide animation using jQuery only works in one direction -

http://jsfiddle.net/webk2/1/ i have group of block elements , i'm attaching slide animation on click. goal elements continue slide , forth smoothly. <section class="stretch"> <div class="block blue"></div><div class="block red"></div><div class="block green"></div><div class="block orange"></div><div class="block silver"></div><div class="block teal"></div><div class="block salmon"></div> </section> <button class="button-left">left</button> <button class="button-right">right</button> and jquery: function moveright() { var lastblock = $(".stretch .block:last-child"); lastblock.remove(); $(".stretch .block:first-child").before(lastblock); $(".stretch .block").each(function(){ $(t

scala - Play 2.1 Reading JSON Objects in order -

json parse: http://www.dota2.com/jsfeed/heropickerdata?v=18874723138974056&l=english hero class , json serialization case class hero( var id:option[int], name: string, bio: string, var truename:option[string] ){} implicit val modelreader: reads[hero] = json.reads[hero] reading data val future: future[play.api.libs.ws.response] = ws.url("http://www.dota2.com/jsfeed/heropickerdata?v=18874723138974056&l=english").get() val json = json.parse(await.result(future,5 seconds).body).as[map[string, hero]] var = 1 json.foreach(p => { p._2.truename = some(p._1) p._2.id = some(i) p._2.committodatabase += 1 }) i need id of each hero. order of heros in json matches id. map unordered , wont work. have other ideas? i have tried use linkedhashmap. tried make implicit reads linkedhashmap i've failed. if thinks answer please give me guidance? it keeps saying "no json deserializer found type scala.collection.mutab

Spotify API - Location -

i trying use "api/location" stated in documentation reason that's failing error code 0 , type transient , not helpful. ideas. var loc = location.query(); loc.load(['latitude']).done(function(loc) { console.log("lat:" + loc.latitude); }).fail(function(track, error){ console.log(error); }); also, if can explain how location retrieved. according answer on question: https://stackoverflow.com/a/20196967/1036087 location api never worked , they're going remove documentation on it.

A page fault caused by reserved bit set -

as know, page fault exception caused when process seeking access area of virtual memory not mapped physical memory, when write attempted on read-only page, when accessing pte or pde reserved bit. regards reserved bit case, know how page table built process , kernel page table? when building page table of process, how can reserved bit of pte or pde set? is set mmu or os?. thank you, cpu can understand virtual addresses regardless of whether kernel page or user page. mmu uses pte convert virtual address physical address. go through paging more info

android - How can i create custom image view so that the pic which i have taken should be fit into that image view -

i trying make application, fetches image storage , place application image size looks it. scaling bitmaps memory can memory intensive. avoid crashing app on old devices, recommend doing this. i use these 2 methods load bitmap , scale down. split them 2 functions. createlightweightscaledbitmapfromstream() uses options.insamplesize perform rough scaling required dimensions. then, createscaledbitmapfromstream() uses more memory intensive bitmap.createscaledbitmap() finish scaling image desired resolution. call createscaledbitmapfromstream() , should set. lightweight scaling public static bitmap createlightweightscaledbitmapfromstream(inputstream is, int minshrunkwidth, int minshrunkheight, bitmap.config config) { bufferedinputstream bis = new bufferedinputstream(is, 32 * 1024); try { bitmapfactory.options options = new bitmapfactory.options(); if (config != null) { options.inpreferredconfig = config; } final bitmapfactory.options decod

eclipse - How to remove "Debug Current Instruction Pointer" -

i tried use debugger in eclipse, when hit breakpoints, eclipse "debug current instruction pointer" pointing @ wrong source line.i want remove "debug current instruction pointer". "project -> clean..." doesn't seem help, nor restarting eclipse, nor rebooting. go debug view (as current debug session running) , complete or terminate current debugging session. way rid of "debug current instruction pointer"

Python float __setformat__? -

i have problem, need float correct upto 18 decimal places. when use default float(number), gives me 12 decimal places only. then did dir(float) ['__abs__', '__add__', '__class__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getformat__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__int__', '__le__', '__long__', '__lt__', '__m od__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__pos__', '__pow__', '__radd__', ' __rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '_ _rmul__', '__rp

buffer - receiving a web page from web server in a c program -

here code web page server (actually google.com): #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #include <unistd.h> char http[] = "get / http/1.1\naccept: */*\nhost: www.google.com\naccept-charset: utf-8\nconnection: keep-alive\n\n"; char page[bufsiz]; int main(int argc, char **argv) { struct addrinfo hint, *res, *res0; char *address = "www.google.com"; char *port = "80"; int ret, sockfd; memset(&hint, '\0', sizeof(struct addrinfo)); hint.ai_family = af_inet; hint.ai_socktype = sock_stream; /* hint.ai_protocol = ipproto_tcp; */ if((ret = getaddrinfo(address, port, &hint, &res0)) < 0) { perror("getaddrinfo()"); exit(exit_failure); } for(res = res0; res; res = res->ai_next) { sockfd = socket(res->ai_family, res->a

cuda - Concurrently running two for loops with same number of loop cycles involving GPU and CPU tasks on two GPU -

i have 2 for loops in code running same number of loop cycles. these 2 loops independent (each loop works on different input data). within 1 loop, there cpu functions , several kernels not running concurrently. can run these iterations on separate gpus? you can run involved kernels separately on 2 different gpus. you have take care synchronization of cpu processings on partial outcomes of 2 gpus. due presence of sequential part, perhaps not experience maximum possible speedup factor of 2 when working 2 gpus. starting cuda 4.0, can use cudasetdevice() set current context corresponding given device without need of creating streams enable multi-gpu processing.

javascript - I'm trying to create a function that Randomizes three numbers in range (0-100) and prints the largest one -

... when call function in console returns undefined. i'm javascript newbie i'm making basic mistake, i'd greatful if me out :-). here code: var randomprint = function(){ x = math.floor(math.random() * 100); y = math.floor(math.random() * 100); z = math.floor(math.random() * 100); console.log(x, y, z); if(x > y && x > z) { console.log("the greatest number is" + " " + x); } else if(y > z && y > x) { console.log("the greatest number is" + " " + y); } else if(z > y && z > x) { console.log("the greatest number is" + " " + z); } }; randomprint(); the answer deceze better solution, see working well. example output in console is: 35 50 47 greatest number 50 undefined the undefined part because function not returning anything. write as var randomprint = function(){ x = math.floor(math.random() * 100);

java - Declaration of variable size dynamic array of objects in processing -

i want ask question processing. have user defined object class, point, , have 2 data members x , y both declared float. have class recognizer. need create constructor of recognizer , inside define object of point[] point0, point[] point1 , etc... dynamically. point [] point0={new point(137,139),new point(50,63),..., new point(78,5)}; point1[],point2[],...,pointn[] how else can add values point0 having values of corresponding x , y coordinate. also note size of each object point1,point2,..., pointn different. how can achieve above goal? how using 2 dimensional array ? point [] points0={new point(137,139),new point(50,63),new point(78,5)}; point [] points1={new point(147,139),new point(60,63),new point(79,5)}; point [] points2={new point(157,139),new point(70,63),new point(80,5)}; void setup(){ point[][] pointlists = {points0,points1,points2}; recognizer r = new recognizer(pointlists); } class point{ float x,y; point(float x,float y){ this.x = x;

ruby on rails - nested attributes create reference only if already present instead of creating new entry -

i newb rails. accepts_nested_attributes_for creates new entry every time how can check if entry present , if present want reference stored in join table. class user < activerecord::base has_and_belongs_to_many :categories accepts_nested_attributes_for :categories, :allow_destroy => true alias_method :categories=, :categories_attributes= end and class category < activerecord::base has_and_belongs_to_many :users end how can this? please me.

dojo: aspect.after is not working -

guys have been trying since hour. unable figure out why aspect.after/before not being called. code. require([ "dojo/aspect", "dojo/on", "dojo/dom", "dojo/domready!" ], function( aspect, on, registry, dom) { var callback = function() { alert("called click"); }; var callback2 = function() { alert("called click 2"); }; var = { clicking : on(dom.byid("alertbutton"), "click", callback) }; aspect.after(my, "clicking", callback2); }); thanks in advance. maybe confusing usage. aspect.after or aspect.before , execute additional functions base on methods. not action. example: aspect.after(my, "clicking", callback2); anywhere calling my.clicking() run callback2 . not execute additional function when running on(dom.byid("alertbutton"), "click", callback) . my english not good, simple explain: f