Skip to content

Instantly share code, notes, and snippets.

@drewolson
drewolson / reflection.go
Last active November 20, 2023 09:39
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@eliasnogueira
eliasnogueira / gist:5340507
Last active December 14, 2022 16:01
Diferença entre Smoke e Acceptance Test num contexto ágil

Hoje um colaborador da lista sobre Teste de Software [DFTestes] (http://br.groups.yahoo.com/group/DFTestes/) perguntou em uma thread sobre PhantomJS qual era a difernça entre Smoke Test e Acceptance Test. Ai resolvi responder. Como a lista é somente de acesso aos usuários registrados, estou colocando um resumo, na minha ótica, a diferença entre eles:

Dentro de um contexto ágil nós temos uma separação clara do que é smoke test e o que é teste de aceitação.

  • Smoke Test: conjunto de testes (bem menor do que o conjunto de teste de aceitaçaõ, que vai configurar posteriormente em uma regressão) com o intuito de validar se os pontos maisimportantes da aplicação continuam funcionando após as alterações.

  • Teste de Aceitação: São os testes funcionais que conhecemos. Em um contexto ágil eles são chamados de aceitação ao invés de funcional, pela ótica que adotamos a estes testes, que vão tanto validar a aplicação funcionalmente como validar também da ótica de um usuário (fazer uma venda completa, por exemplo). Este

@enaeseth
enaeseth / objectid_to_uuid.py
Created June 12, 2013 19:29
Convert a MongoDB ObjectID to a valid, semantically similar UUID.
"""
Convert a MongoDB ObjectID to a version-1 UUID.
Python 2.7+ required for datetime.timedelta.total_seconds().
ObjectID:
- UNIX timestamp (32 bits)
- Machine identifier (24 bits)
- Process ID (16 bits)
- Counter (24 bits)
@ruda
ruda / listchars.vim
Last active March 5, 2024 09:00
Vim: listchars samples
set listchars=tab:→\ ,trail:␣,extends:…,eol:⏎
set listchars=tab:→\ ,trail:␣,precedes:«,extends:»,eol:⏎
set listchars=tab:→\ ,trail:·,precedes:«,extends:»,eol:¶
set listchars=tab:‣\ ,trail:·,precedes:«,extends:»,eol:¬
set listchars=tab:␋\ ,trail:␠,precedes:«,extends:»,eol:␤
set listchars=tab:>-,trail:.,precedes:<,extends:>,eol:$
@vodolaz095
vodolaz095 / NumberOfTheWeekInMonth.go
Created February 19, 2016 15:33
Get the number of the week in Golang
package main
import(
"fmt"
"time"
)
func NumberOfTheWeekInMonth(now time.Time) int {
beginningOfTheMonth := time.Date(now.Year(), now.Month(), 1, 1, 1, 1, 1, time.UTC)
_, thisWeek := now.ISOWeek()
@threeaccents
threeaccents / openbrowser.go
Created February 25, 2016 18:55
open chrome browser with golang function
// openBrowser tries to open the URL in a browser,
// and returns whether it succeed in doing so.
func openBrowser(url string) bool {
var args []string
switch runtime.GOOS {
case "darwin":
args = []string{"open"}
case "windows":
args = []string{"cmd", "/c", "start"}
default:
@turtlemonvh
turtlemonvh / README.md
Last active November 9, 2022 17:51
Golang Equal JSON Strings

JSON string equality

A little utility for testing if 2 json strings are equal, for use in tests.

Example

go run main.go '{"dog": 5, "cat": 3}' '{"cat":3, "dog": 5}'

Caveats

@CMCDragonkai
CMCDragonkai / nix_string_and_path_concatenation.md
Last active May 17, 2024 17:37
Nix: String and Path Concatenation #nix #nixos

Nix String and Path Concatenation

From Bas van Dijk:

To understand these things I would recommend using nix-repl:

$ nix-repl
Welcome to Nix version 1.11.2. Type :? for help.
@kalharbi
kalharbi / httprouter-middleware-example.go
Last active May 27, 2022 01:42
Example of using a middleware with [httprouter](https://github.com/julienschmidt/httprouter)
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
// The type of our middleware consists of the original handler we want to wrap and a message
@miztiik
miztiik / python-scrapy-install-centos.sh
Last active March 3, 2021 04:16
Installing scrapy in CentOS
# Install deltarpm to reduce the size of download
yum install -y deltarpm \
&& yum install -y python-pip \
&& pip install --upgrade pip
# Scrapy Pre-Requisites
yum install -y gcc libffi-devel python-devel openssl-devel
yum install -y libxslt-devel libxml++-devel libxml2-devel
pip install lxml incremental