Skip to content

Instantly share code, notes, and snippets.

This setup is for this template. It runs Rails in API mode, Vue + Webpack for view layer and it's all served from the same root directory.

Steps to get droplet up and running with just Ubuntu 16.04 (i.e. not a "one-click" install)

  1. Create non-root user
adduser production
usermod -aG sudo production

Goal

A build template for static sites that is:

  1. Extensible as requirements upgrade
  2. Buildable to optimize deployments
  3. Repeatable (reuse as many common elements as possible/only customize when necessary)
  4. SEO friendly

Tools to meet goals

  1. Encapsulate everything in Vue components
  2. Use webpack & co (e.g. purgeecss)
@nicholasshirley
nicholasshirley / DO_cap_no_AR.md
Last active December 30, 2018 02:28
Set up DO Rails + nginx + Puma + Capistrano (No ActiveRecord)

Steps to get droplet up and running with just Ubuntu 16.04

  1. Create non-root user
adduser production
usermod -aG sudo production
ssh-keygen
cat ~/.ssh/id_rsa.pub
@nicholasshirley
nicholasshirley / ActiveStorage purge on controller
Last active April 17, 2018 11:29
Example of selective attachment purge on controller
@resource = Training::Resource.find(params[:id])
if params[:attachment_id]
@resource.files.find_by_id(params[:attachment_id]).purge
flash[:success] = 'The resource has been deleted'
redirect_to edit_trainings_resource_path(@resource)
else
@resource.destroy
flash[:success] = 'The resource has been deleted'
redirect_to trainings_resources_path
//madlibs
https://hyperdev.com/#!/join/79bdfb66-8fff-43d5-b598-f389797fe738
//cookie parser
https://hyperdev.com/#!/join/070dd322-b44d-49ab-9e45-ab7968b9bdb4
//cat carosel
https://jsbin.com/focami/1/edit?js,output
//return of fizzbuzz
https://jsbin.com/bacerap/edit?html,js,output
//lights out
https://jsbin.com/vonugo/1/edit?html,css,js,output
//most frequent word
https://jsbin.com/higekon/edit?js,console
//data merge
https://jsbin.com/josoti/edit?js,console
//recipe factory
https://jsbin.com/nizumi/1/edit?html,js,output
//Object creator
https://jsbin.com/xupoyil/edit?js,console
//Object updater
https://jsbin.com/honoger/edit?js,console
//Self reference
https://jsbin.com/repacok/edit?js,console
//Deleting keys
https://jsbin.com/nehujej/edit?js,console
What is scope? Your explanation should include the idea of global vs. local scope.
Scope is the frame in which a variable lives. In JS there are 2 scopes (excluding ES6) global and local. Global variables are availabe to any function and can be called from anywhere (including other files, if loaded first) and local variables are only available inside their function.
Why are global variables avoided?
Global variables are more likely to have unintended side effects. Side effects are when a function reaches outside its scope to change a variable further up the scope chain and unintended indicates that the change is not wanted. If multiple functions are reaching out and changing the same global variable, they can become indeterminate (not produce the same result when run) and lead to bugs.
Explain JavaScript's strict mode
Strict mode, indicated by the 'use strict' at the top of the document (or inside a function), requires variables be explicitly declared before use. One benefit is that if a global variable wou
@nicholasshirley
nicholasshirley / JS-links4
Last active November 1, 2016 12:15
Answers to JS lesson 4 exercises
//min max
https://jsbin.com/zotogo/edit?js,console
//average
https://jsbin.com/wefewoz/edit?js,console
//fizz buzz
https://jsbin.com/yivinaq/edit?js,console