Skip to content

Instantly share code, notes, and snippets.

Josh Freckleton freckletonj

Block or report user

Report or block freckletonj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@freckletonj
freckletonj / ConstrainedVinylRecords.hs
Last active Aug 7, 2017
Attempting to get values out of constrained Vinyl/Composite Extensible Records
View ConstrainedVinylRecords.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module ConstrainedVinylRecords where
@freckletonj
freckletonj / oauth.hs
Created Apr 27, 2017
Haskell Servant OAuth2.0 for GitHub
View oauth.hs
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
module Sand where
import Data.Aeson
@freckletonj
freckletonj / mytime.py
Created Oct 8, 2016
MyTime - Records a Log of My Active Window And Mouse Coordinates
View mytime.py
"""
The MIT License (MIT)
Copyright (c) 2016 Josh Freckleton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WIT
@freckletonj
freckletonj / logic 01.clj
Last active Apr 8, 2016
Clojure core.logic puzzle #01
View logic 01.clj
(run* [q]
(fresh [al finn irv jim
p1 p2 p3 p4
y1 y2 y3 y4]
;; rule #1 ---------
;; Of the item that sold for $175 and the one that sold for $225,
;; one featured Irv Ingram and the other came out in 1983.
(conde
((== irv [:175 (lvar)])
(membero [:225 :1983] [al finn jim]))
@freckletonj
freckletonj / spiralizer.clj
Created Mar 31, 2016
Convert a sequence into spiral matrix
View spiralizer.clj
(defn rotate
"rotate a 2D matrix 90 degrees, it's ok if it's not a perfect square"
[mat]
(loop [remaining (map reverse mat)
result []]
(if (every? empty? remaining)
result
(recur (map rest remaining)
(conj result (remove nil? (mapv first remaining)))))))
@freckletonj
freckletonj / cljsfiddle_save.edn
Last active Mar 29, 2016 — forked from anonymous/cljsfiddle_save.edn
how to have an input with (essentially) two way binding
View cljsfiddle_save.edn
(def search-term (atom ""))
(defn input [model on-change]
(let [external-model (atom @model)
internal-model (atom (or @external-model ""))]
(fn [model on-change]
;; this is taken from recom - http://bit.ly/1SZ1OXn
(when (not= @external-model @model)
(.log js/console "changed to " @model)
(reset! external-model @model)
@freckletonj
freckletonj / notifications.cljs
Created Mar 25, 2016
ClojureScript Notifications
View notifications.cljs
;; this is very much a gist, and it can be tweaked
;; ;; NOTIFICATIONS ----------
;; if (typeof Notification !== 'undefined') {
;; alert('Please us a modern version of Chrome, Firefox, Opera or Safari.');
;; return;
;; }
;; Notification.requestPermission(function (permission) {
;; if (permission !== 'granted') return;
You can’t perform that action at this time.