This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo | |
func Fibonacci(number int) int { | |
if number < 2 { | |
return number | |
} | |
return Fibonacci(number-1) + Fibonacci(number-2) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/mattbaird/elastigo/api" | |
import "github.com/mattbaird/elastigo/core" | |
func main() { | |
type Address struct { | |
ProvinceName string `json:"province_name"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Counter struct { | |
n int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT http://localhost:9200/suggestion -d '{ | |
"mappings": { | |
"address": { | |
"properties": { | |
"province_id": {"type": "integer"}, | |
"province_code": {"type": "string"}, | |
"province_name": {"type": "string"}, | |
"province_name_suggest" : { | |
"type" : "completion" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Payload struct { | |
ProvinceID int `json:"province_id"` | |
} | |
type Suggest struct { | |
Input string `json:"input"` | |
Output string `json:"output"` | |
Payload Payload `json:"payload"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rest.demo; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
@Path("myresource") | |
public class MyResource { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"expvar" | |
"log" | |
) | |
var ( | |
counter = expvar.NewInt("counter for my program") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exception(IllegalArgumentException.class, (e, req, res) -> { | |
res.status(400); | |
res.body(toJson(new ResponseError(e))); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?hh | |
function sayHello(string $name): string { | |
return "Hello ". $name . "! ". PHP_EOL; | |
} | |
echo sayHello("Up1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
fs.readFile("mydata.json", function(err, content) { | |
if (err) { | |
console.error("Got an error", err); | |
} else { | |
console.log("Got result"); | |
} | |
}); | |
console.log("After call readFile") |