Browse Source

Misc deletions and restructuring

Getty Ritter 7 years ago
parent
commit
cce3212210

+ 0 - 14
RSAPair/LICENSE

@@ -1,14 +0,0 @@
-            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
-                    Version 2, December 2004
-
- Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
-
- Everyone is permitted to copy and distribute verbatim or modified
- copies of this license document, and changing it is allowed as long
- as the name is changed.
-
-            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. You just DO WHAT THE FUCK YOU WANT TO.
-

+ 0 - 16
RSAPair/RSAPair.cabal

@@ -1,16 +0,0 @@
-name:                RSAPair
-version:             0.1.0.1
-license:             OtherLicense
-license-file:        LICENSE
-author:              Getty Ritter
-maintainer:          gdritter@galois.com
-category:            Codec
-build-type:          Simple
-cabal-version:       >=1.10
-
-executable rsa-pair
-  main-is:             RSAPair.hs
-  build-depends:       base >=4.6 && <4.8,
-                       bytestring, binary, DRBG, crypto-api, RSA
-  hs-source-dirs:      src
-  default-language:    Haskell2010

+ 0 - 2
RSAPair/Setup.hs

@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain

+ 0 - 27
RSAPair/src/RSAPair.hs

@@ -1,27 +0,0 @@
-module Main where
-
-import           Codec.Crypto.RSA
-import           Crypto.Random
-import           Crypto.Random.DRBG
-import           Data.Binary
-import qualified Data.ByteString.Lazy as BS
-import           Numeric (showHex)
-import           System.Environment (getArgs)
-import           System.IO (hPutStrLn, stderr)
-
-toHex :: (Binary a) => a -> String
-toHex = concat . map (flip showHex "") . BS.unpack . encode
-
-main :: IO ()
-main = do
-  args <- getArgs
-  let size = case args of (s:_) -> read s
-                          _     -> 1024
-  hPutStrLn stderr ("Generating key pair of size " ++ show size)
-  (pub, priv) <- genPair size
-  putStrLn ("pub: " ++ toHex pub)
-  putStrLn ("priv: " ++ toHex priv)
-
-genPair :: Int -> IO (PublicKey, PrivateKey)
-genPair size = go `fmap` (newGenIO :: IO HashDRBG)
-  where go g = let (pub, priv, _) = generateKeyPair g size in (pub, priv)

+ 1 - 3
json2bencode/json2bencode.cabal

@@ -12,9 +12,7 @@ cabal-version:       >=1.10
 
 executable json2bencode
   main-is:             Main.hs
-  -- other-modules:       
-  -- other-extensions:    
-  build-depends:       base >=4.8 && <4.9,
+  build-depends:       base,
                        aeson,
                        bencode,
                        bytestring,

+ 0 - 32
json2bencode/stack.yaml

@@ -1,32 +0,0 @@
-# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
-
-# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
-resolver: lts-3.19
-
-# Local packages, usually specified by relative directory name
-packages:
-- '.'
-
-# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
-extra-deps: []
-
-# Override default flag values for local packages and extra-deps
-flags: {}
-
-# Extra package databases containing global packages
-extra-package-dbs: []
-
-# Control whether we use the GHC we find on the path
-# system-ghc: true
-
-# Require a specific version of stack, using version ranges
-# require-stack-version: -any # Default
-# require-stack-version: >= 0.1.4.0
-
-# Override the architecture used by stack, especially useful on Windows
-# arch: i386
-# arch: x86_64
-
-# Extra directories used by stack for building
-# extra-include-dirs: [/path/to/dir]
-# extra-lib-dirs: [/path/to/dir]

+ 38 - 0
scripts/dir2yaml

@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+import os
+import sys
+import json
+import yaml
+
+
+def die(msg, *args):
+    sys.stderr.write(msg + '\n', *args)
+    sys.exit(99)
+
+
+def load_dir(dir_name):
+    if not os.path.isdir(dir_name):
+        die("{0} is not a directory", dir_name)
+    else:
+        return dict((path, load_elem(os.path.join(dir_name, path)))
+                    for path in os.listdir(dir_name) if path[0] != '.')
+
+
+def load_elem(path):
+    if os.path.isdir(path):
+        return load_dir(path)
+    else:
+        with open(path) as f:
+            content = f.read()
+        try:
+            return json.loads(content)
+        except ValueError:
+            return content.strip()
+
+if __name__ == '__main__':
+    if sys.argv[1:]:
+        dir_name = sys.argv[1]
+    else:
+        dir_name = os.getcwd()
+    yaml.dump(load_dir(dir_name), sys.stdout)

+ 2 - 4
scripts/ghci-with

@@ -39,7 +39,5 @@ cat >>$DIR/$PKG.cabal <<EOF
 EOF
 
 cd $DIR
-cabal sandbox init
-cabal install
-cabal configure
-exec cabal repl
+cabal new-build
+exec cabal new-repl

+ 40 - 0
scripts/yaml2dir

@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+import os
+import sys
+import json
+import yaml
+
+
+def die(msg, *args):
+    sys.stderr.write(msg + '\n', *args)
+    sys.exit(99)
+
+
+def emit(datum, root='./'):
+    if type(datum) is not dict:
+        die("Unexpected type: {0} of type {1}", datum, type(datum))
+    else:
+        for key, val in datum.items():
+            if type(val) is dict:
+                new_root = os.path.join(root, key)
+                os.makedir(new_root)
+                emit(val, root=new_root)
+            elif type(val) is list:
+                die("Cannot serialize lists: {0}", datum)
+            elif type(val) is str or type(val) is unicode:
+                with open(os.path.join(root, key), 'w') as f:
+                    f.write(val)
+                    f.write('\n')
+            else:
+                with open(os.path.join(root, key), 'w') as f:
+                    json.dump(val, f)
+                    f.write('\n')
+
+if __name__ == '__main__':
+    if sys.argv[:1] and sys.argv[1] != '-':
+        with open(sys.argv[1]) as f:
+            datum = yaml.load(f)
+    else:
+        datum = yaml.load(sys.stdin)
+    emit(datum)