Skip to content

Instantly share code, notes, and snippets.

View DavadDi's full-sized avatar

DavadDi DavadDi

View GitHub Profile
package test
import (
"sync"
"testing"
)
var m sync.Mutex
func call() {
@DavadDi
DavadDi / http_graceful_shutdown.go
Last active January 23, 2018 09:55
go_1.8_http_graceful_shutdown
package main
import (
"context"
"fmt"
"html"
"log"
"net/http"
"os"
"os/signal"
@DavadDi
DavadDi / html_template.go
Created February 19, 2017 09:04
html_template.go
package main
import (
"html/template"
"os"
)
type Class struct {
Name string
Value int32
import (
"encoding/base64"
"fmt"
"net/http"
)
type BasicAuthTransport struct {
Username string
Password string
}
@DavadDi
DavadDi / mgoExample.go
Created February 17, 2017 02:00 — forked from border/mgoExample.go
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@DavadDi
DavadDi / iptables.sh
Created November 14, 2016 10:11 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
#! /usr/bin/perl
#
# to test:
# 1) run this script with either "accept" or "select-accept" as the argument
# (the script listens to 127.0.0.1:12345)
# 2) telnet localhost 12345
# 3) if you see "accept failed", there is the thundering herd problem
#
#
use strict;