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 program spins up php-fpm in the background and a Go web server sending | |
// all requests to a PHP router script. | |
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" |
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
-- cabal install MonadRandom | |
-- ghc random_monad_example | |
-- ./random_monad_example | |
-- The code here is stolen from a comment in the MonadRandom source code. | |
import Control.Monad.Random | |
die :: RandomGen g => Rand g Int | |
die = getRandomR (1,6) |
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
#!/usr/bin/env python | |
import argparse | |
import re | |
import sys | |
parser = argparse.ArgumentParser(description= | |
'''Filter some text with a regex, allowing matches to span multiple lines. | |
This tool is based on some ideas from Rob Pike's Sam editor: |
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
;; A concurrent prime sieve translated from | |
;; https://golang.org/doc/play/sieve.go | |
;; by Issac Trotts with help from Chris Murphy and glts on Stack Overflow. | |
(require '[clojure.core.async :as async :refer [<! >! <!! chan go]]) | |
(defn generate-naturals | |
"Sends the sequence 2, 3, 4, ... to channel 'ch'." | |
[ch] | |
(go |
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
#!/usr/bin/env escript | |
%% -*- mode: erlang -*- | |
%%! -smp enable -hidden | |
%% | |
%% A concurrent prime sieve, inspired by the Go prime sieve | |
%% with daisy-chained filter processes. | |
%% https://golang.org/doc/play/sieve.go | |
%% | |
%% Translated by Issac Trotts (2016) | |
%% with help from Amiramix on StackOverflow. |
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" | |
func main() { | |
s := "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := %#v\n\tfmt.Printf(s, s)\n}\n" | |
fmt.Printf(s, 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
// See https://code.google.com/p/go/issues/detail?id=640 | |
package main | |
import "fmt" | |
func main() { | |
args := []int{1, 2, 3} | |
fmt.Println(sum(args...)) | |
} |
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 ( | |
"flag" | |
"fmt" | |
"github.com/elazarl/goproxy" | |
"log" | |
"net/http" | |
"os" | |
) |
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
#!/usr/bin/env runhaskell | |
{-# LANGUAGE TemplateHaskell #-} | |
import Test.QuickCheck ((==>), Property) | |
import Test.QuickCheck.All (quickCheckAll) | |
-- main = interact $ show . checkBalance | |
main = $quickCheckAll | |
checkBalance :: String -> Bool |
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
#!/usr/bin/env runhaskell | |
import Data.List (sort, (\\)) | |
import Test.QuickCheck (Property, (==>)) | |
main = interact (showLn . median . map read . lines) | |
showLn :: Show a => a -> String | |
showLn x = show x ++ "\n" |