Skip to content

Instantly share code, notes, and snippets.

View elfacht's full-sized avatar
🥰
Love code, hate racism

Martin Szymanski elfacht

🥰
Love code, hate racism
View GitHub Profile
async function validatePassword(password: string): string[] {
let errors = []
// 1. Don't regex for things you can trivially express in code
// -----------------------------------------------------------
// For example, we could have written this as `/^.{0,7}$/` but that's not
// nearly as clear as checking the length of the string.
if (password.length < 8) {
errors.push("Password must be at least 8 characters long")
@piotrpog
piotrpog / emailLinks.twig
Created April 25, 2019 23:04
Twig macro converting email addresses in text into links secured from spambots. More info: http://craftsnippets.com/articles/converting-email-addresses-into-links-using-twig-macro
@raybrownco
raybrownco / image_helpers.rb
Last active July 10, 2021 13:37
Inline SVG in Middleman
# Middleman - Inline SVG Helper
# ------------------------------------------------------------------------------
#
# Installation
# ------------
# 1. Save this file at `[project_root]/helpers/image_helpers.rb`
# 2. Open the project's Gemfile and add this line: `gem "oga"`
# 3. Run `bundle install` from the command line
#
# Note: Restart your local Middleman server (if it's running) before continuing
@apfelbox
apfelbox / Article.md
Created March 11, 2015 10:56
Improved double ampersand mixin for Sass

The double ampersand -- or as A list apart called it "lobotomized owl selector" -- is a CSS rule that looks like the following:

* + * {
	/* some declarations */
}

You can also use it with a specific selector:

@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh