Skip to content

Instantly share code, notes, and snippets.

View abhirockzz's full-sized avatar
👋
fmt.Println(hello, world!)

Abhishek Gupta abhirockzz

👋
fmt.Println(hello, world!)
View GitHub Profile
{
"tunnels": [
{
"name": "command_line",
"uri": "/api/tunnels/command_line",
"public_url": "https://b42658ec.ngrok.io",
"proto": "https",
"config": {
"addr": "http://nginx-service:80",
"inspect": true
FROM fnproject/go:dev as build-stage
WORKDIR /function
RUN go get -u github.com/golang/dep/cmd/dep
ADD . /go/src/func/
RUN cd /go/src/func/ && dep ensure
RUN cd /go/src/func/ && go build -o func
FROM fnproject/go
WORKDIR /function
COPY --from=build-stage /go/src/func/func /function/
....
var updateInfo UpdateInfo
json.NewDecoder(in).Decode(&updateInfo)
_, err := cc.UpdateInstance(context.Background(), core.UpdateInstanceRequest{InstanceId: common.String(updateInfo.OCID), UpdateInstanceDetails: core.UpdateInstanceDetails{DisplayName: common.String(updateInfo.NewDisplayName)}})
....
....
var criteria SearchCriteria
json.NewDecoder(in).Decode(&criteria)
cmpt := criteria.CompartmentIDFilter
instances := []Instance{}
resp, err := cc.ListInstances(context.Background(), core.ListInstancesRequest{CompartmentId: common.String(cmpt)})
for _, instance := range resp.Items {
....
tenancy := os.Getenv("TENANT_OCID")
user := os.Getenv("USER_OCID")
region := os.Getenv("REGION")
fingerprint := os.Getenv("FINGERPRINT")
privateKeyName := os.Getenv("OCI_PRIVATE_KEY_FILE_NAME")
privateKeyLocation := privateKeyFolder + "/" + privateKeyName
passphrase := os.Getenv("PASSPHRASE")
privateKey, err := ioutil.ReadFile(privateKeyLocation)
....
FROM fnproject/go:dev as build-stage
WORKDIR /function
RUN go get -u github.com/golang/dep/cmd/dep
ADD . /go/src/func/
RUN cd /go/src/func/ && dep ensure
RUN cd /go/src/func/ && go build -o func
FROM fnproject/go
RUN apk add --no-cache flite
WORKDIR /function
speech, err := ioutil.ReadFile(outputLocation)
if err != nil {
errMsg := "could not read from .wav file " + err.Error()
log.Println(errMsg)
out.Write([]byte(errMsg))
return
}
log.Println("Returning .wav bytes")
defer func() {
fileErr := os.Remove(outputLocation)
if fileErr == nil {
log.Println("Deleted temp file", outputLocation)
} else {
log.Println("Error removing output file", fileErr.Error())
}
}()
...
flite := exec.Command("flite", "-t", text, "-o", outputLocation)
err := flite.Run()
if err != nil {
errMsg := "failed due to " + err.Error()
log.Println(errMsg)
out.Write([]byte(errMsg))
return
}
...
func main() {
fdk.Handle(fdk.HandlerFunc(text2speech))
}
func text2speech(ctx context.Context, in io.Reader, out io.Writer) {
buf := new(bytes.Buffer)
buf.ReadFrom(in)
text := buf.String()
....