Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

init

  • Loading branch information...
commit a31176da8e8bf577e111f7e427ce3b1aef34758e 0 parents
Jinjing Wang authored
23 .gitignore
... ... @@ -0,0 +1,23 @@
  1 +*.swp
  2 +*.swo
  3 +*.o
  4 +*.hi
  5 +.searchpath.default.map
  6 +*.pid
  7 +*.fcgi
  8 +
  9 +*.exe
  10 +
  11 +*.log
  12 +
  13 +/public
  14 +/db
  15 +
  16 +/_darcs
  17 +/dist
  18 +
  19 +manifest
  20 +hello
  21 +Main
  22 +
  23 +.nemesis
31 LICENSE
... ... @@ -0,0 +1,31 @@
  1 +Copyright (c) 2009, Jinjing Wang
  2 +
  3 +All rights reserved.
  4 +
  5 +Redistribution and use in source and binary forms, with or without
  6 +modification, are permitted provided that the following conditions are
  7 +met:
  8 +
  9 + * Redistributions of source code must retain the above copyright
  10 + notice, this list of conditions and the following disclaimer.
  11 +
  12 + * Redistributions in binary form must reproduce the above
  13 + copyright notice, this list of conditions and the following
  14 + disclaimer in the documentation and/or other materials provided
  15 + with the distribution.
  16 +
  17 + * Neither the name of Jinjing Wang nor the names of other
  18 + contributors may be used to endorse or promote products derived
  19 + from this software without specific prior written permission.
  20 +
  21 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 Nemesis
... ... @@ -0,0 +1,30 @@
  1 +nemesis = do
  2 +
  3 + clean
  4 + [ "**/*.hi"
  5 + , "**/*.o"
  6 + , "manifest"
  7 + , "main"
  8 + , "nemesis-tmp.*"
  9 + ]
  10 +
  11 +
  12 + desc "prepare cabal dist"
  13 + task "dist" $ do
  14 + sh "cabal clean"
  15 + sh "cabal configure"
  16 + sh "cabal sdist"
  17 +
  18 +
  19 + desc "put all .hs files in manifest"
  20 + task "manifest" $ do
  21 + sh "find . | grep 'hs$' > manifest"
  22 +
  23 +
  24 + desc "start console"
  25 + task "i" (sh "ghci -isrc src/Codec/SnowWhite.hs")
  26 +
  27 + desc "show sloc"
  28 + task "stat" $ do
  29 + sh "cloc -match-f=hs$ --quiet src --no3"
  30 +
4 Setup.lhs
... ... @@ -0,0 +1,4 @@
  1 +#! /usr/bin/env runhaskell
  2 +
  3 +> import Distribution.Simple
  4 +> main = defaultMain
