Posts

javascript - Function that to look up then perform task -

i trying write short script looks see if class or id present in document. if following: $(".tab_item").removeclass("tab_item_color"); $(this).addclass("tab_item_color"); you can use length property on jquery object. example: if( $('.your-class').length ) { $(".tab_item").removeclass("tab_item_color"); } the if() block execute if there element in dom has class of your-class .

Simplest way to convert a number list to a readable string in VBA -

given array of numbers: [1,3,4,5,8,9,11] what's simplest way in vba convert list readable string, e.g: 1, 3-5, 8-9, 11 i rewrite vb.net function vba it's quite long winded , end longer in vba. public shared function groupednumbers(nums list(of long)) if nums nothing orelse nums.count = 0 return "-" if nums.count = 1 return nums(0) dim lnums = nums.distinct().orderby(function(m) m).tolist dim curpos long = 1 dim lastnum long = lnums(0) dim long = 0 dim numstr string = lnums(0) dim isgap boolean = false until >= lnums.count - 1 until >= lnums.count - 1 orelse lnums(i) + 1 <> lnums(i + 1) += 1 isgap = true loop if isgap numstr += "-" & lnums(i) end if if <> lnums.count - 1 numstr += ", " & lnums(i + 1) isgap = false += 1 end if loop return numst...

c# - IIS replace part of url -

i'm trying replace "se" "sv" in url using url rewrite in iis. url this: www.somedomain.com/ se /baadmarked/baade and should this: www.somedomain.com/ sv /baadmarked/baade my current rule this: <rule name="se sv" patternsyntax="ecmascript" stopprocessing="true"> <match url="(.*)" /> <action type="redirect" url="{c:1}sv{c:3}" appendquerystring="false" /> <conditions logicalgrouping="matchany"> <add input="{http_host}{query_string}" pattern="(.*)(se)(.*)" /> </conditions> </rule> i've tried lot, nothing gets job done. it sounds want use rewrite feature , not redirect feature. the rule should this: <rule name="se sv"> <match url="^(.*)/se/(.*)" /> <action type="rewrite" url="{r:1}/sv/{r:2}" /> </rule>...

how to order list that has date and a word in sql server -

case when prefinallist.truckbooked null 'immediate' else cast(prefinallist.previous_date varchar) end eta the list contain either the word immediate or datetime . how show immediate on top , date in acending. you can try use order this: order (`eta` = 'immediate') asc or can use case statement inside order like order case when eta = 'immediate' 1 else 2 end

regex - Rexex Everything after the "." but ignore "|" -

i have 2 variations of text string: 10.09.2016 | 45 min. | swr fernsehen | ut or 07.09.2016 | 57 min. wdr fernsehen i looking end with: swr fernsehen | ut and wdr fernsehen this have tried capturing group: \\.\s(.*) this returns: | swr fernsehen | ut wdr fernsehen i cant work out how " take after "." ignore "|" any ideas? you may use following regular expression: .*\.(?:\s*\|)?\s*(.*) see regex demo the .*\. match , including last . (because * greedy quantifier), (?:\s*\|)? match 1 or 0 sequences of 0+ whitespaces + | , \s* - 0 or more whitespaces , (.*) grab rest group 1, access group contents tool/language features.

android - unable to get data save in database in fragment containing recyclerview -

i'm working on integrating database save & contact information retrieved in fragment contain recyclerview. app directly crashing when started. fatal exception: main process: com.example.admin.navigationdrawer_demo, pid: 15637 java.lang.runtimeexception: unable start activity componentinfo{com.example.admin.navigationdrawer_demo/com.example.admin.navigationdrawer_demo.mainactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'android.database.sqlite.sqlitedatabase android.content.context.openorcreatedatabase(java.lang.string, int, android.database.sqlite.sqlitedatabase$cursorfactory, android.database.databaseerrorhandler)' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:2416) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.-wrap11(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ ...

java - No Persistence provider found -

i getting following error when using jboss 4.2.3 ga , configured ms-sql.ds file. created entity bean ejb3 , trying access entity bean ejb 2.1 session bean. first of all, wanted check if possible. because when use entitymanager or entitymanagerfactory , entitymanager comming null. instead if use entitymanagerfactory , gives error saying: javax.persistence.persistenceexception: no persistence provider entitymanager named ejbcomponentpu below class public class testbean implements sessionbean { //pass persistence unit entitymanager. @persistencecontext(unitname="ejbcomponentpu") private entitymanager entitymanager; my project folder structure is: src - has packages. inside have meta-inf folder has persistence.xml file thanks help. this persistence.xml file. <?xml version="1.0" encoding="utf-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://...