Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar
👶

Max Countryman maxcountryman

👶
View GitHub Profile
(ns simpleupload.app
(:require [clasp.clasp :refer [defroute wrap-routes]]
[clojure.data.codec.base64 :as b64]
[clojure.java.io :as io]
[clojure.string :refer [split]]
[ring.middleware.multipart-params :refer [wrap-multipart-params]]
[ring.util.response :refer [response]]))
(def KEY "foo")
(filter #(:macro %) (map #(meta (% (ns-publics *ns*))) (keys (ns-publics *ns*))))
@maxcountryman
maxcountryman / flask_login.py
Last active December 15, 2015 17:38
Cleanup.
# -*- coding: utf-8 -*-
'''
flask.ext.login
---------------
This module provides user session management for Flask. It lets you log
your users in and out in a database-independent manner.
:copyright: (c) 2011 by Matthew Frazier.
:license: MIT/X11, see LICENSE for more details.
@maxcountryman
maxcountryman / defroute.clj
Last active December 15, 2015 16:28
Some macro fun.
(defmacro defroute
[routename uri meths handler]
`(defn
~(with-meta routename (assoc (meta routename) :route-handler true))
[req#]
(let [req-meth# (:request-method req#)
bad-meth# (nil? (some #(= req-meth# %) ~meths))
any-meth# (= ~meths [:any])]
(if (and (route-matches ~uri req#) (and bad-meth# (not any-meth#)))
(method-not-allowed req-meth# (get-allowed ~meths))
@maxcountryman
maxcountryman / facebook-cli-py3.py
Created March 30, 2013 16:16
Updated rauth examples supporting Python 3.
from rauth import OAuth2Service
import re
import webbrowser
try:
read_input = raw_input
except NameError:
read_input = input
@maxcountryman
maxcountryman / facebook-cli-py3.py
Created March 30, 2013 15:21
Tweaks to get rauth's Facebook example working with Python 3.
from rauth import OAuth2Service
import re
import webbrowser
try:
read_input = raw_input
except NameError:
read_input = input
@maxcountryman
maxcountryman / twitter-timeline-cli-py3.py
Created March 30, 2013 15:14
Tweaks to get rauth's Twitter example running on Python 3.
from rauth import OAuth1Service
try:
read_input = raw_input
except NameError:
read_input = input
# Get a real consumer key & secret from https://dev.twitter.com/apps/new
twitter = OAuth1Service(
name='twitter',
@maxcountryman
maxcountryman / reddit.py
Created March 29, 2013 07:11
Reddit OAuth via Python with rauth.
from rauth import OAuth2Service
from hashlib import sha1
from random import random
import re
import json
import webbrowser
# Get a real client id and secret from:
import foo
foo.qux("test")
@maxcountryman
maxcountryman / bar.clj
Last active December 15, 2015 08:08
Assume these files live in a dir `testing`.
(ns testing.bar (:require [baz :refer :all]))
;; should expose the same function as foo, i.e. qux