Skip to content

Instantly share code, notes, and snippets.

@clyfe
clyfe / simple_form.rb
Created August 22, 2013 08:20
Bootstrap3 compatible simple_form initializer
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
@clyfe
clyfe / optimized_pdfkit.rb
Created November 1, 2011 11:06
An optimized version of pdfkit, with a slightly more involved interface
# Usage
#
# OptimizedPDFKit.new(html_tempfile).to_pdf(pdf_tempfile_path)
#
class OptimizedPDFKit < PDFKit
def initialize(url_file_or_html, options = {})
@source = Source.new(url_file_or_html)
@stylesheets = []
@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 / 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 / overrides.css.scss
Created March 5, 2012 23:37
AS and TB play nice
/* use with AS 3.2 */
.active-scaffold-header div.actions {
top: 0;
}
.active-scaffold {
input[type="submit"], input[type="reset"], button {
@extend .btn;
@extend .btn-primary;
@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'
@clyfe
clyfe / navigasmic.rb
Last active December 12, 2015 04:28
Navigasmic 0.5.6 monkeypatch initializer to allow block syntax and TB compatibility
Navigasmic.setup do |config|
config.highlighted_class = 'active'
config.with_group_class = 'dropdown-menu'
end
module Navigasmic
# lazy monkey patch, makes it work with twitter bootstrap
class HtmlNavigationBuilder
def item(label = '', options = {}, &proc)
@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: