Posts

scala - How can I implement concrete class which extends trait defining a method with type by the type parameter's type alias -

i ask advanced scala developers. problem access type alias belonging type parameters of class' parent. case class mymodel(foo: string = "bar") case class mydispatcher() trait module[m, d] { type dispatcher = d type model = m } trait myspecificmodule[a <: module[_, _]] { def dispatcher(): a#dispatcher } class moduleclass extends module[mymodel, mydispatcher] { //... } class myspecificmoduleclass extends myspecificmodule[moduleclass] { override def dispatcher(): mydispatcher = mydispatcher() } so myspecificmodule extends generic trait, , should know type of dispatcher method. in case of myspecificmoduleclass should mydispatcher . when try compile code getting compilation error because type of method, not same defined: a#dispatcher , in reality is. error:(21, 18) overriding method dispatcher in trait myspecificmodule of type ()_$2; method dispatcher has incompatible type override def dispatcher(): mydispatcher...

Finding maximum element in an array - is it that you will call greedy algorithm or brute force algorithm or both? -

suppose array of integers given: {1,3,2,4,6,5,2} - max: 6 using brute force , finding maximum element in observe every element ( each element candidate solution ), searching entire search space. considering greedy approach , modify maximum element @ each element of array if necessary. local optimal choice lead global optimal choice. are brute force , greedy approach similar here? exacty difference between 2 algos in general? approach: brute force - starting first element - 1 taking max. considering each , every next element in array - entire search space. choosing maximum @ each step if necessary. brute force. greedy algorithm - starting nothing, taking first element - taking max 1. considering second element - 3, making local optimal choice between 1 , 3- taking 3 maximum. , on other elements. @ last, have 6 maximum element- global optimal choice. how tell difference between 2 algos in general? finding maximum element in unsorted array require brute-for...

selenium webdriver in python -

so i'm trying make script in python uses selenium webdriver open , login website called marketsworlds , retrieve market value of stock. have script able open , login page. cant figure out how capture/get market value , have print out. used inspect element find class: <p class="market_value"> </p> in between open , close brackets inspect element displays market value, changes. tried setting driver.find_element_by_class("market_value") variable , printing variable. print out of " @ object 0x" , ever comes after x. way return displays? if have use selenium navigation, such on javascript-heavy sites, suggest acquiring page source , using html parser extract data want. beautifulsoup great choice of parser. example: html = driver.page_source soup = beautifulsoup(html) # *all* 'p' tags specified class attribute. p_tags = soup.findall('p',{'class':'market_value'}) p in p_tags: print p.te...

sql - Database Update in VBA -

sub uoload_data() dim s(40) integer dim row integer dim integer = 0 row = 7 39 s(i) = sheets("data").cells(row, 5).value = + 1 next dim cn object dim rs object dim strsql string dim strconnection string dim apppath string set cn = createobject("adodb.connection") apppath = application.activeworkbook.path strconnection = "provider=microsoft.ace.oledb.12.0;" & _ "data source=c:\users\devi\desktop\ability.accdb;" cn.open strconnection strsql = "insert mytable values ('" & s(0) & " ', '" & s(1) & " ','" & s(2) & " ','" & s(3) & " ' )" set rs = cn.execute(strsql) set rs = nothing cn.close set cn = nothing end sub i have excel sheet of 40 field. update field access database. while insert record database using insert stat...

security - How can I get rid of a Man in the Middle (MIMA) hacker from stealing web form data? -

i have web form created in adobe business catalyst crm , has placed man in middle (mima) hack on our site or wherever , intercepting web form contacting user submitted form , offering them products using same name website. so two-part question. how rid of , prevent happening again , there legal action can take against mima hackers? business catalyst (bc) secure not convinced there hack on site. should following: contact bc , let them know this. check site code did not create or insert site. recreate web form , insert site. change passwords on bc site. change workflows site. change email password. switch forms use bc secure domain. (ie: https://example.worldsecuresystems.com ) since cannot run server side code on bc doing above steps should solve issue. contact lawyer information on legal action against mima hackers.

javascript - Angular material design valid/invalid input -

couldn't seem find relative existing answer so.. i using angular material design , i'm creating sign in/up form. @ moment when no text entered field label , bottom border turns red; result of ng-required="true" . i turn green when information valid, not amazingly familiar angular not sure if there directive use? alternatively assume css trick; in 1 of css files there - .ng-invalid.ng-dirty { border-color: #fa787e; (red) } .ng-valid.ng-dirty { border-color: #78fa89; (green) } these perfect attached attaching class not seem work (or im doing wrong) here code 1 line of input <md-input-container> <label class="userlabel">username</label> <input ng-model="credentials.username" type="text" ng-required="true" aria-label="password" class="inputtext ng-valid"> </md-input-container> if assist great, in advance you on right track css missing...

c++ - Convert MSB first to LSB first -

i want convert unsigned short value msb first lsb first. did below code not working. can point error did #include <iostream> using namespace std; int main() { unsigned short value = 0x000a; char *m_pcurrent = (char *)&value; short temp; temp = *(m_pcurrent+1); temp = (temp << 8) | *(unsigned char *)m_pcurrent; m_pcurrent += sizeof(short); cout << "temp " << temp << endl; return 0; } what wrong first assigned value 's msb temp 's lsb, shifted again msb , assigned value 's lsb lsb. basically, had interchanged *(m_pcurrent + 1) , *m_pcurrent whole thing had no effect. the simplified code: #include <iostream> using namespace std; int main() { unsigned short value = 0x00ff; short temp = ((char*) &value)[0]; // assign value's lsb temp = (temp << 8) | ((char*) &value)[1]; // shift lsb msb , add value's msb cout << "temp ...