Created
May 25, 2016 07:21
-
-
Save felixhageloh/94d5dd41cc5ff8a633900ffb28bd195a to your computer and use it in GitHub Desktop.
Example widget using the new JS + virtual DOM syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const refreshFrequency = 1000; | |
export const command = `ps axro \"%cpu,ucomm,pid\" \ | |
| sed -e 's/^[ \\t]*//g' -e 's/\\([0-9][0-9]*\\.[0-9][0-9]*\\)\\ /\\1\\%\\,/g' -e 's/\\ \\ *\\([0-9][0-9]*$\\)/\\,\\1/g' -e's/\\ \\ */\\_/g' \ | |
| awk 'FNR>1' \ | |
| head -n 3 \ | |
| awk -F',' '{ printf \"%s,%s,%d\\n\", $1, $2, $3}' \ | |
| sed -e 's/\\_/\\ /g'`; | |
const style = { | |
top: '10px', | |
left: '10px', | |
position: 'absolute', | |
background: 'rgba(255, 255, 255, 0.2)', | |
WebkitBackdropFilter: 'blur(20px)' | |
}; | |
const columnStyle = { | |
padding: '5px 20px', | |
fontSize: '18px' | |
}; | |
export function updateProps(prev, action) { | |
const rows = action.output.split('\n').map((row) => { | |
return row.split(','); | |
}); | |
return rows; | |
} | |
export function render(props) { | |
return <table style={style}> | |
{props.map((row) => | |
<tr> | |
{row.map((col) => <td style={columnStyle}>{col}</td>)} | |
</tr> | |
)} | |
</table>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're an American student trying to figure out how to live in france as an american and need help with your academic workload, PaperWriter.com is a great resource. I found the platform easy to navigate, and placing my order was hassle-free. The paper I received was well-written, delivered on time, and matched my expectations. Their customer support was also prompt and helpful when I had questions. This service made balancing my studies while adjusting to life abroad much more manageable. Highly recommend it!