This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| """ | |
| Prime Number Manipulation Script | |
| Author : Evander Onyango | |
| Date : 23-09-2014 | |
| More: | |
| For a full list of the first 1000 prime numbers visit | |
| http://primes.utm.edu/lists/small/1000.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.conf import settings | |
| class MultiPortMiddleware(object): | |
| """ | |
| Middleware changes the SESSION_COOKIE_NAME to use the current port in the name | |
| """ | |
| def process_request(self, request): | |
| settings.SESSION_COOKIE_NAME = 'sessionid' + request.META['SERVER_PORT'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # oracle: Start/Stop Oracle Database 11g R2 | |
| # | |
| # chkconfig: 345 90 10 | |
| # description: The Oracle Database is an Object-Relational Database Management System. | |
| # | |
| # processname: oracle | |
| . /etc/rc.d/init.d/functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| z, delta := 1.0, 0.0000001 | |
| for i :=0; i <= 100; i++ { // limit iterations to 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "golang.org/x/tour/pic" | |
| func Pic(dx, dy int) [][]uint8 { | |
| slc := make([][]uint8, dy) | |
| for x := range slc { | |
| slc[x] = make([]uint8, dx) | |
| for y := range slc[x] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "golang.org/x/tour/wc" | |
| "strings" | |
| ) | |
| func WordCount(s string) map[string]int { | |
| wordcount := make(map[string]int) | |
| words := strings.Fields(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| // fibonacci is a function that returns | |
| // a function that returns an int. | |
| func fibonacci() func() int { | |
| a, b := 0, 1 | |
| return func() int { | |
| a, b = b, a+b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type IPAddr [4]byte | |
| // TODO: Add a "String() string" method to IPAddr. | |
| func (this IPAddr) String() string { | |
| return fmt.Sprintf("%d.%d.%d.%d", this[0], this[1], this[2], this[3]) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| type ErrNegativeSqrt float64 | |
| func (e ErrNegativeSqrt) Error() string { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "golang.org/x/tour/reader" | |
| ) | |
| type MyReader struct{} | |
| // TODO: Add a Read([]byte) (int, error) method to MyReader. | |
| func (this MyReader) Read(bytes []byte) (int, error) { |