Here's the simplest example showing how to do functional options in Golang.
They're a great way to enable users to set options and ease adding new options later.
package main
import (
"flag"
"fmt"
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Foo struct { | |
FirstName string `tag_name:"tag 1"` | |
LastName string `tag_name:"tag 2"` |
#!/usr/bin/env bash | |
# MIT © Sindre Sorhus - sindresorhus.com | |
# git hook to run a command after `git pull` if a specified file was changed | |
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
check_run() { | |
echo "$changed_files" | grep --quiet "$1" && eval "$2" |
package main | |
import ( | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
) | |
func init() { |
var mongodb = require("mongodb"); | |
var MongoClient = mongodb.MongoClient; | |
var fs = require("fs"); | |
var Transform = require("stream").Transform; | |
var name_surname_email_filter = new Transform({readableObjectMode:true, writableObjectMode:true} ); | |
name_surname_email_filter._transform = function(data, enc, cb) { | |
//console.log(data); | |
var newdata = { first_name: data.first_name, |
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"strconv" | |
) | |
func main() { |
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = | |
let smallerSorted = quicksort (filter (<=x) xs) | |
biggerSorted = quicksort (filter (>x) xs) | |
in smallerSorted ++ [x] ++ biggerSorted |
# Official framework image. Look for the different tagged releases at: | |
# https://hub.docker.com/r/library/node/tags/ | |
image: node:6 | |
before_script: | |
- npm install | |
# This folder is cached between builds | |
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache | |
cache: |
Here's the simplest example showing how to do functional options in Golang.
They're a great way to enable users to set options and ease adding new options later.
package main
import (
"flag"
"fmt"
// Tensorflow Serving Go client for the inception model | |
// go get github.com/golang/protobuf/ptypes/wrappers google.golang.org/grpc | |
// | |
// Compile the proto files: | |
// | |
// git clone https://github.com/tensorflow/serving.git | |
// git clone https://github.com/tensorflow/tensorflow.git | |
// | |
// mkdir -p vendor |
package main | |
import ( | |
"sync" | |
"fmt" | |
"time" | |
) | |
func main() { | |
lock := sync.Mutex{} |