Commits

Miki Tebeka committed 0d1c0c9

weekly

  • Participants
  • Parent commits 20dd35f

Comments (0)

Files changed (8)

 	"bufio"
 	"flag"
 	"fmt"
+	"io"
 	"os"
 )
 
 	if filename == "-" {
 		file = os.Stdin
 	} else {
-		var err os.Error
+		var err error
 		file, err = os.Open(filename)
 		if err != nil {
 			panic(fmt.Sprintf("error: can't open %s", filename))
 	}
 
 	lnum := uint64(0)
-	for _, filename := range(files) {
+	for _, filename := range files {
 		file := open(filename)
 		for {
-			lnum ++
+			lnum++
 			buf, err := file.ReadBytes('\n')
-			if err == os.EOF {
+			if err == io.EOF {
 				break
 			}
 			if err != nil {
 				panic(fmt.Sprintf("%s error - %v", filename, err))
 			}
-			if (*lineNums) {
+			if *lineNums {
 				fmt.Printf("%5d %s", lnum, buf)
 			} else {
 				fmt.Printf("%s", buf)
 package main
 
 import (
-	"big"
 	"flag"
 	"fmt"
+	"math/big"
 	"os"
 	"strconv"
 )
 		os.Exit(1)
 	}
 
-	n, err := strconv.Atoi64(flag.Arg(0))
+	n, err := strconv.ParseInt(flag.Arg(0), 10, 64)
 	if err != nil {
 		fmt.Println("error: bad number -", flag.Arg(0))
 		os.Exit(1)
 package main
 
 import (
-	"big"
 	"flag"
 	"fmt"
+	"math/big"
 	"os"
 	"strconv"
 )
 
 import (
 	"fmt"
-	"http"
+	"net/http"
 )
 
 func handler(w http.ResponseWriter, r *http.Request) {
 
 import (
 	"fmt"
-	"http"
 	"io/ioutil"
+	"net/http"
 	"regexp"
 )
 
 	"flag"
 	"fmt"
 	"net"
-	"netchan"
+	"old/netchan"
 	"os"
 	"time"
 )
 
-
 func server() {
-	out := make(chan int64)
+	out := make(chan time.Time)
 
 	exporter := netchan.NewExporter()
 	exporter.Export("seconds", out, netchan.Send)
 	exporter.ListenAndServe("tcp", ":5959")
 
 	for {
-		out <- time.Seconds()
+		out <- time.Now()
 		time.Sleep(1e9)
 	}
 
 	}
 
 	importer := netchan.NewImporter(conn)
-	in := make(chan int64)
+	in := make(chan time.Time)
 	if err := importer.Import("seconds", in, netchan.Recv, -1); err != nil {
 		panic("can't import")
 	}
 
 import (
 	"bytes"
-	"container/vector"
-	"exec"
 	"fmt"
+	"io"
 	"log"
-	"os"
+	"os/exec"
+
 	"sort"
 	"strconv"
 	"strings"
 )
 
-func keys(m map[int]*vector.IntVector) []int {
+type IntVector []int
+
+func (iv *IntVector) Len() int {
+	return len(*iv)
+}
+
+func (iv *IntVector) Less(i, j int) bool {
+	return (*iv)[i] < (*iv)[j]
+}
+
+func (iv *IntVector) Swap(i, j int) {
+	(*iv)[i], (*iv)[j] = (*iv)[j], (*iv)[i]
+}
+
+func keys(m map[int]*IntVector) []int {
 	keys := make([]int, len(m))
 	i := 0
 	for k, _ := range m {
 	}
 
 	reader := bytes.NewBuffer(out)
-	ps := make(map[int]*vector.IntVector)
+	ps := make(map[int]*IntVector)
 	// Skip Header
 	_, err = reader.ReadBytes('\n')
 	if err != nil {
 	for {
 		line, err := reader.ReadString('\n')
 		if err != nil {
-			if err != os.EOF {
+			if err != io.EOF {
 				log.Fatalf("unknown error - %s", err)
 			}
 			break
 		children := ps[parent_pid]
 
 		if children == nil {
-			children = new(vector.IntVector)
+			children = new(IntVector)
 			ps[parent_pid] = children
 		}
 
 		child_pid, _ := strconv.Atoi(fields[0])
-		children.Push(child_pid)
+		*children = append(*children, child_pid)
 	}
 
 	pids := keys(ps)
 		sort.Sort(children)
 		fmt.Printf("Pid %d had %d children: [", pid, children.Len())
 		for i := 0; i < children.Len(); i++ {
-			fmt.Printf("%d", children.At(i))
+			fmt.Printf("%d", (*children)[i])
 			if i < (children.Len() - 1) {
 				fmt.Printf(", ")
 			}
 
 import (
 	"archive/zip"
-	"csv"
+	"encoding/csv"
 	"fmt"
+	"io"
 	"os"
 	"strconv"
 )
 	var num_impressions uint64
 	for {
 		record, err := reader.Read()
-		if err == os.EOF {
+		if err == io.EOF {
 			break
 		}
-		value, err := strconv.Atoui64(record[1])
+		value, err := strconv.ParseUint(record[1], 10, 64)
 		if err != nil {
 			continue
 		}