Feed Aggregator Page 646
Rendered on Mon, 14 Sep 2020 08:33:24 GMT
Rendered on Mon, 14 Sep 2020 08:33:24 GMT
via Elm - Latest posts by @kraklin Tomáš Látal on Mon, 14 Sep 2020 07:38:06 GMT
Hey folks,
some time before I have created NPM package for transforming Debug.log messages from string to JSON object. Now I’m finishing browser extension version
TLDR: Do you want to help me beta test that extension? Register to beta test and I’d send you the beta version of the plugin for your browser (Chrome-like or Firefox)
Remember elm-debug-transformer? It was welcomed warmly but in time I have found few missing features and problems with it. It was forcing you to install yet another NPM package and init debug output directly to each of your projects, which can be helpful, but it was forcing anybody in the team to be familiar with the new scheme. Plus for the Chrome Custom formatters it needed each team member to have them enabled unless they would like to see crazy amount of metadata for each item in the Debug.log. Also it forced all team to develop on the same browser instead of those which they would prefer.
Now I’m finishing the web browser extension, which would insert the elm-debug-transformer into all pages you are working on without the need to spoil your project with yet another NPM package. Your project can stay clean of such magic and you can have your own settings on how to transform the Debug.log output.
Everything works for me and few of those, who were brave enough to install it But I would like to battle test it more before putting it into the wild, so I’d like to widen the circle of testers a bit.
Are you interested in such extension? Please, register to beta test and I’d send you the beta version of the plugin for your browser (Chrome-like or Firefox)
Thank you for your help, be safe and take care.
Tom
via Elm - Latest posts by @spell Salvatore Pelligra on Sun, 13 Sep 2020 16:11:43 GMT
@miniBill awesome job! Any chance of making it into a library?
via Elm - Latest posts by @MartinS on Sat, 12 Sep 2020 19:31:48 GMT
It looks like this Dict ( Int, Int ) Cell
where each cell is a 16x16 block of ascii characters (along with some extra data like who wrote what and in what order).
via Elm - Latest posts by @rupert Rupert Smith on Sat, 12 Sep 2020 19:22:23 GMT
That is very nice - especially the front and back end in Elm aspect.
I am curious, what data structure did you use for the ‘infinite’ 2d grid of ascii characters?
via Elm - Latest posts by @MartinS on Sat, 12 Sep 2020 17:48:15 GMT
A month ago I realized I really like drawing ascii art. Originally I was using yourworldoftext.com but it lacks features I wanted. So I ended up making my own webapp that lets people draw ascii art together on an infinite canvas.
https://ascii-collab.lamdera.app
Here’s what it looks like in action!
Features:
Both the frontend and backend are written in Elm, using Lamdera. Developing this app went smoothly and I was able to finish it over a span of 6 weeks.
I will open source this eventually but for now it uses undocumented Lamdera features that aren’t ready for release yet.
Oh, also I’ll being giving a short presentation at elm-london on Thursday about this.
via Elm - Latest posts by @temochka Artem Chistyakov on Fri, 11 Sep 2020 21:32:13 GMT
A little late, but finally got around to writing down some of the challenges me and my teammate (also my wife ) faced when working on our submission for the Elm Game Jam #4. Check it out if this sounds interesting!
You can also play the game on itch. Happy to answer any questions!
via Planet Lisp by on Fri, 11 Sep 2020 16:38:20 GMT
This library can be useful for anybody who is writing services which logs their errors with backtraces. It will protect you from leaking sensitive data like passwords and tokens.
For example, let's pretend we have some code which authenticates to a database with a password. At some moment and error can happen and when you log the backtrace, the password will be logged as well:
POFTHEDAY> (defun authenticate (password)
(format t "Authenticating with ~A"
password)
(sb-debug:print-backtrace :count 3))
POFTHEDAY> (defun bar (password)
(authenticate password))
POFTHEDAY> (bar "The Secret Password")
Authenticating with The Secret Password
Backtrace for: #<SB-THREAD:THREAD "sly-channel-1-mrepl-remote-1" RUNNING {1003692013}>
0: (AUTHENTICATE "The Secret Password")
1: (BAR "The Secret Password")
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (BAR "The Secret Password") #<NULL-LEXENV>)
The secret-values
allows to wrap the secret value into the object and retrieve the real value as needed.
POFTHEDAY> (secret-values:conceal-value "The Secret Password" :name "password")
#<SECRET-VALUES:SECRET-VALUE password {100450B623}>
POFTHEDAY> (secret-values:reveal-value *)
"The Secret Password"
Here how we can use it in our example. Pay attention to the backtrace. Now it does not contain the password and such backtrace can be written into the file or sent for diagnostic to the developer:
POFTHEDAY> (defun authenticate (password)
(format t "Authenticating with ~A"
(secret-values:reveal-value password))
(sb-debug:print-backtrace :count 3))
POFTHEDAY> (let ((pass (secret-values:conceal-value "The Secret Password")))
(bar pass))
Authenticating with The Secret Password
Backtrace for: #<SB-THREAD:THREAD "sly-channel-1-mrepl-remote-1" RUNNING {1003692013}>
0: (AUTHENTICATE #<SECRET-VALUES:SECRET-VALUE {10043ABB23}>)
1: (BAR #<SECRET-VALUES:SECRET-VALUE {10043ABB23}>)
2: ((LAMBDA ()))
I definitely will use it! And you should too!
By the way, does somebody know something about the author Thomas Bakketun and his company Copyleft? Seems they are using the Common Lisp in their stack.
via Elm - Latest posts by @miniBill Leonardo Taglialegne on Fri, 11 Sep 2020 06:26:42 GMT
Indeed! The type for variant0
wasn’t general enough!
via Elm - Latest posts by @system system on Fri, 11 Sep 2020 04:01:06 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @rkb Robert K Bell on Fri, 11 Sep 2020 02:02:22 GMT
keen!
I’m not sure how to add a custom type route though… here’s where I got up to: https://ellie-app.com/9WDZnrhbJpta1
type Route
= Blog Int
| Article String Int
| User UserRoute -- this is the new route
| Home
type UserRoute
= About
| Settings
route : UrlCodec (Route -> a) a Route
route =
adt
(\fhome fblog farticle fuser value ->
case value of
Home ->
fhome
Blog i ->
fblog i
Article se i ->
farticle se i
User user_route ->
fuser user_route
)
|> variant0 Home
|> variant1 Blog (comb (s "blog") int)
|> variant2 Article string int
|> variant1 User (comb (s "user") userRoute) -- using a `variant1` feels right, here...
|> buildCustom
userRoute : UrlCodec (UserRoute -> a) a UserRoute
userRoute =
adt
(\fabout fsettings value ->
case value of
About ->
fabout
Settings ->
fsettings
)
|> variant0 About
--|> variant1 Settings userSettings
|> variant0 Settings -- but neither `variant0` or `variant1` feel right here?
|> buildCustom
via Elm - Latest posts by @miniBill Leonardo Taglialegne on Fri, 11 Sep 2020 00:08:35 GMT
Disclaimer: I’m not sure the API is general enough but LGTM: https://ellie-app.com/9WCmVb7gHswa1
EDIT: wrong link
via Planet Lisp by on Thu, 10 Sep 2020 19:38:39 GMT
A few days ago, I tried to review a cl-vcr - a library which should remember and replay HTTP calls in your tests. But unfortunately it didn't work.
But Vincent Dardel did a good job, finding the similar project called vcr
. It is not in Quicklisp, but can be downloaded from GitHub or Ultralisp:
Today we'll check if vcr
will work for remembering our HTTP calls.
First, let's make Drakma understand that application/json
is a text format. Thanks to the @vseloved for this tip!
POFTHEDAY> (push '("application" . "json")
drakma:*text-content-types*)
(("application" . "json") ("text"))
POFTHEDAY> (drakma:http-request "https://httpbin.org/delay/5")
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7371-a16e828d5dc4cb52867d2d09\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/5\"
}
"
200 (8 bits, #xC8, #o310, #b11001000)
((:DATE . "Thu, 10 Sep 2020 18:41:58 GMT") (:CONTENT-TYPE . "application/json")
(:CONTENT-LENGTH . "360") (:CONNECTION . "close")
(:SERVER . "gunicorn/19.9.0") (:ACCESS-CONTROL-ALLOW-ORIGIN . "*")
(:ACCESS-CONTROL-ALLOW-CREDENTIALS . "true"))
#<PURI:URI https://httpbin.org/delay/5>
#<FLEXI-STREAMS:FLEXI-IO-STREAM {100238A0A3}>
T
"OK"
Now it is time to see if our requests will be cached:
POFTHEDAY> (time
(vcr:with-vcr "foo"
(drakma:http-request "https://httpbin.org/delay/10")))
Evaluation took:
10.849 seconds of real time
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7b55-4ceacc38a3d473a1e8ce9f01\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
;; Second call returns immediately!
POFTHEDAY> (time
(vcr:with-vcr "foo"
(drakma:http-request "https://httpbin.org/delay/10")))
Evaluation took:
0.001 seconds of real time
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7b55-4ceacc38a3d473a1e8ce9f01\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
Seems the library works. But it does not support multiple values and it will break you application if it uses status code or headers, returned as the second and third values.
This is strange because I see in it's code an attempt to handle multiple values :/
Now, how about making it work with Dexador
? To do this, we have to rebind the vcr:*original-fn-symbol*
variable:
POFTHEDAY> (let ((vcr:*original-fn-symbol* 'dexador:request))
(time
(vcr:with-vcr "foo"
(dex:get "https://httpbin.org/delay/10"))))
Evaluation took:
10.721 seconds of real time
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7d84-7de184b7a8524404e7ecc234\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
POFTHEDAY> (let ((vcr:*original-fn-symbol* 'dexador:request))
(time
(vcr:with-vcr "foo"
(dex:get "https://httpbin.org/delay/10"))))
Evaluation took:
0.001 seconds of real time
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7d84-7de184b7a8524404e7ecc234\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
Ups! Why did we send "Drakma" in the User-Agent header??? Let's recheck without the vcr
wrapper:
POFTHEDAY> (dex:get "https://httpbin.org/delay/10")
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Drakma/2.0.7 (SBCL 2.0.8; Darwin; 19.5.0; http://weitz.de/drakma/)\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7e04-fed39a80da9ac640b6835a00\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
200 (8 bits, #xC8, #o310, #b11001000)
((:DATE . "Thu, 10 Sep 2020 19:27:10 GMT") (:CONTENT-TYPE . "application/json")
(:CONTENT-LENGTH . "361") (:CONNECTION . "close")
(:SERVER . "gunicorn/19.9.0") (:ACCESS-CONTROL-ALLOW-ORIGIN . "*")
(:ACCESS-CONTROL-ALLOW-CREDENTIALS . "true"))
#<PURI:URI https://httpbin.org/delay/10>
#<FLEXI-STREAMS:FLEXI-IO-STREAM {1006A2DB43}>
T
"OK"
Hmm, but if we'll restart our lisp process and check it on the fresh, the result will be different (and correct):
POFTHEDAY> (dex:get "https://httpbin.org/delay/10")
"{
\"args\": {},
\"data\": \"\",
\"files\": {},
\"form\": {},
\"headers\": {
\"Accept\": \"*/*\",
\"Content-Length\": \"0\",
\"Host\": \"httpbin.org\",
\"User-Agent\": \"Dexador/0.9.14 (SBCL 2.0.8); Darwin; 19.5.0\",
\"X-Amzn-Trace-Id\": \"Root=1-5f5a7ef4-ede1ef0036cd44c08b326080\"
},
\"origin\": \"178.176.74.47\",
\"url\": \"https://httpbin.org/delay/10\"
}
"
200 (8 bits, #xC8, #o310, #b11001000)
#<HASH-TABLE :TEST EQUAL :COUNT 7 {1004BD1153}>
#<QURI.URI.HTTP:URI-HTTPS https://httpbin.org/delay/10>
#<CL+SSL::SSL-STREAM for #<FD-STREAM for "socket 192.168.43.216:63549, peer: 3.221.81.55:443" {1003F79823}>>
Oh, seems, vcr
is always calling dexador:http-request
, because that is what it does on the top level:
(defparameter *original-fn-symbol* 'drakma:http-request)
;; The symbol original-fn is internal for the package so
;; no name conflict is possible.
(setf (symbol-function 'original-fn)
(symbol-function *original-fn-symbol*))
Also, I found the same problem as with the original cl-vcr
- this library does not use unwind-protect
and in case if some error will be signalled, it will break the original drakma:http-request
function :(
To finalize, I think it can be used by those who are using Drakma if somebody will fix how the multiple values are handled and original function restoration.
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 18:06:25 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 17:13:40 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 15:58:52 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 15:58:32 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 14:56:05 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
via Elm - Latest posts by @marciofrayze Marcio Frayze on Thu, 10 Sep 2020 12:59:19 GMT
Thanks a lot for your reply.
But I’m able to create a select and use it. My main problem is how to create an automated test to simulate this cenario using elm-test.
So with buttons I’m able to test them very easily with: Event.simulate Event.click
My problem is how to do something similar to this with a select.
Anyway, your example will help me with another problem I’m having, so thank you
via Elm - Latest posts by @rkb Robert K Bell on Thu, 10 Sep 2020 09:54:08 GMT
Thanks miniBill, that’s very interesting! The oneOf
problem is a stumper…
via Elm - Latest posts by @system system on Thu, 10 Sep 2020 09:38:08 GMT
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.