freenode/#lisp - IRC Chatlog
Search
4:15:36
dwts
hey guys, doing something like this: curl http://api.urbandictionary.com/v0/define?term={nuts} I'm getting a json output. I'm trying to perform the same results with drakma. But drakma complains about illegal characters(curly brackets)
4:17:53
Bike
with drakma you give ti the GET parameters separately and not as part of the url, maybe
4:22:06
dwts
Bike: hmmm...the drakma documentation says to use this kind of syntax: (drakma:http-request "http://lisp.org/") . Can't find it documented either the separate GET parameters
4:49:48
loke`
dwts: The full parameter documentation for drakma is in the docstring for HTTP-REQUEST
4:51:29
dwts
loke`: thanks! is there an easy way to access to that docstring directly through emacs?
5:01:31
dwts
loke`: I'm trying something different. (defparameter *k* (drakma:url-encode "http://api.urbandictionary.com/v0/define?term={nuts}" :utf-8)) Then this: (drakma:http-request *k* :method :get)
5:02:27
loke`
I'm guessing you have read the API documentation, where the curlies are there to indicate that this is where you put your own text.
5:02:54
loke`
secondly, in order to have all the URL encoding working correctly, you should use the :PARAMETERS argument:
5:03:08
loke`
(drakma:http-request "http://api.urbandictionary.com/v0/define" :parameters '(("term" . "nuts")))
5:03:16
resttime
If you don't mind some newer libs check out dexador: https://github.com/fukamachi/dexador
5:03:35
resttime
Outputs -> "{\"tags\":[],\"result_type\":\"no_results\",\"list\":[],\"sounds\":[]}"
5:03:55
loke`
resttime: His problem si that he's passing the curlies. Even if he encodes them correctly he'll get an error message tfrom the remote server
5:07:02
resttime
dwts: You're trying to use what I suppose is curl syntax with other things, this wouldn't even work if you used like Python or something
5:08:10
dwts
while what loke` suggested get's executed successfully(drakma http-request), I still don't see the json output
5:11:41
loke`
dwts: It's returned as binary data. You can eiter convert it using something libe (babel:octests-to-string ... :encoding :urf-8)
5:14:50
loke`
The drakma documentation says: ”If the message body doesn't have a text content type or if FORCE-BINARY is true, the body is always returned as an array of octets.”
5:15:20
loke`
The request you make returns application/json, which is why it's returned as a binary vector and not a string.
5:16:33
loke`
dwts: You probably want to pass the decoded output to something like ‘st-json’ or one of the other JSON libraries.
5:17:10
resttime
Ah here we go, I recall something that's nice. If you want drakma to convert to text automatically: (push (cons "application" "json") drakma:*text-content-types*)
5:17:20
loke`
You should do something like (babel:octets-to-string (drakma:http-request ...) :encoding :utf-8)
5:18:31
loke`
dwts: I'm not debugging anything. I know drakma pretty well (even though I missed the part about *TEXT-CONTENT-TYPES*)
5:19:16
resttime
dwts, loke`. Just remembered running into it some time before couldn't recall top of head but a good old google helps all the time :)
5:20:01
dwts
loke`: yeah, takes some time to get used to the output. there's enough info there I guess, now I noticed the full message: (:CONTENT-TYPE . "application/json; charset=utf-8")
5:20:11
loke`
resttime: In 99% of cases, I use :WANT-STREAM, and just wrap it in a flexi-stream to do the parsing anyway.
5:21:09
loke`
I guess that the *TEXT-CONTENT-TYPES* has the benefit of parsing the ;charset= parameter for you... In case you meet a server that is insane enough to give you JSON with a non-utf-8 encoding. :-)
5:37:27
resttime
nginx proxy server to https://github.com/fukamachi/woo -> with https://github.com/fukamachi/ningle
6:02:22
resttime
(dex:get "https://google.com" :stream t :insecure t) Something like that should be making a new stream with the right flags I think
6:14:29
resttime
Yeah there we go recent commit too: https://github.com/fukamachi/dexador/commit/0b0e0b56f9c695d052a46c85f9e20f6e30946526#diff-94c10f296dac06851e39cc9ad5773f9b
6:36:48
loke`
The onyl way I can get around this, it seems, is by getting the cert used for signing and add that manually.
6:56:29
resttime
https://github.com/fukamachi/dexador/commit/0b0e0b56f9c695d052a46c85f9e20f6e30946526#diff-94c10f296dac06851e39cc9ad5773f9b
8:12:19
Shinmera
Dexador is nicely fast (drakma is dog slow), but I've had some issues with it just erroring over simple stuff
8:12:32
Shinmera
Don't remember the context of the breakage, but it wasn't even anything about cl+ssl.
14:39:39
drmeister
Is anyone interested in writing a Common Lisp library to parse DWARF? It would be generally useful to get Common Lisp to understand C++ code.
14:40:32
drmeister
I'm interested because we've got a Common Lisp compiler (Clasp) that generates DWARF and I'd like to use a DWARF interpreter for the debugger.
14:41:42
Xach
https://github.com/angavrilov/cl-linux-debug/blob/master/code-info/dwarf.lisp is the first thing on google, but i don't think that's what i was remembering.
14:43:16
drmeister
What did you google? I swear I've used the google dozens of times looking for things like this.
14:44:09
drmeister
If anyone knows anything about Common Lisp libraries to interpret DWARF - I'd love to hear about it.
14:44:55
drmeister
We generate DWARF and are going to do it better in the near future with the wonderful new cst-to-ast source tracking features that beach has added to Cleavir.
14:45:39
drmeister
But like the cursed cook who can prepare sumptuous meals - but never taste them - we generate DWARF but cannot interpret it.
14:46:51
jurov
Seems I've found a quicklisp/asdf bug. When a system has a.lisp and b.lisp and macro in b.lisp calls a function A from a.lisp at loading time...
14:46:53
drmeister
In other news - Clasp now has multithreading with compacting semi-conservative garbage collection.
14:47:02
jurov
...later I updated A, but the compiled macro was not recompiled by quicklisp, I had to remove cached fasl files.
14:49:25
drmeister
Some things are and some things aren't. Integer numerical code is approaching C/Fortran speed - maybe off by a factor of 2. The compiler is slow.
14:49:44
Xach
jurov: you changed a.lisp and saved the file but b.lisp was not updated when you used (asdf:load-system "your-system")?
14:49:59
Shinmera
drmeister: Last time we had MPS running it was a significant factor slower than Boehm
14:50:53
drmeister
Shinmera: Ah - yes - I haven't profiled it much yet but it's about as fast as Boehm. The bottlenecks we experience are not due to the GC.
14:51:29
drmeister
The problems we had before were probably due to a multi-megabyte character property array that was being allocated during startup.
14:52:01
drmeister
Stassats found that and we removed it. It was also being created in ECL - but not to the same extent.
14:53:53
drmeister
I don't look to our previous experiences with MPS as illuminating anything about performance - there were too many problems with my implementation.
14:55:19
jurov
Xach ah yes, the a.lisp and b.lisp are just listed as components without any :depends-on info
14:55:45
drmeister
The thing about MPS is that allocations are just pointer bumps. Once we get allocations inlined into the Common Lisp code that uses them - they will be as fast as they can be.
15:00:18
Xach
jurov: can you share the system file? and the other files? or maybe provide simplified versions? i'm still quite curious
15:00:24
jurov
OK. It's actually this one: https://github.com/adolenc/cl-neovim/blob/master/cl-neovim.asd . the macro is in api.lisp and the function called by macro is in vim-utils.lisp
15:01:36
Xach
jurov: and you observe that changing vim-utils.lisp and saving it, then using (asdf:load-system "cl-neovim") does not result in recompiling api.lisp?
15:02:31
jurov
Yes. I commented out #'clean-up-name in vim-utils completely and system loaded despite that
15:04:29
scymtym
Xach: in my mental model, :serial only affects immediately contained :components, not transitively contained ones
15:06:45
smokeink
Is it possible in CL to replace 't with 'true ? (define-symbol-macro true 't) can make 'true be read as 't , but how to make the repl display true instead of t (when something evals to t) ?
15:15:42
smokeink
tried this but it doesn't work: (defmethod print-object ((obj t) out) (format out "~A" 'true))
15:18:07
smokeink
yes, I thought so , but how to make it work for any class, including the class of 't itself ? Actually I need it to work just for 't
15:21:09
beach
smokeink: You might want to try ((obj (eql t)) out) but I am pretty sure that this would be undefined behavior.