Skip to content

Instantly share code, notes, and snippets.

@alxerg
alxerg / pprof.md
Created April 22, 2023 20:48 — forked from slok/pprof.md
Go pprof cheat sheet

Enable profiling

Default http server

import (
    _ "net/http/pprof"
    "net/http"
)
@alxerg
alxerg / pubsub.go
Created January 11, 2021 01:58 — forked from miguelmota/pubsub.go
Golang redis pub/sub example
package pubsub
import (
"github.com/garyburd/redigo/redis"
log "github.com/sirupsen/logrus"
)
// Service service
type Service struct {
pool *redis.Pool
@alxerg
alxerg / sse.go
Created July 26, 2019 17:53 — forked from ismasan/sse.go
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@alxerg
alxerg / sonarqube-docker-compose.yml
Created June 28, 2019 07:53 — forked from Warchant/sonarqube-docker-compose.yml
docker-compose file to setup production-ready sonarqube
version: "2"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
@alxerg
alxerg / command.go
Created May 8, 2019 07:14 — forked from riston/command.go
Simple command pattern in Go lang
package main
import "fmt"
type Command interface {
Execute() string
}
type PingCommand struct{}
func (p *PingCommand) Execute() string {
@alxerg
alxerg / tmux-cheatsheet.markdown
Created April 10, 2019 13:52 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@alxerg
alxerg / Makefile
Created August 22, 2018 17:40 — forked from h4cc/Makefile
Ubuntu 18.04 Bionic Beaver - Basic packages i usually install
#
# Ubuntu 18.04 (Bionic Beaver)
#
# Basic packages i usually install.
#
# Author: Julius Beckmann <github@h4cc.de>
#
# Upgraded Script from 17.04: https://gist.github.com/h4cc/09b7fe843bb737c8039ac62d831f244e
# Upgraded Script from 16.04: https://gist.github.com/h4cc/fe48ed9d85bfff3008704919062f5c9b
@alxerg
alxerg / cloudformation-new-vpc.template
Created August 8, 2018 08:04 — forked from lrakai/cloudformation-new-vpc.template
AWS k8s cluster CloudFormation template with VPC (flattened to remove nested stacks)
# Copyright 2017 by the contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@alxerg
alxerg / security-group-cleanup.py
Created August 7, 2018 20:47 — forked from miketheman/security-group-cleanup.py
AWS EC2 Unused Security Group cleanup
#!/usr/bin/env python
import sys
import boto
import pprint
del_flag = ''
if len(sys.argv) > 1:
del_flag = sys.argv[1]
@alxerg
alxerg / main_1.go
Created August 5, 2018 14:34 — forked from pseudomuto/main_1.go
Blog Code: Clean SQL Transactions in Golang
package main
import (
"database/sql"
"log"
)
func main() {
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE")
handleError(err)