Skip to content

Instantly share code, notes, and snippets.

View fathur's full-sized avatar

Fathur Rohman fathur

View GitHub Profile
@fathur
fathur / ticket.sh
Created October 11, 2022 07:34
Git hook prepare commit message with ticket number
#!/bin/bash
# Extract the ticket number from the branch name and prepend it in the commit message.
# This script will run in the git hook prepare-commit-msg.
BRANCH=$(git rev-parse --abbrev-ref HEAD)
MESSAGE_FILE=$1
MESSAGE=$(cat $MESSAGE_FILE)
TICKET=$(echo $BRANCH | grep -Eo '^(\w+/)?(\w+[-_])?[0-9]+' | grep -Eo '(\w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")
@fathur
fathur / julo-application.json
Last active February 20, 2022 17:15
Julo Application OpenAPI 3.0
{
"openapi": "3.0.0",
"info": {
"title": "Underwriting API",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:3000"
}
@fathur
fathur / variation-call.php
Created April 29, 2020 17:39
Namespace 5
<?php
echo \Foo\Bar\Apple::hello(); // hello Apple
echo \Foo\Bar\hello(); // hello world
echo \Foo\Bar\HELLO; // WORLD
@fathur
fathur / variation.php
Created April 29, 2020 17:35
Namespace 4
<?php
namespace Foo\Bar;
class Apple() {
public static function hello() {
return 'hello Apple';
}
}
@fathur
fathur / index.php
Last active April 29, 2020 17:26
Namespace 3
<?php
use App\Buah\Jambu;
use App\Makanan\Jambu;
echo App\Buah\Jambu::biji(); // 7
echo App\Makanan\Jambu::biji(); // 10
@fathur
fathur / jambu.php
Last active April 29, 2020 17:25
Namespace 2
<?php
namespace App\Makanan;
class Jambu {
public static function biji() {
return 10;
}
}
@fathur
fathur / jambu.php
Last active April 29, 2020 17:25
Namespace 1
<?php
namespace App\Buah;
class Jambu {
public static function biji() {
return 7;
}
}
@fathur
fathur / risks-many-to-many.rb
Last active July 10, 2019 10:50
Risk many to many logic
module ObserverInterface
def update(observable)
raise ImplementationError # Class ZBC not implemented method xyz
end
end
class Risk
include ObserverInterface
include RiskInterface
end
class MidwifeRegistrationService
def initialize(options = {})
@params = options[:params]
end
def call
create_user
send_sms
self
class RegistrationEndpoint < Grape::API
params do
optional :name
optional :phone
optional :email
optional :password
optional :password_confirmation
end
post :register do