Posts

Showing posts from January, 2013

ajax - Tricky workflow from public page to restricted page with specific conditions -

i have public page data-request = onclaim button. a user can use button whether logged or not when user "claims" page, if conditions fulfilled, database must updated , specific restricted access page have displayed new updated datas. if conditions not met, user stay on public page warning message. to know if these conditions met, user must logged in (using account or creating new one) note: when restricted page displayed other way button. no specific data updated hard explain, best ! please, how implement workflow elegantly (or not)? development environment: october 419 rainlab user plugin debugbar 1.0.8 plugin sweet alert 1.1.0 plugin i tried tricks according xy problem , prefer don't talk about

c# - Created a login form with a local SQL database, upon execution and after a login attempt an "ArgumentException Unhandled" error occurs -

i understand same thing has been asked before , closed due simple typo. can see don't have typos , i've tried figure out problem googling no luck. i have created login window. main login window i have created local sql database within visual studio (2015) store users. establish connection database have written line of code in enter button visible in main login window. sqlconnection sqlconn = new sqlconnection(@"data source=(localdb)\mssqllocaldb;initial catalog=c: \users\nikos\desktop\nikos();\safe box\database\safeboxdb.mdf;integrated security=true;connect timeout=30;encrypt=false;trustservercertificate=true;applicationintent=readwrite;multisubnetfailover=false"); this path has been pasted right clicking database , selecting properties. in properties there field named connection string. that's have copied , pasted, above path in code. this code. //find path sql connection sqlconnection sqlconn = new sqlconnection(@"data sourc...

angularjs - webdriver-manager error when calling update with "Unhandled 'error' event" -

i have project uses jasmine , selenium on top of node.js. protractor provides useful modules use, installed , tried run using "protractor conf.js". ended getting following errors: [15:55:03] e/direct - error code: 135 [15:55:03] e/direct - error message: not find update-config.json. run 'webdriver-manager update' download binaries. [15:55:03] e/direct - error: not find update-config.json. run 'webdriver-manager update' down load binaries. when try run webdriver-manager update, this: [15:46:10] i/file_manager - creating folder c:\program files\node-v8.1.0-win-x86\node_modules\protract or\node_modules\webdriver-manager\selenium events.js:182 throw er; // unhandled 'error' event i saw other threads similar errors didn't seem work me. suspect might related fact want run protractor without angularjs, i'm not sure since believed possible run protractor without angular. appreciated. edit: tried setting ...

Javascript Keycode for a: 65 or 97? -

Image
i'm working javascript (on macbook pro osx 10.11.x, not sure if matters) using chrome browser. im using function: window.onkeypress = function(e) { var key = e.keycode ? e.keycode : e.which; console.log("keypressed = " + key); } when press 'a' key on keyboard, logs 97, not correspond other keycode list find on internet, states 'a' 65. this same other keys well, example, 's' me 115, else states 's' 83. is there dependency i'm missing? if fire event assuming == 95, work on other browsers? thanks. so found capital a indeed, 65. a lowercase a 97 please see chart: chart original location: http://www.asciitable.com/

send a TTL signal through a twisted pair -

i need send 2 ttl signals +5v , ground distance of 10 feet. heard twisted pair minimize interference , crosstalk have not used before. i thinking using cat5 cables. there 4 pairs of wires in them. wondering ones should paired together. example, use: pair 1: ttl a/gnd pair 2: ttl b/gnd pair 3: vcc/gnd pair 4: gnd/gnd does make sense or should use other schemes? lot!

c# - IF statement dilemma -

i'm creating .csv report xml file looks this: <registration> <registrationid>1</registrationid> <type>2</type> </registration> <registration> <registrationid>2</registrationid> <type>3</type> </registration> how can string value "true", if in xml file there @ least 1 <type>3</type> in <registration> tag, or "false" if there none. for getting value of each <registrationid> this string type = ""; foreach (cgxml.registrationrow rr in fisier.registration) { type = rr.type.tostring sout.writeline(string.concat(new string[] { "\"", type, "\"" })); } but sadly current skills i'm unable make work each <registrationid> "true/false" statement... so, code this, or should start reading learn/understand of immense help. thank time. welcome stack overflow! first o...

ios - Reordering tableview cells -

