Skip to content

Instantly share code, notes, and snippets.

View iamralch's full-sized avatar

Svetlin Ralchev iamralch

View GitHub Profile
@iamralch
iamralch / spec.proto
Created December 17, 2015 08:26
Protocol Buffers Company Example
syntax = 'proto2';
package example;
enum CompanyType {
Private = 17;
Public = 18;
NonProfit = 19;
};
@iamralch
iamralch / spec.pb.go
Created December 17, 2015 08:25
Sample Golang implementation of spec.proto
// Code generated by protoc-gen-go.
// source: spec.proto
// DO NOT EDIT!
/*
Package example is a generated protocol buffer package.
It is generated from these files:
spec.proto
@iamralch
iamralch / golang_pprof.go
Last active June 23, 2020 03:22
A code snippet that demonstrates how to use custom pprof profiles
package main
import (
"bufio"
"fmt"
"net/http"
pprofHTTP "net/http/pprof"
"os"
"runtime/pprof"
"strings"
@iamralch
iamralch / context.go
Created November 20, 2015 13:05
An example that illustrates how to work with https://godoc.org/golang.org/x/net/context
package main
import (
"bufio"
"fmt"
"os"
"strings"
"time"
"golang.org/x/net/context"
@iamralch
iamralch / zipit_keep_hierarchy.go
Created November 20, 2015 09:20
Modification of ZipIt function to keep the directory hierarchy or not
func zipit(source, target string, keepHierarchy bool) error {
zipfile, err := os.Create(target)
if err != nil {
return err
}
defer zipfile.Close()
archive := zip.NewWriter(zipfile)
defer archive.Close()
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified into a gotemplate by Nick Craig-Wood <[email protected]>
// Package list implements a doubly linked list.
//
// To iterate over a list (where l is a *List):
// for e := l.Front(); e != nil; e = e.Next() {
package main
import "fmt"
//go:generate stringer -type=MessageStatus
type MessageStatus int
const (
Sent MessageStatus = iota
Received
package main
//go:generate jsonenums -type=Status
type Status int
const (
Pending Status = iota
Sent
Received
Rejected
//go:generate ffjson $GOFILE
package education
type Student struct {
FirstName string
LastName string
}
type University struct {
Name string
@iamralch
iamralch / gist:c4e883f12be80d815d7f
Last active September 5, 2015 13:16 — forked from richp10/gist:1c367d3c67aec762788e
Secure iptables configuration for coreos ??
// This systemd runs iptables-restore on boot:
[Unit]
Description=Packet Filtering Framework
DefaultDependencies=no
After=systemd-sysctl.service
Before=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore /opt/docker/scripts/iptables/iptables.rules