Skip to content

Instantly share code, notes, and snippets.

View billmei's full-sized avatar
☑️
Verified Profile

Bill Mei billmei

☑️
Verified Profile
View GitHub Profile
@billmei
billmei / validateEmail.js
Last active July 12, 2016 04:35
Quick and simple email validation. Returns a boolean.
function validateEmail (email) {
return /.+@.+\..+/.test(email);
}
@billmei
billmei / HTMLchecklist.md
Last active September 2, 2022 05:40
Checklist to have a W3C compliant, secure, SEO friendly, mobile-friendly, maximally-compatible HTML site.

Checklist for new websites

Once you're done coding your site, go through this checklist to make sure you have a W3C compliant, valid HTML, secure, maximally-compatible, optimal-performance, responsive and mobile-friendly, SEO-friendly website.

SEO

  • <title> is keyword friendly
  • <meta name="description" content="" />
  • ``
@billmei
billmei / non-www-conversion
Last active December 14, 2015 22:19
.htaccess configuration file for Apache to convert a www website to a non-www website and vice-versa. Example: "http://www.example.com" to "http://example.com"
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
@billmei
billmei / em-scale.css
Last active April 22, 2016 21:51
Font-size standard scale
body { font-size: 100%; } /* 16px standard, but should make this scale with mobile */
h1 { font-size: 3em; } /* 16 x 3 = 48 */
h2 { font-size: 2.25em; } /* 16 x 2.25 = 36 */
h3 { font-size: 1.5em; } /* 16 x 1.5 = 24 */
h4 { font-size: 1.125em; } /* 16 x 1.125 = 18 */
p { font-size: 1em; } /* 16 x 1 = 16 */
@billmei
billmei / randInt.js
Last active December 17, 2015 17:39
Return a random integer with JavaScript
function randInt (maximum) {
return Math.floor(Math.random() * maximum);
}
function randBetween (minimum, maximum) {
return Math.floor(Math.random() * (maximum - minimum) + minimum);
}
// This version is not zero-indexed
function randIntPlusOne (maximum) {
@billmei
billmei / ResponsiveSizes.css
Last active April 22, 2016 21:53
Sizes for responsive grid as of Bootstrap 2.3.2
/* Large Desktop */
@media (min-width: 1200px) {}
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 979px) {}
/* Landscape phone to portrait tablet */
@media (max-width: 767px) {}
/* Landscape phones and down */
@media (max-width: 480px) {}
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
import os
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses base 64 encode instead to generate a random key
@billmei
billmei / h1flair.css
Created November 3, 2013 21:54
Flair (lines) around (before and after) and h1 element
/* from http://stackoverflow.com/a/5214234/2142259 */
h1 {
overflow: hidden;
text-align: center;
}
h1:before,
h1:after {
background-color: #000;
content: "";
@billmei
billmei / strikethrough.js
Last active March 31, 2021 09:11
Adds unicode strikethrough characters to your input so that you can post it to comment boxes and social media websites (Facebook, Twitter, etc.) that don't accept HTML tags
const strikethroughText = text =>
text.split('').reduce((acc, char) =>
acc + char + '\u0335', '')
// strikethroughText("amazingly few discotheques provide jukeboxes")
// "a̵m̵a̵z̵i̵n̵g̵l̵y̵ ̵f̵e̵w̵ ̵d̵i̵s̵c̵o̵t̵h̵e̵q̵u̵e̵s̵ ̵p̵r̵o̵v̵i̵d̵e̵ ̵j̵u̵k̵e̵b̵o̵x̵e̵s̵"