Skip to content

Instantly share code, notes, and snippets.

View tamlyn's full-sized avatar

Tamlyn Rhodes tamlyn

View GitHub Profile
@tamlyn
tamlyn / README.md
Last active January 24, 2024 16:44
The case against ORMs

The case against ORMs

My experience of ORMs goes mostly as follows:

  • you have to write your queries in the proprietary DSL but that's OK because there's lots of documentation you can read to learn how to do the things that you already know how to do in SQL
  • inevitably some queries are not possible in the DSL but that's OK because you can also run raw SQL queries through the ORM
  • when running raw SQL queries you lose type safety and the 'mapper' part of the ORM is no longer automatic but that's OK because there's an API to let you specify the types and the mapping yourself
  • lazily loading associated entities is too slow but that's OK because you can specify up front which related objects should be fetched from the database
  • when dealing with large amounts of data all the instantiated classes take up too much memory and kill performance but it's OK because you can specify that you want data-only objects (without methods)

How the Apollo Client cache works

Queries

A query is only served from cache if the same query path, with the same variables, was previously requested.

For example if you fetch all Fund objects:

openapi: 3.0.0
info:
title: Test case
version: "1"
paths:
/users:
get:
responses:
"200":
@tamlyn
tamlyn / Readme.md
Created May 20, 2020 09:33
Camunda

Issues with Camunda

It fails to deliver on its promise

The idea is nice:

  • You separate the business rules from the code.
  • You use a graphical language that non-developers can understand.
  • The developers then write adapters for the business process diagram to enact the business rules.
  • Non-developers can both see and edit the business flow at any time in response to changing business needs.
function removeOrigin(dom) {
let origin = window.location.origin;
let $internalElements = dom.querySelectorAll(`[href^="${origin}"],[src^="${origin}"]`);
for (let $el of $internalElements) {
const attr = $el.hasAttribute('href') ? 'href' : 'src';
const value = $el.getAttribute(attr);
$el.setAttribute(attr, value.replace(origin, ''));
}
return dom
@tamlyn
tamlyn / cartpole.ipynb
Last active December 22, 2020 08:54
OpenAI Gym CartPole-v1 with Pytorch 1.0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamlyn
tamlyn / Barknet.ipynb
Created November 23, 2018 21:02
Error when training
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
'use strict';
var fact = function () {
var _ref = _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var response, data;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
'use strict';
let fact = (() => {
var _ref = _asyncToGenerator(function* () {
const response = yield fetch('https://catfact.ninja/fact');
const data = yield response.json();
return data.fact;
});
return function fact() {
async function fact() {
const response = await fetch('https://catfact.ninja/fact')
const data = await response.json()
return data.fact
}