Skip to content

Instantly share code, notes, and snippets.

View freeformz's full-sized avatar

Edward Muller freeformz

View GitHub Profile
@freeformz
freeformz / README.txt
Created February 1, 2012 20:14
FizzBuzz
Looking for creative FizzBuzziness.....
One per file, all languages accepted.
@freeformz
freeformz / exceptional.io.js
Created February 20, 2012 19:58
DotJS s/h2/pre/
function preify() {
if ( $('#tmplPaging').css('display') == 'none' ) {
setTimeout( preify, 1000);
} else {
$('#offline_occurrences li h2')
.replaceWith(function() { return '<pre>' + $(this).text() + '</pre>' });
}
}
$(document).ready( preify );
@freeformz
freeformz / gist:2866845
Created June 4, 2012 07:06
PL/PGSQL fizzbuzz
CREATE OR REPLACE FUNCTION fizzbuzz()
RETURNS setof text as $$
BEGIN
FOR i IN 1 .. 100 LOOP
IF MOD(i, 15) = 0 THEN
return next 'FizzBuzz';
ELSIF MOD(i, 5) = 0 THEN
return next 'Buzz';
@freeformz
freeformz / gist:3107457
Created July 13, 2012 21:08
My GoTour Exercise #44 (http://tour.golang.org/#44) solution
package main
import (
"fmt"
"math"
)
func sqrt(target, guess float64) float64 {
return guess - (math.Pow(guess, 2)-target)/(2*guess)
}
@freeformz
freeformz / gist:3107723
Created July 13, 2012 21:44
My GoTour Exercise #45 (http://tour.golang.org/#45) solution
package main
import (
"strings"
"code.google.com/p/go-tour/wc"
)
// Maybe strings.Fields is cheating?
func WordCount(s string) map[string]int {
@freeformz
freeformz / gist:3108052
Created July 13, 2012 22:50
My GoTour Exercise #46 (http://tour.golang.org/#46) solution
package main
import (
"code.google.com/p/go-tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
s := make([][]uint8, dy)
for y := range s {
s[y] = make([]uint8, dx)
@freeformz
freeformz / gist:3108146
Created July 13, 2012 23:06
My GoTour Exercise #47 (http://tour.golang.org/#47) solution
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
curr := 0
succ := 1
return func() int {
@freeformz
freeformz / gist:3108235
Created July 13, 2012 23:35
My GoTour Exercise #48 (http://tour.golang.org/#48) solution
package main
import (
"fmt"
"math"
"math/cmplx"
)
func cbrt(target, guess complex128) complex128 {
return guess - (cmplx.Pow(guess, 3)-target)/(3*cmplx.Pow(guess,2))
@freeformz
freeformz / gist:3112361
Created July 14, 2012 17:53
My GoTour Exercise #58 (http://tour.golang.org/#58) solution
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
@freeformz
freeformz / gist:3112430
Created July 14, 2012 18:12
My GoTour Exercise #58b (http://localhost:3999/#58) solution
package main
import (
"net/http"
)
type String string
type Struct struct {
Greeting string