Skip to content

Instantly share code, notes, and snippets.

View mgenov's full-sized avatar

Miroslav Genov mgenov

View GitHub Profile
package app
import (
"fmt"
"time"
)
type SessionClock interface {
SessionDuration() time.Duration
@mgenov
mgenov / SampleTest.java
Created July 16, 2013 13:59
Sample test which compares factory vs provider
import com.google.inject.Provider;
import com.google.inject.util.Providers;
import org.jmock.Expectations;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
/**
Datastore datastore = new Datastore();
datastore.findAll(Person.class,where("name").is("john");
@mgenov
mgenov / Slice.java
Created September 3, 2012 05:42
A simple collection similar to Go's built-in notion of "slices".
import java.util.Collection;
import java.util.Iterator;
/**
* A simple collection similar to Go's built-in notion of "slices".
* <p/>
* These are essentially bounded array objects with an immutable underlying store. Appending and
* inserting elements requires a new backing store to be allocated, but slicing out a contiguous
* subset just creates a new Slice that references the existing backing store.
* <p/>
@mgenov
mgenov / App.java
Created August 29, 2012 12:10
Sitebricks Sample
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
install(new SitebricksModule() {
@Override
protected void configureSitebricks() {
at("/r/customer").serve(CustomerService.class);
}
});
}
@mgenov
mgenov / gist:3413773
Created August 21, 2012 09:05 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mgenov
mgenov / PaymentUsingFactory.java
Created August 10, 2012 07:54
PaymentUsingFactory.java
interface CreditCard {
void charge(Double amount);
}
interface CreditCardFactory {
CreditCard create(String customerId);
}
@mgenov
mgenov / README.md
Created August 6, 2012 08:19
sample.sql

Sample Query File

  • Selecting unknown users
  • Selecting known users
@mgenov
mgenov / CalculatorTest.java
Created July 22, 2012 10:41
CalculatorTest.java
package com.clouway.calculator;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
@mgenov
mgenov / CalendarUtil.java
Created June 27, 2012 09:03
QueriesLearningTest
public final class CalendarUtil {
@SuppressWarnings("unused")
CalendarUtil() {
}
public static Date january(int year, int day) {
return newDate(year, 1, day);
}