Posts

how to define a rule of a pattern repeated by a fixed number of times using antlr grammar -

Image
i know '+', '?' , '*'. if want repeats for, say, 5 times? example, if identifier must string of hexdecimal numbers of length 5? to more specific, i'm thinking define general lexer rule of unlimited length, , then, @ parsing time count how many time repeated, if equals 5, rename type of token, how can this? or there easy way? at parsing time count how many time repeated, if equals 5, rename type of token, how can this? or there easy way? yes, can disambiguating semantic predicate ( explanation ): grammar t; parse : (short_num | long_num)+ eof ; short_num : {input.lt(1).gettext().length() == 5}? num ; long_num : {input.lt(1).gettext().length() == 8}? num ; num : '0'..'9'+ ; sp : ' ' {skip();} ; which parse input 12345 12345678 follows: but can change type of token in lexer based on property of matched text, this: grammar t; parse : (short | long)+ eof ; num : '0'..'9'+...

spring - LazyInitializationException even with OpenEntityManagerInViewFilter -

i trying use openentitymanageinviewfilter, keep having lazyinitializationexception. people had similar problems when having entitymanager initialized twice - seems not case. in exception log can see, filter correctly firing. web.xml: <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>web-application</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>web-application</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <context-param> ...

Count number of redirections using HTMLUnit -

i using htmlunit track 302 redirection(s). when visit page instance of webclient , 1 or more redirections might involved before landing on url. once do, mywebclient.setredirectenabled(true); , can http status code using currentpage.getwebresponse().getstatuscode(); , check if 302. problem how track sequence of redirections total number of redirections before landing on page. idea? in case still need solution, com.gargoylesoftware.htmlunit.util.webconnectionwrapper can used keep track of requests , change response (change status code stop further redirects)

How to parse json in bash or pass curl output to python script -

i'm looking find way have pretty print of curl's output in json. wrote short python script purpose, won't work pipe don't want use subprocesses , run curl them: so python: #!/usr/bin/python import simplejson pprint import pprint import sys print pprint(simplejson.loads(sys.argv[1])) and json information is: {"response": {"utilization": {"eic": [{"date": "2012.03.06", "usage": []}, {"date": "2012.03.07", "usage": [{"srvcode": "svc302", "upload": 267547188, "api-calls": {"filegetinfo": 30, "getuserstoragequota": 0, "setuserstoragequota": 0, "fileuploadflashinit": 31, "getapisessionuser": 0, "setfileaccesscontrol": 0, "filegetpreviewurl": 0, "filestartmultipartupload": 0, "getservicequota": 0, "filegetpreviewurlsforbunch": 10, "x...

Cannot call custom-made Javascript function -

possible duplicate: cannot call javascript function cannot call javascript function i have same problem link above. still don't know solution problem hope can me. thanks. make sure there aren't invisible elements in front of input tag causing problems. make sure that, if there's event propagation, earlier click events preventing default behavior. the function syntax in related question accurate, , work on @ least local machine (safari).

reporting services - SSRS: Top n AND Bottom n (filter) -

is there way can filter in ssrs return top n , bottom n e.g. if have numbers -50 through +50 and filtered on top 5 , bottom 5 i expect see -50,-49,-48,-47,-46,46,47,48,49,50 is possible, allows when i've tried appears ignore second filter you can defining 2 groups. 1 group has filter top 5 , other count of records less 5 bottom n filter this technique described in full @ http://www.bidn.com/blogs/mikedavis/ssis/172/top-n-bottom-n-grouping-in-ssrs-2008 if there chance on getting duplicate records @ boundary need retrieve boundary value , return matching value or (more/less depending on top/bottom). the duplicate handling can done eg http://www.bidn.com/blogs/mikedavis/ssis/1875/ssrs-top-n-and-bottom-n-reporting-with-duplicates

php - Magento - Adding page number to title on products listing -

i have extension uses products list block show products grid filter attribute (the extension attribute info pages ). in "_preparelayout" function of extension block extension sets page's title , description using code : $head = $this->getlayout()->getblock('head'); . . . $head->settitle($title); head->setdescription($des); i want add text title , description in format : $page_info = "page of b "; $title = $page_info . title; $items_info = "listings x-y (out of z) "; $des = items_info . $des; i've tried code order current page, last page, number , items , on : $html_pager = mage::getblocksingleton('page/html_pager'); $html_pager->setcollection($product_collection); $limit = mage::getsingleton('core/app')->getrequest()->getparam('limit'); if(empty($limit)) { $limit = 8; } $html_pager->setlimit($limit); $lastpagenumber = $html_pager->getlast...