Skip to content

Instantly share code, notes, and snippets.

View davidpaulhunt's full-sized avatar
🏖️
#RemoteLife

David Hunt davidpaulhunt

🏖️
#RemoteLife
View GitHub Profile

What is a variable?

Note: You will usually see const and let when using variables. However, you will see legacy code that uses var to declare variables. DO NOT DO THIS, it is uneccessary in modern JavaScript.

A variable is a container for some value, usually one we want to re-use.

Consider this plain english example:

My name is Clark Kent.
@davidpaulhunt
davidpaulhunt / immediately-invoked-function-expressions.js
Created February 19, 2021 15:30
Node.js Design Patterns - Log Rocket inspired notes
// simulate static variable
// auto incrementing id generator
const idGen = (() => {
let id = 0;
return () => {
id++;
return id;
};
})();
@davidpaulhunt
davidpaulhunt / currency-context.js
Created November 13, 2020 02:38
React Context Example 1
import * as React from "react";
const Ctx = React.createContext({
currency: "USD",
format: (val) => val,
setCurrency: () => {},
});
Ctx.displayName = "CurrencyCtx";
<h1>IHEARTRADIO FAMILY PRIVACY & COOKIE NOTICE</h1>
<p>UPDATED AS OF: July 15, 2019</p>
<p>iHeartMedia, Inc. (“iHeartMedia”, “we”, “us”, or “our”) is committed to maintaining your confidence and trust as it relates to the privacy of children who use our technology platforms. This policy complies with the Children’s Online Privacy Protection Act (“COPPA”). Please read below to learn how we collect, protect, share and use information collected via our child-directed technology platforms (“Platforms”), including iHeartRadio Family.</p>
<h2>QUICK GUIDE TO CONTENTS</h2>
<ol><li>INFORMATION WE COLLECT</li>
<li>HOW WE USE THE INFORMATION WE COLLECT</li>
<li>SHARING OF INFORMATION</li>

Keybase proof

I hereby claim:

  • I am davidpaulhunt on github.
  • I am davidhunt (https://keybase.io/davidhunt) on keybase.
  • I have a public key ASDmBgtUpvurri5GvWpWXLw6q_hfxbm_0dUtmYqBCNeF8Qo

To claim this, I am signing this object:

@davidpaulhunt
davidpaulhunt / controller.md
Last active February 18, 2019 23:41
Rails 6 (Beta) Generator Help

Controller

Description:

Stubs out a new controller and its views. Pass the controller name, either
CamelCased or under_scored, and a list of views as arguments.

To create a controller within a module, specify the controller name as a
path like 'parent_module/controller_name'.

This generates a controller class in app/controllers and invokes helper,
@davidpaulhunt
davidpaulhunt / steps_getting_started_with_aws.md
Last active May 18, 2018 18:11
Steps I followed to get started using AWS on my machine.

IAM User Account Creation

Assuming that your account has been created for you, be certain to receive and store the following key/value pairs:

  • username
  • password
  • access_key_id
  • secret_access_key
  • sign-in link
@davidpaulhunt
davidpaulhunt / tryingJSON.js
Created February 5, 2018 19:09
You should try JSON
const request = require('request');
const INIT_URL = 'http://letsrevolutionizetesting.com/challenge.json';
function requestChallenge(url) {
return new Promise((resolve, reject) => {
request.get(url, { json: true }, (error, response, body) => {
if (error) {
reject(error);
} else {
@davidpaulhunt
davidpaulhunt / exercise-stringer-solution.go
Created September 10, 2017 15:49
My solution to Go's Tour Exercise: Stringers
package main
import "fmt"
type IPAddr [4]byte
// Problem: Add a "String() string" method to IPAddr.
// Solution:
func (ip IPAddr) String() string {
return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3])