Image
i trying re order cells based on priority (an enum). have double checked enum values correct. here enum enum priority{ case low case neutral case high case urgent } as can see, lower priority has lower hash values. trying compare 2 cells; cell , cell above it. if cell's value greater 1 above it, shift upwards. obtain indexpath of cell above using var newindexpath = indexpath(row: indexpath.row - 1 , section: indexpath.section) after comparing enum values using if(comparepriority.hashvalue < priorityvalue.hashvalue) i attempt switch order using tableview.moverow(at: indexpath, to: newindexpath) the result interesting, use pictures explain. note of code in cellforrowat function , cells given priority correspond name except "test", these pictures taken in slow motion meaning user wouldn't able see switch happening. mid-segue cells finish switching just sort array of items according these priorities , table reload. i...

Create multiple lists that meet one condition Python 3.6 -

i have class city: class city(object): #a city has 2 coordinates in graph(x,y), , set of order def __init__(self, name, x, y, orders): self.name = name self.x = x self.y = y self.orders = orders i create list of cities: example: list_cities = [city1, city2, city3, city4] city1 (0.0, 0.0) [1, 2] city2 (1.0, 0.0) [2, 3] city3 (2.0, 0.0) [1, 3] city4 (3.0, 0.0) [2] i group cities orders this: list1 = [city1, city3] list2 = [city1, city2, city4] list3 = [city2, city3] i've tried dictionaries, list lists , sets still not give me results , not know how else it. leave code have tried: tours = [] city = city.create(arraycity) in range(0,len(city.orders)): tours[city.orders[i]].append(city) this outputs: indexerror: list index out of range i hope can me. thank much class city: def __init__(self,name,x,y,orders): self.name = name self.x = x self.y = y self.orders = orders ci...

c# - Slow Performance VS2015 with Telerik -

i haven't used telerik controls before desktop application. i'm wondering why application slow. system spec good. example if select 1 control add property , go next control takes seconds selected. when save, takes seconds save. have wait every time , save. computer in network. , guess computer in different location not work. reason slow performance though system spec enough? thank you!

php - enabling jquery2 in an admin module for prestashop 1.7 -

i'm using prestashop 1.7.2.0 write admin module adds nested categories , products csv file. understood addjquery() deprecated , i'm trying jquery code work. i uncaught referenceerror: $ not defined . i have created displaybackofficeheader hook following: public function hookdisplaybackofficeheader(){ $this->context->controller->addjs($this->_path.'/js/jqshim.min.js'); $this->context->controller->addcss($this->_path.'/css/getcontent.css'); $this->context->controller->addjs($this->_path.'/js/getcontent.js'); } as can see have tried including jqshim.min.js , still got same error. missing? thanks you can include $this->context->controller->addjquery(); in first line of hookdisplaybackofficeheader() function.

java - When asynctask in activity finishes how to reload ui in fragment? -

my activity loads fragment , starts asynctask. class getparkingareasasync extends asynctask<string, string, string> { @override protected string doinbackground(string... args) { return mrepository.getparkingareas(mcontext.getactiveuser()); } @override protected void onpostexecute(string value) { (int i=0; i<mcontext.getactiveuser().getparkingareas().size(); i++){ log.i(tag_areas, "parking area " + +": " + mcontext.getactiveuser().getparkingareas().get(i).getname()); } } } this asynctask in activity loads data (i store in context). when finishes how can reload ui in fragment show data loaded (in parent activity)? the onpostexecute runs in uithread, need fragment call activity. way defining interface fragment. this: public interface yourfragmentlistener { void onparksloaded(list<string> names) } then on activity: public class youractivity implements yourfragmentl...

Implement an O(log n) Foldable.elem for binary search trees in Haskell -

consider following definition binary trees: data tree = nil | node (tree a) (tree a) the foldable instance can defined follows: instance foldable tree foldr _ z nil = z foldr f z (node l d r) = foldr f (f d (foldr f z l)) r but problem elem function runs in o(n) rather o(log n) . when try implement custom elem : elem x nil = false elem x (node l d r) | x == d = true | x < d = elem x l | otherwise = elem x r i could not deduce (ord a) arising use of ‘<’ . how can problem fixed? you cannot use elem method foldable class, since foldable api requires elem implementation of instances able search elements of type eq instance. "an elem polymorphic eq " intentional choice in design of foldable typeclass. your elem function, while useful, not compatible elem method foldable typeclass, since not generic enough typeclass's desires. best way export elem function type define separate function outside of typeclass.

