Skip to content

Instantly share code, notes, and snippets.

View bad6e's full-sized avatar
💭
Founder of TrekWeather.com

Bret Doucette bad6e

💭
Founder of TrekWeather.com
View GitHub Profile
@bad6e
bad6e / lazyLoad.jsx
Created December 12, 2019 16:35
Lazy Load Image React
import React, { useState, useEffect } from 'react'
import AspectRatio from 'react-aspect-ratio'
import handleViewport from 'react-in-viewport'
import BootstrapImage from 'react-bootstrap/Image'
// Utils
import { INIT, LOADING, LOADED } from '../../utils/constants'
// Scss
import './lazyImage.scss'
@bad6e
bad6e / global.js
Last active November 22, 2019 20:34
// Globally Scoped Variables
var mickeyMouse = "Mickey Mouse"
let age = 90
const creator = "Walt Disney"
doMagic()
function doMagic () {
console.log(`${mickeyMouse} is ${90} years old. He was created by ${creator}`)
}
if(true) {
var globallyScoped = 'globallyScoped'
}
console.log(globallyScoped)
// returns
// globallyScoped
function outer(){
var variable1 = 'variable1'
const variable2 = 'variable2'
let variable3 = 'variable3'
function inner() {
console.log(variable1)
console.log(variable2)
console.log(variable3)
}
function blockScope() {
if(true) {
// I am inside the block
var functionScopeVariable = 'functionScopeVariable'
const blockScopedVariable1 = 'blockScopedVariable1'
let blockScopedVariable2 = 'blockScopedVariable2'
}
console.log(functionScopeVariable)
console.log(blockScopedVariable1)
function whatIsDisneyLand() {
// Functionally Scoped Variables
var themeParkLocation = "Disneyland is Happiest Place on Earth"
let question = "Have you been?"
const response = "Too Many Times"
console.log(`${themeParkLocation} ${question} ${response}`)
}
// Globally Scoped Variables
var mickeyMouse = "Mickey Mouse"
let age = 90
const creator = "Walt Disney"
doMagic()
function doMagic () {
console.log(`${mickeyMouse} is ${90} years old. He was created by ${creator}`)
}
@bad6e
bad6e / delete_and_add_team_roles.rb
Created October 23, 2018 22:55
For a given lender, remove all team roles and create new ones
# To Delete Team Roles
lender = Lender.find(2327)
lender.team_roles.destroy_all
# To Create Team Roles, associate team role with existing loan files (if applicable), and set default to true (if applicable)
teams = [1368, 1600, 1520, 1154, 1596, 1440, 1442, 1463, 1457, 1374, 1377, 1458, 1583, 1714, 1152, 1475, 1439, 1218, 1593, 1444, 1433, 1507, 1698, 1412, 1397, 1363, 1487, 1361, 1379, 1420, 1454, 1409, 1362, 1465, 1427, 1445, 1485, 1604, 1699, 1506, 1474, 1403, 1586, 1148, 1364, 1434, 1408, 1513, 1150, 1384, 1483, 1484, 1373, 1438, 1149, 1605, 1488, 1548, 1776, 1452, 1503, 1153, 1505, 1429, 1481, 1493, 1517, 1467, 1450, 1468, 1472, 1576, 1636, 1460, 1461, 1549, 980, 1490, 1478, 1432, 1446, 1694, 1151, 1510, 1612, 1219, 1389, 1441, 1508, 1428, 1599, 1217, 1437, 1391, 1500, 1410, 1464, 1497, 1701, 1456, 1386, 1489, 1477, 1371, 1592, 1394, 1502, 1491, 1406, 1390, 1591, 1383, 1376, 1518, 1398, 1511, 1365, 1220, 1606, 1713, 1607, 1215, 1367, 1417, 1515, 1393, 1521, 1421, 1436, 1550, 1501, 1405, 1575, 1431, 151
@bad6e
bad6e / DemoModal.jsx
Created September 24, 2018 14:02
DemoModal
import React from 'react'
import jsxToString from 'jsx-to-string'
import BootstrapModal from 'components/utils/bootstrap_modal'
import Spinner from 'components/utils/spinner'
export class DemoModal extends React.Component {
constructor(props) {
super(props)
this.state = {
show: false,
@bad6e
bad6e / dynamic-onchange.js
Created February 13, 2018 15:04
Dynamic onChange
handleChange = (event) => {
const { target: { name, value } } = event
this.setState({ [name]: value })
}