This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-20
Channels
- # beginners (35)
- # boot (81)
- # braveandtrue (7)
- # cider (74)
- # cljs-dev (52)
- # cljsrn (5)
- # clojure (114)
- # clojure-austin (1)
- # clojure-belgium (3)
- # clojure-brasil (8)
- # clojure-czech (7)
- # clojure-greece (18)
- # clojure-ireland (1)
- # clojure-russia (67)
- # clojure-uk (11)
- # clojurescript (52)
- # core-async (5)
- # core-matrix (3)
- # cursive (13)
- # data-science (3)
- # datomic (8)
- # emacs (80)
- # events (2)
- # hoplon (8)
- # immutant (7)
- # jobs-discuss (3)
- # juxt (25)
- # ldnproclodo (21)
- # leiningen (27)
- # mount (24)
- # off-topic (6)
- # om (23)
- # onyx (48)
- # parinfer (1)
- # proton (4)
- # re-frame (41)
- # reagent (9)
- # spacemacs (8)
- # untangled (122)
@moizsj have a look at @mpenet's Jet: https://github.com/mpenet/jet
One thing you should ask yourslef first is, are there already operations that achieve what I want?
Jetty based, http/websocket server/client. Not sure about the exact option you are after, but I have enjoyed contributing to Max's https://github.com/mpenet/alia on occasion. He's very responsive, code quality is top notch.
@d-t-w: thats a nice reference. But unfortunately, this too does not appear to support the 'permessage-deflate' extension. I am looking at -- https://github.com/mpenet/jet/blob/master/src/clj/qbits/jet/client/websocket.clj#L15 As you can see, its not amongst the options in the options map.
@mpenet: thank you. I am trying another approach atm (pure java interop code with the undertow websocket client lib), If i get a chance i'll make the PR.
@mpenet: For now, I have created two issues. One for support of extensions in the websocket client, and another for support of subprotocols. (Both I believe are supported by Jetty's ClientUpgradeRequest
)
Hey guys, I’m relatively new to Clojure and am looking to throw myself into it by writing an executable command line application with it. Before I go into it, are there any clojars that you’d recommend I use for writing this kind of app?
joenorman: https://github.com/clojure/tools.cli is useful for arg parsing, otherwise just uberjar your lib and you should be good to go
Awesome - I’ve seen that before but just wanted to check it was the best choice. Thanks @mpenet!
Hello All, has anybody had to sort a vector of maps with IP addresses? i have this but the sort-by
does not know how to sort the addresses.
(def my-vec
[{:id 1
:ip "10.2.0.22"}
{:id 2
:ip "10.2.0.4"}
{:id 3
:ip "10.2.0.191"}])
(sort-by :ip my-vec) ;({:id3, :ip "10.2.0.191"} {:id 1, :ip "10.2.0.22"} {:id 2, :ip "10.2.0.4"})
@joenorman: also if you’re on a Mac you might be interested in planck https://github.com/mfikes/planck
@manutter51: Also see https://itunes.apple.com/us/app/replete/id1013465639?mt=8 if on iOS
You know, I have Replete on my iPhone, but I’ve never found anything I really want to use it for. Maybe it’s just because I’m an old geezer, but typing code on a mobile touch screen seems like way too much work for me. I wonder if I’m missing something though
@yatesj9: It sorts them correctly, the problem is it will then compare the strings lexicographically (which is correct). To get around that, you need to convert the IP string to a number:
(require '[clojure.string :as s])
(let [strip-dots #(s/replace % #"\." "")
to-int #(Integer/parseInt %)
ip-comp (comp to-int strip-dots :ip)]
(sort-by ip-comp my-vec))
(sort-by my-vec) ;=> ({:id 2, :ip "10.2.0.4"} {:id 1, :ip "10.2.0.22"} {:id 3, :ip "10.2.0.191"})
(defn ip-addr-sort-key [a] (reduce (fn [m s] (+ (* m 256) (Integer/parseInt s))) (clojure.string/split a #"\.")))
which turns each address back into (more or less) the 32 bit number it represents. Handwaving slightly as the IP stack was defined by C/assembly programmers who were somewhat cavalier about punning integers and bytes
I'm trying to model the flow of a conversation as a FSM using: https://github.com/ztellman/automat — now there are situations where a transition should move to a previous state (eg. "is this correct?" - "no" - "ok enter again") — does anyone have some pointers how to achieve something like that with automat
?
@sgerguri @telent you can also sort vectors of integers, which might be a little simpler and acts as desired here, I think
Sorry, i'm still having troubles, @sgerguri function works but as @telent says it will not sort correctly when stripping the dots. I can't seem to get @telent function working for me
user=> (defn ip-address-sort-key [a] (reduce (fn [m s] (+ (* m 256) (Integer/parseInt s))) 0 (clojure.string/split a #"\."))) #'user/ip-address-sort-key user=> (sort-by (comp ip-address-sort-key :ip) my-vec) ({:id 2, :ip "10.2.0.4"} {:id 1, :ip "10.2.0.22"} {:id 3, :ip "10.2.0.191"})
@telent: that is working perfectly, now i just need to break it down to see what it's doing and try to understand it
;; automat with loop
(view [1 2 3 (a/* ['a 2 3]) 4])
or as loganmhb suggests you could compare vectors of integers instead of doing all that multiplying
user=> (defn ip-address-sort-key [a] (mapv #(Integer/parseInt %) (clojure.string/split a #"\.")))
(there is some function that turns a java method into a proper function so you don't have to write #(Integer/parseInt %) , but I can't remember the name)
https://github.com/giakki/uncss uses a phantom js browser, runs javascript, and extracts the set of rules that are used
whenever I do “jack-in” in CIDER to boot.clj driven project - Java Cup icon shows up on OS X Dock. It’s driving me nuts. has anyone have this problem? Setting export JAVA_TOOL_OPTIONS="-Dapple.awt.UIElement=true”
fixed that for me in terminal, but “jacking in” in Emacs still pops up foreground Java process. I can’t close it - it kills the repl.
the way gui apps are launched in osx means they don't get environment as setup by .profile or whatever
if you google around you can find ways to setup the environment for gui apps by editting some plists
for example: http://stackoverflow.com/questions/603785/environment-variables-in-mac-os-x/4567308#4567308
hi guys, do you recommend using an authentication library (e.g. Friend or Buddy) instead of using your own auth middleware?
@robincarlo84: I've always heard use a library, and so I've always used passport on Node.js and will use Buddy on Clojure
anytime you have this question, the answer is invariably: roll your own. This especially applies to date/time libraries and encryption
also, definitely joking. Often libraries do whatever you need right away. And I would never write any library that deals with date times or encryption
@dpsutton: sorry, do you mean that you prefer using an auth library?
I actually have no first hand knowledge of it. But i have seen some people recommend it highly. Seems like a de facto standard
note that none of the "auth frameworks" provide for password resets or anything else useful iirc
@bvulpes sorry for my question, and yes I will need roles too
while > often libraries do whatever you need right away frequently you get three months down the road before realizing that you've bought into an authentication model that's woefully inadequate for your needs
it won't be a SPA, but it will only have a 5-7 users
1 admin and the rest are users
for other, more complex work, i do different things. my SPA toolchain checks username and password at login, and returns a one-time-use token for the next request. which returns another one-time-use token.
tokens which are trivially reworked to be valid for some amount of time to support UI's that make calls in parallel.
the point i'm trying to make is that unless you're slamming out rails or django apps, when working in a lib-centric environment like clojure, it's frequently both more expedient and better for the codebases in question to write the auth logic for each app seperately.
@bvulpes right, make sense.
@bvulpes: “my SPA toolchain checks username and password at login, and returns a one-time-use token for the next request. which returns another one-time-use token” this is cool! Can you make this into a library 😄?
thanks for your time, appreciate it
thanks guys
I’m trying to use codox to write documentation. It generates an index that has a heading called “Topics" on the right hand side, and under that it says “Introduction to mylibrary”. If I click the “introduction to mylibrary” heading, I get to a page with that heading and under it is written “TODO: write great documentation”. Some other libraries using codox don’t have that “Topics” heading. Does anyone know how to get rid of the “Topic” heading, or where I can put some documentation to take the place of “TODO: write great documentation”?