Skip to content

Instantly share code, notes, and snippets.

View berkeleycole's full-sized avatar

alyssamhope berkeleycole

  • Shift
  • San Diego
View GitHub Profile
### Keybase proof
I hereby claim:
* I am berkeleycole on github.
* I am alyssamhope (https://keybase.io/alyssamhope) on keybase.
* I have a public key ASBR2NDZn9uXM0EUDQ37PToLB-hJo34GltSE21qZ6NtAKwo
To claim this, I am signing this object:
// ------------------------------------- ENV VARS AND REQUIRES
require('dotenv').config()
const fetch = require("node-fetch")
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
const DBService = require('./services/db')
const AuthService = require('./services/auth')
@berkeleycole
berkeleycole / index.html
Created August 22, 2019 03:50
srcset-with-sizes
<img src="my-awesome-image.png"
alt="something awesome"
srcset="my-awesome-image.png 100w, my-awesome-image.png 500w, my-awesome-image.png 1000w"
sizes="(min-width: 900px) 1000px,
(max-width: 900px) and (min-width: 400px) 50em,
( not (orientation: portrait) ) 300px,
( (orientation: landscape) or (min-width: 1000px) ) 50vw,
100vw"
/>
@berkeleycole
berkeleycole / basic.html
Last active August 21, 2019 04:07
basic srcset example
<img
src="awesome-image-800w.jpg"
alt="My most awesome image"
srcset="awesome-image-320w.jpg 320w,
awesome-image-480w.jpg 480w,
awesome-image-800w.jpg 800w"
/>
function pigLatinify() {
// take in words to be translated
var longstring = document.getElementById('input').value
var pigLatin = function(string) {
let newArray = []
let lowerString = string.toLowerCase()
@berkeleycole
berkeleycole / loose_functions_code_smell.js
Created December 5, 2018 19:29
loose_functions_code_smell.js
var fetch = require("node-fetch");
module.exports = (app) => {
// Collect some information from the Pull Request in order to leave a comment later
let number;
let id;
// listen for a newly opened pull request and find its number
app.on('pull_request.opened', async context => {
function pigLatinify() {
// take in words to be translated
var longstring = document.getElementById('input').value
var pigLatin = function(string) {
let newArray = []
let lowerString = string.toLowerCase()
@berkeleycole
berkeleycole / conditionals_code_smell.js
Last active December 11, 2018 03:30
JS Code Smells -- Examples and Solutions
// example 1 -- easy level
// password checker function
function check_password(password) {
if (
password != "password" &&
password.length >= 6 &&
(password.indexOf("!") != -1) &&
(password.indexOf("#") != -1) &&
(password.indexOf("$") != -1) &&

Rules of React

  • Never update State directly, always use setState()
  • Never alter the dom directly, always operate on a value in state
  • Only call setState once per method or render cycle
  • State is for values that change, Props is for values that don't, constants should be set outside the component

For cleaner React

  • instead of using this.state multiple times, destructure the state object to save values
@berkeleycole
berkeleycole / index.md
Last active August 29, 2015 14:27 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one