Skip to content

Instantly share code, notes, and snippets.


Biniam biniama

View GitHub Profile
biniama / pom.xml
Created Mar 19, 2021
View pom.xml
<!-- The app must be a webapp to have an embedded container (e.g. Tomcat) on the classpath. -->
<!-- Otherwise, the app starts and shuts down automatically. -->
biniama /
Created Feb 24, 2021
Hacker Rank Exercises
import math
import os
import random
import re
import sys
biniama /
Created Jun 24, 2020 — forked from cooervo/
biniama /
Last active Nov 19, 2019
Find date format given the date object
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
* Source:
public class DateFormatFinder {
biniama /
Last active Mar 12, 2020
Swagger Documentation with Spring Boot (working UI)
package com.example.springbootswagger.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
biniama /
Created Nov 2, 2018
Convert POJO to JSON
import com.fasterxml.jackson.databind.ObjectMapper;
private static void pojoToJson(Object object) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();;
biniama / How to run Simple Server Locally
Last active Oct 30, 2018
Simple API Server using Spring Boot
View How to run Simple Server Locally
1. Make sure Spring Boot is installed
`sdk install springboot`
`spring --version`
2. Run
`spring run app.groovy`
biniama / Difference
Last active Oct 20, 2018
Adapter vs Decorator vs Bridge
View Difference
In scope and intent
Adapter - intent is to mix an interface into a class that doesn't currently implement htat interface.
Decorator - intent is to change the way a method behaves differently for different decorators.
Bridge - intent is to insolate sub-systems so you can swap out sub-systems without impacting the code that is using that sub-systems.
The point of a Bridge is to isolate two subsystems so that they can be independently modified. Bridges are big things, often comprised of other patterns (like Adapters and Decorators). This segment looks at how to implement a Bridge and discusses the differences between Bridge and similar patterns like Adapter.
E.g. JDBC (bad implementation of Bridge since swapping doesn't work as it should)
Best example: ORM systems like Hibernate.
biniama /
Last active Oct 20, 2018
Singleton Pattern - Multiple Implementations by Allen Holub (
class Singelton {
static Singleton instance = null;
//private constructor
private Singelton() {}
public static Singleton getInstance() {
if(instance == null)
instance = new Singleton();
return instance;
biniama /
Last active Oct 17, 2018
"Find Unique Numbers of Length n" using Java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PhonePadExercise {
public static void main(String[] args) {
Integer selectedDigit = 4;