gdritter repos GRUtils / db21bbe
Changed name of ToJSString; added expseq and expanded README Getty Ritter 10 years ago
13 changed file(s) with 136 addition(s) and 54 deletion(s). Collapse all Expand all
1 -- Initial ToJSString.cabal generated by cabal init. For further
2 -- documentation, see http://haskell.org/cabal/users-guide/
3
4 name: EscapedString
5 version: 0.1.0.0
6 -- synopsis:
7 -- description:
8 -- license:
9 license-file: LICENSE
10 author: Getty Ritter
11 maintainer: gdritter@galois.com
12 -- copyright:
13 category: Codec
14 build-type: Simple
15 -- extra-source-files:
16 cabal-version: >=1.10
17
18 executable ToJSString
19 main-is: EscapedString.hs
20 build-depends: base >=4.6 && <4.7, aeson, text, bytestring
21 hs-source-dirs: src
22 default-language: Haskell2010
1 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 Version 2, December 2004
3
4 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
6 Everyone is permitted to copy and distribute verbatim or modified
7 copies of this license document, and changing it is allowed as long
8 as the name is changed.
9
10 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
13 0. You just DO WHAT THE FUCK YOU WANT TO.
14
1 import Distribution.Simple
2 main = defaultMain
1 module Main where
2
3 import Data.Aeson (Value(String), encode)
4 import Data.ByteString.Lazy.Char8 (putStrLn)
5 import Data.Text.IO (getContents)
6 import Prelude hiding (getContents, putStrLn)
7
8 main = getContents >>= putStrLn . encode . String
1 module Main where
2
3 import Control.Monad ((>=>))
4 import Data.Aeson (Value(String))
5 import Data.Text.IO (getContents)
6 import Prelude hiding (getContents)
7
8 main = getContents >>= putStrLn . show . String
1 Whatchamacallit
2 ===============
3
4 Miscellaneous command-line utilities to do various small tasks. They're split
5 up into different libraries so they can be installed individually, but also
6 kept in a single repo because they're all tiny.
7
8 All these are licensed under the WTFPL.
9
10 RSAPair/
11 --------
12
13 A single RSAPair executable that produces a hex-encoded public/private key
14 pair on stdout. In Haskell; cabalized.
15
16 EscapedString/
17 -----------
18
19 Reads in stdin and produces an escaped string on stdout with surrounding
20 quotation marks, in particular by converting it to a JSON string and emitting
21 it. In Haskell; cabalized.
22
23 YAMLize/
24 --------
25
26 Two programs, one ToYAML which converts JSON on stdin to YAML on stdout, and
27 one FromYAML, which goes vice versa. May not round-trip correctly because of
28 the semantics of the GHC Yaml library. In Haskell; cabalized.
29
30 expseq/
31 -------
32
33 A rough analogue of seq for generating exponentially increasing numbers rather
34 than sequentially. In C; has Makefile.
+0
-14
ToJSString/LICENSE less more
1 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 Version 2, December 2004
3
4 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
6 Everyone is permitted to copy and distribute verbatim or modified
7 copies of this license document, and changing it is allowed as long
8 as the name is changed.
9
10 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
13 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+0
-2
ToJSString/Setup.hs less more
1 import Distribution.Simple
2 main = defaultMain
+0
-22
ToJSString/ToJSString.cabal less more
1 -- Initial ToJSString.cabal generated by cabal init. For further
2 -- documentation, see http://haskell.org/cabal/users-guide/
3
4 name: ToJSString
5 version: 0.1.0.0
6 -- synopsis:
7 -- description:
8 -- license:
9 license-file: LICENSE
10 author: Getty Ritter
11 maintainer: gdritter@galois.com
12 -- copyright:
13 category: Codec
14 build-type: Simple
15 -- extra-source-files:
16 cabal-version: >=1.10
17
18 executable ToJSString
19 main-is: ToJSString.hs
20 build-depends: base >=4.6 && <4.7, aeson, text, bytestring
21 hs-source-dirs: src
22 default-language: Haskell2010
+0
-8
ToJSString/src/ToJSString.hs less more
1 module Main where
2
3 import Data.Aeson (Value(String), encode)
4 import Data.ByteString.Lazy.Char8 (putStrLn)
5 import Data.Text.IO (getContents)
6 import Prelude hiding (getContents, putStrLn)
7
8 main = getContents >>= putStrLn . encode . String
+0
-8
ToJSString/src/ToJSString.hs~ less more
1 module Main where
2
3 import Control.Monad ((>=>))
4 import Data.Aeson (Value(String))
5 import Data.Text.IO (getContents)
6 import Prelude hiding (getContents)
7
8 main = getContents >>= putStrLn . show . String
1 CC = gcc
2 LDFLAGS = -lm
3
4 all: expseq
5
6 expseq:
7 $(CC) $(LDFLAGS) expseq.c -o $@
8
9 clean:
10 rm -f expseq expseq.o
1 #include <math.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 int main(int argc, char* argv[])
6 {
7 int fstnum = 0, lstnum;
8 if (argc == 2) {
9 char* endptr = argv[1];
10 lstnum = strtol(argv[1], &endptr, 10);
11 if (!endptr) {
12 fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[1]);
13 return 0;
14 }
15 } else if (argc == 3) {
16 char* endptr = argv[1];
17 fstnum = strtol(argv[1], &endptr, 10);
18 if (!endptr) {
19 fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[1]);
20 return 0;
21 }
22 endptr = argv[2];
23 lstnum = strtol(argv[2], &endptr, 10);
24 if (!endptr) {
25 fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[2]);
26 return 0;
27 }
28 } else {
29 fprintf(stderr, "%s: missing operand\n", argv[0]);
30 return 0;
31 }
32 int i = fstnum;
33 while (i <= lstnum) {
34 printf("%d\n", (int) pow(2, (float) i));
35 i++;
36 }
37 return 0;
38 }