Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
@ahx
ahx / cursor-pagination.md
Last active November 17, 2022 21:13
Example implementation of cursor-based pagination

Example implementation of cursor-based pagination

This shows how one can paginate throug a list of tenants with id and name using two different sortings. The limit is always 2.

Data used

Table: tenants

id name
1 a
@ahx
ahx / results.md
Last active March 4, 2024 15:56
openapi_first benchmark comparison

These are the results running these benchmarks (code).

openapi_first 1.3.2

ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]
Warming up --------------------------------------
 ./apps/committee.ru     1.000 i/100ms
./apps/committee_with_response_validation.ru
                         1.000 i/100ms
./apps/no-validation.ru
@ahx
ahx / openapi_first-committee-comparison.md
Last active March 13, 2024 12:10
Comparing openapi_first and committee

This is a feature comparison of openapi_first and committee

I will try to keep this updated. Please create an issue if you see something wrong/missing here.

JSON Schema validation

Most of these differences are because openapi_first uses json_schemer, which has build in support for OpenAPI 3.1 where committee/openapi_parser currently ships it's own implementation.

Feature openapi_first committee

Keybase proof

I hereby claim:

  • I am ahx on github.
  • I am ahx (https://keybase.io/ahx) on keybase.
  • I have a public key ASBSrbMPKIOib3rD_NwUTx_Q2NdBDg6VrachPzYVumBF9go

To claim this, I am signing this object:

JSON:API

Your anti bikeshedding weapon.

By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus on what matters: your application.

jsonapi.org


{
@ahx
ahx / object.js
Created April 23, 2015 06:07
How to make Ember never auto-generate ObjectControllers (deprecated), but normal Controllers
// Add this file: app/controllers/object.js – Done.
// Ember.ObjectController will be removed in Ember 2.0 and auto-generated ObjectControllers
// cause deprecation warning since Ember 1.11.
// This file is here so ember does not generate ObjectControllers anymore.
// See https://github.com/emberjs/ember.js/blob/06e41ad7ccd28558dd4e651aa070bc06f7757821/packages/ember-routing/lib/system/generate_controller.js#L11-L26
import Ember from 'ember';
export default Ember.Controller;
// adapters/application.js
var ApplicationAdapter = DS.Adapter.extend({
init: function() {
this.hoodie = window.hoodie; // FIXME?
this._super();
},
find: function(store, type, id) {
return this.hoodie.store.find(type.typeKey, id);
@ahx
ahx / hoodie_adapter.js
Last active March 15, 2018 19:52
A ember-model adapter for hoodie.js. Hoodie: http://hood.ie ember-model: https://github.com/ebryn/ember-model
// Usage:
// HoodieAdapter.create({type: "mystuff", url: "some/url"})
// "type" is required. "url" is optional.
var hoodie,
get = Ember.get,
Promise = Ember.RSVP.Promise;
function mustImplement(message) {
var fn = function() {
@ahx
ahx / validate_session_cookie.rb
Last active December 17, 2015 19:09
Use an additional secure cookie to validate the session across HTTP/HTTPS This technique is described here: http://railscasts.com/episodes/356-dangers-of-session-hijacking?view=asciicast
@ahx
ahx / application.html.haml
Created January 31, 2013 18:35
How to add conditional classes to your html tag using HAML. This adds a ie8/i9 class when using IE and nothing when using real browsers. The whole backstory: http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ Yes, i will try Slim next time.
!!!
/[if IE 8] <html class="ie-lt10 ie8" lang="de">
/[if IE 9] <html class="lt-lt10 ie9" lang="de">
:plain
<!--[if gt IE 9]><!--><html lang="de"><!--<![endif]-->
%head
%body
:plain