Arc Forumnew | comments | leaders | submitlogin
Show and Tell: elliottslaughter.net
3 points by eds 5973 days ago | 12 comments
Hi everyone,

I finally managed to put up my first arc site! It doesn't look like much, since I haven't gotten around to doing any formatting at all yet. Right now the only things I have up are a bare bones main page and a this random star system generator I hacked together (which I use for my pencil-and-paper, sci-fi RPG).

Thanks's to the great walkthrough at http://plpatterns.blogspot.com/2008/05/arc-news-forum.html, setting up the site wasn't much of a problem. But setting up Apache for the first time was extremely confusing, even with lojic's configuration (http://arclanguage.com/item?id=3486), learning to enable all the required modules was rather slow. (So for the benefit of future noobs, it would be very helpful if someone put up a walkthrough that included Apache installation and configuration.)

Also, antiimist's suggestion of using the screen utility (http://arclanguage.org/item?id=7564), and byronsalty's automatic reloading (http://arclanguage.org/item?id=2739) were extremely helpful.

Although I have managed to figure out how to enable forwarding port 80, I can't find anything on stopping access to port 8080 (so you can still access that port from the internet...). If someone could tell me how to lock that down, I would appreciate it. Thanks in advance.

As I said before, there isn't much on the site yet, but if you want to try the random star system generator, navigate to http://elliottslaughter.net/rand.



2 points by almkglor 5973 days ago | link

> Although I have managed to figure out how to enable forwarding port 80, I can't find anything on stopping access to port 8080 (so you can still access that port from the internet...). If someone could tell me how to lock that down, I would appreciate it. Thanks in advance.

http://arclanguage.org/item?id=2697

-----

1 point by eds 5973 days ago | link

Thanks for the reminder, I had forgotten about that.

I'm still not sure that's a complete solution though... you don't really prevent access to the port, you just send an access denied message instead of serving the request. (But I don't know that much about web security, so maybe that really is sufficient.)

-----

1 point by almkglor 5973 days ago | link

Not sure either. It depends on whether the Arc Server is secure/{not dumb} enough such that it won't be fooled by someone pretending to be from 127.0.0.1 , for example.

-----

1 point by eds 5973 days ago | link

Couldn't you just make Apache or Linux firewall port 8080 so all attempts to access it from outside are blocked? (That said, I wouldn't know how to do that off the top of my head.)

-----

2 points by gnaritas 5971 days ago | link

Yes, and that's the right approach. See http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-p... and scroll down to iptables to see how to setup a firewall on Linux.

-----

1 point by eds 5965 days ago | link

Thanks! That was a really useful article, and not only for setting up firewalls.

-----

2 points by eds 5973 days ago | link

Another thing (which I feel I really ought to already know the answer for...), how do you format floating point numbers (say, to three decimal places)? I could do this trivially with #'format in CL, but I don't see anything in the Arc docs to help me, and I don't know enough about Scheme to hack around it with ($ ...).

-----

2 points by almkglor 5973 days ago | link

Arc doesn't have any.

If it's always N decimal places of a reasonable number, you can do magic stuff like:

  (def to-N-places (f (o N 3))
    (with (fact (let rv 1
                  (repeat N (zap * rv 10))
                  rv)
           float [+ _ 0.0])
      (pr:/ (float:floor:* f fact) (float fact))))
It won't pad though.

-----

3 points by eds 5973 days ago | link

Your version doesn't round.

  arc> (do (to-N-places 5.123456789 5) (prn))
  5.12345
  nil
But the following function will.

  (def to-N-places (f (o N 3))
    (let s (string (to-nearest f (expt 10.0 (- N))))
      (cut s 0 (min (+ N 1 (pos #\. s)) (len s)))))

  arc> (to-N-places 5.123456789 5)
  "5.12346"
(That said, there may be other problems with it.)

Personally, I think we really need CL-style format.

-----

1 point by eds 5969 days ago | link

After a bit more searching, I finally found a page on printing numbers in the scheme cookbook (http://schemecookbook.org/Cookbook/NumberPrinting), specifically the first example which uses SRFI 48 for some basic formatting support (http://srfi.schemers.org/srfi-48/srfi-48.html). The following to works in Anarki/MzScheme 352.

  arc> ($ (require (lib "48.ss" "srfi")))
  #<void>
  arc> (def format args ($ (format ,@args)))
  #<procedure: format>
  arc> (format "~4,4F" (sqrt 2))
  "1.4142"
Enjoy ;-)

-----

2 points by tokipin 5973 days ago | link

'to-nearest might help:

http://arcfn.com/doc/math.html#to-nearest

-----

1 point by eds 5973 days ago | link

  arc> (to-nearest 5.123 .1)
  5.1000000000000005
Um...

-----