Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Launching MVP

Bèr Kessels berkes

🚀
Launching MVP
View GitHub Profile
View gist:71fb555d0e9a14b755755373071252d6
irb(main):001:1* class Wrapper
irb(main):002:2* def initialize(wrapped)
irb(main):003:2* @wrapped = wrapped
irb(main):004:1* end
irb(main):005:1*
irb(main):006:2* def call(name)
irb(main):007:2* @wrapped.call(name)
irb(main):008:1* end
irb(main):009:0> end
=> :call
@berkes
berkes / HAL-libraries-for-ruby.md
Last active Nov 4, 2021
HAL Libraries for Ruby - evaluation
View HAL-libraries-for-ruby.md

HAL API libraries for Ruby

https://github.com/mikekelly/hal_specification/wiki/Libraries#ruby used as seed.

Evaluation of various HAL clients to build and consume HAL JSON APIs for Plannel. Evaluation purely by reading code and README. No Proof of Concept or experience with any of the libs.

The evaluation was done with a clear goal in mind: build the HTTP+HAL+JSON adapter on an existing business-domain that (hexagonal architecture). Preferably using Sinatra, since this HTTP adapter does not interact with databases or other plumbing etc: only with Models (Root Aggregates) and Commands. Clean, and easy to understand architecture is an important criteria. As are some other criteria: this is very opinionated and might not match what you are looking for, at all: it may very well be that something listed as "con" is a "pro" for you.

Tests for the API need a HAL client, the implementation needs a server. Client and server need not be the same library.

@berkes
berkes / example.php
Created Oct 8, 2021
URL shortner without storage
View example.php
<?php
composer require "tuupola/base85:^1.0"
$url = "https://ultimatemotherfuckingwebsite.com/"
$base85 = new Tuupola\Base85;
$tokenized = $base85->encode($url);
$shortened = "https://big.pm/$tokenized";
View openpgp.md
View base.rb
# frozen_string_literal: true
require 'delegate'
module Workflows
##
# Common workflow generics
class Base < SimpleDelegator
attr_reader :test_obj
View query_wtf.sql
SELECT DISTINCT SUBPATH(categories.path, 0, 1) FROM "gauges" INNER JOIN "entities" ON "entities"."id" = "gauges"."entity_id" INNER JOIN "categories_gauges" ON "categories_gauges"."gauge_id" = "gauges"."id" INNER JOIN "categories" ON "categories"."id" = "categories_gauges"."category_id" WHERE (entities.path <@ '1924544') AND (gauges.id IN (SELECT "gauges"."id" FROM "gauges" LEFT OUTER JOIN categories_gauges
ON categories_gauges.gauge_id = gauges.id
AND categories_gauges.category_id IN (SELECT "categories"."id" FROM "categories" WHERE (categories.path <@ '5005')) WHERE (categories_gauges.category_id IN (5129,2496,2500,2504,2509,2513,2517,2521,2525,2529,8012,8015,4274,4318,4556,4322,3124,3203,3089,3081,3091,3123,3093,3059,3067,3055,3075,3125,3133,3108,3113,3114,3116,3119,3118,3129,3100,3670,3663,3700,4044,4020,4030,4011,4050,3094,3101,3194,3196,3197,3103,3038,6610,5007,5008,5006,7578,7581,7795,7802,7810,7817,7820,7824,7827,7830,7833,7836,7841,7814,7805,8933,8977,9706,9303,9323,9456,9063,9073,9076,962
View password.rb
#!/usr/bin/ruby
# English:
# file = "/usr/share/dict/british-english"
# file = /usr/share/dict/words
file = "/usr/share/dict/nederlands"
words = File.read(file).split("\n")
16.times do
View scheldwoorden.rb
require 'pp'
prefixes = %w{
rot
graf
plak
vuil
prut
pluis
}
@berkes
berkes / command
Last active Mar 6, 2020
Dutch Domains in The Duckduckgo Tracker Radar Dataset
View command
git clone https://github.com/duckduckgo/tracker-radar
cd tracker-radar
grep -R "\"domain\":" | grep "\.nl\"" | cut -d ":" -f3- | sed "s/[ \"\,]//g"
@berkes
berkes / CouponManager.sol
Created Nov 26, 2018
CouponManager v0.1.0
View CouponManager.sol
pragma solidity ^0.4.22;
contract CouponManager {
enum Answers { NoAnswer, Approved, Denied, Pending }
struct Batch {
string description;
uint expiresAt;
uint24 amount;
uint24 free;