Skip to content

Instantly share code, notes, and snippets.

const getArr = (start, stop, step) => {
return Array.from({length: (stop - start) / step + 1}, (_, i) => start + (i * step));
};
@davidyeungcoding
davidyeungcoding / mixin_sass
Last active September 10, 2018 06:31
Using mixins with sass
$colors (
primary: #fff,
secondary: #eee
);
$desktop: 840px;
@function color($color-name) {
// passing one argument for colors var
// hard coded $colors as the obj to map through
@davidyeungcoding
davidyeungcoding / css_parallax_element
Last active November 16, 2021 02:27
Create parallax element with only css
.landingBackground {
background-image: url('../../images/adam-wilson-138927-unsplash.jpg');
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
// use to set height of element to the view port
// normally would use 100vh, but 93vh was used to compensate for the navbar
height: 93vh;
@davidyeungcoding
davidyeungcoding / hr_styling
Last active July 23, 2018 11:36
Styling options for <hr>
.landingHR {
// set thickness of the hr
height: 2px;
background-color: #000;
// optional gradiant scheme
background: linear-gradient(to right, #f5f5f5, #000, #f5f5f5)
}
@davidyeungcoding
davidyeungcoding / full_view_port_background
Created July 23, 2018 03:25
Background image set to full view port
.registerTest {
background-image: url('../../images/david-straight-341873-unsplash.jpg');
height: 100vh;
min-height: 100vh;
}
@davidyeungcoding
davidyeungcoding / phone_validation
Last active July 23, 2018 03:26
Phone Validation
phoneValidation() {
if (/\d{3}-\d{3}-\d{4}/.test(this.state.phone)) return 'success';
};
@davidyeungcoding
davidyeungcoding / email_validation
Last active July 23, 2018 03:27
Email Validation
// ===============================
// || Email Validation Frontend ||
// ===============================
emailValidation() {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (re.test(this.state.email)) return 'success';
};
// ==============================
@davidyeungcoding
davidyeungcoding / us_states
Last active July 23, 2018 03:27
US States Select Form in React-Bootstrap
// ========================
// || Array of US States ||
// ========================
const STATES = [ 'AK', 'AL', 'AR', 'AS', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'GU', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VI', 'VT', 'WA', 'WI', 'WV', 'WY'];
// ===============================
// || Select Form for US States ||
// ===============================
@davidyeungcoding
davidyeungcoding / fizzbuzz.py
Created January 23, 2018 18:42
Fizz Buzz Game
import sys
while True:
try:
if len(sys.argv) > 1:
k = int(sys.argv[1])
else:
k = int(input("Please enter the upper limit: "))
break
except: