This file contains hidden or 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 '[clojure.string :as str]) | |
| (use '[ring.util.response :only [redirect]]) | |
| (defn remove-utm-params) | |
| [query-string] | |
| (->> (.split query-string "&") | |
| (filter (fn [^String p] (.startsWith p "utm_"))) | |
| (str/join "&"))) | |
| (defn utm-redirect |
This file contains hidden or 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
| ;; original function | |
| (defn assoc-meta [metable & kvs] | |
| (with-meta metable (apply assoc (meta metable) kvs))) | |
| ;; rewritten with an explicit conjugation | |
| (defn conjugate [translate untranslate f] | |
| (comp untranslate f translate)) |
This file contains hidden or 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
| """A very simple, and minimal, multimethod implement in python inspired by clojure's multimethods | |
| No support for default arguments, or hierarchies, and it relies on pythons default equality tests. | |
| """ | |
| class Multimethod(object): | |
| def __init__(self, dispatch_fn): | |
| self.dispatch_fn = dispatch_fn | |
| self.handlers = {} | |
This file contains hidden or 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
| // parser | |
| var _parser_global_state = null; | |
| function ParseFailed () {}; | |
| function run_parser(p, input_list) { | |
| input_list = input_list.slice() | |
| try { | |
| var old_parser_input = _parser_global_state; | |
This file contains hidden or 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
| // the first hack needed to support mutable refs in Roy is allowing in place edits | |
| // to JS arrays | |
| let aSet (arr:[#a]) (idx:Number) (v:#a) :[#a] = | |
| Array.prototype.splice.call arr idx 1 v | |
| arr | |
| // wrapper type is currently a structural type rather than an ADT because I couldn't | |
| // get ADTs to have an Array as a field | |
| type Ref = {_val: [#a]} |
This file contains hidden or 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
| function on_drag(el, handler) { | |
| var el = $(el); | |
| el.on("mousedown", function (e) { | |
| var initial_x = e.clientY; | |
| var initial_y = e.clientY; | |
| function drag_handler(e) { | |
| var delta_x = e.clientX - initial_x; | |
| var delta_y = e.clientY - initial_y; |
This file contains hidden or 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 django.db import models | |
| class LambdaManager(models.Manager): | |
| """LambdaManager is a simple manager extension that is instantiated with a callable. | |
| This callable is passed the query set by get_query_set so that it can perform any | |
| additional transformations to it such as eg filtering. | |
| """ | |
| def __init__(self, f): |
This file contains hidden or 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 sorl.thumbnail import get_thumbnail | |
| def make_thumbnail_method(get_fn=lambda o:o.image, | |
| dimensions="100x60", | |
| crop="center"): | |
| """A function factory for producing admin_thumbnail methods. | |
| """ | |
| def admin_thumbnail(self): | |
| image = get_fn(self) |
This file contains hidden or 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
| """This is an alternate typescript handler from future webassets as there | |
| is a bug in the 0.8 version with recent tsc | |
| """ | |
| import os | |
| import subprocess | |
| import tempfile | |
| from io import open # Give 2 and 3 use same newline behaviour. | |
| from webassets.filter import Filter, register_filter |
This file contains hidden or 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 '[clojure.string :as str]) | |
| (->> (map (comp rand-nth | |
| (group-by first (seq (.split (slurp "/usr/share/dict/words") "\n"))) | |
| char) | |
| [121 111 108 111]) | |
| (str/join " ") | |
| print) |