Skip to content

Instantly share code, notes, and snippets.

@walm
walm / 1_server-stats-json.sh
Last active January 28, 2024 17:11
Simple Linux Server stats as JSON
#!/bin/sh
echo -n '{'
# memory as "mem": { "current": 800, "total": 1024, "load", 82 } where amount is in MB and load in %
free -m | awk 'NR==2{printf "\"mem\": { \"current\":%d, \"total\":%d, \"load\": %.2f }", $3,$2,$3*100/$2 }'
echo -n ','
# diska as "disk": { "current": 6, "total": 40, "used": 19 } where amount is in GB and used in %
df -h | awk '$NF=="/"{printf "\"disk\": { \"current\":%d, \"total\":%d, \"used\": %d }", $3,$2,$5}'
@soaj1664
soaj1664 / gist:1c40e52c7a8f78981623
Created October 6, 2014 13:12
StyleContextCleaner Function
<!--
/**
* XSS protection function for style context only
* @usecases
* @double quoted case e.g.,
* <span style="use this function if output reflects here"></span>
* @single quoted case e.g.,
* <div style='use this function if output reflects here'></div>
* OR <style>use this function if output reflects here</style>
* @description
@bobbygrace
bobbygrace / trello-css-guide.md
Last active May 15, 2024 16:01
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@tkon99
tkon99 / name.js
Last active April 19, 2024 14:38
Random Name Generator for Javascript
/*
(c) by Thomas Konings
Random Name Generator for Javascript
*/
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 25, 2024 13:55
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.