Skip to content

Instantly share code, notes, and snippets.

<dependency>
<groupId>co.paralleluniverse</groupId>
<artifactId>capsule</artifactId>
<version>0.7.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
...
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>capsule-full</id>
<formats>
<format>jar</format>
</formats>
<baseDirectory>/</baseDirectory>
<dependencySets>
body, pre, code {
background-color: #002B36;
color: #839496;
font-family: "Source Code Pro", monospace;
}
.form-control {
background-color: #073642;
color: #eee8d5;
font-family: "Source Code Pro", monospace;
func GenerateRandomString(length int) string {
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"
rand.Seed(time.Now().Unix())
str := make([]string, length)
for i := 0; i < length; i++ {
index := rand.Intn(len(chars))
str[i] = chars[index : index+1]
}
return strings.Join(str, "")
}
type Paste struct {
// Generated
Id string `datastore:"id"`
Timestamp time.Time `datastore:"timestamp"`
// Required
Content string `datastore:"content,noindex"`
Email string `datastore:"email"`
// Optional/Best-effort
Title string `datastore:"title"`
Language string `datastore:"language"`
class MyTest {
@Module(injects = MyTest.class, includes = TestModule.class)
static class MyTestModule {
}
}
// module is a test module that overrides production settings
Guice.createInjector(module).injectMembers(target);
@Provides
@Singleton
Foo provideFoo(FooImpl fooImpl)
return fooImpl;
}
@Provides
ThirdPartyFoo provideThirdPartyFoo() {
return new ThirdPartyFoo();
}

Keybase proof

I hereby claim:

  • I am diwakergupta on github.
  • I am diwaker (https://keybase.io/diwaker) on keybase.
  • I have a public key whose fingerprint is C970 E785 A79A 46A2 A5B3 4753 401F EE74 A63B B63A

To claim this, I am signing this object: