Skip to content

Instantly share code, notes, and snippets.

@nicolopignatelli
nicolopignatelli / commit-msg-hook.sh
Last active August 21, 2020 09:44
Git hooks enforcing branch name and commit message to include a formally valid JIRA issue key.
#!/bin/sh
# This hook enforces the following commit message format "[PROJ-123] some message"
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
INPUT_FILE=$1
<?php
interface Maybe
{
public function ifSome(callable $f): self;
}
package com.myproject.myfeature
// Configuration of My Feature
interface Configuration {
// Returns whether the feature is enabled or not
public bool isFeatureEnabled();
}
final case class Card(private val rank: Rank, private val suit: Suit)
final class Card {
private Rank rank;
private Suit suit;
public Card(Rank rank, Suit suit) {
this.rank = rank;
this.suit = suit;
}
public boolean sameAs(Card anotherCard) {
package com.mywonderfulbnb.bnb.definition
final class Service {
private Bnbs Bnbs;
private ActivatedOwners activatedOwners;
private Publisher publisher;
private Logger logger;
public Service(Bnbs bnbs, ActivatedOwners activatedOwners, Publisher publisher, Logger logger) {
this.bnbs = bnbs;
@nicolopignatelli
nicolopignatelli / Aborted.java
Last active April 9, 2019 23:11
Result micro-library. Emoji powered.
final class Aborted extends Failure {
public Result<T> ✅(Consumer<T> f) {
return this;
}
public Result<T> ❌(Consumer<ExceptionStack> f) {
return this;
}
}
package com.mywonderfulbnb.bnb.definition
final class Bnb implements ReadOnlyBnb {
private BnbId bnbId;
private OwnerId ownerId;
private Name name;
private Rooms rooms;
public Bnb(BnbId bnbId, OwnerId ownerId, Name name, Rooms rooms) {
this.bnbId = bnbId;
package com.mywonderfulbnb.bnb.definition
interface Bnbs {
Optional<Bnb> load(BnbId);
void save(Bnb);
}
package com.mywonderfulbnb.bnb.definition
final class Bnb {
private BnbId bnbId;
private OwnerId ownerId;
private Name name;
public Bnb(BnbId bnbId, OwnerId ownerId, Name name) {
this.bnbId = bnbId;
this.ownerId = ownerId;