Skip to content

Instantly share code, notes, and snippets.

@thgaskell
thgaskell / main.ts
Created March 27, 2020 00:18
Hello, Deno!
import { parse } from "https://deno.land/std/flags/mod.ts";
function greet(name?: string): void {
if (!name) {
console.log('Hello, World!');
} else {
console.log(`Hello, ${name}!`);
}
}
@thgaskell
thgaskell / merged.geojson
Created March 20, 2020 07:33
List of Grab-and-Go Meal School Sites
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thgaskell
thgaskell / keybase.md
Created November 1, 2017 19:09
keybase.md

Keybase proof

I hereby claim:

  • I am thgaskell on github.
  • I am thgaskell (https://keybase.io/thgaskell) on keybase.
  • I have a public key ASAxNZp0H4yBT01iTtYYwRSBVqYADK8D-ciTgo_CyVDwowo

To claim this, I am signing this object:

module.exports = {
create: function () {
var display = [
{ name: "chips", price: 0.75, quantity: 5 },
{ name: "soda", price: 1.50, quantity: 0 },
{ name: "candy", price: 1.00, quantity: 5 }
];
var vendingMachine = {
"restock": function (itemIndex) {
@thgaskell
thgaskell / README.md
Last active November 7, 2019 20:47
Basic Authentication with Passport

Basic Authentication with Passport

Basic authentication is one of the simplest authentication strategies because it doesn't require cookies, sessions, or even a login form! Instead, it uses HTTP headers which means credentials are transmitted on each request.

Installation

You will need to install passport and passport-http. The passport-http module is what allows you set up the Basic Authentication Scheme, in addition to a couple other authentication strategies.

$ npm install express passport passport-http --save
@thgaskell
thgaskell / README.md
Created July 9, 2015 06:50
Pixel Painter Schemas

Pixel Painter Schema Migrations

Using your existing Pixel Painter project, we're going to upgrade it to use Express (if it isn't already).

In addition, intialize the project with sequelize, to create the folders: config, migrations, and models.

Now that we know a little bit about creating migrations, let's use Sequelize to create a couple migration files.

  1. Using sequelize model:create to create model and migration files for a Drawing table.
  2. The only requirement for the Drawing table is that it must have a data column, with the data type json.
@thgaskell
thgaskell / gist:5987fccbd8473b5ef78f
Last active September 21, 2018 02:49
Introduction to Sequelize Migrations

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.

Before you begin

Make sure that the project you are in is a node project (it has a package.json) and you have already installed and initialized sequelize (npm install --save sequelize, sequelize init). Also make sure that your config.json file has the correct credentials to connect to your database.

@thgaskell
thgaskell / README.md
Last active January 18, 2022 10:30
Sequelize Express Starter Guide
@thgaskell
thgaskell / ES5-Number.js
Created May 4, 2015 06:27
Private variables with TypeScript WeakMaps
var Number;
(function (Number_1) {
var map = new WeakMap();
var internal = function (object) {
if (!map.has(object))
map.set(object, {});
return map.get(object);
};
var Number = (function () {
function Number(x) {
@thgaskell
thgaskell / README.md
Created February 22, 2015 23:57
Sequelize Associations

File Structure:

  • seed_database.js
  • config.json
  • models/
    • index.js
    • User.js
    • UserType.js

Make sure that the SQL configs are in config.json.