Skip to content

Instantly share code, notes, and snippets.

View reevik's full-sized avatar
:octocat:

Erhan Bağdemir reevik

:octocat:
View GitHub Profile
@reevik
reevik / init.vim
Created February 3, 2022 11:28 — forked from celso/init.vim
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
@Service
@Path("/")
public class MatrixResource {
@GET
@Path("/status/ping")
@Produces("text/plain")
public String ping(@MatrixParam("name") String name) {
return String.format("matrix variable name=%s", name);
}
}
@Service
@Path("/")
public class MatrixResource {
@GET
@Path("/{status}/ping")
@Produces("text/plain")
public String ping(@PathParam("status") PathSegment status) {
MultivaluedMap<String, String> matrixParameters = status.getMatrixParameters();
String nameMatrixFromStatus = matrixParameters.getFirst("name");
return String.format("matrix variable name=%s", nameMatrixFromStatus);
@RestController
public class MatrixResource {
@RequestMapping(value="/{status}/ping", method=RequestMethod.GET)
public String pong(
@PathVariable("status") String status,
@MatrixVariable(name="name", pathVar="status", required=false) String name) {
return String.format("matrix variable name=%s", name);
}
}
(defprotocol Command
(perform [this metric city param]
"Executes the command logic."))
(deftype command-runner [] ;; ➊
Command
(perform [this metric city day] ;; ➋
(try
(run metric city day) ;; ➌
(catch Exception e
(handle-error e)))))
;; Multimethod definition showing that the run
;; might have multiple informations. The identity
;; function is used as dispatcher function to
;; determine which implementation of run is to be
;; called
(defmulti run identity)
;; The run method implementation for temp.
(defmethod run "temp"
[city day]
(get-temp city day))
public class Cat {
private AnimalSound sound;
public Cat(AnimalSound animalSound) {
this.sound = animalSound;
}
public void sing() {
soundEffect(sound);
}
}
Cat cat1 = new Cat(AnimalSoundLib.MEOW);
cat1.sing(); // meooww
Cat cat2 = new Cat(AnimalSoundLib.MEOOO);
cat2.sing(); // meoooo
// more cats
public class Lion extends Cat {
public Lion(AnimalSound animalSound) {
super(animalSound);
}
public void hunt() {}
// and other lion related methods.
}