Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
@johnbintz
johnbintz / def-run.clj
Last active August 29, 2015 13:57
def.run for ClojureScript and AngularJS
(defmacro def.run [sym params & body]
(list '.run ;; .run(
(list '.module 'js/angular sym) ;; angular.module(sym)
(concat ['array] ;; Array.new(
(map str params) ;; "$rootScope", "$q"
[(concat ['fn params] body)] ;; , function($rootScope, $q) { code; }))
)
)
)
@johnbintz
johnbintz / Gruntfile.coffee
Last active August 29, 2015 13:57
Run lein cljsbuild auto with Grunt
module.exports = (grunt) ->
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
grunt.initConfig {
app:
dev: "app"
watch:
sass:
files: ['<%= app.dev %>/**/*.scss']
tasks: ['compass:dist']
@johnbintz
johnbintz / board.cljs
Created April 13, 2014 17:11
Board directive for Can't Catch Me, Olivia!
(def.directive cant_catch_me_olivia.board []
(obj :restrict "E"
:replace true
:templateUrl "partials/board.html"
:link (fn [scope element attrs]
(let [board (.find element ".board")
cells (atom [])
each-span (fn [code] (doseq [data @cells] (apply code data)))]
(doseq [y (range 0 5)]
(let [row (js/$ "<li class='row'><ol class='board-row'></ol></li>")
@johnbintz
johnbintz / clj-into-js.clj
Created April 18, 2014 00:22
clj->into->js
(defn- map-names [items]
(into {} (mapv (fn [item] {(item :name) item}) items))
)
(defn- reset-objects! [objects mapped-clj-objects]
(.forEach objects
(fn [object]
; the objects in these happen to be indexed by object.name
(let [clj-object (mapped-clj-objects (.-name object))]
(doseq [[k v] clj-object]
@johnbintz
johnbintz / join_kickstarter_exports.rb
Last active August 29, 2015 14:04
Join Kickstarter CSV files for shipping purposes
require 'csv'
fields_to_keep = [
"Backer Id", "Pledge Amount", "Shipping Name", "Shipping Address 1",
"Shipping Address 2", "Shipping City", "Shipping State", "Shipping Postal Code",
"Shipping Country Name"
]
sort_result_on = "Backer Id"
module R18n
class Translation
def iterate(s)
root = self
s.split('.').each { |key| root = root[key] }
root
end
end
end
#
# Get SCSS working in Sinatra
#
configure do
Tilt.register 'scss', Tilt::SassTemplate
set :sass, Compass.sass_options.merge({:syntax => :scss})
end
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
export PS1="\[\e[0;37m\][\[\e[0;31m\]\u\[\e[1;37m\]@\[\e[0;32m\]\h\[\e[0;37m\]] \[\e[1;37m\]\w\$(parse_git_branch) \$ \[\e[0;37m\]"
[[ "${TERM}" == "screen" ]] && echo -n -e '\ek'${HOSTNAME%%.*}'\e\'
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
# Install Local Terminal (Incubation) from the Helios Marketplace
# then set an Env variable for your shell for IS_ECLIPSE=yes
# and be sure to do /bin/bash -l, too
if [ "$IS_ECLIPSE" == "yes" ]; then
@johnbintz
johnbintz / webpack-watch.js
Created September 15, 2015 22:50
Webpack + Babel with React Native Android, using react-native-webpack-server's internals
// this is a hack until react-native-webpack-server gets updated (and I'm
// sure it will soon. :) )
//
// you'll need 0.4.0-rc or better of react-native-webpack-server
// don't run react-native-webpack-server's server for now, use react-native's
//
// also, run me in pure node and not babel-node, or react-native will try and
// load polyfills that are already loaded. :/
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');