Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
@gregorynicholas
gregorynicholas / api.py
Created June 19, 2018 18:33 — forked from alanhamlett/api.py
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort
@gregorynicholas
gregorynicholas / Oauth2.md
Created June 19, 2018 18:33 — forked from mziwisky/Oauth2.md
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.

@gregorynicholas
gregorynicholas / pyvenvex.py
Created June 19, 2018 18:26 — forked from vsajip/pyvenvex.py
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages. The script needs Python 3.3 or later; invoke it using "python pyvenvex.py -h"…
#
# Copyright (C) 2013 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
@gregorynicholas
gregorynicholas / local_storage_model.js
Created June 15, 2018 03:58 — forked from js1972/local_storage_model.js
SAPUI5 Local Storage Model
sap.ui.define([
"sap/ui/model/json/JSONModel",
"jquery.sap.storage"
], function(JSONModel, jQuery) {
"use strict";
return JSONModel.extend("sap.ui.demo.cart.model.CartModel", {
_STORAGE_KEY : "LOCALSTORAGE_MODEL",
_storage : jQuery.sap.storage(jQuery.sap.storage.Type.local),
@gregorynicholas
gregorynicholas / VIDEO-QA with Tensorflow 1.2RC0.ipynb
Created June 15, 2018 03:57 — forked from Kjeanclaude/VIDEO-QA with Tensorflow 1.2RC0.ipynb
EXAMPLE OF VIDEO-QA IMPLEMENTATION WITH TENSORFLOW 1.2RC0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gregorynicholas
gregorynicholas / chartio_vs_amplitude_job_count_query.sql
Created June 15, 2018 03:50
Query to get count for different job states on 6/19/2017.
with data as (
select distinct
case when creation_client = 'customer.api' then true else false end as is_api_job,
-- j.customer_uuid
j.job_uuid
-- , j.job_date_local
, date_trunc('hour',job_date_local) as hour
-- , date_trunc('day',job_date_local) as day
, date_trunc('hour',job_date_utc) as utc_hour
-- , j.job_date_utc
@gregorynicholas
gregorynicholas / logger.js
Created June 7, 2018 04:16 — forked from jareware/logger.js
Simple utility for unified logging to the console, with optional timestamping.
/**
* Simple utility for unified logging to the console, with optional timestamping.
*
* @example // Create several loggers around the application:
* var log = logger.create('main');
* var logInAnotherModule = logger.create('anotherModule');
*
* // Call the created loggers:
* log('Application started');
* logInAnotherModule('Module started');
@gregorynicholas
gregorynicholas / gist.md
Created June 7, 2018 04:16 — forked from jareware/gist.md
Backporting Compass flexbox mixins from bleeding-edge (0.13.alpha.4) to current stable (0.12.2)

⇐ back to the gist-blog at jrw.fi

New Compass flexbox mixins

The current Compass bleeding-edge (0.13.alpha.4) contains awesome new flexbox mixins that allow you to generate styling for all three (!) past and current specifications. See http://css-tricks.com/using-flexbox/ for the details behind the careful interweaving of different properties and prefixes, but the beef is support for:

  • Chrome any
  • Firefox any
  • Safari any
  • Opera 12.1+
@gregorynicholas
gregorynicholas / gist.md
Created June 7, 2018 04:15 — forked from jareware/gist.md
Project-specific lint rules with ESLint

⇐ back to the gist-blog at jrw.fi

Project-specific lint rules with ESLint

A quick introduction

First there was JSLint, and there was much rejoicing. The odd little language called JavaScript finally had some static code analysis tooling to go with its many quirks and surprising edge cases. But people gradually became annoyed with having to lint their code according to the rules dictated by Douglas Crockford, instead of their own.

So JSLint got forked into JSHint, and there was much rejoicing. You could set it up to only complain about the things you didn't want to allow in your project, and shut up about the rest. JSHint has been the de-facto standard JavaScript linter for a long while, and continues to do so. Yet there will always be things your linter could check for you, but doesn't: your team has agreed on some convention that makes sense for them, but JSHint doesn't have an option

@gregorynicholas
gregorynicholas / geotagging.md
Created June 7, 2018 04:15 — forked from jareware/geotagging.md
Media Geotagging and Massaging on macOS

Media Geotagging and Massaging on macOS

Synchronizing image timestamps

The one and only ExifTool will adjust the various timestamps in Exif data. Take a look at the current values:

$ exiftool DSC02833.JPG | grep Date

If this camera is behind the reference camera (that you want to sync with) by, say, 6 hours, 58 minutes and 10 seconds, add that much to each image in the dir: