Skip to content

Instantly share code, notes, and snippets.

@jpotts18
jpotts18 / create_dates.sql
Last active August 29, 2023 19:49
Date Dimension for Postgres
CREATE TABLE public.dates (
id int4 NOT NULL PRIMARY KEY,
date date NOT NULL,
datetime timestamp NOT NULL,
julian_day int4 NOT NULL,
day int4 NOT NULL,
day_name varchar NOT NULL,
day_abbrev varchar NOT NULL,
@jpotts18
jpotts18 / create_times.sql
Last active October 13, 2020 10:33
Time Dimension for Postgres
CREATE TABLE "public"."times" (
id int4 NOT NULL,
time time,
hour int2,
military_hour int2,
minute int4,
second int4,
minute_of_day int4,
second_of_day int4,
quarter_hour varchar,
@jpotts18
jpotts18 / Alamofire-JSON-Serialization.md
Last active August 17, 2020 15:44
Alamofire JSON Serialization of Objects, Collections, Nesting

Alamofire JSON Serialization of Objects and Collections

Alamofire is a great Swift library developed by the creator of AFNetworking @mattt. The purpose of this gist is to explain how to use the built-in power of Alamofire to serialize your JSON. In this example we will be serializing a simple blog API. First we will start with serializing a single JSON object and add complexity as we go along.

Warning: This was written before Swift 1.2

A Single JSON Serialization

This is the first JSON object that we will be serializing.

@jpotts18
jpotts18 / linux-cheatsheet.md
Last active February 7, 2020 21:09
linux cheat sheet

tail

-n = number of lines to show
-f = follow
-q = quite (don't show file headers)
@jpotts18
jpotts18 / boston.ipynb
Last active January 15, 2020 05:58
Linear Regression on Boston Housing Data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package com.mydietitian.android.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.mydietitian.android.activities.LoginActivity;
/**
# install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
brew install hub
# install brew cask
brew tap caskroom/cask
<?php
// https://codeigniter.com/userguide3/general/creating_libraries.html
class EventPublisher {
const SOURCE = 'admin'
public function __construct($params, $resource_name)
{
$this->CI =& get_instance();
@jpotts18
jpotts18 / node-aes-cbc-example.js
Created December 13, 2018 19:02
Node AES CBC Example
// AES RFC - https://tools.ietf.org/html/rfc3602
const crypto = require('crypto');
const algorithm = 'aes-256-cbc';
// generate with crypto.randomBytes(256/8).toString('hex')
const key = process.env.AES_KEY;
const IV_LENGTH = 16;
const encrypt = (text) => {
const iv = crypto.randomBytes(IV_LENGTH);
@jpotts18
jpotts18 / HealthCheckRoute.js
Created July 26, 2018 05:46
Node.js Healtcheck
const express = require('express');
const { sequelize } = require('../models');
const router = express.Router();
/**
* @swagger
* /api/health-check: