Skip to content

Instantly share code, notes, and snippets.

View jasenmichael's full-sized avatar

Jasen Michael jasenmichael

View GitHub Profile
@jasenmichael
jasenmichael / properly-sorting-arrays-javascript.md
Last active February 7, 2018 02:56
How to properly sort an array using JavaScript

How to properly sort an array using JavaScript

var arr = new Array(4, 11, 2, 10, 3, 1, 7, 8)  
console.log('this is arr\n', arr)
console.log('-------------')

var ASCIIsortedArr = arr.sort()
@jasenmichael
jasenmichael / git-deploy-to-sftp-guide.md
Last active December 27, 2018 20:06
use git to deploy via sftp

use git to deploy via sftp

this method can be used to push your project to a service like GoDaddy, HostGator, or BlueHost that is running git.

  • create a remote repository on your server

    • ssh into the server

    • cd into the directory

JavaScript fetch error handling

fetch("https://galvanize-leader-board.herokuapp.com/api/v1/leader-board/GBP")
    .then(function(response) {
        if (!response.ok) {
            throw Error(response.statusText);
        }
 return response;

Serve a directory with express

An simple way to host the client in a separate directory using node express
var path = require('path')

var express = require('express')

JavaScript Object Constructors

try it on repl.it

// Constructor function to create "Person" objects
function Person(first, last, age, eye) {
    this.firstName = first;
    this.lastName = last;
 this.age = age;

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

shuffle-array-javascript

check out a more detailed version on replit

function shuffle(array) {
  let counter = array.length;
  // While there are elements in the array
 while (counter > 0) {
@jasenmichael
jasenmichael / index.html
Created December 24, 2018 18:40
VueFlix - Vue Streaming App
<div id="app">
<section class="hero is-primary is-medium">
<router-view></router-view>
<div class="hero-foot">
<div class="columns is-mobile">
<div v-for="movieChoice in movieChoices" class="column">
<router-link :to="`/${movieChoice.id}`" tag="li" class="movie-choice">
<i :class="[{ 'fa fa-check-circle favorite-check': movieChoice.favorite }]" aria-hidden="true"></i>
<img :src="`${movieChoice.smallImgSrc}`" class="desktop"/>
@jasenmichael
jasenmichael / index.html
Last active December 26, 2018 06:05
vue-fullscreen-lightbox-slideshow
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue-fullscreen-lightbox-slideshow</title>
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/lightbox.css'>
<link rel="stylesheet" href="css/style.css">