Skip to content

Instantly share code, notes, and snippets.

View mgenov's full-sized avatar

Miroslav Genov mgenov

View GitHub Profile
@mgenov
mgenov / README.md
Created August 6, 2012 08:19
sample.sql

Sample Query File

  • Selecting unknown users
  • Selecting known users
@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 / 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 / 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 / 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/>
Datastore datastore = new Datastore();
datastore.findAll(Person.class,where("name").is("john");
@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;
/**
package app
import (
"fmt"
"time"
)
type SessionClock interface {
SessionDuration() time.Duration
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS,Europe/Sofia} %-5level %logger{35} - %msg%n</Pattern>
</layout>
</appender>
<logger name="com.clouway" level="DEBUG">
package main
import (
"github.com/codegangsta/martini"
"github.com/gorilla/websocket"
"log"
"net"
"net/http"
"sync"
)