Skip to content

Instantly share code, notes, and snippets.

package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
swagger: '2.0'
info:
version: 1.0.9-abcd
title: Swagger Sample API
description: >-
A sample API that uses a petstore as an example to demonstrate features in
the swagger-2.0 specification
host: my.api.com
consumes:
- application/json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"items": {
"minItems": 1,
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"type": {
package main
import (
"fmt"
"strconv"
)
func main() {
i := 123
t := strconv.Itoa(i)
x = "[[1,2,[3]],4]"
x.gsub!(/[\[\]]/,'') # Remove the [ and ] from the string. It is required to escape the [ and ] characters
puts x.split(",") # Join the string making it an array
package main
import "log"
type Admin struct {
*User
Level string
}
func (a *Admin) Notify() error {
@gerep
gerep / compact.go
Last active June 29, 2021 18:32
Compacting json data removing unused spaces: https://golang.org/pkg/encoding/json/#Compact
package main
import (
"bytes"
"encoding/json"
"fmt"
)
func main() {
data := `{ "spacedValue": "spaced value" }`
[ -r /etc/profile.d/cnf.sh ] && . /etc/profile.d/cnf.sh
#source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
export BROWSER=/usr/bin/google-chrome-stable
export EDITOR=/usr/local/bin/vim
TERM=xterm
case $TERM in
xterm*)
@gerep
gerep / httpbenchmark.go
Last active May 6, 2016 12:36 — forked from luisbebop/httpbenchmark.go
http benchmark tool
import (
"flag"
"fmt"
"net/http"
)
var (
n = flag.Int("n", 100, "number of GETs to run")
s = flag.Bool("s", false, "whether to use HTTPS")
c = flag.Bool("c", false, "whether to run concurrently")
package main
import "fmt"
func main() {
primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
p := binarySearch(primes, 59)
fmt.Println("O número 11 esta na posição ", p)
}