Posts

ruby - Own class with spaceship operator does not work for LCS Diff -

i'm trying implement custom class including comparable mixin. later class used diff. class looks like class element include comparable attr_reader :name def initialize(name) @name = name end def <=>(other) @name <=> other.name end end now test values 2 added entries compared a. a = array.new b = array.new a.push element.new('y1') a.push element.new('y2') a.push element.new('y4') a.push element.new('x1') a.push element.new('x2') a.push element.new('x4') b.push element.new('y1') b.push element.new('y2') b.push element.new('y3') b.push element.new('y4') b.push element.new('x1') b.push element.new('x2') b.push element.new('x3') b.push element.new('x4') and run diff between both arrays puts diff::lcs.diff(a, b).inspect i expect 2 added objects finds 8 changes... ideas why? [[["-", 2, #<element:0x007fa9fb567898 ...

json - add time in loading web service in windows phone -

this code load web service in app: public loaddata() { initializecomponent(); postdata(); } private void postdata() { uri uri = new uri("my web service url"); webclient client= new webclient(); client.headers[httprequestheader.contenttype] = "application/x-www-form-urlencoded"; client.uploadstringasync(uri); client.uploadstringcompleted += client_uploadcomplete; } public void client_uploadcomplete(object sender, uploadstringcompletedeventargs e) { var test= jsonconvert.deserializeobject<main>(e.result); } at point if web service takes more 10 seconds load data in variable test, message box or popup box open " slow connection please retry" along retry button again load postdata(); how possible add time in loading web service in wp please me on this..... add timer event , start before asynchronous upload. event fires after 10 secs. if code reaches inside ur complete event disable timer....

windows - for command is executed only for the first value when a label is inside -

i have script for /f "delims=" %%i in ('dir "%folder%*.txt" /b /s') ( set s=%%i set s=!s:%folder%=! set new_s=!s:\=! if "x!new_s!" neq "x!s!" ( :processlistsource /f "tokens=1* delims=\" %%a in ("!s!") ( if "%%a" neq "" ( if "!folder1!" neq "" ( set folder1=!folder1!\!name! )else ( set folder1=!name! ) set name=%%a ) if "%%b" neq "" ( set s=%%b goto :processlistsource ) ) echo folder is: !folder1! echo name is: !name! echo --------------------- ) else ( echo not folder !s! ) ) but not work have expected: first executed once , last echo printed on screen. given folder need files subfolders w...

ruby on rails - Heroku not reflecting codes pushed to it and differs from Localhost -

i have done web app ruby on rails , made changes on codes in computer. thereafter, did git add ., git commit, git push , git push heroku master. the localhost:3000 webpage reflected codes , showed change on heroku, webpage did not reflect codes/change. how resolve this? did precompile? otherwise won't see css changes. rails_env=production bundle exec rake assets:precompile also see https://devcenter.heroku.com/articles/rails-asset-pipeline

file - Difference between .dat and .txt in c++ -

i using .txt files in program reading , writing records (records contains both text , numerals). came know .dat file can used .txt file operations. know difference between 2 , advantages , disadvantages of 1 on another. text files or .txt files bit hard parse in programs , easy read. whereas .dat used store data not plain text. generally .txt files contains letters, characters , symbols readable. .dat binary text file in data not printable on screen.

python - Need more faster image capturing and processing method -

im using command thats opencv image capturing , using pil processing. take 2 second capture , completing processing. need more simple command , fastest processing work robots. have suggestion please advice. import cv2 cv2 import * pil import image import rpi.gpio gpio import time im = 0 . . . . . def imgcrop(im): box = (0, 190, 640, 200) region = im.crop(box) region.save('crop.jpg') return region def imgthres(im): gray = im.convert('l') bw = gray.point(lambda x: 0 if x<150 else 255, '1') bw.save("bw.jpg") return bw def find_centroid(im, rez): width, height = im.size xx, yy, count = 0, 0, 0 x in xrange(0, width, rez): y in xrange(0, height, rez): if im.getpixel((x, y)) == 255: xx += x yy += y count += 1 return xx/count, yy/count def camera (): cam ...

How to select a field from html table using Selenium web driver in java -

in web page have html table , contains multiple radio button. want select 1 radio button. far able find values table not able select. code: getting error on syntax aname.click(); error "the method click() undefined type string" import java.io.*; import org.openqa.selenium.support.ui.expectedconditions; import org.openqa.selenium.support.ui.select; import org.openqa.selenium.support.ui.webdriverwait; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.ie.internetexplorerdriver; import java.util.list; import java.util.concurrent.timeunit; public class sendtxn1 { static webdriver d1=null; public static void main(string[] args) throws ioexception, interruptedexception { file file1=new file("c:\\selenium\\iedriverserver_win32_2.35.3\\iedriverserver.exe"); system.setproperty("webdriver.ie.driver",file1.getabsolutepath()); ...