Skip to content

Instantly share code, notes, and snippets.

@kevinrobinson
kevinrobinson / gist:5808736
Created June 18, 2013 19:58
Jasmine beforeEach functions get called for each nested example
describe "setup", =>
@val = 0
beforeEach => @val += 10
afterEach => @val -= 100
describe "when loaded", =>
it "a", => expect(this.val).toEqual 10
it "b", => expect(this.val).toEqual 10
it "c", => expect(this.val).toEqual 10
@kevinrobinson
kevinrobinson / circleci-frontend-walkthrough.md
Last active January 9, 2021 16:09
CircleCI frontend walkthrough

Hello!

This is a commentary and discussion from walking through what happens on startup in [https://github.com/circleci/frontend], looking at this SHA in December 2014: [https://github.com/circleci/frontend/commit/273558250040ce197e44e683d5528381f36c4eea].

The first part is a literal walkthrough, where I'm tracing my reading of how the code works. This is a way to check my understanding, since of course I don't have all of your context. And it's also a way to echo back to you how someone else might experience this code without that context. The second part is about asking questions, making suggestions, and exploring some paths for making it even more awesome. I also mixed in a few asides in the walkthrough part where I jump ahead a bit.

Doing this with colleagues has worked well for me as a way to do in-depth code reviews about more abstract design and architectural questions. The goal of the the first part is to clarify we're all looking at the same thing, which creates the space and shared understa

@kevinrobinson
kevinrobinson / wider.js
Created May 7, 2015 20:28
Wider GitHub pull request diffs
javascript:(function() { $('.container').css({ width: '90%', 'margin-right': 'none', 'margin-left': 'none' }); $('.repository-content').width('auto');$('.repository-sidebar').remove() })();
# This is based off https://docs.docker.com/compose/rails/
rails:
build: .
volumes:
- .:/mnt/somerville-teacher-tool
working_dir: /mnt/somerville-teacher-tool
environment:
DATABASE_URL: postgresql://postgres@postgres # overrides hostname and username
ports:
- "3000:3000"
...
# Create a folder, and only copy the Gemfile and Gemfile.lock
RUN mkdir /mnt/somerville-teacher-tool
COPY Gemfile /mnt/somerville-teacher-tool/Gemfile
COPY Gemfile.lock /mnt/somerville-teacher-tool/Gemfile.lock
# Now run bundle install. This step will only be invalidated
# if the Gemfile or Gemfile.lock changes.
RUN bundle install
FROM ruby:2.2
# see update.sh for why all "apt-get install"s have to stay as one long line
RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*
# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole
RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*
ENV RAILS_VERSION 4.2.5
// Sprockets style:
//= require jquery
//= require profile
//= require profile_interventions
//= require session_timeout_warning
// CommonJS style:
window.jQuery = window.$ = require('jquery');
require('./profile');
require('./profile_interventions');
FROM node:4.2.2
RUN npm install -g webpack
COPY package.json /mnt/webpack/
WORKDIR /mnt/webpack
RUN npm install
COPY . /mnt/webpack/
# Asset compilation works by having the webpack container continually build an artifact,
# and that artifact being mounted for Rails to serve statically.
webpack:
build: webpack/.
command: npm run watch
volumes:
- ./webpack/config:/mnt/webpack/config
- ./webpack/src:/mnt/webpack/src
- ./volumes/webpack_build:/mnt/build
# ...
# Before, Sprockets:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => false %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => false %>
# After, a plain artifact:
<script src="/webpack_build/dev/webpack_bundle.js"></script>