Skip to content

Instantly share code, notes, and snippets.

View evandertino's full-sized avatar
🎧
In the zone

Evander Otieno evandertino

🎧
In the zone
  • Foursquare
  • Nairobi, Kenya
View GitHub Profile
@evandertino
evandertino / prime_manip.py
Created September 23, 2014 10:29
Prime Number Manipulation Script
#!/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
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']
@evandertino
evandertino / oracle.sh
Last active August 29, 2015 14:14 — forked from aguegu/oracle.sh
#!/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
@evandertino
evandertino / sqrt.go
Last active August 29, 2015 14:18
Go Exercise: Loops and Functions - http://tour.golang.org/flowcontrol/8
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
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] {
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)
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
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])
}
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
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) {