Skip to content

Instantly share code, notes, and snippets.

View mbj's full-sized avatar

Markus Schirp mbj

View GitHub Profile
@mbj
mbj / literal.rb
Created March 26, 2021 02:09
json to ruby literal
require 'json'
require 'unparser'
include Unparser::NodeHelpers
def mk_hash(hash)
s(:hash, *mk_pairs(hash))
end
def mk_pairs(hash)
@mbj
mbj / logical_implication.sql
Created October 15, 2020 15:10
Postgresql logical implication operator
CREATE FUNCTION
logical_implication(a boolean, b boolean)
RETURNS
boolean
LANGUAGE
sql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
COST 1
@mbj
mbj / errors.txt
Last active May 21, 2019 22:27
Stripe OpenAPI validator errors
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 492, Warning count: 0
Errors:
-attribute paths.'/v1/orders'(post).requestBody.content.encoding.contentType is missing
-attribute paths.'/v1/reporting/report_types'(get).requestBody.content.schema.additionalProperties is not of type `object`
-attribute paths.'/v1/application_fees/{id}/refunds'(get).requestBody.content.schema.additionalProperties is not of type `object`
-attribute paths.'/v1/customers/{customer}/customer_balance_transactions/{transaction}'(get).requestBody.content.schema.additionalProperties is not of type `object`
-attribute paths.'/v1/tokens'(post).requestBody.content.schema.additionalProperties is not of type `object`
-attribute paths.'/v1/invoices'(post).requestBody.content.schema.additionalProperties is not of type `object`
-attribute paths.'/v1/account/capabil
@mbj
mbj / crash.rb
Last active December 5, 2018 19:38
Crash Ruby 2.5.3
system('uname -a')
# not relevant just to make sure we terminate early
# core dumping is expensive.
Thread.abort_on_exception = true
MUTEX = Mutex.new
# You may have to up this on your platform
50.times do
@mbj
mbj / report.txt
Created March 21, 2016 23:30
First mutant self pass
$ bundle exec mutant --include lib --require mutant --zombie --use rspec -- 'Mutant*'
Matcher: #<Zombie::Mutant::Matcher::Config match_expressions: [Mutant*]>
Integration: Zombie::Mutant::Integration::Rspec
Expect Coverage: 100.00%
Jobs: 8
Includes: ["lib"]
Requires: ["mutant"]
Subjects: 469
Mutations: 14827
Results: 14827
@mbj
mbj / gist:852757dc1d52aee9034f
Created March 19, 2016 02:32
Rubygems user assisted downgrade attack
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for
compiling with OpenSSL using RVM are available at http://rvm.io/packages/openssl.
@mbj
mbj / gist:b24eafdcd9ed25a79f34
Created December 1, 2015 21:37
remaining-linter-errors.txt
* reimbursement - can't write unknown attribute `customer_return_id' (ActiveModel::MissingAttributeError)
* promotion - PG::NotNullViolation: ERROR: null value in column "promotion_category_id" violates not-null constraint
DETAIL: Failing row contains (1, null, null, null, Promo, null, null, all, null, f, null, 2015-12-01 21:12:15.576455, 2015-12-01 21:12:15.576455, null).
: INSERT INTO "spree_promotions" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id" (ActiveRecord::StatementInvalid)
* promotion_with_item_adjustment - PG::NotNullViolation: ERROR: null value in column "promotion_category_id" violates not-null constraint
DETAIL: Failing row contains (2, null, null, null, Promo, null, null, all, null, f, null, 2015-12-01 21:12:15.580228, 2015-12-01 21:12:15.580228, null).
: INSERT INTO "spree_promotions" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id" (ActiveRecord::StatementInvalid)
* promotion_with_order_adjustment - PG::NotNullViolation: ERROR: null value
@mbj
mbj / violations.txt
Created November 29, 2015 16:44
Invariant violations from spree factories
* stock_movement - PG::CheckViolation: ERROR: new row for relation "spree_products" violates check constraint "check_spree_products_tax_category_id"
DETAIL: Failing row contains (1, Product #1 - 9597, Et quibusdam vero dolore numquam ratione. Temporibus consequatur..., 2014-11-29 16:45:22.377, null, product-1-9597, null, null, 1, 1, 2015-11-29 16:45:22.539038, 2015-11-29 16:45:22.539038, t, ).
: INSERT INTO "spree_products" ("available_on", "created_at", "description", "name", "shipping_category_id", "slug", "tax_category_id", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" (ActiveRecord::StatementInvalid)
* product_property - PG::CheckViolation: ERROR: new row for relation "spree_products" violates check constraint "check_spree_products_tax_category_id"
DETAIL: Failing row contains (2, Product #2 - 6090, Tempore voluptas est ut esse molestias in sit. Aut ut debitis an..., 2014-11-29 16:45:22.54812, null, product-2-6090, null, null, 1, 1, 2015-11-29 16:45:22.556678, 2015-11-29 16:45:2
@mbj
mbj / coredumps.txt
Created November 15, 2015 21:56
Sad state of MRI under mutation testing :(, ignore the systemd part from blaming ;)
Nov 15 21:26:18 mbj systemd-coredump[13250]: Process 13247 (ruby) of user 1000 dumped core.
Nov 15 21:26:47 mbj systemd-coredump[14510]: Process 14507 (ruby) of user 1000 dumped core.
Nov 15 21:30:23 mbj systemd-coredump[15870]: Process 15867 (ruby) of user 1000 dumped core.
Nov 15 21:34:17 mbj systemd-coredump[19688]: Process 19685 (ruby) of user 1000 dumped core.
Nov 15 21:35:57 mbj systemd-coredump[30246]: Process 30243 (ruby) of user 1000 dumped core.
Nov 15 21:36:51 mbj systemd-coredump[510]: Process 507 (ruby) of user 1000 dumped core.
Nov 15 21:37:39 mbj systemd-coredump[11273]: Process 11270 (ruby) of user 1000 dumped core.
Nov 15 21:38:00 mbj systemd-coredump[11630]: Process 11627 (ruby) of user 1000 dumped core.
Nov 15 21:39:14 mbj systemd-coredump[23801]: Process 23798 (ruby) of user 1000 dumped core.
Nov 15 21:50:51 mbj systemd-coredump[29197]: Process 29194 (ruby) of user 1000 dumped core.
@mbj
mbj / break_method_dispatch.rb
Created June 6, 2015 21:50
Break ruby method dispatch
class Foo
def bar
p :original
end
end
module SomeModule
def bar
p :some_module
end