Skip to content

Instantly share code, notes, and snippets.

@clyfe
clyfe / user.cljs
Created January 9, 2020 11:42
ClojureScript Integrant REPL
(ns cljs.user
(:require-macros [x.macros :as m])
(:require [integrant.core :as ig]))
(enable-console-print!)
(def config (m/read-config "config.edn"))
(def system nil)
(defn- halt-system [system]
@clyfe
clyfe / modulant.core.cljc
Created December 15, 2019 19:13
Module system extracted from Duct Core, in cljc source.
(ns modulant.core
"Make a system out of a system: `(md/exec modules-map) ;; => system-map`."
(:require
[clojure.walk :as walk]
[integrant.core :as ig]
[modulant.merge :as merge]))
;;; Logic
(defn- fold
@clyfe
clyfe / middleware.clj
Last active October 13, 2015 12:08
Allow arrays as nested values
;; Portions of this file are taken from the clj-http project.
;; https://github.com/dakrone/clj-http
;; They are licenced under MIT License.
(ns client.middleware
"clj-http 3.0.0 master is a bit in limbo, rather than fork it, or wait for the maintainer,
this namespace tries to make up for some of it's shorcomings.
See:
@clyfe
clyfe / ik-submenu.html
Last active August 29, 2015 14:14
Prevent submenu collapse in polymer's core-submenu
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/core-menu/core-submenu.html">
<!--
Similar to core-submenu, can be set to stay always open.
When selected, also selects it's first child.
<ik-submenu icon="settings" label="Topics" alwaysOpened>
<core-item label="Topic1"></core-item>
<core-item label="Topic2"></core-item>
@clyfe
clyfe / designer.html
Last active August 29, 2015 14:12
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-tooltip/core-tooltip.html">
<polymer-element name="my-element" fit="">
<template>
<style>
@clyfe
clyfe / gist:05a89c6ae297f4f620ce
Created November 14, 2014 16:55
polymer smooth scroll
<core-animation id="animation" duration="300" easing="ease-in-out" fill="forwards"></core-animation>
...
var start = scroller.scrollTop;
var end = section.offsetTop;
var delta = end - start;
this.$.animation.target = scroller;
this.$.animation.customEffect = function (timeFraction, target, animation) {
@clyfe
clyfe / model.rb
Created September 23, 2014 19:04
Wizard
# step : Integer
class Model < ActiveRecord::Base
with_options if: "step < 1" do |assoc|
validates :foo, presence: true
end
with_options if: "step < 2" do |assoc|
validates :bar, presence: true
end
# ...
end
@clyfe
clyfe / view.coffee
Last active August 29, 2015 14:06
Just the view, Backbone and Marionette extraction
# Minimal view thingie to make code a bit more manageable.
# Usage example:
#
# class MyView extends View
# ui:
# button: '.my-button'
# events:
# 'click @ui.button': 'doAction'
# constructor: ->
# super
@clyfe
clyfe / file.rb
Last active December 24, 2015 01:59
View context
class Template < ActionView::Base
include ApplicationHelper
def initialize; super(ActionController::Base.view_paths) end
end
tmpl = Template.new()
tmpl.render(template: "foos/foo", layout: 'layouts/bar')
@clyfe
clyfe / Vagrantfile
Last active December 22, 2015 04:18
Simple Vagrat for Rails stuff on Ubuntu - simple shell based provisioning - uses ruby-2.0.0-p247 via rbenv - uses mysql (tweak it for posgresql yourself)
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'script/provision.sh'