Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

giving it a little push #4

Open
wants to merge 1 commit into from

7 participants

@iandennismiller

I noticed a printout containing OCaml and I tried to get it working. I also included a readme because I had to learn about OCaml package management in order to run the code, and I thought others might benefit as well.

Thanks.

@yjerem

Ooh, nice work!

@mikaa123

That's great. Thanks!

@iandennismiller

Hopefully a few people can run this tomorrow so we're sure to enjoy _why's next printouts! There may be some benefit to having multiple people run the code simultaneously. Who knows?

@aarondandy

From like four o clock to let's say twelve?

@meowy
@aarondandy

AM or PM?

@meowy
@iandennismiller

I'm assuming NST:

http://en.wikipedia.org/wiki/Newfoundland_Standard_Time_Zone

That's a wild guess, of course, but I'm guessing NST because it's a neat one. No other reason, actually.

Edit: Seriously, it's UTC. The print spool uses YYYY-MM-DDT00:00Z as its data format and I think, according to ISO 8601, the Z indicates it's UTC.

@spro

I considered installing OCaml, but had some tea instead, and ended up with this shell script: https://gist.github.com/spro/5416485

@mntmn

Thanks for sharing! It works great here. I was surprised a few minutes ago by a sudden printout. Fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2013
  1. @iandennismiller
This page is out of date. Refresh to see the latest.
Showing with 96 additions and 0 deletions.
  1. +39 −0 Readme.md
  2. +57 −0 just_let_this_sit.ml
View
39 Readme.md
@@ -0,0 +1,39 @@
+2013-04-16
+Ian Dennis Miller
+
+Transcribed from _why's handwritten-then-scanned printout 'HOMEWORK'
+
+This is an OCaml script that polls a site (e.g. whytheluckystiff.net)
+When it finds something it likes, it'll print it directly with lp
+
+## usage
+
+ ocaml just_let_this_sit.ml http://whytheluckystiff.net
+
+## Getting started on OS X
+
+ brew install ocaml
+ wget http://download.camlcity.org/download/findlib-1.3.3.tar.gz
+ wget http://download.camlcity.org/download/ocamlnet-3.6.3.tar.gz
+
+## This is approximate
+
+ for tgz in (findlib ocamlnet); do \
+ tar xvfz ${tgz}*.tar.gz && cd $tgz && ./configure && make all \
+ && sudo -u admin make install && cd ..; \
+ done
+
+## Notes
+
+So-called "problem 4.18" is probably a reference to April 18. Maybe there will be something to print then?
+
+set your own printer name in *just_let_this_sit.ml* because the default H12230 probably won't work.
+
+if you're not going to be printing the stuff to a real printer, consider the following:
+
+ Sys.command("wget -q -O ./" ^ doc ^ ".pcl " ^ q ^ "/" ^ doc)
+
+
+## Disclaimer
+
+I don't really know OCaml, so this may be buggy.
View
57 just_let_this_sit.ml
@@ -0,0 +1,57 @@
+(*
+ Correct answer to problem 4.18
+*)
+
+#use "topfind";;
+#require "netclient";;
+
+let private_press = "H12230"
+let ppppprint_the q doc =
+ Sys.command("wget -q -O _tmp " ^ q ^ "/" ^ doc);
+ Sys.command("lp -o raw -d " ^ private_press ^ " _tmp")
+
+let sscan_the thisfar q line =
+ let entry = Str.split(Str.regexp "\t") line in
+ let nyman = List.hd entry in
+ if not (Hashtbl.mem thisfar nyman) then
+ let exitid = ppppprint_the q nyman in
+ Printf.printf "NEW %s\n" nyman;
+ Hashtbl.add thisfar nyman (List.nth entry 1)
+
+let hhit_the q =
+ Http_client.Convenience.http_get(q ^ "/index.html")
+
+let wwhat_the q =
+ let thisfar = Hashtbl.create 32 in
+ while true do
+ let index = hhit_the q in
+ let lines = Str.split(Str.regexp "\n") index in
+ List.iter (fun s ->
+ if Str.string_match(Str.regexp "^SPOOL") s 0
+ then sscan_the thisfar q s) lines; Unix.sleep 300
+ done
+
+let _ = match Sys.argv with [| _; q |] -> wwhat_the q
+ | _ -> failwith "come on give me a push here."
+
+(*
+ 2013-04-16 Ian Dennis Miller
+ Transcribed from _why's handwritten-then-scanned printout 'HOMEWORK'
+
+ This is an OCaml script that polls a site (e.g. whytheluckystiff.net)
+ When it finds something it likes, it'll print it directly with lp
+
+ So-called "problem 4.18" is probably a reference to April 18.
+ Maybe there will be something to print then?
+
+ Getting started on OS X; the following is approximate
+
+ brew install ocaml
+ wget http://download.camlcity.org/download/findlib-1.3.3.tar.gz
+ wget http://download.camlcity.org/download/ocamlnet-3.6.3.tar.gz
+
+ for tgz in (findlib ocamlnet); do \
+ tar xvfz ${tgz}*.tar.gz && cd $tgz && ./configure && make all \
+ && sudo -u admin make install && cd ..; \
+ done
+*)
Something went wrong with that request. Please try again.