Skip to content

Instantly share code, notes, and snippets.

View waiting-for-dev's full-sized avatar
🏠
Working from home

Marc Busqué waiting-for-dev

🏠
Working from home
View GitHub Profile

Unhappy path

Before delving into how we support database (DB) transactions, let's first consider how we can handle operations that only pertain to the unhappy path. This consideration is important because, as we will see, it will become relevant when we reach the main topic.

Most of the time, the unhappy path is something managed by the caller (e.g., a controller rendering an error in case of failure). However, there are situations where it makes sense to encapsulate part of the unhappy path within the operations class. For instance, you might want to log the failure somewhere.

When relying on the vanilla #steps method, the implementation is straightforward:

class CreateUser < Dry::Operation
# frozen_string_literal: true
require 'octokit'
require 'faraday/retry'
class Updater
attr_reader :client
SOLIDUSIO = 'solidusio'
@waiting-for-dev
waiting-for-dev / FIFO.ini
Last active November 17, 2021 09:32 — forked from hmijail/FIFO.ini
A CopyQ command to implement a Clipboard FIFO
[Command]
Command="
copyq:
maxrow = count() - 1
select(maxrow)
paste()
if (config('move') == 'true') {
remove(0)
} else {
remove(maxrow)
@waiting-for-dev
waiting-for-dev / dry_transaction_resurrection.rb
Last active December 30, 2021 12:53
POC for a new version of dry-transaction
# frozen_string_literal: true
require "dry/monads"
require "rspec"
require "ostruct"
module Dry
module TransactionResurrection
def self.[](monad)
Module.new do
require 'logger'
require 'byebug'
require 'dry/monads'
require 'dry/monads/do'
require 'dry/matcher/result_matcher'
module Dry
module Transaction
module Steps
This file has been truncated, but you can view the full file.
{"label":"","duration":18592.858384999912,"markers":[{"end":1596.5449410000583,"endStack":null,"isOffMainThread":false,"name":"nsCycleCollector::ForgetSkippable","processType":0,"stack":null,"start":1595.9524039999815},{"end":1621.1153550000163,"endStack":null,"eventPhase":2,"isOffMainThread":false,"name":"DOMEvent","processType":0,"stack":null,"start":1620.9124489999376,"type":"mousemove"},{"causeName":"EventListener.handleEvent","end":1621.1104840000626,"endStack":null,"isOffMainThread":false,"name":"Javascript","processType":0,"stack":1,"start":1620.935107999947},{"causeName":"CC_WAITING","end":1674.7230330000166,"endStack":null,"isOffMainThread":false,"name":"MinorGC","processType":0,"stack":null,"start":1673.6202110000886},{"causeName":"REFRESH_FRAME","end":1712.1202819999307,"endStack":null,"isOffMainThread":false,"name":"MinorGC","processType":0,"stack":null,"start":1711.7321020000381},{"causeName":"REFRESH_FRAME","end":1811.9146579999942,"endStack":null,"isOffMainThread":false,"name":"MinorGC","proces
@waiting-for-dev
waiting-for-dev / gist:ec481ca658e2777e65c214327f35f511
Last active August 11, 2016 10:44
`bundle exec derailed bundle:objects` with a Gemfile with just axlsx
Measuring objects created by gems in groups [:default, "production"]
Total allocated: 11269732 bytes (61895 objects)
Total retained: 4477284 bytes (11381 objects)
allocated memory by gem
-----------------------------------
6256569 axlsx-2.0.0
3278098 nokogiri-1.6.6.2
1100457 rubyzip-0.9.9
517043 htmlentities-4.3.4
function epub() {
tags="$@"
if [ x = x${tags} ]; then
filename=$(date -I)_feeds
else
filename=$(date -I)_${tags// /_}_feeds
fi
ebook-convert ~/projects/recipes/newsbeuter/newsbeuter.recipe $filename.epub --tags="${tags// /,}"
}
#!/bin/sh
if [ x = x${2} ]; then
BRANCH_NAME=$(git symbolic-ref --short HEAD)
STORY_NUMBER=$(echo $BRANCH_NAME | sed -n 's/.*-\([0-9]\)/\1/p')
if [ x != x${STORY_NUMBER} ]; then
sed -i.back "1s/^/\n\n[#$STORY_NUMBER]/" "$1"
fi
fi
@waiting-for-dev
waiting-for-dev / merge2ass.sh
Last active October 16, 2018 16:19
Script to run mplayer with two subtitles tracks at the same time. Usage: mplayer2 video sub1 sub2. merge2ass.sh (http://www.abclinuxu.cz/blog/Joseho_blog/2007/7/30/188299) script must be in the path.
#!/bin/bash
# merge2ass.sh - script for merging two text-subtitles into an ass subtitle file
# version 0.9b, 02-feb-2013
# comments/criticism/praise to jose1711-gmail-com
# dependencies: mplayer (if your subtitle files need to be converted to srt), gnu utils
# thanks to:
# - d.watzke for comments
# - belisarivs for testing