Skip to content

Instantly share code, notes, and snippets.

@stroxler
stroxler / resources.org
Last active January 24, 2022 21:50
The Most Discoverable Python Typing Tutorials, Etc (circa 2022/01)

This gist is a collection of all the easy-to-find online resources for using typed python as of 2022/01. I collected these notes for two reasons:

  • As an aside in an extensive python-dev typing discussion, Guido mentioned that it would be helpful
  • There’s an active but very slow-moving effort to write official python type system docs in python/typing, and I figured having an easy to skim list of the best existing discussions would be handy.

The official documentation

from rest_framework import viewsets
from rest_framework.response import Response
# https://gist.github.com/ivlevdenis/a0c8f5b472b6b8550bbb016c6a30e0be
class ExtendViewSet(object):
"""
This viewset mixin class with extended options list.
"""
@cmcginty
cmcginty / keypass-setup-and-sync.md
Last active April 26, 2024 17:59
KeePass2 Password Manager Settings and Auto-Synchronization

KeePass2 Setup and Auto-Synchronization Guide

KeePass is a password management utility for Windows, Linux, and Mac.

The first section describes the steps needed to setup KeyPass2 in Linux and how to add FireFox and Chrome plugin integrations.

The (optional) second section documents a robust way to automatically synchronize the password DB across multiple devices.

@stormchasing
stormchasing / Auto Check-In to Southwest Flights.user.js
Last active April 17, 2024 00:04
Auto Check-In to Southwest Flights.user.js
// ==UserScript==
// @name Auto Check-In to Southwest Flights
// @namespace http://www.ryanizzo.com/southwest-auto-check-in/
// @version 1.8
// @author Nicholas Buroojy (http://userscripts.org/users/83813)
// @contributor Ryan Izzo (http://www.ryanizzo.com)
// @contributor JR Hehnly (http://www.okstorms.com @stormchasing)
// @contributor Trevor McClellan (github.com/trevormcclellan)
// @description Automatically check in to Southwest Airline flights at the appropriate time.
// @include https://www.southwest.com/air/check-in/index.html*
@SpotlightKid
SpotlightKid / aescrypt.py
Created September 3, 2014 18:29
Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
Usage:
File Encryption:
aescrypt.py [-f] infile [outfile]
@mziwisky
mziwisky / Oauth2.md
Last active February 15, 2024 23:31
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.

@revskill10
revskill10 / lopmonhoc.js.jsx
Created January 22, 2014 09:25
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
@keturn
keturn / trackwindow.py
Created September 25, 2013 05:56
Log Windows focus changes.
"""Log window focus and appearance.
Written to try to debug some window popping up and stealing focus from my
Spelunky game for a split second.
Developed with 32-bit python on Windows 7. Might work in other environments,
but some of these APIs might not exist before Vista.
Much credit to Eric Blade for this:
https://mail.python.org/pipermail/python-win32/2009-July/009381.html
@ibarovic
ibarovic / forms.py
Created July 11, 2012 20:00
django crispy forms and django inline forms example (inlineformset_factory)
class AuthorForm(ModelForm):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field('name'),
)
super(AuthorForm, self).__init__(*args, **kwargs)
class Meta:
model = Author