This file contains 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" | |
) | |
// square root function using Newton's method | |
func Sqrt(x float64) float64 { | |
z := 1.0 |
This file contains 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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
slicePic := make([][]uint8, dy) | |
for y := range slicePic { | |
slicePic[y] = make([]uint8, dx) | |
for x := range slicePic[y] { | |
slicePic[y][x] = uint8(x ^ y) |
This file contains 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 ( | |
"code.google.com/p/go-tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
wordCount := make(map[string]int) | |
for _, word := range strings.Fields(s) { |
This file contains 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 { | |
// we use seed values of F_−2 and F_−1 | |
// that way the first fibonacci number returned will be F_0 | |
a, b := -1, 1 |
This file contains 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/cmplx" | |
) | |
func Cbrt(x complex128) complex128 { | |
z := complex(1.0, 0) | |
for cmplx.Abs(z*z*z-x) > 1e-9 { |
This file contains 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
var fs = require('fs') | |
fs.readFile('words-da', function(err, data) { | |
if(err) throw err | |
var array = data.toString().split("\n") | |
var avl = {} | |
for(i in array) { | |
avl[array[i]] = 1 |
This file contains 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
;; This is free and unencumbered software released into the public domain. | |
;; Assume nothing works, and you may be pleasantly surprised; and when it breaks, you get to keep both pieces. | |
;; A Simple macro that enables you to change your testing groups to pending | |
(defmacro pending [name & body] | |
(let [message (str "\n" name " is pending !!")] | |
`(testing ~name (println ~message)))) |
This file contains 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
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.List; | |
public class Main { | |
private static int getNode(int i, int j) { | |
return i * 1000 + j; | |
} |
This file contains 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
# This is free and unencumbered software released into the public domain. | |
# Assume nothing works, and you may be pleasantly surprised; and when it breaks, you get to keep both pieces. | |
wget http://someonewhocares.org/hosts/zero/hosts && \ | |
echo "127.0.0.1 $(cat /etc/hostname)" >> hosts && \ | |
sudo cp /etc/hosts /etc/hosts.bak && \ | |
sudo mv hosts /etc/hosts && \ | |
grep --color=auto "Last updated" /etc/hosts |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<!--This is free and unencumbered software released into the public domain.--> | |
<title>Recover private key</title> | |
<script src="https://cdn.rawgit.com/bitwiseshiftleft/sjcl/1.0.3/sjcl.js"></script> | |
<script> | |
function submit() { | |
var id = document.getElementsByTagName('input')[0].value; |
OlderNewer