Turn markdown table into html table - css

I´m currently using a tool, which creates a little informational report over solidity smart contracts with some usefull informations in it, that I want to partially display on the website I´m working on.
The tool is called solidity-metrics (https://github.com/ConsenSys/solidity-metrics) and can be used as CLI or as a library in your backend for example, which is what I want to use.
I´m sending files to my backend, which than scans those solidity files with the metrics tool.
It creates can create an object with a lot of meta-data using metrics.total() but it also can create a markdown string using metrics.generateReportMarkdown().
It includes taledata, which is only displayed in the markdown, not in the metrics.total() object, so I need to somehow turn it into html.
The table content from the markdown looks like this:
| Type | File | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex. Score | Capabilities |
|========|=================|============|=======|=======|===============|==============|
| 📝 | ./uploads/contracts/ProjectName.sol | 1 | **** | 564 | 535 | 308 | 152 | 221 | **<abbr title='Uses Assembly'>🖥</abbr><abbr title='Payable Functions'>💰</abbr><abbr title='Uses Hash-Functions'>🧮</abbr><abbr title='create/create2'>🌀</abbr>** |
| 📝 | ./uploads/contracts/ERC2981.sol | 1 | **** | 48 | 37 | 24 | 7 | 15 | **** |
| 🔍 | ./uploads/contracts/IERC2981.sol | **** | 1 | 18 | 14 | 3 | 10 | 3 | **** |
| 📝 | ./uploads/contracts/MockERC721.sol | 1 | **** | 27 | 27 | 19 | 1 | 18 | **** |
| 📝 | ./uploads/contracts/TokenName.sol | 1 | **** | 285 | 262 | 157 | 46 | 159 | **<abbr title='Uses Assembly'>🖥</abbr><abbr title='Uses Hash-Functions'>🧮</abbr>** |
| 📝 | ./uploads/contracts/Originals.sol | 1 | **** | 142 | 128 | 83 | 22 | 81 | **<abbr title='Uses Hash-Functions'>🧮</abbr>** |
| 📝 | ./uploads/contracts/SutterTreasury.sol | 1 | **** | 23 | 23 | 17 | 1 | 20 | **<abbr title='Payable Functions'>💰</abbr>** |
| 📝🔍 | **Totals** | **6** | **1** | **1107** | **1026** | **611** | **239** | **517** | **<abbr title='Uses Assembly'>🖥</abbr><abbr title='Payable Functions'>💰</abbr><abbr title='Uses Hash-Functions'>🧮</abbr><abbr title='create/create2'>🌀</abbr>** |
What I´ve tried and found out so far:
So the table actually kinda looks like normal markdown to me, but somehow, when trying to throw it inside a .md files it still doesn´t look like it should:
I figured out, that they have linked this github.css file in their credits:
https://gist.github.com/tuzz/3331384
tryed to import it into the .md file but it also didn´t seem to work, don´t even know if that makes sense to import a css file into a .md file...
To come to an end, does anyone have an idea on how to turn this markdown into html, which looks like the image I posted above (which I created with the function, which you can build into vs code, where you can mark the files, right click and scan them using metrics)?
Edit: So I figured out, that the equal signs, splitting the headers from the table body could be replaced by hyphens, which would work out fine in the markdown. I could solve that by replacing all "=" with "-", but that would destroy the rest of the markdown file, because there are also other usecases for the equal sign.

Related

Get memory, cpu and disk usage for each tenant in Openstack

I am looking for the CPU, Memory and Disk consumption for each Tenant in Openstack,and their relationship by users, instances, flavors in use. Horizon only shows utilization of memory, cpu of a global way. Is it possible to get it with Openstack commands?
My openstack is based on Rocky.
Any ideas will be really appreciated
The only thing I know is
openstack limits show --absolute --project <Project_ID/Tenant_ID>
see also https://docs.openstack.org/python-openstackclient/pike/cli/command-objects/limits.html
In the output you have information like for example totalCoresUsed, which represents the number of cores, which are used by the selected project.
Example:
root#openstack-controller:~# openstack limits show --absolute --project 416f937f505f4ff6b623c48a61228a86
+--------------------------+-------+
| Name | Value |
+--------------------------+-------+
| maxTotalInstances | 10 |
| maxTotalCores | 20 |
| maxTotalRAMSize | 51200 |
| maxSecurityGroups | 10 |
| maxTotalFloatingIps | 10 |
| maxServerMeta | 128 |
| maxImageMeta | 128 |
| maxPersonality | 5 |
| maxPersonalitySize | 10240 |
| maxSecurityGroupRules | 20 |
| maxTotalKeypairs | 100 |
| maxServerGroups | 10 |
| maxServerGroupMembers | 10 |
| totalRAMUsed | 2560 |
| totalCoresUsed | 7 |
| totalInstancesUsed | 7 |
| totalFloatingIpsUsed | 0 |
| totalSecurityGroupsUsed | 1 |
| totalServerGroupsUsed | 0 |
| maxTotalVolumes | 10 |
| maxTotalSnapshots | 10 |
| maxTotalVolumeGigabytes | 1000 |
| maxTotalBackups | 10 |
| maxTotalBackupGigabytes | 1000 |
| totalVolumesUsed | 5 |
| totalGigabytesUsed | 7 |
| totalSnapshotsUsed | 0 |
| totalBackupsUsed | 0 |
| totalBackupGigabytesUsed | 0 |
+--------------------------+-------+
The quotas and so the limitations are bind to projects and not to users, so I don't know if it is possible to get a relationshit by users. The only idea I would have, would a simple bash-script, which iterates over all instances and volumes of a project and collect the information of each ressource by the user, who created it.
Update 30.7.2020:
Found a better solution now, which also allows to get the resource usage per user of a project. It comes with the new placement-component with the stein-release of openstack (tested in train-release of openstack).
Installation of the openstack-client extension: pip install osc-placement
Ressource-usage of a project:
openstack resource usage show --os-placement-api-version 1.9 <PROJECT_ID>
Ressource-usage of a specific user within a project:
openstack resource usage show --os-placement-api-version 1.9 --user-id <USER_ID> <PROJECT_ID>
Example:
openstack resource usage show --os-placement-api-version 1.9 --user-id 98378bd3cdd94218bf7b6ef4ec80e74a 7733616a513444c2a106243db318b0dd
+----------------+-------+
| resource_class | usage |
+----------------+-------+
| VCPU | 3 |
| MEMORY_MB | 768 |
| DISK_GB | 9 |
+----------------+-------+

How to make a table with separators in R-Markdown

I am not sure whether I can make a table with separator in R markdown.
This is all I can do so far.
| Student ID |Exam 1|Exam 2|Exam 3|
| --------------|:----:|:-----:|:-----:|
| K | 91 | 35 | 67 |
| L | 45 | 40 | 80 |
| M | 27 | 85 | 62 |
| N | 75 | 93 | 55 |
What I meant by separator is that I want a line between "Student ID" and "Exam 1" columns, etc. Just like how we create a table in Microsoft word.
Thank you.
P.S I drew a line between two columns. I have not still figured out how to do that in R markdown.

dojo how to have multiple rows in a datagrid header

i need to have a datagrid with the following layout:
------------------------------------------------
| | | player |
| date | time |-------------------------------|
| | | first name | last name | age |
|----------------------------------------------|
| jan | 14:02 | roy | batty | 3 |
|----------------------------------------------|
| mar | 17:12 | pika | chu | 1 |
|----------------------------------------------|
| dec | 05:31 | louie | dickens | 33 |
------------------------------------------------
Preliminary inquiries seem to reveal that dojo does not support this kind of behavior, am i right?
thank you very much
This is possible in dojo, you need to use CompoundColumns feature for this and then you will achieve this.
Please follow this link,
CompoundColumns for multilevel row in dojo grid
Please do try this and do let me know if have any issue/concern.

Is there a way to show partitions on Cloudera impala?

Normally, I can do show partitions <table> in hive. But when it is a parquet table, hive does not understand it. I can go to hdfs and check the dir structure, but that is not ideal. Is there any better way to do that?
I am using Impala 1.4.0 and I can see partitions.
From the impala-shell give the command:
show partitions <mytablename>
I have something looking like this:
+-------+-------+-----+-------+--------+---------+--------------+---------+
| year | month | day | #Rows | #Files | Size | Bytes Cached | Format |
+-------+-------+-----+-------+--------+---------+--------------+---------+
| 2013 | 11 | 1 | -1 | 3 | 25.87MB | NOT CACHED | PARQUET |
| 2013 | 11 | 2 | -1 | 3 | 24.84MB | NOT CACHED | PARQUET |
| 2013 | 11 | 3 | -1 | 2 | 19.05MB | NOT CACHED | PARQUET |
| 2013 | 11 | 4 | -1 | 3 | 23.63MB | NOT CACHED | PARQUET |
| 2013 | 11 | 5 | -1 | 3 | 26.56MB | NOT CACHED | PARQUET |
Alternatively you can go to your table in HDFS . They are normally seen in this path:
/user/hivestore/warehouse/<mytablename> or
/user/hive/warehouse/<mytablename>
Unfortunately no. Issue is open though. So checking it manually seems to be the only option right now.

Hmisc Table Creation

Just starting out with R and trying to figure out what works for my needs when it comes to creating "summary tables." I am used to Custom Tables in SPSS, and the CrossTable function in the package gmodels gets me almost where I need to be; not to mention it is easy to navigate for someone just starting out in R.
That said, it seems like the Hmisc table is very good at creating various summaries and exporting to LaTex (ultimately what I need to do).
My questions are:1)can you create the table below easily in the Hmsic page? 2) if so, can I interact variables (2 in the the column)? and finally 3) can I access p-values of significance tests (chi square).
Thanks in advance,
Brock
Cell Contents
|-------------------------|
| Count |
| Row Percent |
| Column Percent |
|-------------------------|
Total Observations in Table: 524
| asq[, 23]
asq[, 4] | 1 | 2 | 3 | 4 | 5 | Row Total |
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
0 | 76 | 54 | 93 | 46 | 54 | 323 |
| 23.529% | 16.718% | 28.793% | 14.241% | 16.718% | 61.641% |
| 54.286% | 56.250% | 63.265% | 63.889% | 78.261% | |
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
1 | 64 | 42 | 54 | 26 | 15 | 201 |
| 31.841% | 20.896% | 26.866% | 12.935% | 7.463% | 38.359% |
| 45.714% | 43.750% | 36.735% | 36.111% | 21.739% | |
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
Column Total | 140 | 96 | 147 | 72 | 69 | 524 |
| 26.718% | 18.321% | 28.053% | 13.740% | 13.168% | |
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
The gmodels package has a function called CrossTable, which is very nice for those used to SPSS and SAS output. Try this example:
library(gmodels) # run install.packages("gmodels") if you haven't installed the package yet
x <- sample(c("up", "down"), 100, replace = TRUE)
y <- sample(c("left", "right"), 100, replace = TRUE)
CrossTable(x, y, format = "SPSS")
This should provide you with an output just like the one you displayed on your question, very SPSS-y. :)
If you are coming from SPSS, you may be interested in the package Deducer ( http://www.deducer.org ). It has a contingency table function:
> library(Deducer)
> data(tips)
> tables<-contingency.tables(
+ row.vars=d(smoker),
+ col.vars=d(day),data=tips)
> tables<-add.chi.squared(tables)
> print(tables,prop.r=T,prop.c=T,prop.t=F)
================================================================================================================
==================================================================================
========== Table: smoker by day ==========
| day
smoker | Fri | Sat | Sun | Thur | Row Total |
-----------------------|-----------|-----------|-----------|-----------|-----------|
No Count | 4 | 45 | 57 | 45 | 151 |
Row % | 2.649% | 29.801% | 37.748% | 29.801% | 61.885% |
Column % | 21.053% | 51.724% | 75.000% | 72.581% | |
-----------------------|-----------|-----------|-----------|-----------|-----------|
Yes Count | 15 | 42 | 19 | 17 | 93 |
Row % | 16.129% | 45.161% | 20.430% | 18.280% | 38.115% |
Column % | 78.947% | 48.276% | 25.000% | 27.419% | |
-----------------------|-----------|-----------|-----------|-----------|-----------|
Column Total | 19 | 87 | 76 | 62 | 244 |
Column % | 7.787% | 35.656% | 31.148% | 25.410% | |
Large Sample
Test Statistic DF p-value | Effect Size est. Lower (%) Upper (%)
Chi Squared 25.787 3 <0.001 | Cramer's V 0.325 0.183 (2.5) 0.44 (97.5)
-----------
================================================================================================================
You can get the counts and test to latex or html using the xtable package:
> library(xtable)
> xtable(drop(extract.counts(tables)[[1]]))
> test <- contin.tests.to.table((tables[[1]]$tests))
> xtable(test)

Resources