Skip to content

Instantly share code, notes, and snippets.

View ahx's full-sized avatar

Andreas Haller ahx

View GitHub Profile
@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
@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 / 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

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 / 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 / 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
@ahx
ahx / app.rb
Created January 5, 2009 07:08
An example for an OpenID consumer using Sinatra
# An example for an OpenID consumer using Sinatra
require 'rubygems'
require 'sinatra'
gem 'ruby-openid', '>=2.1.2'
require 'openid'
require 'openid/store/filesystem'
helpers do
def openid_consumer
// 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 / 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