This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Add user created_by and modified_by foreign key refs to any model automatically. | |
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
from django.db.models import signals | |
from django.utils.functional import curry | |
class WhodidMiddleware(object): | |
def process_request(self, request): | |
if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): | |
if hasattr(request, 'user') and request.user.is_authenticated(): | |
user = request.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from silo.models import Silo, DataField, ValueStore | |
from django.contrib.auth.decorators import login_required | |
import json as simplejson | |
from django.template import RequestContext | |
from django.contrib.auth.models import User | |
from django.http import HttpResponseRedirect, HttpResponseBadRequest, HttpResponse | |
from django.shortcuts import render_to_response, get_object_or_404, redirect, render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_record" | |
ActiveRecord::Base.establish_connection('postgres:///testing') | |
ActiveRecord::Migration.verbose = false | |
ActiveRecord::Migration.class_eval do | |
create_table :played_quizzes, force: true do |t| | |
t.integer :player_ids, array: true | |
t.json :quiz_snapshot | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""How to validate Okta Access Tokens Locally with Python""" | |
import jwt | |
from jwt.algorithms import RSAAlgorithm | |
# Key pulled from https://{example}.oktapreview.com/oauth2/{client-id}/v1/keys | |
key_json = '{"kty":"RSA","alg":"RS256","kid":"your-kid-value-here","use":"sig","e":"AQAB","n":"your-long-key-here"}' | |
aud = "your-audience-value-here" | |
token_to_validate = "your-access-token-value-here" |