Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
TerrorJack / gist:a61e9515a0320e7d4a4b
Created November 22, 2014 15:12
FP-style list in C++11
#include <memory>
#include <iostream>
template <typename T>
struct _list;
template <typename T>
using list = std::shared_ptr<_list<T>>;
template <typename T>
struct _list {
@TerrorJack
TerrorJack / gist:1fc8f0eb8a8a45f78f14
Last active August 29, 2015 14:10
Memoization in haskell
fib :: Int -> Integer
fib = head . makefib where
makefib 0 = [0]
makefib 1 = [1,0]
makefib n = (head nextfib + head (tail nextfib)):nextfib where nextfib = makefib $ n - 1
main :: IO ()
main = print $ fib 1000
@TerrorJack
TerrorJack / gist:224b21657cc82f079413
Created December 19, 2014 09:34
Call-by-value lambda calculus interpreter (which won't work)
import qualified Data.Map as Map
type Env = Map.Map String Term
data Term =
VarTerm String
| IntTerm Int
| BoolTerm Bool
| LambdaTerm String Term
| AppTerm Term Term
@TerrorJack
TerrorJack / webproxy.json
Created March 14, 2015 07:17
Web proxies. Keys are domains, values indicate country, software and SSL support.
{"0010freeproxy.info": ["DE", "Glype", false], "0013freeproxy.info": ["DE", "Glype", false], "0021freeproxy.info": ["DE", "Glype", false], "007browser.info": ["US", "Glype", false], "123anonymous.com": ["US", "Glype", false], "1774.info": ["US", "Glype", false], "1agent.info": ["US", "Glype", false], "1block.info": ["US", "Glype", false], "1catch.info": ["US", "Glype", false], "1close.info": ["US", "Glype", false], "1closed.info": ["US", "Glype", false], "1force.info": ["US", "Glype", false], "1good.info": ["US", "Glype", false], "1lazy.info": ["US", "Glype", false], "1mesh.info": ["US", "Glype", false], "1proxy.us": ["US", "PHProxy", true], "1total.info": ["US", "Glype", false], "2999.info": ["US", "Glype", false], "2action.info": ["US", "Glype", false], "2closed.info": ["US", "Glype", false], "2fastsurfer.eu": ["US", "Glype", false], "2fix.info": ["US", "Glype", false], "2g23.com": ["US", "Glype", false], "2g34.com": ["US", "Glype", false], "2gram.info": ["US", "Glype", false], "2insta.info": ["US", "Glype"
@TerrorJack
TerrorJack / icfp.json
Created March 25, 2015 16:43
some acm data for fun.
This file has been truncated, but you can view the full file.
{
"event_title": "International Conference on Functional Programming",
"event_contents": [
{
"conference_title": "Commercial Users of Functional Programming",
"conference_contents": [
{
"proceeding_title": "CUFP '10:ACM SIGPLAN Commercial Users of Functional Programming",
"proceeding_contents": [
{
@TerrorJack
TerrorJack / gist:95a964c649c325c8bf87
Last active August 29, 2015 14:22
A minimal PEG parsing library.
import Control.Applicative
import Control.Monad.State
import Data.Char
import Data.Function
type Parser = StateT String Maybe
parse :: Parser a -> String -> Maybe (a,String)
parse = runStateT
@TerrorJack
TerrorJack / gist:7844978a7db17d836d18
Last active August 29, 2015 14:22
By now, only fibState works. All other functions cause memory overflow.
{-
Different ways to implement Fibonacci function in Haskell.
F(0)=0 F(1)=1 F(n)=F(n-1)+F(n-2)
-}
import Control.Monad.State.Strict
import Control.Monad.ST.Strict
import Data.STRef.Strict
import System.TimeIt
@TerrorJack
TerrorJack / gist:1f1cb2e6f9cd93a8bed0
Last active August 29, 2015 14:22
A simple concurrent crawler in Haskell.
{-# OPTIONS_GHC -Wall -O2 -threaded -with-rtsopts="-N" #-}
import Control.Concurrent
import Control.Concurrent.Async.Pool
import Data.ByteString.Lazy hiding (replicate)
import Network.HTTP.Client
import Network.HTTP.Client.TLS
getConcurrently :: [String] -> IO [ByteString]
getConcurrently urls = withManager tlsManagerSettings $ \mgr ->
@TerrorJack
TerrorJack / gist:f1c5e26dab474927c756
Last active August 29, 2015 14:23
Haskell blogs worth reading

Haskell blogs worth reading

This is a (hopefully) short list of Haskell blogs I consider worth reading for intermediate Haskellers.

* Technical choice: use HTML5.
*
* Portability to multiple platforms(resolutions) are great concerns
* Serve contents online (like Kancolle); opens potential for updating, user-login, and many more
* For traditional offline galgames, start a local server and use a browser
* Markup format for scripts
*
* Use XML markup for manuscripts; compile/dynamic load, reference HTML5 slides framework like impress.js