Skip to content

Instantly share code, notes, and snippets.

View paulkoegel's full-sized avatar

Paul Kögel paulkoegel

View GitHub Profile
a {
color: #005A70;
}
.logo {
width: 200px;
height: 200px;
position: absolute;
top: 20px;
right: 50%;
margin-right: -100px;
@paulkoegel
paulkoegel / The Functional Final Frontier - (David Nolen.ClojureWest.2014-03).markdown
Last active July 6, 2017 06:11
The Functional Final Frontier - David Nolen at Clojure/West 2014

The Functional Final Frontier - David Nolen at Clojure/West 2014

(still incomplete, covers only the first 16 minutes)

Video

  • Functional programming and programming with values have proven their usefulness when building all kinds of systems, but they've been hard to apply when building user interfaces.

  • Object-oriented programming and user interfaces came up at around the same time and went hand in hand ever since. First user interfaces were, e.g., written in Smalltalk (created in 1972 by Alan Kay). This led to the development of the Model-View-Controller paradigm.

#wrapper {
position: relative;
margin: 0 auto;
width: 800px;
text-align: center;
}
#doge {
width: 500px;
height: 576px;
}
@paulkoegel
paulkoegel / ClojureScript - Lisp's Revenge (David Nolen.Goto conference).markdown
Last active August 29, 2015 13:57
ClojureScript - Lisp's Revenge (David Nolen.Goto conference)

LISP's Revenge - David Nolen (Goto Conference)

LISP

  • invented by John McCarthy in 1957 to solve the problem of artificial intelligence - simply because no existing programming language could meet his needs.
  • along the way, McCarthy invented interpreters, high-level meta programming, garbage collection, dynamic programming languages, functional programming, programming with recursive functions.
  • simplicity-to-expressive-power-ratio is VERY nice. Not the only language that has this, though.a

The languages we have today are not good tools for the task. We mainly build distributed systems on the web and nearly everything interesting we do is asynchronous - and with that also very likely concurrent.

@paulkoegel
paulkoegel / closures_illustrated.html
Last active August 29, 2015 13:56
JavaScript closures illustrated
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src='javascript.js'></script>
<link href="style.css" media="all" rel="stylesheet" type="text/css">
</head>
<body>
<h1>
JavaScript Closures Illustrated
</h1>
(deftest test-two
(is (= 2 2 ads)))
@paulkoegel
paulkoegel / strong_parameter_matcher.rb
Created September 12, 2013 16:01 — forked from DonSchado/example_spec.rb
Thoughtbot retracted their initial implementation of strong parameters matchers in v2.0.0 of shoulda-matchers, so we decided to build our own until new officail ones are released. The following is a small matcher for testing what params should be permitted in controllers. The matcher's syntax is based on validation matchers. If you're not follow…
# usage:
#
# it { should permit_params(:email, :name) }
# it { should permit_params(:email, :name).for_class(SpecialUser) }
# it { should permit_params(:name).params_method(:my_params_method) }
module StrongParameterMatcher
class PermitMatcher
attr_reader :permitted_params, :errors_protected, :errors_permitted
module Slug
def generate_slug
temp_slug = SecureRandom.hex 8
# ensure slug is unique
while self.class.where(slug: temp_slug).count > 0
temp_slug = SecureRandom.hex 8
end
self.slug = temp_slug
end
@paulkoegel
paulkoegel / window_innerHeight_ios.coffee
Last active January 29, 2016 18:47
Workaround to get the real window.innerHeight on Safari and Chrome on iOS with auto-hiding address bars
# window.innerHeight with auto-hiding address bar
# When calling `window.innerHeight` on DOM.ready in Safari or Chrome
# on iOS (in 2013-05 at elast ;) you'll get the height of the available
# screen area between the address bar - which is displayed on page load and
# then automatically hidden once you start scrolling - and the toolbar.
# On my iPhone simulator it's 356px with the address bar and 416px without.
# To get the window's real height, we first need to trigger a scroll event,
# which will auto-hide the address bar, and then chain all further calculations
# of window.innerHeight inside a timeout. Ironically, when loading the page,
@paulkoegel
paulkoegel / mixed_layout.md
Last active December 11, 2015 19:28
Extended MarionetteLayout to which you can pass an array of region names and View instances (via .addViews()); automatically creates the required region DOM containers. SEE BELOW FOR CODE.

MixedLayout

MixedLayouts are our custom extension of MarionetteLayouts which we use to wrap a heterogeneous collection of Backbone Views. This allows us to change the contents of complex pages all at once while preventing zombie views and leaving certain static elements like Navigation, Toolbar, or FooterViews on the page.

Rationale and Raison d'être

Marionette's Composite and CollectionViews are limited to rendering all their associated collection's items with the same ItemView. For our homepage, e.g., we need to encapsulate various Views - TopView, CategoryView, QuoteOfTheDayView etc. - in dynamic order into one Marionette View construct that can be .closed() to prevent zombie views. The Marionette view component designed to encapsulate heterogeneous subviews is the Layout. However, we cannot use a vanilla MarionetteLayout for the homepage because a Layout relies