smarty string_format doesn't round up - smarty

Based on the documentation of string_format
This:
{$testy = 16.99}{$testy|string_format:'%d'}
Should output 17 but it gives me 16 instead
Anyone knows how to fix it?

I think there is an error in the new documentation.
If you look at the old version it is correct.
In cases you need 17 I recommend this:
{$testy|ceil|string_format:"%d"}

Related

How to put 7 events in one eventset in PAPI

In PAPI Im trying to put 7 events in one eventset so I can read 7 results in one operation but I always get return -1 ,can anyone help me?my code like this:
int events1[] = {
PAPI_L1_TCM,
PAPI_L2_TCM,
PAPI_L3_TCM,
PAPI_MEM_WCY,
PAPI_RES_STL,
PAPI_TLB_DM,
PAPI_TLB_IM};
PAPI_library_init(PAPI_VER_CURRENT);
i = PAPI_start_counters(events1,7);
where i appears to be -1 which means PAPI_EINVAL.
I tried change the value PAPI_NUM_TLS but it didn't work.
I have the same problem now. But as I have found, the trouble comes from 5th and 6th counters. Here: https://icl.cs.utk.edu/projects/papi/wiki/PAPI3:PAPI_add_event.3
at IBM POWER6 NOTES there is mentioned that these two counters are specific and as I understand should count concrete events. I have not found the solution yet. For 5th one, I added PAPI_TOT_INS and seems to work but for 6th one PAPI_TOT_CYC gives PAPI_ECNFLCT error as they say.

Parsing data with multiple delimitters using Pig

I am new to Pig. What would be the efficient way for parsing data like this? I am looking at picking each field value after = operator like date, time, devname, etc.
Jun 24 05:25:01 23.45.56.222 date=2014-06-24 time=05:04:43 devname=XX-FGT-Primary
device_id=FG3K8A3408600390 log_id=0021000002 type=traffic subtype=allowed pri=notice
vd=XX-Internet src=23.83.57.99 src_port=7569 src_int="amc-sw1/2" dst=23.91.19.16
dst_port=343 dst_int="amc-sw1/1" SN=116445695565 status=accept policyid=2272
dst_country="India" src_country="India" dir_disp=org tran_disp=noop service=HTTPS
proto=6 duration=122 sent=124 rcvd=84 sent_pkt=3 rcvd_pkt=2
Any code snippets would really help.
I think you are looking for UDF called REGEX_EXTRACT_ALL.
And for code snippet, look here.

Rails 3 I want to remove some part of string from the other string

I am working on rails 3 and ruby 1.9.3 I want ro remove
"[\
part from
"[\"NAS1149C0363R"
I am working with sub method but could not achieve so Please help me.
Maybe this could help:
"[\"NAS1149C0363R".sub(/\[\"/,'')
You probably mean you want to remove [\", not "[\.
"[\"NAS1149C0363R".delete('["')

XPath: using or

I need to find elements on a dynamic website that contain either test.gif or test2.gif. Tt my be that one of those is not present. Whats the correct synax to do it? My take with:
'.//*[#src="http://test/test1.gif"] or .//*[#src="http://test/test2.gif"]'
doesn't seem to work.
have you tried with:
#src="http://test/test1.gif" or #src="http://test/test2.gif"

Descendent-or-self in InfoPath

I want to use XPath code in an InfoPath form to sum the data in field12 when field11 is equal to IT. I tried using the following code, but it doesn't work.
number(sum(/descendant-or-self::node()/my:group12[my:field11 = "IT;"]/my:field12))
I suspect this has to do with the multilayering of groups, as shown below. Does anyone know the code that would allow me to get to the data in group12? Thanks in advance for your help.
myfields>group9>group10>group11>group12>field11 field12
Genipro
Looks like:
number(sum(/descendant-or-self::my:group12[my:field11 = 'IT;']/my:field12))
could be right.
decendant-or-self should not be necissary in this case (unless you need the expression to work even if group12 is moved).
This should work fine:
sum(/my:myfields/my:group9/my:group10/my:group11/my:group12[contains(my:field11,'IT')]/my:field12)
It doesn't matter if any of the other groups are repeating either. All group12's will be checked.

Resources