Browse Source

Changed name of ToJSString; added expseq and expanded README

Getty Ritter 10 years ago
parent
commit
f24cb8f087

+ 2 - 2
ToJSString/ToJSString.cabal

@@ -1,7 +1,7 @@
 -- Initial ToJSString.cabal generated by cabal init.  For further 
 -- documentation, see http://haskell.org/cabal/users-guide/
 
-name:                ToJSString
+name:                EscapedString
 version:             0.1.0.0
 -- synopsis:            
 -- description:         
@@ -16,7 +16,7 @@ build-type:          Simple
 cabal-version:       >=1.10
 
 executable ToJSString
-  main-is:             ToJSString.hs
+  main-is:             EscapedString.hs
   build-depends:       base >=4.6 && <4.7, aeson, text, bytestring
   hs-source-dirs:      src
   default-language:    Haskell2010

ToJSString/LICENSE → EscapedString/LICENSE


ToJSString/Setup.hs → EscapedString/Setup.hs


ToJSString/src/ToJSString.hs → EscapedString/src/EscapedString.hs


ToJSString/src/ToJSString.hs~ → EscapedString/src/ToJSString.hs~


+ 34 - 0
README

@@ -0,0 +1,34 @@
+Whatchamacallit
+===============
+
+Miscellaneous command-line utilities to do various small tasks. They're split
+up into different libraries so they can be installed individually, but also
+kept in a single repo because they're all tiny.
+
+All these are licensed under the WTFPL.
+
+RSAPair/
+--------
+
+A single RSAPair executable that produces a hex-encoded public/private key
+pair on stdout. In Haskell; cabalized.
+
+EscapedString/
+-----------
+
+Reads in stdin and produces an escaped string on stdout with surrounding
+quotation marks, in particular by converting it to a JSON string and emitting
+it. In Haskell; cabalized.
+
+YAMLize/
+--------
+
+Two programs, one ToYAML which converts JSON on stdin to YAML on stdout, and
+one FromYAML, which goes vice versa. May not round-trip correctly because of
+the semantics of the GHC Yaml library. In Haskell; cabalized.
+
+expseq/
+-------
+
+A rough analogue of seq for generating exponentially increasing numbers rather
+than sequentially. In C; has Makefile.

+ 10 - 0
expseq/Makefile

@@ -0,0 +1,10 @@
+CC      = gcc
+LDFLAGS = -lm
+
+all: expseq
+
+expseq:
+	$(CC) $(LDFLAGS) expseq.c -o $@
+
+clean:
+	rm -f expseq expseq.o

+ 38 - 0
expseq/expseq.c

@@ -0,0 +1,38 @@
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char* argv[])
+{
+  int fstnum = 0, lstnum;
+  if (argc == 2) {
+	char* endptr = argv[1];
+	lstnum = strtol(argv[1], &endptr, 10);
+	if (!endptr) {
+	  fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[1]);
+	  return 0;
+	}
+  } else if (argc == 3) {
+	char* endptr = argv[1];
+	fstnum = strtol(argv[1], &endptr, 10);
+	if (!endptr) {
+	  fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[1]);
+	  return 0;
+	}
+	endptr = argv[2];
+	lstnum = strtol(argv[2], &endptr, 10);
+	if (!endptr) {
+	  fprintf(stderr, "%s: non-numeric arg: %s\n", argv[0], argv[2]);
+	  return 0;
+	}
+  } else {
+	  fprintf(stderr, "%s: missing operand\n", argv[0]);
+	return 0;
+  }
+  int i = fstnum;
+  while (i <= lstnum) {
+	printf("%d\n", (int) pow(2, (float) i));
+	i++;
+  }
+  return 0;
+}