nightwatch.js - In Magellan / Nightwatch, how do we assert that an element comes before another element? -

for example, if user has gift card, want assert gift card section comes first: <section id="gift-card-section"> ... </section> <section id="credit-card-section"> ... </section> otherwise, want assert credit card section comes first. how can done in magellan / nightwatch? my thinking n in n-th child ... , assert n1 < n2 or other way around. how done in magellan / nightwatch? this great case using xpath. explicit, if know these should first , second section elements. browser .usexpath().assert.attributecontains('(//section)[1]', 'id', 'gift-card-section'); .usexpath().assert.attributecontains('(//section)[2]', 'id', 'credit-card-section'); or, if need not ordered, , @ same level in dom (if siblings) use attribute equals: browser .usexpath().assert.attributeequals("//section[@id='credit-card-section']/following-sibling:://section[@id='gift-card-secti...

android - Updating a cursor object in a thread when onChange is called in the ContentObserver -

i have intentservice tracks changes of database table of outgoing messages using contentobserver. i watching when of rows hit specific state. when happens want finish intent service, or let service retry operations on row did not complete properly. i can build contentobserver , know when data changes , onchange(boolean selfchange) called. but how update ongoing loop in calling intentservice watching cursor? how use onchange call update/requerry cursor using in intentservice? my contentobserver anonymous class , cannot assign new value cursor outgoingmessagecursor eg: cursor outgoingmessagecursor = getundeliveredmessagescursor(); contentobserver messageobserver = new contentobserver(null){ @override public void onchange(boolean selfchange) { super.onchange(selfchange,null); } @override public void onchange(boolean selfchange, uri uri) { super.onchange(selfchange, uri); } }; outgoi...

python - How to read Jinja from a model in Django? -

i want store small django templates in database , include them in view. need call <ul> {% item in foo.items.all %} <li>{{ item.snippit }}</li> {% endfor %} </ul> where snippet string this product made {{ bar.percent }} &percnt; recycled materials i need know how go rendering text jinja before sending client for simple answer see https://stackoverflow.com/a/2462909/7976758 for more elaborate solution use https://github.com/jazzband/django-dbtemplates django template loader database stored templates. it allows store templates in database. it provides template loader enables django load templates database.

javascript - Complex CSS selector - how to require visible -

i'm writing css selector, have working far: input[placeholder*='mail'] but i'd ensure it's not finding invisible (ie: not visible) elements. i've been trying :visible in various places in pattern (because couldn't find reference on css selector lexer, not luck these: input[placeholder:visible*='mail'] input:visible[placeholder*='mail'] input[placeholder*='mail']:visible how do this? , have reference on learning more complex selector formats? there no css selector :visible . sould work classes , target elements have class .visible . (or not have class .visible . the :visible selector available in jquery example, uses pseudo selector finding elements visible in current scroll view.

windows - Are delay-loaded DLLs useful to avoid linking specific functions? -

consider following code needs call 1 of 2 functions in user32.dll . if( iswindowsvistaorgreater() ) addclipboardformatlistener(hwnd) ; else setclipboardviewer(hwnd) ; if i'm not mistaken, program fail start on winxp because addclipboardformatlistener not exist in user32.dll under xp. one way solve not calling addclipboardformatlistener directly rather pointer ourselves: getprocaddress(getmodulehandle("user32.dll"), "addclipboardformatlistener") . however, if instruct linker delay-load user32.dll ... would avoid loading specific function under xp don't need call getmodulehandle , getprocaddress ? is recommended delay-load dll when few functions need delay-loaded? the case of user32.dll particularly dramatic on second point since of functions used in program know exist in dll on windows versions. guess linking @ load-time more efficient @ run-time since latter needs additional checks before each function call. i'm guessin...

With Roo 2.0 I don't find web.xml so how do I configure Spring MVC -

i have been spring developer time , have tried roo in past, , read through improvements roo in 2.0 used build web application works fine...to point. when tried find web.xml applicationcontext.xml let me override of spring mvc classes , add interceptor filters , handlers, not find web.xml what's that? have push in @ point? if web.xml appear, doubt it. spring roo 2.0.0.rc1 generates spring boot applications, there aren't neither web.xml nor application-context.xml to learn more what's new in spring roo 2.0 read http://docs.spring.io/spring-roo/docs/2.0.0.rc1/reference/html/#getting-started-whatsnew to learn spring boot goals read http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#getting-started-introducing-spring-boot hope helps

Nonlinear logistic regression package in R -

is there r package performs nonlinear logistic regression? in more words: have glm , can go glm (cbind (success, failure) ~ variable 1 + variable2, data = df, family = binomial (link = 'logit')) , , can use nls go nls (y ~ * x^2 + b * x + c, data = df) . i'd have function take formula cbind (success, failure) ~ int - slo * x + gap / (1 + x / sca) (where x , success , , failure data , else parametres) binomial (link = 'logit') family, i.e. combine both things. i've been scouring google , haven't been able find that. try gnlm::bnlr() . default link logit , can specify nonlinear function of data , parameters. include 2 answers depending on whether or not gap , sca data or parameters. library(gnlm) in case of gap , sca data: ## if gap , sca data: set.seed(1) dat <- data.frame( x = rnorm(10), gap = rnorm(10), sca = rnorm(10), y = rbinom(10,1,0.4)) y_cbind = cbind(dat$y, 1...

Selecting JsonPath using sub properties -

given { "bb:fund": [{ "label": "visa - 4113", "amount": 24.96, "amountdisplay": "$24.96", "cchash": "8cb41346976847bfb17d8a4da346e989", "_links": { "profile": [{ "href": "https://host/profiles/price-line" }, { "href": "https://host/profiles/price-line-credit-card" }] } }] } i select fund object matching profile href, like $.bb:fund[?(@..href=='https://host/profiles/price-line-credit-card')] or $.bb:fund[?(@_links.profile[*].href=='https://host/profiles/price-line-credit-card')] neither ever seem work. i end using hack selecing based on unique attribute know won't present on other profiles. ie $.bb:fund[?(@.cchash)] isn't guarnateed true forever...while profile is.

java - Call dialog.dismiss after the successful login toast message which will hide the dialog -

can show me how dismiss dialog because trying dialog.dismiss() , alertdialog.dismiss getting error cannot resolve symbol , access , use input email , password package com.example.marcusgrant.test12345; import android.os.bundle; import android.support.annotation.nullable; import android.support.v7.app.alertdialog; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.imageview; import android.widget.toast; public class console_activity extends appcompatactivity { @override protected void oncreate(@nullable bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.console_login); final imageview xshowdialog = (imageview) findviewbyid(r.id.xboximbtn); imageview pshowdialog = (imageview) findviewbyid(r.id.psnimbtn); xshowdialog.setonclicklistener(new view.onclicklistener() { @override public void oncli...

using jena to convert an owl file to N-triple from terminal returns an empty file -

i have generated owl file using generator http://swat.cse.lehigh.edu/projects/lubm/ i want transform file in n-triples , have done before using $ riot -out n-triple ~/lubm20/*.owl > lubm20.nt for reason empty file (lubm20.nt) and when use $ rdfcat -out n-triple ~/lubm20/*.owl > lubm20.nt i error exception in thread "main" org.apache.jena.riot.riotexception: <file:///root/lubm20/classes\university0_0.owl> code: 4/unwise_character in path: character matches no grammar rules of uris/iris. these characters permitted in rdf uri references, xml system identifiers, , xml schema anyuris. @ org.apache.jena.riot.s5ystem.iriresolver.exceptions(iriresolver.java:371) @ org.apache.jena.riot.system.iriresolver.resolve(iriresolver.java:328) @ org.apache.jena.riot.system.iriresolver$iriresolversync.resolve(iriresolver.java:489) @ org.apache.jena.riot.system.iriresolver.resolveiri(iriresolver.java:254) @ org.apache.jena.riot.system.iriresolver.resolvestring(irire...

python - Reversed upstream/downstream relationships when generating multiple tasks in Airflow -

Image
the original code related question can found here . i'm confused both bitshift operators , set_upstream / set_downstream methods working within task loop i've defined in dag. when main execution loop of dag configured follows: for uid in dash_workers.get_id_creds(): clear_tables.set_downstream(id_worker(uid)) or for uid in dash_workers.get_id_creds(): clear_tables >> id_worker(uid) the graph looks (the alpha-numeric sequence user ids, define task ids): when configure main execution loop of dag this: for uid in dash_workers.get_id_creds(): clear_tables.set_upstream(id_worker(uid)) or for uid in dash_workers.get_id_creds(): id_worker(uid) >> clear_tables the graph looks this: the second graph want / have expected first 2 snippets of code have produced based on reading of docs. if want clear_tables execute first before triggering batch of data parsing tasks different user ids should indicate clear_tables >> id_worke...

matlab - How can I traverse through pixels? -

Image
suppose, have following image in hand. i have marked pixels of image follows, now, have obtained pixel mask, how can traverse through pixels in mask? the original question: how can save pixels interested in? ... question: now, in step#2, want save pixels in data-structure (or, whatever) d can apply function f2(i, d, p,q,r) on image on basis of pixels d. create binary mask try using logical mask of image keep track of pixels of interest. i'll make random image example here: randimg = rand(64,64,3); imgmask = false(size(randimg(:,:,1))); imgmask(:,[1:4:end]) = true; % take every 4 columns d. % show talking maskimg = zeros(size(randimg)); imgmaskforrgb = repmat(imgmask,1,1,3); maskimg(imgmaskforrgb) = randimg(imgmaskforrgb); figure('name','psychadelic'); subplot(2,1,1); imagesc(randimg); title('random image'); subplot(2,1,2); imagesc(maskimg); title('masked pixels of interest'); here's looks like: i...

javascript - Program keeps returning cannot read property toLowerCase of Undefined -

function isisogram(str) { if (typeof str === undefined) { return true } var passing = true; var strn = str.tolowercase() var counts = {} (i = 0; <= strn.length; i++) { var letter = strn.charat(i) if (counts[letter]) { counts[letter] = 1 + counts[letter] } else { counts[letter] = 1 } if(counts[letter] > 1) { return passing = false } } return passing } after running code against tests keep getting; typeerror: cannot read property 'tolowercase' of undefined. please how resolve , getting wrong? it should "undefined" . e.g. if (typeof str === "undefined") but replace line check null parameters. if (!str) { return true; } e.g. function isisogram(str) { if (!str) { return true; } var passing = true; var strn = str.tolowercase(); var counts = {}; (i = 0; <= strn....

Autohotkey - Send Left control on long press otherwise send Enter -

here script. capslock mapped send left control on long press,otherwise send escape. working expected. setcapslockstate, alwaysoff capslock:: send {lcontrol down} keywait, capslock send {lcontrol up} if ( a_priorkey = "capslock" ){ send {esc} } return ; send left control when long pressed, otherwise behave normal enter key enter:: send {lcontrol down} keywait, enter, t5 send {lcontrol up} if ( a_priorkey = "enter" ){ send {enter} } return however enter key not waiting long press, timing out quickly.this not expectation. should behave above snippet if i'm understanding issue correctly, should require: enter:: sendinput, {lctrl down} sleep, 100 keywait, enter sendinput, {lctrl up} if ( a_priorkey = "enter" ){ send {enter} } return also, assume have catch @ end pass through single enter keystroke. if isn't case, , you're wanting pass through ...

C# Linq - Extract members of list within dictionary -

i have use case dictionary one var foo = new dictionary<string, list<string>>() so collection hold hierarchical data this key 1 value 1 value 2 key 2 value 3 and need get\project list of values ignoring keys, result be value 1 value 2 value 3 on first attempt came this ireadonlylist<string> bar = foo.select(r => r.value.select(x => x.tostring())) .select(r => r.tostring()) .tolist(); is good? use selectmany : foo.selectmany(x => x.value).tolist();

javascript - Automate logout user -

our web app use username,password verify user , use tokens stored in 'localstorage' maintain user login status,this token expire in 8h, safety reasons have log user out if he/she closed our app tab or close browser, if he/she open our web app next time he/she have login again use username , password. 1 have proper method? in advance! this article give perfect answer. use php sessions. how change session timeout in php?

arrays - How do I sync item list position in Jquery UI-Sortable of 2 Groups? -

i'm using jquery ui's ui-sortable sort list of divs of 2 groups. the thing is, have 2 groups, , b. when user rearrange item in group a: example, item 3 item 2, group b same exact list re-arrange moving item 3 item 2. it 1 way direction, means user cannot re-arrange group b item position, editing it's form. it bit complicated explain have include attachment explain problem. see visual explanation so there way of syncing position of item between 2 group using ui-sortable when user finish moving item in group a? many thanks~!!!

laravel - Nesting custom tags in Vue -

i have laravel / vue app i'm building , i've run bit of snag. have been able create individual stand-alone components, when try nest stand-alone component component, nested component shows up. bit of code: companylogo.vue <template> <figure class="company-logo" :style="{ width: size, height: size, backgroundimage: `url(${src})` }"></figure> </template> logouploader.vue <template> <div class="logo-container"> <company-logo size="65px" :src="`${company.logo.url}`"></company-logo> </div> <div class="logo-uploaded-details"> <p>last updated: {company.logo.last_updated}</p> <button class="file-browse-btn">upload image</button> </div> </template> what's happening when in company.blade.php have <logo-uploader></logo-uploader> the a...

large data volumes - Slowly Increasing Save Time When Saving As in Excel -

ok, stack overflow, far can tell, one's doozy. i have created macro enabled excel file that, when run, performs following actions (high level): user selects template file (which macro enabled) via file dialog user selects data files (which not macro enabled) via file dialog macro steps through data files and, 1 one, opens them, formats data, migrates data new worksheet in intermediary workbook, , closes data file without saving it once files have been looped through, intermediary workbook saved, kept open once data files have been looped through, each sheet of intermediary workbook looped through, data in current worksheet transferred template file, , template file saved new, uniquely labeled file. 1 row of data in now-data-containing file copied summary sheet (it's bit more complicated that, important aspects far can tell) here's problem; number of data files being selected in thousands (so far biggest run we've attempted 4000 files). macro progresse...

java - Scala pattern match types within JsValue -

so have these 2 similar functions in scala, both convert jsvalue java typed number , differ specific type: import play.api.lib.json._ import java.lang.{double => javadouble, integer => javainteger} def getdouble(jsdouble : jsvalue) : javadouble = { val strdouble : string = jsdouble.asinstanceof[jsstring].value.replace(",", "") val jdouble : javadouble = javadouble.valueof(strdouble) jdouble } def getinteger(jsinteger : jsvalue) : javainteger = { val strinteger : string = jsinteger.asinstanceof[jsstring].value.replace(",", "") val jinteger : javainteger = javainteger.valueof(strinteger) jinteger } since they're similar, each other, hoping combine them 1 function , and use generic type differ 2 , pattern match type: def getnumber[t](jsnumber : jsvalue) : t = { val strnumber: string = jsnumber.asinstanceof[jsstring].value.replace(",", "") t.valueof(strnumber) match { case typeof[javaint...

android - What does super.run() mean within a thread in Java? -

i don't meaning of super.run(); and super.handlemessage(msg); necessaary? where should code written? before super.run(); / super.handlemessage(msg); or after them? new thread(){ @override public void run() { super.run(); } }.start(); / handler handler = new handler() { @override public void handlemessage(message msg) { super.handlemessage(msg); } }; question i don't meaning of super.run() , super.handlemessage(msg) necessaary? where should code written? before super.run() or after them? answer - 1 this unnecessary in code in question. new thread(){ @override public void run() { super.run(); } }.start(); public class thread implements runnable { ... @override public void run() { if (target != null) { target.run(); } } ... } super.run call thread class. therefore, not necessary because there empty function. answer - 2 ...

java - AWS Lambda execute JAR from S3 which is encrypted using KMS -

we use aws lambda in our project work. lambda function implemented using java. code bundled jar file , uploaded s3. path of jar file in s3 given input when lambda function created. challenge in our project, files uploaded s3 bucket must encrypted using kms security reasons. when jar file taken lambda, not know jar encrypted, , there no option specify kms key decrypt code also. how can handled?

c# - Time are being displayed wrong even formatted -

i'm trying format time. want show in hh:mm format. i'm passing dictionary view contains list of datetime objects. has format: var mapmovies = new dictionary<string, list<datetime>>(); pretty simple. doing in view: foreach(var time in movie.value) { @html.displayfor(modelitem => time.tostring("{0:hh:mm}")) } when reaches point got known "templates can used field access, property access, single-dimension array index, or single-parameter custom indexer expressions." exception. removing tostring("{0:hh:mm}") displays incorrectly in format {0:dd/mm/yyyy hh:mm} me it's strange thing format time again because in model that: [datatype(datatype.time)] [displayformat(applyformatineditmode = true, dataformatstring = "{0:hh:mm}")] public datetime sessiontime { get; set; } if have defined way want show in model, why happening? adopted solution format time in controller mapmovies[s.movie.moviename].add...

java - Change action based on which button opened Activity? -

i'm trying make app asks user maths questions. have number of buttons, such multiplication, addition etc. want code have series of if/else statements tells operator use based on button clicked in previous activity. what use access information? just put button id in intent. this; intent i=new intent(context,myactivity.class); i.putextra("button_id", buttonid); context.startactivity(i);` then in activity; intent =get intent(); int buttonid = intent.getintextra("button_id");

OnItemSelectedListener method in Spinner is not called when i set JSON data to Spinner Android -

when select static data spinner, onitemselectedlistener method works fine, when add json data spinner, populates json data , onitemselectedlistener not getting called. problem? here code: class list_activity extends activity implements onitemselectedlistener { progressdialog progressdialog; requestqueue requestqueue; string json_id; string json_dept; list<string> spinner_dept; list<string> categories; string selectedcity; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_list_); progressdialog = new progressdialog(this); progressdialog.setmessage("loading"); progressdialog.show(); // spinner element spinner spinner = (spinner) findviewbyid(r.id.spinner3); requestqueue= volley.newrequestqueue(this); // spinner click listener spinner.setonitemselectedlistener(this); // spinner drop down elements spinner_dept =...

Interpreter behaviour in Python -

i know python interpreter executes command line line without compiling entire program @ start. not understood why catching syntax errors on next subsequent lines without executing starting lines. for example, in script, if write following statements: print("i first") print("second") print(third") # syntax error. missed 1 " this gives below output: file "script2.py", line 3 print(third") ^ syntaxerror: eol while scanning string literal i expecting output below: i first second file "script2.py", line 3 print(third") ^ syntaxerror: eol while scanning string literal i keen learn why python interpreter exhibits behavior. it depends on how run python interpreter. if give full source file, first parse whole file , convert bytecode before execution instruction. if feed line line, parse , execute code block block so go one line @ time

Machine learning: which algorithm fits for questions answering -

i want build ml program talks user , inputs user. ml program analyze input data(keywords) predict best solution. so, looking @ ai application needs sort of machine intelligence processing natural language. let language of choice here english. there many things considered before building such system. dependency parsing word sense disambiguation verb sense disambiguation coreference resolution semantic role labelling universe of knowledge. in brief need build above essential modules before can generate response. need decide kind of problem working on? open domain or closed domain problem, meaning scope of knowledge of application. example: google open domain problem can practically take possible input. applications pertain particular task automating food orders in app etc scope of questions can asked limited. once decided, need parse input sentence , dependency parsing way go. can use stanford core nlp suite achieve of nlp tasks mentioned above. once input...

ip address - Python IP range to IP range match -

is there method check if ip addresses network range present in subnets of ip range? example: 10.0.1.0/18 in 123.1.0.0/8 if exists, need return true, else false. since python 3.3, can use ipaddress module of standard library: from ipaddress import ipv4address, ipv4network ipv4address('192.0.2.6') in ipv4network('192.0.2.0/28') # true ipv4address('10.0.1.0') in ipv4network('192.0.2.0/28') # false if mean if networks overlap, use overlaps : in [14]: ipv4network('10.0.1.0/24').overlaps(ipv4network('192.0.2.0/28')) out[14]: false note module marked provisional in python 3.3, no longer in 3.6. enjoy it!

php - Database Security (phpmyadmin) -

i have put phmyadmin folder on our server root folder. m accessing database www.example.com/phpmyadmin. want access through ip address no other can access database. can 1 me. thanks set prevention in 'hosts.allow' , hosts.deny file you can edit hosts files , configure allow specific ip access server files or database. try, may help.

oop - Dynamic dispatch and type checking mechanism in Java -

i understand how object in java internally represented consisting of "pointers" fields , functions in vtables , how these internal representations change when there assignments, implicit casts , explicit casts done, , how static , dynamic type checking works. consider example extended from: dynamic method dispatch in java class a{ int a=10; public void show(){ system.out.println("show a: "+a); } } class b extends a{ public int b=20; public void show(){ system.out.println("show b: "+b); } } class c extends b{ public int c=30; public void show(){ system.out.println("show b: "+c); } } how objects constructed in memory? happens when there assignment (or equivalently parameter passed)? difference in memory-represenation of object in following cases? b bobj = new b(); aobj = new b(); c cobj = new b(); what happens in memory-representation when there explicit up/down casting? how check if such cast a...

java - How to refresh div using Scheduler in spring -

how refresh div using scheduler in spring mvc , jsp.without using javascript setinterval possible.?what is @scheduled(fixeddelay=5000) public void dosomething() { // should execute periodically } but not getting how refresh div/page using it.thank in advance.

python - Storing xlsx sheet in sql server -

i trying store xlsx sheet sql server using python , error: sql server error traceback (most recent call last):   file ".\script_to_extract_mh_data.py", line 104, in      m_flag = sheet.cell(r, 22).value   file "c:\python27\lib\site-packages\xlrd\sheet.py", line 401, in cell     self._cell_types[rowx][colx], indexerror: array index out of range import xlrd import pymssql book = xlrd.open_workbook("c:/users/talha/documents/maharashtradata.xlsx") sheet = book.sheet_by_index(0) # establish mssql connection servername = "192.168.1.100" database = "imddata" username = "saaa" password = "abcd@aassapla_2012" conn = pymssql.connect(server=servername, user=username, password=password, database=database) cursor = conn.cursor() #cursor = database.cursor() query = """insert forecast_db (srno, state, statecd, district, issuedon, day, n_rainfall, n_tempmax, ...

bash - Linux - How to access/execute file from another folder and not changing folder -

i tried multiple scenarios these things more of headace. tried writing bash same, need change in same file need execute. can me same. #!/bin/bash -p if [ $# -lt 1 ]; echo "no arguments provided" exit 0 fi current_dir=`pwd` exec_dir=`dirname "$1"` filename="`basename $1`" cd $exec_dir cmd="./$filename ${@:2}" $cmd cd $current_dir i need 2 liner work same file need execute. if script present in /opt/ , in /opt/dir/ can run script there --> ../script.sh run script previous folder , run in present folder

visual c++ - Is there any way of getting a user drawn control onto MFC ribbon -

as per title, there way of getting user drawn control onto mfc ribbon? i'd access cwnd draw , update placed in ribbon tab. nearest can see derive control cmfcribbonbaseelement has overrides ondraw , getrect.

visual c++ - In MFC how to increase the time tooltips remain Visible -

i using below code create tooltips. m_ctrltooltip.create(this, tts_alwaystip|tts_balloon); m_ti.cbsize = sizeof(toolinfo); m_ti.uflags = ttf_idishwnd|ttf_track|ttf_transparent|ttf_absolute; m_ti.hwnd = m_hwnd; m_ti.hinst = null; m_ti.uid = (uint)1; m_ti.lpsztext = "";; m_ti.rect=crect(0,0,0,0); m_ctrltooltip.setmaxtipwidth(shrt_max); m_ctrltooltip.setdelaytime(ttdt_autopop,5000); m_ctrltooltip.activate(true); void cladioview::onmousemove(uint nflags, cpoint point) { static cpoint prevpoint =0; static cladremoteiomodule* plastio=null; cladremoteiomodule* plastio1=plastio; plastio=null; bool btooltipset = false; // go thru each module added position pos = gobjeztouchapp.m_objladderlogic.m_objsysattr.m_objremoteiomodulelst.getheadposition(); for( ; pos != null; ) { cladremoteiomodule* pio = gobjeztouchapp.m_objladderlogic.m_objsysattr.m_objremoteiomodulelst.getnext(pos); // rectangle module crect rectmodule ...

html - JavaScript- cannot change style when my script in head -

i'm trying javascript work when insert script head or body elements. here examples: firstly insert body this example ( working ): <html> <body> <p id="p2">hello world!</p> <script> document.getelementbyid("p2").style.color = "blue"; </script> <p>the paragraph above changed script.</p> </body> </html> when move script end of body ( also working ): <html> <body> <p id="p2">hello world!</p> <p>the paragraph above changed script.</p> <script> document.getelementbyid("p2").style.color = "blue"; </script> </body> </html> but when move head stops working : <html> <head> <script> document.getelementbyid("p2").style.color = "blue"; ...