hcard format for company address type - hcard

I'm looking for best way to use hCard format on my site and my concern is about type of company address
My contacts data goes like this:
CompanyX
Office 28 Nulla St. Mankato Mississippi 96522
CompanyX
Headquarters 92 Dictum Av. San Antonio MI 47096
CompanyX
Customer Service 48 Dolor. Av. Muskegon KY 12482
My vcard html goes like this:
<div class="vcard">
<strong class="org">CompanyX <span class="category">Office</span></strong>
<div class="adr">
<div class="street-address">28 Nulla St.</div>
<span class="postal-code">96522</span> <span class="locality">Mankato Mississippi</span>
</div>

Related

How to use tokens from 2 time range inputs in single Splunk dashboard query?

I'm using Splunk classic dashboards where I have 2 time range inputs. I want to compare data for 2 time frames in a single table. Essentially, I want to perform query which counts errors by type for period A and B, then join the searches by error type so that I can see how many errors of each type there were in period A as opposed to period B.
I added a panel as follows:
because I want to use tokens from both time inputs for the query:
(index=myindex) earliest="$runATimeInput.earliest$" latest="$runATimeInput.latest$" environment="$runAEnvironment$" level=ERROR
| spath input=message
| stats count by logIdentifier
| sort count desc
| join left=L right=R where L.logIdentifier = R.logIdentifier
[| search (index=myindex) earliest="$runBTimeInput.earliest$" latest="$runBTimeInput.latest$" environment="$runBEnvironment$" level=ERROR
| spath input=message
| stats count by logIdentifier ]
The problem is that the query doesn't return any results although it should. The main query returns results:
(index=myindex) earliest="$runATimeInput.earliest$" latest="$runATimeInput.latest$" environment="$runAEnvironment$" level=ERROR
| spath input=message
| stats count by logIdentifier
| sort count desc
However the subsearch query doesn't return any results (although a separate search for the same period in a new tab returns results):
[| search (index=myindex) earliest="$runBTimeInput.earliest$" latest="$runBTimeInput.latest$" environment="$runBEnvironment$" level=ERROR
| spath input=message
| stats count by logIdentifier ]
When I click on Run Search in Splunk panel in order to open the search in a new tab I see strange values for earliest/latest tokens. For the main query the values are: earliest="1669500000" latest="1669506493.677" where 1669500000 is the Tue Jan 20 1970 09:45:00 and 1669506493.677 is Sun Nov 27 2022 01:48:13 whereas the timeframe for period 1 was Sun Nov 27 2022 00:00:00 - Sun Nov 27 2022 01:48:13. That being said the main query works and it respects the original time frame.
The values for the second query are earliest="1669813200" latest="1669816444.909" where 1669813200 is Tue Jan 20 1970 09:45:00 and 1669816444.909 is Wed Nov 30 2022 15:54:04 whereas the period 2 timeframe was Wed Nov 30 2022 15:00:04 - Wed Nov 30 2022 15:54:04`.
Am I doing something wrong in the panel settings or the query? Or maybe there's another way to do this in Splunk?
Below is the dashboard XML:
<form>
<label>My Dashboard</label>
<description>My Dashboard</description>
<fieldset submitButton="false" autoRun="true">
<input type="time" token="runATimeInput" searchWhenChanged="true">
<label>Run A</label>
<default>
<earliest>-24h#h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="runAEnvironment" searchWhenChanged="true">
<label>Run A Environment</label>
<choice value="prod">prod</choice>
<default>prod</default>
</input>
<input type="time" token="runBTimeInput" searchWhenChanged="true">
<label>Run B</label>
<default>
<earliest>-24h#h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="runBEnvironment" searchWhenChanged="true">
<label>Run B Environment</label>
<choice value="prod">prod</choice>
<default>prod</default>
</input>
</fieldset>
<row>
<panel>
<title>Top Exceptions</title>
<table>
<title>Top Exceptions</title>
<search>
<query>(index=distapps) earliest="$runATimeInput.earliest$" latest="$runATimeInput.latest$" environment="$runAEnvironment$" level=ERROR | spath input=message
| stats count by logIdentifier
| sort count desc
| join left=L right=R where L.logIdentifier = R.logIdentifier
[| search (index=myindex) earliest="$runBTimeInput.earliest$" latest="$runBTimeInput.latest$" environment="$runBEnvironment$" level=ERROR
| spath input=message
| stats count by logIdentifier ]</query>
<earliest>$runATimeInput.earliest$</earliest>
<latest>$runBTimeInput.latest$</latest>
</search>
<option name="drilldown">none</option>
<option name="refresh.display">progressbar</option>
</table>
</panel>
</row>
</form>
Here's a test dashboard I created that uses two timepickers. It produces results for both time periods. How is yours different? Could it be the count field is used in both the main and subsearches?
<form version="1.1">
<label>test</label>
<fieldset submitButton="false">
<input type="time" token="runATimeInput">
<label>A</label>
<default>
<earliest>-24h#h</earliest>
<latest>now</latest>
</default>
</input>
<input type="time" token="runBTimeInput">
<label>B</label>
<default>
<earliest>-48h#h</earliest>
<latest>-24h#h</latest>
</default>
</input>
</fieldset>
<row>
<panel>
<table>
<search>
<query>(index=_internal) earliest="$runATimeInput.earliest$" latest="$runATimeInput.latest$"
| stats count as countA by component
| join component [| search (index=_internal) earliest="$runBTimeInput.earliest$" latest="$runBTimeInput.latest$"
| stats count as countB by component ]</query>
<earliest>$runATimeInput.earliest$</earliest>
<latest>$runATimeInput.latest$</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="drilldown">none</option>
<option name="refresh.display">progressbar</option>
</table>
</panel>
</row>
</form>
Don't use any tokens or time selector on the panel itself
You should be able to reference your two time tokens' .earliest and .latest just fine in any searches on the dashboard

Money filter giving worng asnwer in calculations liquid shopify

I am tryign to display amount after discount with my product. It works fine in calculation
For example my total price is 500 and discoutn is of 50% i get my answer 250 which is correct but when i use money filter to display currency unit i.e(Rs. ) it gives wrong answer which is Rs. 3
My code that gives correct output but without currency unit
{% assign percent_calculated = section.settings.custom_discount_title | times: productprice | divided_by: 100 %}
<span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo" style="color:#FFDAB9" >{{ productprice |minus : percent_calculated }} </span></div>
OUTPUT
250
I want to display it as Rs. 250 but to achieve that i use "|money " filter and get wrong answer
{% assign percent_calculated = section.settings.custom_discount_title | times: productprice | divided_by: 100 %}
<span href="https://wdtcv.myshopify.com/discount/discount%2520code%2520promo" style="color:#FFDAB9" >{{ productprice |minus : percent_calculated | money }} </span></div>
OUTPUT
Rs. 3 (answer should be Rs. 250)
I got the solution which was to remove money_without_currency filter
as I used it because I was confused that liquid language requires data type casting you I used it a bit earlier.

SQL - return rows with a duplicate value, where one row in each group has a certain attribute and not another

I am a SQL novice at best - appreciate any help on this answer. It's specific to the program MediaMonkey, but more broadly applicable I think since MediaMonkey's database is I believe SQLite 3. The table I'm querying is called Songs and all the columns I'm referencing are in this table.
I am using the Custom4 field in MediaMonkey to store a song's Work ID from Musicbrainz, and the Custom5 field to store the AcoustID. I'm trying to create a playlist of cover / alternate / live versions of songs that I've rated 5 stars, but where the 5 star song is not a classical work or a jazz recording (I use the Grouping field (GroupDesc) to indicate if a track is classical or jazz).
Parameters for the SQL query need to be something like this:
Same Work ID as a 5 star recording (Rating = 100), where the Grouping
of the 5 star recording is not 'Classical' or 'Jazz' (I am OK with
classical or jazz covers of 5 star popular works)
Different AcoustID from any 5 star recording (eliminate duplicate
recordings)
Rating < 5 stars (I don't want to include the 5 star songs
themselves)
I cobbled together the following SQL query from some examples I found:
Songs.Custom4 IN (SELECT Custom4 FROM Songs GROUP BY Custom4 HAVING Count(*) > 1 AND Max(Rating) > 99 AND Custom4 <> '' AND GroupDesc <> 'Classical' AND GroupDesc <> 'Jazz')
What this appears to include is the following:
Same WorkID as a 5 star recording
Classical or jazz tracks only if the classical or jazz track is rated
5 stars and there is another track with the same Work ID that is not
classical or jazz, or if the classical or jazz track has the same
Work ID as a 5 star recording that is not classical or jazz
Includes duplicates of the 5 star recording, and includes the 5 star
recordings themselves
Somehow then I need to filter out the 5 star classical or jazz tracks and the tracks that have the same Work IDs as those tracks, and I need to exclude the duplicates and the 5 star recordings.
Let's say you have a table like this:
<table class="blueTable">
<thead>
<tr>
<th> Song</th>
<th>Grouping</th>
<th>Rating</th>
<th>Work ID</th>
<th>AcoustID</th>
</tr>
</thead>
<tbody>
<tr>
<td>A1</td>
<td>Classical </td>
<td>100 </td>
<td>a12 </td>
<td>b12 </td>
</tr>
<tr>
<td>A2</td>
<td>Jazz </td>
<td>100 </td>
<td>a21 </td>
<td>b21 </td>
</tr>
<tr>
<td>A3</td>
<td> NULL</td>
<td>100 </td>
<td>a31 </td>
<td>b31 </td>
</tr>
<tr>
<td>A4</td>
<td>NULL </td>
<td>NULL </td>
<td>a12 </td>
<td>b41 </td>
</tr>
<tr>
<td>A5</td>
<td>NULL </td>
<td>NULL </td>
<td>a31 </td>
<td>b31 </td>
</tr>
<tr>
<td>A6</td>
<td>Classical </td>
<td>NULL </td>
<td>a31 </td>
<td>b61 </td>
</tr>
<tr>
<td>A7</td>
<td>NULL </td>
<td>NULL </td>
<td>a31 </td>
<td>b71 </td>
</tr>
</tbody>
</table>
I'd want my query to include the following songs: A6, A7
Here's the logic: A1 and A2 would be excluded since they are Classical and Jazz tracks and are not covers of a popular song with a rating of 100. A3 would be excluded since it has a rating of 100. A4 would be excluded since it's a popular cover of a Classical track that is rated 100. A5 would be excluded since it's a duplicate of A3. A6 is included - it's a Classical cover of A3. A7 is included - it's a cover of A3.

How to locate a name using xpath out of three items?

I've written an xpath to locate a name from th tag but the thing is there are three items attached within a "th" tag separated by "br" tag. How to locate only the first item which is in this case the name among three? Here is what I tried with:
//td[#class='data']/table//th
Elements within the items are:
<td class="data" valign="top" nowrap="">
<table width="350">
<tbody><tr>
<td valign="top" nowrap="">Owner Name &<br>Mailing Address:</td>
<th align="left" valign="top" nowrap="">
<!-- ---------- OWNER NAME ---------- -->
PADILLA ISAI & JOSEFINA<br>
<!-- ---------- MAILING ADDRESS ---------- -->
<!-- ---------- MAILING ADDRESS (MAIL TO) ---------- -->
<!-- ---------- MAILING ADDRESS (ADDR1 AND ADDR2) ---------- -->
8227 FINDLAY ST<br>
<!--
------------------------------------------------
'RA 09/11/2012:
Changed order of Owner / Address to :
Owner Name(s)
MailTo
Addr_1
Addr_2
City
State
Zip
Country
------------------------------------------------
8227 FINDLAY ST
------------------------------------------------
-->
<!-- ---------- MAILING ADDRESS (CITY-STATE-ZIP OR COUNTRY)---------- -->
HOUSTON TX 77017-2328<br>
<!--<br />-->
</th>
</tr>
</tbody></table>
</td>
With my expression the result I'm getting is:
DURAN FRANCISCO & AURORA
4010 BALMORHEA AVE
HOUSTON TX 77039-2510
But I expect to get only:
DURAN FRANCISCO & AURORA
In general cases I would probably go for:
//td[#class='data']/table//th/text()[1]
But, selenium doesn't support text indexing either. What can I do to get the name only from the th tag?
Try below code and let me know in case it won't return expected result:
element = driver.find_element_by_xpath("//td[#class='data']/table//th")
print(driver.execute_script("return arguments[0].childNodes[2].textContent", element).strip())
I have the following way to execute the xpath which doesn't supported by selenium directly :
JavascriptExecutor js = (JavascriptExecutor)driver;
Object message = js.executeScript("var value = document.evaluate(\"//td[#class='data']/table//th/text()[1]\",document, null, XPathResult.STRING_TYPE, null ); return value.stringValue;");
System.out.println(message.toString());
Still having issue let me know :)
Get more details from this answer

How to get specific word from the string column using SQL Server

I have a table.
create table tblProduct
(
ProductID int primary key identity(1000,1),
ProductName varchar(100),
ProductDescription nvarchar(max)
)
In this table, there are 1000 records like this...
ProductID=1001
ProductName='Apple i6'
ProductDescription='Lorem Ipsum is simply dummy text of the printing and typesetting industry. **Product of USA** Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.'
ProductID=1002
ProductName='Micromax Canvas'
ProductDescription='Scrambled it to make a type specimen bookLorem Ipsum is simply dummy text of the printing and typesetting industry. **Product of INDIA** Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.'
ProductID=1003
ProductName='Oppo Z3'
ProductDescription='Lorem Ipsum is simply dummy text of the printing and typesetting industry. **Product of INDIA** Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.'
and so on....
Now I want to find only country name (no duplicate and no other word) from the productDescription column of the tblProduct...
Output must be something like this:
Country Name - Total(Group By)
USA - 1
INDIA - 2
Note: "product of XXX*" will be available almost all rows of productdescription column.
*xxx is the country name.
You can use string manipulation functions LEFT/RIGHT/PATINDEX:
WITH cte AS
(
SELECT
r = RIGHT(ProductDescription, LEN(ProductDescription) -
PATINDEX('%Product of%' ,ProductDescription) - 10)
FROM #tblProduct
WHERE PATINDEX('%Product of%' ,ProductDescription) > 0
)
SELECT country = LEFT(r, CHARINDEX(' ', r)-1), COUNT(*) AS Total
FROM cte
GROUP BY LEFT(r, CHARINDEX(' ', r)-1);
LiveDemo
But you have to think about corner cases:
country name contains multiple words like Russian Federation
what with multiple names (U.S./USA/United States of America...) you will get multiple groups, you need data cleansing
Note: "product of XXX*" will be available almost all rows of
productdescription column.
If you know all countries in advance it will be much easier. Just create table countries:
name master
'U.S.' 'USA'
'USA' 'USA'
'India' 'India'
SELECT c.master, COUNT(*) AS total
FROM #tblProduct p
JOIN countries c
ON p.Description LIKE '%Product of ' + c.name + '%'
GROUP BY c.master;
EDIT:
WITH cte AS
(
SELECT r = RIGHT(ProductDescription, LEN(ProductDescription) - PATINDEX('%Product of <strong>%' ,ProductDescription) - 18)
FROM #tblProduct
WHERE PATINDEX('%Product of <strong>%' ,ProductDescription) > 0
)
SELECT country = LEFT(r, CHARINDEX('<', r)-1), COUNT(*) AS Total
FROM cte
GROUP BY r,LEFT(r, CHARINDEX('<', r)-1);
LiveDemo2