Skip to content

Instantly share code, notes, and snippets.

const express = require('express');
const path = require('path');
const bodyparser = require('body-parser');
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
// const cookieParser = require('cookie-parser');
const session = require('express-session')
const RedisStore = require('connect-redis')(session);
@nakaz
nakaz / letsencrypt.sh
Last active March 4, 2017 04:24
Nginx, LetsEncrypt, CertBot basic configuration/setup (OPTIONAL: nginx mainline with http2)
# as super user after pointing domain to server. ref: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04
cd /usr/local/sbin
wget https://dl.eff.org/certbot-auto
chmod a+x /usr/local/sbin/certbot-auto
certbot-auto certonly -a webroot --webroot-path=/usr/share/nginx/html -d [[site.com]] -d www.[[site.com]]
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
# as root, edit the nginx config for the site you just set up
vim /etc/nginx/conf.d/[[site.com]].conf
# when editing the file, just follow all the directions to comment and uncomment TLS-related config
@nakaz
nakaz / coffee-warehouse.md
Last active September 30, 2017 23:15
Coffee Warehouse API

Coffee Warehouse API

You've been tasked to build a RESTful API that will help serve and manage data of coffee at a warehouse. Another team will be depending this API in building a front-end application to interact with it.

Draft a routes overview table or list of how you plan on designing your API and submit it to the senior developer for confirmation.

An example can be found on buzzword-bingo: https://github.com/devleague/Buzz-Word-Bingo/blob/master/README.md

We'll be depending on you to build a well-designed RESTful API for our front-end team to work with. Good route naming conventions will be key in providing a simple yet effective API for others to work with.

@nakaz
nakaz / simple.vimrc
Created September 24, 2016 00:26
Simple vim runcom file for comfortable server editing
" Break away from vi
set nocompatible
" Map Leader to space
let mapleader = "\<Space>"
let g:mapleader = "\<Space>"
" Basic Stuff
set number
@nakaz
nakaz / SudokuValidator.js
Last active May 28, 2016 20:32
Answer key for SudokuValidator Challenge
/* SudokuValidator(sudoku)
*
* @param sudoku a multidimensional array containing the sudoku puzzle
*
* @public property sudoku the sudoku grid
*
* @public method validate(num) num is the squared value or max value of sudoku number
for example: 9(result of 3x3 grid) or 4 (2x2).
*/
library(idbr) # devtools::install_github('walkerke/idbr')
library(ggplot2)
library(animation)
library(dplyr)
library(ggthemes)
idb_api_key("Your Census API key goes here")
male <- idb1('JA', 2010:2050, sex = 'male') %>%
mutate(POP = POP * -1,
@nakaz
nakaz / nginxproxy.md
Created October 8, 2015 08:52 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@nakaz
nakaz / intro-mongo.md
Created October 5, 2015 03:30 — forked from sgnl/intro-mongo.md
MongoDB... COME ON DOOOOOOOWN

Before starting run the commands brew doctor and then brew update

Unix Users please install using the docs

Install Mongodb via Homebrew

$ brew install mongodb

Once brew is done installing, take note of the Caveats section that is printed to your console. Just like what we did previously for postgres it might be best to create a symlink then two aliases to start and stop the mongo progress.

  • Start your mongodb service
@nakaz
nakaz / installfest.md
Created October 5, 2015 03:30 — forked from sgnl/installfest.md
Dev league Day 0 Installfest

Installfest

If you have already installed any of these programs before, then you may skip it.

iTerm2(osx)

  • Linux flavors can use instead use the Terminal application that comes installed.

Scroll to the bottom of the page and find the install code for your operating system:

  • OSX: follow the instructions in the Via curl tab

What are Migrations

Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.

I'm not really sure what that means...

Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users and your friend is going to create the Events.

Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users table when you are working with the database.

Creating models and migrations