Skip to content

Instantly share code, notes, and snippets.

View bradwestfall's full-sized avatar

Brad Westfall bradwestfall

View GitHub Profile
@bradwestfall
bradwestfall / gist:002312c3628eac9cc215
Last active July 11, 2022 15:09
Beginner JavaScript
@bradwestfall
bradwestfall / gist:c87fb32047247eac899b
Last active August 29, 2015 14:02
jQuery Event Delegation (Live Binding)

Event Binding in jQuery

In jQuery, event binding can be a confusing topic at first. Especially when we attempt to do Delegated Events (or live binding , binding to elements that don't exist on the screen yet)

But first, let's clear up just a few things regarding normal event binding...

.click vs .on('click')

jQuery provides specific methods such as .click() or .mouseover() which can be used in this way

Ubuntu IP Tables (Firewall)

When setting up an Ubuntu server, you'll want to establish basic security including a firewall to only allow certain types of requests, and to allow only certain types of responses. This code will:

  • Flush your current firewall
  • Because it's our server and we're not hosting other people's stuff (like a shared server), we'll allow all output
  • Allow input requests for SSH, Port 80 and 443 (Web and TLS (SSL))
  • Log bad requests with the prefix "iptables denied:"
  • Then save these rules to a file called /etc/iptables.up.rules
@bradwestfall
bradwestfall / gist:f5a010e96fb0c4d18556
Last active November 20, 2022 14:40
Pull Instagram Images via JavaScript
@bradwestfall
bradwestfall / gist:c3e44d5c1e4a74ad852e
Last active August 25, 2017 16:35
OS X (Yosemite) Apache Environment Setup

OS X (Yosemite) Apache Environment Setup

Instructions for setting up a basic Apache environment on OS X Yosemite Only. For Mavericks, view this guide

For this guide, square brackets are used to denote places where you need to plugin your own stuff. In none of these cases are you supposed to use actual square brackets.

Note that /private/etc and /etc go to the same place on Yosemite. This is good to know for later.

If you've already configured Apache correctly and you just want to know the part about setting up a new Virtual Host, then you can skip to that section. If not, then you'll need to configure Apache.

Bump Semver - https://docs.npmjs.com/cli/version

# One of these
npm version patch -m 'Git commit message'
npm version minor -m 'Git commit message'
npm version major -m 'Git commit message'

Push to GitHub

sudo npm uninstall npm -g
brew uninstall node

Then

sudo rm -rf /usr/local/lib/dtrace/node.d /usr/local/lib/node_modules /usr/local/bin/npm /usr/local/bin/nodemon /usr/local/bin/node /usr/local/include/node ~/.npm* ~/.node* /usr/local/share/man/*/node* /usr/local/share/man/*/npm*

It seems as though some people like me are experiencing a weird thing when upgrading mac these days, the RSA keys still work for connecting to things like GitHub but my keychain doesn't want to remember the password and is annoyingly asking me for it with every git push.

The solution I found that works is at http://stackoverflow.com/a/41576222

Basically, edit my ~/.ssh/config file to be:

Host *
    UseKeychain yes
@bradwestfall
bradwestfall / S3-Static-Sites.md
Last active April 10, 2024 16:40
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

⚠ This post is fairly old. I don't keep it up to date. Be sure to see comments where some people have posted updates

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation
@bradwestfall
bradwestfall / docker.sh
Last active January 15, 2018 18:50
Docker Cheat Sheet
# Build a container from a local Dockerfile
# 1. -t is the tagname
# 2. The appname is any name we want to distinguish containers
# 3. . the path to Dockerfile
docker build -t <appname> .
# List Images
docker images
# Remove an Image