135 changelog.md
Source Rendered
... ... @@ -0,0 +1,135 @@
  1 +2009.10.30
  2 +----------
  3 +
  4 +### Feature
  5 +
  6 +* add remoteHost field
  7 +
  8 +2009.7.15
  9 +---------
  10 +
  11 +### Feature
  12 +
  13 +* new hackCache header using strict bytestrings
  14 +
  15 +2009.5.19
  16 +---------
  17 +
  18 +### Feature
  19 +
  20 +* Use lazy bytestring for performance and hinting utf-8 encoding
  21 +* remove some unused fields
  22 +* use haskell naming convention
  23 +
  24 +2009.4.52
  25 +---------
  26 +
  27 +### Feature
  28 +
  29 +* Remove useless type alias
  30 +
  31 +### Fix
  32 +
  33 +* Default error stream should take utf8 string
  34 +
  35 +
  36 +2009.4.51
  37 +---------
  38 +
  39 +### Feature
  40 +
  41 +* add documentation
  42 +
  43 +2009.4.50
  44 +---------
  45 +
  46 +### Feature
  47 +
  48 +* add version info in default
  49 +
  50 +2009.4.30
  51 +----------
  52 +
  53 +### Feature
  54 +
  55 +* seperate handler from core module
  56 +* seperate contrib from Hack.hs
  57 +* now Hack.hs is only an interface file, where everything links to. This allows me to soft link handler in Hack.Contrib and Hack.Handler in development mode :)
  58 +
  59 +2009.4.29
  60 +-----------
  61 +
  62 +### Fix
  63 +
  64 +* -Wall clean
  65 +
  66 +
  67 +2009.4.28
  68 +-----------
  69 +
  70 +### Fix
  71 +
  72 +* File return status code 200 on success
  73 +
  74 +2009.4.27
  75 +---------
  76 +
  77 +### Fix
  78 +
  79 +* hyena handler show real message ( Safari won't work without this fix )
  80 +
  81 +2009.4.26
  82 +---------
  83 +
  84 +### Fix
  85 +
  86 +* add hyena handler
  87 +
  88 +2009.4.25
  89 +---------
  90 +
  91 +### Featuer
  92 +
  93 +* more middleware
  94 +* hyena handler for simple use server
  95 +
  96 +2009.4.23
  97 +---------
  98 +
  99 +### Feature
  100 +
  101 +* more middleware
  102 + * ContentSize
  103 + * SimpleAccessLogger
  104 +
  105 +* request helper
  106 +
  107 +2009.4.22
  108 +---------
  109 +
  110 +### Feature
  111 +
  112 +* more middleware
  113 + * ContentType
  114 + * RawRouter
  115 + * SimpleRouter
  116 +
  117 +2009.4.21
  118 +------------
  119 +
  120 +### Feature
  121 +
  122 +* demo SimpleRoute middleware
  123 +
  124 +### Fix
  125 +
  126 +* env for kibro adapter
  127 +* homepage in hack.cabal
  128 +
  129 +2009.4.20
  130 +-----------
  131 +
  132 +### Feature
  133 +
  134 +* raw specification
  135 +* shiny kibro hack handler
1  hello.txt
... ... @@ -0,0 +1 @@
  1 +
0  known-issues.md
Source Rendered
No changes.
12 readme.md
Source Rendered
... ... @@ -0,0 +1,12 @@
  1 +Snow White
  2 +==========
  3 +
  4 +encode any binary instance to white space
  5 +
  6 +example
  7 +
  8 + SnowWhite.pack "hello"
  9 + >
  10 +
  11 + SnowWhite.unpack " "
  12 + > hello
31 snow-white.cabal
... ... @@ -0,0 +1,31 @@
  1 +Name: snow-white
  2 +Version: 2009.12.1
  3 +Build-type: Simple
  4 +Synopsis: encode any binary instance to white space
  5 +Description:
  6 +
  7 +
  8 +-- @
  9 +-- SnowWhite.pack "hello"
  10 +-- >
  11 +--
  12 +-- SnowWhite.unpack " "
  13 +-- > hello
  14 +-- @
  15 +
  16 +License: BSD3
  17 +License-file: LICENSE
  18 +Author: Wang, Jinjing
  19 +Maintainer: Wang, Jinjing <nfjinjing@gmail.com>
  20 +Build-Depends: base
  21 +Cabal-version: >= 1.2
  22 +category: Web
  23 +homepage: http://github.com/nfjinjing/snow-white/tree/master
  24 +data-files: readme.md, changelog.md
  25 +
  26 +library
  27 + ghc-options: -Wall
  28 + build-depends: base >= 4 && < 5, mps, bytestring, binary
  29 + hs-source-dirs: src/
  30 + exposed-modules:
  31 + Codec.SnowWhite
33 src/Codec/SnowWhite.hs
... ... @@ -0,0 +1,33 @@
  1 +module Codec.SnowWhite (pack, unpack) where
  2 +
  3 +import Data.Binary
  4 +import Numeric
  5 +import MPS.Env hiding (encode, decode)
  6 +import Prelude ()
  7 +import qualified Data.ByteString.Lazy.Char8 as B
  8 +import Data.Char
  9 +
  10 +c2w, w2c :: Char -> Char
  11 +c2w '0' = ' '
  12 +c2w '1' = '\t'
  13 +c2w _ = error "not 0 or 1"
  14 +
  15 +w2c ' ' = '0'
  16 +w2c '\t' = '1'
  17 +w2c _ = error "not 0 or 1"
  18 +
  19 +b2s, pack :: (Binary a) => a -> String
  20 +b2s = encode > B.unpack > map (ord > (base 2) > rjust 8 '0' > map c2w) > concat
  21 +
  22 +base :: Int -> Int -> String
  23 +base p n = showIntAtBase p intToDigit n ""
  24 +
  25 +from_base :: Int -> String -> Int
  26 +from_base p = readInt p (const True) digitToInt > first > fst
  27 +
  28 +s2b, unpack :: (Binary a) => String -> a
  29 +s2b = select (belongs_to " \t") > in_group_of 8 > map (map w2c > from_base 2 > chr) > B.pack > decode
  30 +
  31 +
  32 +pack = b2s
  33 +unpack = s2b
0  src/Main.hs
No changes.

0 comments on commit a31176d

Please sign in to comment.
Something went wrong with that request. Please try again.