This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-26
Channels
- # beginners (55)
- # bristol-clojurians (4)
- # calva (9)
- # clj-kondo (29)
- # cljsrn (1)
- # clojars (6)
- # clojure (57)
- # clojure-dev (4)
- # clojure-uk (22)
- # clojurescript (52)
- # code-reviews (1)
- # core-async (33)
- # cursive (12)
- # datomic (46)
- # docker (7)
- # figwheel-main (13)
- # fulcro (8)
- # graalvm (3)
- # instaparse (1)
- # kaocha (2)
- # perun (1)
- # portkey (5)
- # re-frame (3)
- # shadow-cljs (46)
- # spacemacs (7)
- # specter (3)
- # vim (1)
- # vscode (3)
Hi, I'm new for clojure and start enjoying it. I've found command history is available in clojure by apt installation(ubuntu16/18). I'd like to know how do I let it enable on 'script installer edition' (from Getting-Started). I wonder what difference from them. thanks.
The script installer edition is the one that installs commands named clj
and clojure
? If so, clj
is a bash script that uses the rlwrap
command to enable command history. On Ubuntu Linux, you can install that via sudo apt install rlwrap
Thanks to tell me about rlwrap, it is good for my question. Im trying to study rlwrap.
Note that quite a few Clojure developers do not care so much about rlwrap
support, because they only type Clojure expressions/code into their editor or IDE, and then configure a simple keystroke to send the previous or surrounding Clojure expression to a REPL session.
Since you then have the full power of your editor/IDE to manipulate code, and can store it in a file, etc., it can do more things than rlwrap can.
I‘ll remember your advice. thanks.
Ah, I believe you may be referring to the clojure
command provided by the Leiningen package on Debian which starts a lein repl.
rlwrap is useful for wrapping almost any command and providing command history and line-editing functionality, so useful to know for other reasons.
Leinin package is first for me also. Id like to check it.
If you installed clojure via apt
, that's indeed what it was.
Thank you for all advices, hints, knowleges. I get to know that knowing leiningen
let me be able to read more repositories from small example to large project. I'll learn leiningen
I guess actually rlwrap
is useful not just clojure but others seen. I'm lucky to got it.
good-night.
Hi everyone
is it safe to save clojure text code into db and fetch and invoke on demand ?
is that bad practice ?
my goal is: i want to make each user has extendible set of functions to apply on thein input data
so i will save the code into the db per user, and insert as many methods to the user and fetch once i want to invoke them
There's the https://github.com/Raynes/clojail project for sandboxing Clojure code, which is used by 4clojure
It's very difficult, if not impossible, to stop attackers exploiting vulnerabilities this way. You're opening your server up for remote code execution.
You could save a list of representative command names against each user, then in your code match the command names against your own functions
what do you mean here?
i'm trying to make it very extendable per user, ...
so each time i wanna support new method for specific user, i just ingest the code for it and use the name, but it will be dangerous as you said
what alternatives can you think of?
hi, this is (hopefully) a simple question. I have bit of code, in a separate namespace, that wraps a REST API. It has functions for the various endpoints and methods. However, how do I let the callers of these functions supply some configuration information (host, port, etc.) that each of the endpoints need? What's the Clojure-idiomatic equivalent of a constructor, I guess is what I'm trying to figure out.
In other words, I want the code requiring my set of functions to provide the configuration just once and then go on and use the endpoint/method functions without further ado.
Usually these kind of functions take the configuration as their first argument.
I see, ok. So I'd create the config map in my calling application and pass it in as the first argument for every method. Seems a little awkward, but if that's idiomatic way...
Or maybe I can provide an init or config function and have the module squirrel that away somewhere.
But then I'd have to check whether the config/init was called in every method, which brings us back to awkward...
You/the client of your code can partial apply the configurations if they are static (def new-endpoint-fn (partial endpoint-fn config-map))
Why records are better than maps? are they more performant or something else? or maybe convenience?...
Hello, I'm still struggling to understand some subtleties of macros. As an example, consider the following definitions:
(defn f [expr] (println expr))
and
(defmacro m [test arg] `(if ~test ~(f arg)))
Calling
(m false (2 2))
causes the REPL to print (2 2)
and nil
, leading me to conclude that arg
is not evaluated (since it is an invalid expression and it should blow up).
However, if I slightly change the definition of m
to m1
as follows
(defmacro m1 [test arg] `(if ~test ~(f (1 1))))
and call
(m1 false (2 2))
it does fail: Unexpected error (ClassCastException) macroexpanding m1 at (REPL:1:1) [...]
.
Why is it that?No one? 😞
I did. It does not help that much. m
expands to
user=> (macroexpand '(m false (2 2)))
(2 2)
(if false nil)
what that reveals is that the macro prints as a side effect while expanding, then emits (if false nil)
as the code that will get run when the macro is used
okay I have a question about parsing xml. I'm making a http request and getting an xml response in the body. I'm trying to parse that xml data to get out a list of <DATA> items. Trying to follow http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html but I keep getting Execution error (MalformedURLException) at http://java.net.URL/<init> no protocol: <RETS ReplyCode="0" ReplyText="Operation Successful">
<COUNT Records="3330" />
<DELIMITER value="09" />
<COLUMNS> LA1_AgentID LA1_AgentLicenseID LA1_HiddenUsCID LA1_PhoneNumber1 LA1_PhoneNumber1CountryCodeId LA1_PhoneNumber1Desc LA1_PhoneNumber1Ext LA1_PhoneNumber2 LA1_PhoneNumber2CountryCodeId LA1_PhoneNumber2Desc LA1_PhoneNumber2Ext LA1_Status LA1_UserFirstName LA1_UserLastName LA1_UserMI LA1_WebPage LA2_AgentID LA2_HiddenUsCID LA2_PhoneNumber1 LA2_PhoneNumber1CountryCodeId LA2_PhoneNumber1Desc LA2_PhoneNumber1Ext LA2_PhoneNumber2 LA2_PhoneNumber2CountryCodeId LA2_PhoneNumber2Desc LA2_PhoneNumber2Ext LA2_Status LA2_UserFirstName LA2_UserLastName LA2_UserMI LA2_WebPage LFD_CONSTRUCTION_2 LFD_COOLING_1 LFD_DOCSONFILE_19 LFD_FIREPLACE_3 LFD_GARAGETYPE_4 LFD_GREENBUILDINGCERT_226 LFD_HANDICAPACCESSIBLE_111 LFD_HEATING_5 LFD_INCLUDEDKITCHENFEATURES_6 LFD_LANDUSE_7 LFD_LOTFEATURES_11 LFD_POOLSPA_12 LFD_ROOF_13 LFD_SEWER_14 LFD_SPRINKLERSYSTEM_8 LFD_STRUCTUREFEATURES_15LFD_TERMS_16 LFD_WATERHEATER_227 LFD_WATER_17 LMD_MP_AddressLine LMD_MP_Latitude LMD_MP_Longitude LMD_MP_MatchCode LMD_MP_MatchedMethod LMD_MP_PostalCode LMD_MP_PrimaryCity LMD_MP_Quality LMD_MP_SecondaryCity LMD_MP_Subdivision LMD_MP_UpdateDate LMD_MP_ZoomLevel LM_Char10_1 LM_Char10_11 LM_Char10_12 LM_Char10_17 LM_Char10_18 LM_Char10_19 LM_Char10_2 LM_Char10_20 LM_Char10_21 LM_Char10_22 LM_Char10_23 LM_Char10_24 LM_Char10_25 LM_Char10_26 LM_Char10_27 LM_Char10_28 LM_Char10_29 LM_Char10_3 LM_Char10_30 LM_Char10_4 LM_Char10_5 LM_Char1_1 LM_Char1_19 LM_Char1_2 LM_Char1_5 LM_Char1_8 LM_Char25_12 LM_Char25_14 LM_Char25_15 LM_Char25_16 LM_Char25_17 LM_Char25_6 LM_Char50_1 LM_DateTime_1 LM_Dec_12 LM_Dec_14 LM_Dec_15 LM_Dec_16 LM_Dec_3 LM_Dec_4 LM_Dec_5 LM_Dec_6 LM_Dec_8 LM_Dec_9 LM_Int1_20 LM_Int2_1 LM_Int2_10 LM_Int2_11 LM_Int2_12 LM_Int2_13 LM_Int2_2 LM_Int2_3 LM_Int2_4 LM_Int2_5 LM_Int2_6 LM_Int2_8 LM_Int4_1 LM_Int4_4 LM_char100_1 LM_char10_31 LM_char10_32 LM_char10_33 LM_char10_34 LM_char10_35 LM_char10_39 LM_char10_40 LM_char10_41 LM_char10_42 LM_char10_43 LM_char10_44 LM_char10_45 LM_char10_48 LM_char10_69 LM_char10_70 LM_char1_39 LM_char1_40 LM_char255_1 LM_char5_1 LM_char5_10 LM_char5_11 LM_char5_12 LM_char5_13 LM_char5_14 LM_char5_15 LM_char5_16 LM_char5_17 LM_char5_18 LM_char5_2 LM_char5_21 LM_char5_3 LM_char5_4 LM_char5_5 LM_char5_6 LM_char5_7 LM_char5_8 LM_char5_9 LM_int4_27 LO1_BranchOfOrgID LO1_HiddenOrgID LO1_HiddenOtyIDLO1_OrgAddress2 LO1_OrgAddressStreet LO1_OrgCity LO1_OrgState LO1_OrgZip LO1_OrganizationName LO1_PhoneNumber1 LO1_PhoneNumber1CountryCodeId LO1_PhoneNumber1Desc LO1_PhoneNumber1Ext LO1_ShortName LO1_WebPage LO1_board_id LO2_BranchOfOrgID LO2_HiddenOrgID LO2_HiddenOtyID LO2_OrgAddress2 LO2_OrgAddressStreet LO2_OrgCity LO2_OrgState LO2_OrgZip LO2_OrganizationName LO2_PhoneNumber1 LO2_PhoneNumber1CountryCodeId LO2_PhoneNumber1Desc LO2_PhoneNumber1Ext LO2_ShortName LO2_WebPage LO2_board_id LR_remarks22 LV_vow_address LV_vow_avm LV_vow_comment LV_vow_include L_Address L_Address2 L_AddressDirection L_AddressNumber L_AddressSearchNumber L_AddressStreet L_Area L_AskingPrice L_City L_Class L_DOM L_DisplayId L_FirstPhotoAddDt L_IdxInclude L_Keyword1 L_Keyword2 L_Keyword5 L_Keyword6 L_Keyword7 L_LastDocUpdate L_Last_Photo_updt L_ListAgent1 L_ListAgent2 L_ListOffice1 L_ListOffice2 L_ListingDate L_ListingID L_PictureCount L_PriceDate L_PricePerSQFT L_Remarks L_SaleRent L_State L_Status L_StatusCatID L_StatusDate L_StatusID L_SystemPrice L_Type_ L_UpdateDate L_Zip VT_ExtVTourURL1 VT_ExtVTourURL2 VT_ExtVTourURL3 VT_ExtVTourURL4 VT_ExtVTourURL5 VT_VTourURL </COLUMNS>
<DATA> 553819 AB8067 Realtor
<MAXROWS />
<RETS-STATUS ReplyCode="0" ReplyText="Operation Successful" />
</RETS>
what am I doing wrong?
Xml/parse assumes if you pass it a string that string is a url pointing to the xml you want parsed
I would take a closer look at that tutorial, I can't point to any specific part the code examples in it don't load for me, but I assume they do for you
Ah, they load of I request the desktop site, checkout the putting it altogether section
OK I have been staring at and fiddling with this code for a couple of hours now and can't figure out the problem:
(defn configure
"Configure request options and url"
[{:keys [url keystore keystore-pass]
:or {:url "
:keystore "/some/path/file.p12"
:keystore-pass "super-secret-password"}
:as opts}]
opts)
The error is: Syntax error macroexpanding clojure.core/defn at (*cider-repl git/cosmos-login:localhost:41267(clj)*:70:7).
{:keys [url keystore keystore-pass], :or {:url "
({:keys [url keystore keystore-pass], :or {:url "
I understand that the underlying error is "Extra input", but I don't understand where it is telling me.
yeah, pretty sure that should be symbols instead of keywords
Ah! Thank you. Should have asked this a couple of hours ago.
that said; the spec error is not great at pointing out the problem in your :or