Skip to content

Instantly share code, notes, and snippets.

View shelajev's full-sized avatar

Oleg Šelajev shelajev

View GitHub Profile
@shelajev
shelajev / Default methods override
Last active August 29, 2015 13:58
Java 8, default methods
package org.shelajev.throwaway.defmeth;
public class Main {
public static void main(String[] args) {
// what does this program produce?
B b = new B();
b.m1();
b.callM1();
b.callSuperM1();
}
@shelajev
shelajev / dsu-analysis
Last active August 29, 2015 14:11
DSU system analysis diagram description:
# http://bramp.github.io/js-sequence-diagrams/
DSU solution->Genrih: notifies about upcoming update
Genrih->>DSU solution: request changed classes
DSU solution->Genrih: provides changed classes
Genrih->Diff tool: old code, new code
Diff tool->>Genrih: list of changes
Note right of Genrih: changes => potential phenomena
Genrih->Oracle: list of phenomena
Oracle->Runtime: queries state
Runtime->>Oracle: state information
@shelajev
shelajev / app.groovy
Created December 3, 2015 16:32
4 Examples of a Dynamic Language... post snippets
@RestController
class ThisWillActuallyRun {
   @RequestMapping("/")
   String home() {
       return "Hello World!"
   }
}
@shelajev
shelajev / Foo1.java
Last active December 9, 2015 16:56
RebelLabs post: A Fluent API or not API fluent a? That is the Question!
public class Foo {
private String bar;
private int number;
public Foo() {
// Do some stuff
}
public String getBar() { return this.bar; }
@shelajev
shelajev / ExampleActor.java
Last active December 18, 2015 19:16
RebelLabs post: Exploring the virtues of microservices with Play and Akka
class ExampleActor extends AbstractActor {
// this child will be destroyed and re-created upon restart by default
final ActorRef other = getContext().actorOf(new Props(OtherActor.class), "childName");
public ExampleActor() {
receive(ReceiveBuilder
.match(Request1.class, r ->
other.tell(r.getMsg(), self())
)
.match(Request2.class, r ->
@shelajev
shelajev / snackbar-example.java
Created January 15, 2016 16:14
retrofit2-snackbar-example.java
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, “Super fast hello world”, Snackbar.LENGTH_LONG)
.setAction(“Action”, null).show();
}
});
@shelajev
shelajev / contributor.java
Created January 15, 2016 16:16
retrofit2-contributor.java
public class Contributor {
String login;
String html_url;
int contributions;
@Override
public String toString() {
return login + " (" + contributions + ")";
@shelajev
shelajev / GitHubService-1.java
Created January 15, 2016 16:16
retrofit2-GitHubService-1.java
public interface GitHubService {
@GET(“repos/{owner}/{repo}/contributors”)
Call<List<Contributor>> repoContributors(
@Path(“owner”) String owner,
@Path(“repo”) String repo);
}
@shelajev
shelajev / GitHubService.java
Created January 15, 2016 16:17
retrofit2-GitHubService.java
interface GitHubService {
@GET("repos/{owner}/{repo}/contributors")
Call<List<Contributor>> repoContributors(
@Path("owner") String owner,
@Path("repo") String repo);
public static final Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.addConverterFactory(GsonConverterFactory.create())
@shelajev
shelajev / Retrofit-call.java
Created January 15, 2016 16:17
retrofit2-Retrofit-call.java
GitHubService gitHubService = GitHubService.retrofit.create(GitHubService.class);
Call<List<Contributor>> call = gitHubService.repoContributors(“square”, “retrofit”);
List<Contributor> result = call.execute().body();