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
defmacro def_identity_matcher(name, map) do
quote do
def unquote(name)(unquote(map)), do: unquote(map)
end
end
@boxxxie
boxxxie / hacky sync version.js
Last active July 26, 2016 01:35
reading in a list of files in nodejs
var fs = require('fs');
function readFiles(dirname, onFileContent, onError) {
fs.readdir(dirname, function(err, filenames) {
if (err) {
onError(err);
return;
}
filenames.forEach(function(filename) {
fs.readFile(dirname + filename, 'utf-8', function(err, content) {
@boxxxie
boxxxie / basic todo list.elm
Last active June 28, 2016 02:19
this isn't the most basic. as it is showing how to use commands in the update function, and thus can't be used with HTML.beginnerProgram. this is an extension from the egghead todo list tutorial
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App as Html
import Html.Events exposing (onInput, onClick)
import String exposing (..)
import Random exposing (..)
main =
Html.program
{
@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
(def file-locations-from-shas
'[ :find ?location
:in $ [[?sha]]
:where
[?e :file/sha ?sha]
[?e :file/location ?location]])
(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",
(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
@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
@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 / 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) {