class Tally | |
def self.empty | |
new({}) | |
end | |
def initialize(raw) | |
@raw = empty_hash.merge raw.slice(:small, :medium, :large) | |
end | |
# Accessors |
This document is an attempt to pin down all the things you don't think about when quoting for a project, and hopefully provide a starting point for some kind of framework to make quoting, working and delivering small-medium jobs more predictable and less stressful.
# frozen_string_literal: true | |
class AssociationLoader < GraphQL::Batch::Loader | |
attr_reader :klass, :association | |
def initialize(klass, association) | |
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol) | |
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base | |
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association) | |
@klass = klass |
2015-01-29 Unofficial Relay FAQ
Compilation of questions and answers about Relay from React.js Conf.
Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.
Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).
I'm sad that the world has adopted English as the language of science and business. English is a mutt language that has never been redone, reworked or even designed. It's a combination of ice cream, meatballs and wine. All fine things by themselves but terrible when combined.
There are more English learners than there are native English speakers in the world. I'm really sorry world. I'm just so so sorry that you have to learn Germanic-French-Latin nonsense. It's terrible. It's a terrible language.
Update: I wrote this before I read Mother Tongue by Bill Bryson. It's fantastic and a better write-up of what I'm trying to say here.
. | |
├── actions | |
├── stores | |
├── views | |
│ ├── Anonymous | |
│ │ ├── __tests__ | |
│ │ ├── views | |
│ │ │ ├── Home | |
│ │ │ │ ├── __tests__ | |
│ │ │ │ └── Handler.js |
#this is a very simple, work in progress helper method for stubbing the stripe checkout.js | |
#this creates a fake server that will generate stripe token as if it's coming from stripe. So we can test credit card input | |
class FakeStripe < Sinatra::Base | |
def self.boot | |
instance = new | |
Capybara::Server.new(instance).tap { |server| server.boot } | |
end | |
get '/checkout.js' do |
A few notes on how I organize my code lately. It's not the sexiest topic in the world but it matters, especially given that I keep about 160 repos cloned on my system at any given time.
I've spent a couple years now trying to avoid the urge to mirror my personal code working space after github repo pathnames, but I'm a weak man and have given in.
When I want to clone a repo, I'll give it a directory matching the pattern ~/code/<owner>/<repo>
.
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.