Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
)
type Value struct {
Name string
Value interface{}
@serverhorror
serverhorror / gist:3379719
Created August 17, 2012 15:12
Debian Repository Structure...
deb http://ftp.de.debian.org/debian/ wheezy main non-free contrib
# http://ftp.de.debian.org/debian/${DIST}/${COMPONENT}/${TYPE}-${ARCH}/Packages.gz
# DIST="stable"|"wheezy"|"unstable"|"testing"
# COMPONENT="main"|"non-free"|"contrib"
# TYPE="binary-${ARCH}"
# ARCH="amd64"|"i386"
deb-src http://ftp.de.debian.org/debian/ wheezy main non-free contrib
# http://ftp.de.debian.org/debian/${DIST}/${COMPONENT}/${TYPE}/Packages.gz
func RecordTime(start time.Time) {
pc, _, _,ok := runtime.Caller(0)
caller := runtime.FuncForPC(pc)
elapsed := time.Since(start)
if ok {
log.Printf("Function `%s` took `%s`",
caller.Name(), elapsed)
} else {
log.Printf("UNKNOWN Function took `%s`", elapsed)
}
import socket
import paramiko
import multiprocessing
import logging
import sys
import netaddr
import json
from datetime import datetime
# logging.basicConfig(
def fib(max):
a, b = 1, 2
while a<max:
yield a
a, b = b, a + b
def even(n):
if n%2==0: return True
return False
sum(filter(even, fib(4000000)))
def test(n):
if n%3==0: return True
if n%5==0: return True
return False
sum(filter(test, range(1000)))
@serverhorror
serverhorror / mdserv
Created April 11, 2014 18:47 — forked from smoser/mdserv
#!/usr/bin/python
"""
To use this to mimic the EC2 metadata service entirely, run it like:
# where 'eth0' is *some* interface. if i used 'lo:0' i got 5 second or so delays on response.
sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255
sudo ./mdserv 169.254.169.254:80
Then:
wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo
curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"code.google.com/p/go.crypto/openpgp/armor"
"fmt"
"io/ioutil"
"log"
)

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

@serverhorror
serverhorror / main.go
Created June 2, 2014 17:21
(Some) Linux HW Info with golang
package main
import (
"encoding/json"
"fmt"
"log"
"net"
)
func main() {