Skip to content

Instantly share code, notes, and snippets.

View mjw's full-sized avatar

Marcus Williams mjw

  • bar-coded
  • Cambridge, UK
View GitHub Profile
@mjw
mjw / mural_oauth_example.py
Last active February 27, 2024 19:30
Authentication for Mural API in python (demonstrates Mural OAuth issue with refresh_token)
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import TokenExpiredError
from http.server import HTTPServer, BaseHTTPRequestHandler
import time
import http
from requests_toolbelt.utils import dump
def log_response(response, *args, **kwargs):
data = dump.dump_all(response)
print(data.decode('utf-8'))
@mjw
mjw / bashrc
Created November 21, 2011 13:55
Clipboard manipulation in bash
# A shortcut function that simplifies usage of xclip.
# - Accepts input from either stdin (pipe), or params.
# - If the input is a filename that exists, then it
# uses the contents of that file.
# ------------------------------------------------
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
@mjw
mjw / 20.pod
Created June 20, 2011 13:29 — forked from SpiceMan/20.pod
Leak checking in Catalyst

Checking for leaks in MyApp.

Wait a minute. Catalyst leaks? No, but our application might be leaking.

The single most common leak cause in Catalyst, which we'll cover later, is stashing a closure which needs to use the Catalyst context (usually $ctx or $c). But that's hardly the only cause.

The Real Culprit(TM): circular references

@mjw
mjw / maintenance-mode.htaccess
Created March 26, 2010 10:04
Easy maintenance mode switch for Apache
# From: http://neutroncreations.com/blog/a-simple-technique-for-web-app-maintenance-modes-using-apache/
#
# To use: touch maintenance.txt to go into maintenance mode
# go to SUPER_SECRET_URL to set cookie to allow dev work access
#
# Part I
RewriteCond APP_ROOT/maintenance.txt -f
RewriteRule SUPER_SECRET_URL / [R,L,CO=AllowMaintenance:1:YOUR-DOMAIN.COM]