Skip to content

Instantly share code, notes, and snippets.

@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@netojoaobatista
netojoaobatista / cielo.sh
Last active November 4, 2020 12:30
Instalação dos certificados Cielo em servidores Linux
#!/bin/bash
if [ $EUID != 0 ]; then
echo 'Você precisa ser root para instalar certificados.'
exit $?
fi
# Diretório onde os certificados serão instalados
cert_path=`openssl version -d|sed 's/.*\"\(.*\)\"/\1/g'`/certs
# Path para o certificado da Cielo
@honkskillet
honkskillet / byte-sizetuts.md
Last active August 22, 2024 14:19
A series of golang tutorials with youtube videos.
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@alganet
alganet / md.md
Last active March 19, 2018 11:55
Non-Fluent Respect\Validation

Non-Fluent Respect\Validation

Hi! I'm one of the developers of Respect\Validation and other less known Respect components. Feel free to ask any questions here or on reddit.

There are many micro-frameworks that rely on magic methods. We don't. In this article I'm gonna explore the Respect\Validation API without fluent interfaces or magic methods. I'll use a traditional dependency injection approach.

The following validator was inspired by one of our README examples:

@stof
stof / FeatureContext.php
Created December 29, 2014 08:44
Accessing other contexts in Behat 3
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
class FeatureContext implements Context {
private $subContext;
/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope)
@adionditsak
adionditsak / RELK.sh
Last active February 21, 2021 04:25
Install the ELK stack (with Redis) with one script for the central log server (CentOS 6.5).
#/bin/bash
##########################################################
### INTRODUCTION
##########################################################
: '
Install and configure R (Redis) + ELK server from scratch on CentOS 6.5.
* Logstash version 1.4.2
* Elasticsearch version 1.3.2
@homburg
homburg / my-go-service.conf
Last active January 4, 2019 21:09
Golang upstart init script (from githbucket.org/kardianos/service)
# /etc/init/my-go-service.conf
# My go service
description "My go service"
env DAEMON=/usr/local/bin/my-go-service
env NAME=my-go-service
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
@Kartones
Kartones / postgres-cheatsheet.md
Last active April 18, 2025 10:32
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@augustohp
augustohp / custom-respect-validation-rules.md
Last active March 24, 2022 17:24
How to create custom Respect\Validation rules.

Custom rules on Respect/Validation

You may not know that [the most awesome validation engine for PHP][1] out there is [Respect/Validation][2]. If you do, this is tailored for you!

All rules on [Respect/Validation][2] are meant to be used together, composing a more complex validation rule that is closer to the domain of your application than the existing ones, let's try an example: