Skip to content

Instantly share code, notes, and snippets.

View lukemorton's full-sized avatar

Luke Morton lukemorton

View GitHub Profile
@lukemorton
lukemorton / productPageSpec.js
Last active April 5, 2016 13:38
Feature testing in node.js
feature('Product detail page', function () {
scenario('User viewing page', function (done) {
whenUserViewsAProduct(
thenTheyShouldSeeCommonProductProperties(done)
);
});
function whenUserViewsAProduct(then) {
var productPath = '/Hurley-Hoodies-Hurley-Mataro-Hoody-Mahogany/Product/223996';
makeRequest(testRequest(app).get(productPath), then);
import { actions } from 'tarnish';
function handleResponse(form) {
return function ({ token, errors }) {
if (errors) {
return actions.form.validationErrors(form, errors);
} else {
return actions.state.merge({ page: 'home#Index', token });
}
};
feature 'Thing' do
scenario 'Creating a thing' do
when_creating_thing
then_should_see_thing_created
end
scenario 'Updating a thing' do
when_updating_thing
then_should_see_thing_updated
end
{
"env": {
"es6": true,
"browser": true,
"node": true
},
"rules": {
"curly": 0,
"comma-dangle": [2, "always-multiline"],
"comma-spacing": 0,
@lukemorton
lukemorton / clock.cljs
Created November 27, 2015 15:11
Comparison of JSX and CLJS
(q/defcomponent Clock
:name "Clock"
:on-update #(set-doc-title-as-time %2)
[time]
(let [[hours minutes seconds] time]
(dom/div {:className "clock"}
(dom/span {:className "clock__hour"} hours)
(dom/span {:className "clock__minute"} ":" minutes)
(dom/span {:className "clock__second"} ":" seconds))))
@lukemorton
lukemorton / ex1a.js
Last active November 1, 2015 17:55
Reasons why I prefer ruby and clojure to js
className () {
let className = 'purchase_orders_table';
if (this.state.sticky) className += '--sticky';
return className;
}
(q/defcomponent Article
(dom/article {:class-name :article}
(dom/header
(dom/h1 {} title)
(dom/section {:class-name :byline}
(dom/span {:class-name :date}
published-at))
(dom/section body))))
@lukemorton
lukemorton / 01_schema.rb
Last active October 21, 2015 08:35
falcor like stuff for ruby
# Designing a data structure spec
module Schema
Product = Typed::Hash[name: String,
url: String,
properties: Typed::Array[Property]]
Property = Typed::Hash[name: String, value: Typed::Any]
ProductList = Typed::Array[Product]
class Person < TypedStruct[first_name: String, last_name: String]
def full_name
"#{first_name} #{last_name}"
end
end
class Person < TypedStruct[first_name: String,
last_name: String,
age: [Integer, :optional]]
def full_name
@lukemorton
lukemorton / boot.rb
Created October 2, 2015 08:53
For rails 4.2 projects served from inside vagrant
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
# Override default IP binding so that we can work inside vagrant!!
#
require 'rails/commands/server'
module Rails
class Server