Skip to content

Instantly share code, notes, and snippets.

@nicolopignatelli
nicolopignatelli / commit-msg-hook.sh
Last active Aug 21, 2020
Git hooks enforcing branch name and commit message to include a formally valid JIRA issue key.
View commit-msg-hook.sh
#!/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
View Maybe.php
<?php
interface Maybe
{
public function ifSome(callable $f): self;
}
View Configuration.java
package com.myproject.myfeature
// Configuration of My Feature
interface Configuration {
// Returns whether the feature is enabled or not
public bool isFeatureEnabled();
}
View Card.scala
final case class Card(private val rank: Rank, private val suit: Suit)
View Card.java
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) {
View Service.java
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 Apr 9, 2019
Result micro-library. Emoji powered.
View Aborted.java
final class Aborted extends Failure {
public Result<T> ✅(Consumer<T> f) {
return this;
}
public Result<T> ❌(Consumer<ExceptionStack> f) {
return this;
}
}
View Bnb.java
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;
View Bnbs.java
package com.mywonderfulbnb.bnb.definition
interface Bnbs {
Optional<Bnb> load(BnbId);
void save(Bnb);
}
View Bnb.java
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;