Skip to content

Instantly share code, notes, and snippets.

View boxxxie's full-sized avatar
👙
disrupting absurdism

Paul Iannazzo boxxxie

👙
disrupting absurdism
View GitHub Profile
@boxxxie
boxxxie / imageinput.js
Created March 26, 2014 16:30
image input directive
.directive('inputImage', function() {
'use strict'
return {
template: "<input type='file' accept='image/*'>",
restrict: 'E',
require: "ngModel",
link: function (scope, element, attrs, ngModel) {
element.bind('change', function (evt) {
@boxxxie
boxxxie / autoupdate.js
Last active August 29, 2015 13:57
auto-update directive that uses restangular
.directive("autoUpdate", function(debounce_timeout){
return {
require: "ngModel",
link: function(scope, element, attrs, ngModel){
var model_path_array = attrs.ngModel.split(".");
var field_name = _.last(model_path_array);
var model_name = _.chain(model_path_array).last(2).first().value();
function save_model_to_backend(){
@boxxxie
boxxxie / keys.clj
Created December 3, 2014 19:22
key binding file
;; User keymap
;; -----------------------------
;; Keymaps are stored as a set of diffs that are merged together to create
;; the final set of keys. You can modify these diffs to either add or
;; subtract bindings.
;;
;; Like behaviors, keys are bound by tag. When objects with those tags are active
;; the key bindings are live. Keys can be bound to any number of Light Table commands,
;; allowing you the flexibility to execute multiple operations together. To see a list
;; of all the commands you can execute, start typing a word related to the thing you
(ns chestnut-test2.core
(:require
[cljs.core.async :as async :refer [chan close! <! >! put! timeout alts! to-chan]])
(:require-macros
[cljs.core.async.macros :refer [go go-loop]]))
(def c (to-chan [1 2 3 4])) ;;works
(go (print (<! c))) ;;works
(defn versions-to-fetch [local remote]
(let [versions-missing (second (diff local remote))]
(->> versions-missing
(map #(with-meta (select-keys % [:sha]) %))
set
(map meta)
set)))
(def data
#{{:date "2014-12-08T18:44:53.846-00:00", :id 1, :location "apps/version1.js",
(def file-locations-from-shas
'[ :find ?location
:in $ [[?sha]]
:where
[?e :file/sha ?sha]
[?e :file/location ?location]])
@boxxxie
boxxxie / pre-push
Created April 17, 2015 14:40
jshint git hook
#!/bin/bash
echo running pre-push hook for jshint
# Make a temp directory for writing the .jshintrc file
TMP_DIR=`mktemp -d`
EXIT_CODE=0
# Run JSHint on the file and redirect the output back to Git
jshint `git root` >&2
(helper-macro menubuttons :Field :Type :Collation :Attributes :Null :Default :Extra :Action)
;produces
(defstruct menubuttons-fields :Field :Type :Collation :Attributes :Null :Default :Extra :Action )
(def *menubuttons-csv-file* "data/menubuttons.csv")
(defn fetch-menubuttons-data [] (load-data-from-csv *menubuttons-csv-file* inventory-fields))
(defn contains-transaction? [transactions transaction] (contains? transactions (:TransactionID transaction)))
(defmulti conj-transaction contains-transaction?)
(defmethod conj-transaction true [transactions transaction]
(let[id (:TransactionID transaction)
transaction-list (get transactions id)]
(assoc transactions id (conj transaction-list transaction))))
(defmethod conj-transaction false [transactions transaction]
(let [id (:TransactionID transaction)]
(defn contains-transaction? [transactions transaction] (contains? transactions (:TransactionID transaction)))
(defmulti conj-transaction contains-transaction?)
(defmethod conj-transaction true [transactions transaction]
(let[id (:TransactionID transaction)
transaction-list (get transactions id)]
(assoc transactions id (conj transaction-list transaction))))
(defmethod conj-transaction false [transactions transaction]
(let [id (:TransactionID transaction)]