Skip to content

Instantly share code, notes, and snippets.

Code smells in CSS

How can you tell if your CSS code smells? What are the signs that the code is sub-optimal, or that the developer hasn't done a good job? What do you look for in the code to determine how good or bad it is?

  1. Styles that undo styles
  2. Magic Numbers - header.menu { margin: 12px 37px 9px 6px; }
  3. Complex Selectors - header.top-header .nav-bar nav.menu ul.main-nav > li a.link-item { font-weight: bold; }
  4. Increasing Specificity Needlessly - body.cms-home-page .footer-block .footer-title { font-size:35px; }
  5. "!important" - !important should only ever be used proactively, not reactively. - .footer-block .footer-title { font-size:33px !important; }
@joepie91
joepie91 / random.md
Last active April 27, 2024 22:59
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@hfreire
hfreire / qemu_osx_rpi_raspbian_jessie.sh
Last active March 24, 2024 14:35
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location
@Vestride
Vestride / encoding-video.md
Last active April 24, 2024 09:59
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus