Skip to content

Instantly share code, notes, and snippets.

View brpaz's full-sized avatar

Bruno Paz brpaz

View GitHub Profile
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Rankings struct {
Keyword string
func scanFile() {
f, err := os.OpenFile(logfile, os.O_RDONLY, os.ModePerm)
if err != nil {
log.Fatalf("open file error: %v", err)
return
}
defer f.Close()
sc := bufio.NewScanner(f)
for sc.Scan() {
package main
import "fmt"
func main() {
var i interface{} = "hello"
s := i.(string)
fmt.Println(s)
package handler
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
func main() {
u := User{Id: "US123", Balance: 8}
b := new(bytes.Buffer)
json.NewEncoder(b).Encode(u)
res, _ := http.Post("https://httpbin.org/post", "application/json; charset=utf-8", b)
var body struct {
// httpbin.org sends back key/value pairs, no map[string][]string
Headers map[string]string `json:"headers"`
Origin string `json:"origin"`
}
@brpaz
brpaz / main.go
Created March 15, 2019 19:57
#golang
if err != nil {
switch err.(type) {
case *ErrZeroDivision:
fmt.Println(err.Error())
default:
fmt.Println("What the h* just happened?")
}
}
@brpaz
brpaz / example.spec.js
Created March 12, 2019 21:52
#vuejs #testing
import { shallowMount } from '@vue/test-utils';
import HelloWorld from '@/components/HelloWorld.vue';
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message';
const wrapper = shallowMount(HelloWorld, {
propsData: { msg },
});
expect(wrapper.text()).toMatch(msg);
@brpaz
brpaz / .gitlab-ci.yml
Created February 16, 2019 19:08
#gitlab #docker
image: golang:1.11
variables:
TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
RELEASE_CI_REGISTRY: registry.hub.docker.com
RELEASE_IMAGE: $RELEASE_CI_REGISTRY/brpaz/gitlab-mr-commenter:$CI_COMMIT_TAG
RELEASE_IMAGE_LATEST: $RELEASE_CI_REGISTRY/brpaz/gitlab-mr-commenter:latest
stages:
- test
@brpaz
brpaz / Makefile
Last active April 25, 2020 17:09
PROJECT_NAME := "do-snapshot-pruner"
.SHELLFLAGS = -c # Run commands in a -c flag
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
.DEFAULT_GOAL:=help
.PHONY: fmt lint vet test test-cover build-docker release help
@brpaz
brpaz / xdtool.md
Created February 3, 2019 10:42
Set window size with xdtool #xdtool #linux

Set window size with xdtool

Find the window ID:

xdotool search --onlyvisible --name firefox

Set the window size