Skip to content

Instantly share code, notes, and snippets.

@mpaltun
mpaltun / JavaApplication1.java
Created February 14, 2023 14:52 — forked from adamretter/JavaApplication1.java
UUID to BigInteger rountrip
package javaapplication1;
import java.math.BigInteger;
import java.util.UUID;
public class JavaApplication1 {
public static void main(String[] args) {
final UUID uuid = UUID.randomUUID();
System.out.println("uuid=" + uuid.toString());
@mpaltun
mpaltun / EventBusAutoRegisterSampleModule.java
Last active March 17, 2021 19:28
Auto register guice services annotated with Subscribe to EvenBus
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matchers;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static java.util.Objects.requireNonNull;
/**
* Rust inspired Result type which represents either success or failure
*
* @param <T> the success value type
@mpaltun
mpaltun / ubuntu.md
Last active August 17, 2018 07:58
Ubuntu tools
@mpaltun
mpaltun / Restful.md
Last active November 20, 2017 15:26
Restful API Notes

PUT

  • You are referring to an entity, not to a collection.
  • The entity you are supplying is complete (the entire entity).
  • Idempotent
  • Could be used for partial updates but need to create a new resource for every field. PUT /users/123/email, /users/123/address

PATCH

  • Partial updates
  • Not idempotent
@mpaltun
mpaltun / books.md
Last active August 29, 2015 14:09
books
  • [Java I/O, 2nd Edition] (http://shop.oreilly.com/product/9780596527501.do)
  • Java NIO
  • Refactoring: Improving the Design of Existing Code
  • Building Microservices
  • RESTful Java with JAX-RS
  • RESTful Web Services with Dropwizard
  • RESTful Web APIs
  • Practical Vim
  • XMPP: The Definitive Guide
  • Getting Started with Google Guava
@mpaltun
mpaltun / apidoc.md
Created August 7, 2014 15:32
apiary markdown

Group Gist

Gist-related resources of Gist Fox API.

Gist [/gists/{id}]

A single Gist object. The Gist resource is the central resource in the Gist Fox API. It represents one paste - a single text note.

The Gist resource has the following attributes:

  • id
  • created_at
/* built with Studio Sketchpad:
* http://sketchpad.cc
*
* observe the evolution of this sketch:
* http://sketchpad.cc/sp/pad/view/ro.VNh0DUzwa1U/rev.390
*
* authors:
* mustafa
* tayfun
@mpaltun
mpaltun / LifeTest.java
Created December 8, 2012 15:10
lifetest
package com.cr;
import static junit.framework.Assert.*;
import org.junit.Test;
public class LifeTest {
public abstract class Cell {
public abstract boolean isAliveOnTick();
public abstract void addNeighbour(Cell neighbour);
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
ListIterator<String> listIterator = list.listIterator(2);
while (listIterator.hasNext())
{
System.out.println(listIterator.next());