I’ve moved to http://lbolla.info/blog/!
please update your links😉
reg-dom-libs are a set of libraries for
Perl to convert an arbitrary domain name to the registered domain name.
- for simple domains, like
news.ycombinator.com, the task is trivial.
- for more complicated ones, like
http://www.japantimes.co.jp, handling the second level subdomain is a little painful.
- for exoteric ones, like
公司.cn, the problem becomes virtually impossible.
- after seeing stupid ones, like
http://www.comune.caserta.it(believe it or not, the registered domain is
comune.caserta.it!), I gave up finding an elegant algorithm for the problem.
- a full list of valid registered domain is necessary. luckily, it is available (and nightly updated) here.
a demo is availble here.
twill is a simple language that allows users to browse the Web from a command-line interface. With twill, you can navigate through Web sites that use forms, cookies, and most standard Web features.
unfortunately, development on twill seems to have stopped 3 years ago.
I’ve cloned the project on Github, fixed some deprecation warnings and added a cool new feature to inspect headers, as well as html.
testing is more interesting than I thought.
I’ve spent a little time to make it work with python3.
I considered the spectral norm benchmark and compared the C and SBCL implementations.
I started re-running the tests without any further optimization and the results were similar to the ones reported with C beating SBCL by a factor of 2.
(for the C optimization used, see here).
then, I noticed that there was no
(declaim (optimize (speed 3) (safety 0) (space 0))) in the SBCL file!
I’ve added it and rerun the test. here are my results:
gcc 0.15u 0.00s 0.17r
sbcl 0.08u 0.02s 0.21r
gcc 5.60u 0.00s 5.69r
sbcl 5.18u 0.01s 5.41r
gcc 18.81u 0.01s 19.12r
sbcl 17.42u 0.02s 17.76r
the SBCL implementation is actually faster than C!
you can find the code for the tests here.
today I wanted to experiment with threads in lisp (sbcl, in particular).
here is a trivial example of how to access a shared resource (a closure, keeping a list of integers), from a set of
(use-package :sb-thread) ;; number of threads (defparameter *nt* 10) ;; threads (defvar *threads* '()) ;; mutex to use with shared resource accessed by the threads (defvar *a-mutex* (make-mutex :name "acc-lock")) ;; shared closure accessed by the threads (let ((x '())) (defun acc (v) (with-mutex (*a-mutex*) (push v x))) (defun get-acc () x)) ;; print the shared resource (print (get-acc)) ;; wait for all the threads to return (mapcar #'join-thread ;; run the threads (loop :for i :below *nt* ;; bind i to x so it is local to the thread :collect (let ((x i)) (make-thread #'(lambda () ;; body of the thread (sleep (random 2)) (acc x)) :name x)))) ;; print the shared resource (print (get-acc))
it can’t get much simpler than that…
I like old things, therefore I started to learn Lisp.
(require 's-xml-rpc) (defpackage :wp (:use :cl :cl-user :s-xml-rpc)) (in-package :wp) (defparameter +interfaces+ '((get-blogs "wp.getUsersBlogs" username password) (get-tags "wp.getTags" blog-id username password) (get-comment-count "wp.getCommentCount" blog-id username password post-id) (get-post-status-list "wp.getPostStatusList" blog-id username password) (get-page-status-list "wp.getPageStatusList" blog-id username password) (get-page-templates "wp.getPageTemplates" blog-id username password) (get-options "wp.getOptions" blog-id username password) (delete-comment "wp.deleteComment" blog-id username password comment-id) (get-comment-status-list "wp.getCommentStatusList" blog-id username password) (get-page "wp.getPage" blog-id page-id username password) (get-pages "wp.getPages" blog-id username password) (get-page-list "wp.getPageList" blog-id username password) (delete-page "wp.deletePage" blog-id username password page-id) (get-authors "wp.getAuthors" blog-id username password) (get-categories "wp.getCategories" blog-id username password) (delete-category "wp.deleteCategory" blog-id username password category-id) (suggest-categories "wp.suggestCategories" blog-id username password category max-results) (get-comment "wp.getComment" blog-id username password comment-id)) "Interface definition to WP services") (defun defunwp (params) (destructuring-bind (name service &rest rest) params (setf (fdefinition name) (compile nil `(lambda (host ,@rest &optional (url "/xmlrpc.php")) (block ,name (xml-rpc-call (encode-xml-rpc-call ,service ,@rest) :host host :url url))))) name)) (mapcar #'(lambda (interface) (export (defunwp interface))) +interfaces+)
example usage is as follows:
* (wp:get-blogs "username.wordpress.com" "your-username" "your-password") ; returns the list of blogs for the user * (wp:get-pages "username.wordpress.com" your-blog-id "your-username" "your-password") ; returns the list of pages
and so on (see
wp::+interfaces+ for function names and required params).