Skip to content

Instantly share code, notes, and snippets.

server {
listen 80;
server_name example.com www.example.com;
root /path/to/example.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
<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();
}