Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

4chan CL interface

Name: Anonymous 2009-10-19 17:01


; incomplete

(defvar +DEFAULT-SERVER+ "dis")
(defvar +DEFAULT-BOARD+ "prog")

(defstruct post-profile
  (name "Anonymous" :type string)
  (e-mail "" :type string)
  (signature (lambda (&optional profile) (declare (ignore profile))))
  (post-count 0)
  (posts ()))

(defvar *default-post-profile*
  (make-post-profile))                                                                                                                                                             

(defun thread-info (line)
  "Return the information extracted from subject.txt"
  (remove-if (lambda (x)
               (zerop (length x)))
             (cl-ppcre:split "<>" line)))

(defun num-to-str (num)
  (if (stringp num)
      num
      (write-to-string num)))

(defmacro with-thread ((&rest names) line &body body)
  `(destructuring-bind `,(,@names &rest ,(gensym))
       (thread-info ,line)
     ,@body))

(defun server-link (&optional (server +DEFAULT-SERVER+) (domain "4chan.org"))
  "Return link to a suitable HTTP link to the domain/ip"
  (concatenate 'string
               "http://" server "." domain))

(defun thread-link (&key (id nil) (server +DEFAULT-SERVER+)
                    (bbs +DEFAULT-BOARD+) (post-number ""))
  (concatenate 'string
               (server-link server)
               (if id
                   (concatenate 'string
                                "read/" bbs "/" id "/"
                                (num-to-str post-number))
                   (concatenate 'string "/" bbs))))

(defmacro 4chan-post (bbs id name e-mail comment &optional subject)
  (if subject
      `'(("bbs" . ,bbs)
         ("id" . ,id)
         ("schiichan" . "proper2")
         ("subj" . ,subject)
         ("kotehan" . ,name)
         ("meiru" . ,e-mail)
         ("com" . ,comment))
      `'(("bbs" . ,bbs)
         ("id" . ,(num-to-str id))
         ("schiichan" . "proper2")
         ("kotehan" . ,name)
         ("meiru" . ,e-mail)
         ("com" . ,comment))))

(defun new-comment (id comment &key (bbs +DEFAULT-BOARD+)
                    (server +DEFAULT-SERVER+) (post-profile *default-post-profile*))
  "Make a new comment (post)."
  (declare (ignore bbs post-profile id comment))
  (drakma:http-request (concatenate 'string
                                    (server-link server)
                                    "/post")
                       :method :post
                       :content-length t
                       :parameters
                       (4chan-post bbs id
                                   (post-profile-name post-profile)
                                   (post-profile-e-mail post-profile)
                                   (concatenate 'string
                                                comment
                                                (funcall post-profile-signature
                                                         post-profile)))))

(defun new-thread (subject comment &key (bbs +DEFAULT-BOARD+)
                   (server +DEFAULT-SERVER+) (post-profile *default-post-profile*))
  (declare (ignore bbs post-profile comment subject))
  (let ((index-page (get-page)))
    (declare (ignore index-page))
    (drakma:http-request (concatenate 'string
                                      (server-link server)
                                      "/post")
                         :method :post
                         :content-length t
                         :parameters
                         (4chan-post bbs index-page
                                     (post-profile-name post-profile)
                                     (post-profile-e-mail post-profile)
                                     comment subject))))

Name: Anonymous 2009-10-19 18:34

GTFO

Name: Anonymous 2009-10-19 19:59

>>1
You should expose this as a REST service

Name: Anonymous 2009-10-19 20:29

I AM INTRIGUED IN THIS SOURCE'S PROCEDURE

Name: Anonymous 2009-10-19 21:16

Now how about a CL progscrape?

Name: Anonymous 2009-10-20 2:25

1. Write C library
2. Use FFI
3. ???
4. Profit!

Name: discount MBT 2010-02-22 20:52

http://www.unbootssale.com

----------------------------------------------
----------------------------------
http://www.unbootssale.com MBT shoes store
http://www.unbootssale.com MBT shoes clearance
http://www.unbootssale.com cheap MBT shoes
http://www.unbootssale.com buy MBT shoes is nol onger imagination.here is a excited place

Name: Anonymous 2010-02-22 23:24

(defparameter *DEFAULT-SERVER* "dis")
(defparameter *DEFAULT-BOARD* "prog")

FTFY

Name: Anonymous 2010-02-22 23:30

>>8
Do you mean DEFCONSTANT

Name: Anonymous 2010-02-23 1:01

>>9
DEFCONSTANT considered harmful

Name: Anonymous 2010-02-23 3:49

>>10
[b]write a[\b] macro instead

Name: Anonymous 2010-02-23 3:51

>>10
I blame SBCL(or more correctly the ANSI comittee for defining  defconstant that way):
http://www.sbcl.org/manual/Defining-Constants.html

Name: Anonymous 2010-02-23 7:45

>>12
is the committee due to ever meet again?

Name: Anonymous 2010-02-23 7:58

>>13
Don't think so, besides this is a simple and user-fixable problem, so it's unlikely it would get fixed, however there is an unofficial CLtL3 effort.

Name: Anonymous 2010-02-23 22:22

>>9
No, since it's a parameter.

Name: Anonymous 2010-02-23 23:48

what a terrible language

Name: Anonymous 2010-02-24 0:47

>>16
Blub programmer detected.

Name: Anonymous 2010-02-24 7:40

Is anyone actually using this language for anything?

Name: Anonymous 2010-02-24 7:42

>>18
yes

Name: Anonymous 2010-02-24 13:48

Ok as someone new to lispy languages, I recently discovered Clojure and I was very impressed with what it had to offer. Would it be a bad idea idea to skip out on CL/Scheme and jump right into the lisp world with Clojure? As far as functional languages go I only have experience with Haskell. I'm interested in opinions on this.

Name: Anonymous 2010-02-24 14:03

>>20

It just doesn't fucking matter. Learn Lisp, learn Scheme, learn Clojure, or learn Haskell. Continually jumping to the coolest newest language isn't going to help you at all--what matters is actually understanding one of them. Then move on to the next.

Name: Anonymous 2010-02-24 14:59

>>20
When people have never done functional programming before, I ususally tell them to learn Scheme first because it doesn't require you to fuck around with the world's third most complicated type system. But since you already know some Haskell, Clojure will make plenty of sense to you. So go right ahread.

Name: Anonymous 2010-02-24 17:13

>>20
Clojure is lispy, but it's different from CL and Scheme in many ways. I think you should try other Lisps too, but for now you'd probably be fine with it. I started by learning Scheme from SICP and R5RS, but eventually ended up learning CL, and to this day it's my favorite language, however for some people CL might be harder to learn in one go.

Name: Anonymous 2010-02-24 17:13

>>20
Clojure is lispy, but it's different from CL and Scheme in many ways. I think you should try other Lisps too, but for now you'd probably be fine with it. I started by learning Scheme from SICP and R5RS, but eventually ended up learning CL, and to this day it's my favorite language, however for some people CL might be harder to learn in one go.

Name: Anonymous 2010-02-24 18:31

Clojure is absolute shit. No reader macros except the shitty default ones for useless data structures like arrays and hash maps, using ~ instead of , in macros, useless STM, (it's been proven not to work! WHY IMPLEMENT IT ANYWAY?!) no proper TCO, broken optimization pragmas, slow, shity, ugly, no proper LOOP or FORMAT. I can go on and on.

Also, defn? Really? Can't rite one extra letter huh Dick Hickey?

Name: Anonymous 2010-02-24 18:36

>>25
Also, defn? Really? Can't rite one extra letter huh Dick Hickey?
CL isn't any better if we are going to argue about naming. defun, defmacro, defgeneric... Is it so hard to write define, define-macro, define-generic?

Name: Anonymous 2010-02-24 19:03

>>26
DEFUN is part of a long tradition of idiosyncratic Lisp form names, along with SETQ, ASSQ,e tc.

Name: Anonymous 2010-02-24 19:20

>>27
I actually understand memq, memv, assq, etc. because they are specialisations of slightly more sensibly named functions like member and assoc, but I will never understand why they chose RPLACA and RPLACD.

Name: Anonymous 2010-02-24 19:34

>>28
Then you will never reach さとり。

Name: Anonymous 2010-02-24 19:40

>>29
I'll get there, but I'm sure as hell redefining them to set-car! and set-cdr!

Name: Anonymous 2010-02-24 20:09

>>28,30
I'm just happy using (setf (car x) y) and (setf (cdr x) y), they expand to rplaca/rplacd anyway. I don't remember the exact naming rationale of RPLACA/RPLACD, but I think it was something along the lines of ``RePLAce Contents of the Accumulator/Decrement part.'', which do make some sense if you think of car/cdr's naming, albeit they're both historical artifacts, not that having a better name would be of much benefit: FIRST/REST make sense when you're talking of lists, but cons cells are more general than that (an efficient stucture holding 2 arbitrary pointers can be used for many things).

Name: Wooden Mirror 2010-03-18 22:51

we supply all kinds of bamboo and wooden products,such as bamboo garden products and bamboo torches and Bamboo Bird House&Feeder and wooden flooring and wooden mirror and so on,we supply high quality & low
http://www.china-torches.com/

Name: Anonymous 2010-03-18 22:59

>>31
Generalized places are even more niggling, IMO. There's no clear treatment of them anywhere (even ANSI CL smoothes over them!)

Name: Anonymous 2010-03-18 23:16

>>33
In ANSI CL, SETF is a macro, and you have various possibilities of extending it in any way you'd want (functional extension, as a macro, own setf expanders, symbol macros, etc). SETF is maybe too extensible, which is why some people have trouble with it. Every SETF will eventually expand to a lower level API, which performs the actual operation. It's a bit more tricky because SETQ which is supposed to be a low-level operator(special form) will expand to SETF if the value to be setted is a symbol macro, and the SETF itself will expand to something else.

Name: mbt shoes 2010-05-14 1:07

This is a great stuff for sharing.Thanks for sharing.keep it up! http://www.86mbtshop.com

Name: mbt 2010-05-14 1:08


Thank you for your nice post! http://www.chihairsshop.com

Name: cheap ugg boots 2010-08-07 3:02

This is a great stuff for sharing.Thanks for sharing.keep

Name: Anonymous 2011-02-03 6:52

Name: cheap shoes 2011-05-31 21:54

A great post but How to select a cool shoes. we sell <a href="http://www.cheap-shoes-online.org" title="cheap shoes">cheap shoes</a> We are the best store provided various  <a href="http://www.cheap-shoes-online.org" title="cheap designer shoes">cheap designer shoes</a> but only a little white to make <a href="http://www.cheap-shoes-online.org" title="coach shoes online">coach shoes online</a>

Don't change these.
Name: Email:
Entire Thread Thread List