Re: Help Getting Sente to Work

2014-07-27 Thread Peter Taoussanis
The new 
docstring: 
https://github.com/ptaoussanis/sente/blob/65fcf8d9be14bfc69a7798b5c159780d1d2a3804/src/taoensso/sente.cljx#L787

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help Getting Sente to Work

2014-07-27 Thread Peter Taoussanis
Hey Tim, sorry for not responding earlier - didn't notice your post till 
now (not often on the group).

Glad you found a solution (thanks Dan, Bob!). 

Just to clarify one thing though - a CSRF middleware is definitely 
recommended, but shouldn't be _necessary_. If Sente detects that no CSRF 
token is present in the Ring request during handshake, it'll print a 
warning to the JS console - but it should still continue to function 
normally after that.

It sounds to me like the issue you were having was with the default 
`chsk-url-fn`. A misconfigured CSRF middleware would result in a 403 error 
(forbidden), not a 404 error (not found).

The change you made for Austin looks good, but you will need to make an 
allowance for cases where the `websocket?` argument is false (i.e. for Ajax 
connections). You can see the `default-chsk-url-fn` as an example:

(def default-chsk-url-fn
  "`window-location` keys:
:href ; \"http://www.example.org:80/foo/bar?q=baz#bang\";
:protocol ; \"http:\" ; Note the :
:hostname ; \"example.org\"
:host ; \"example.org:80\"
:pathname ; \"/foo/bar\"
:search   ; \"?q=baz\"
:hash ; \"#bang\""
  (fn [path {:as window-location :keys [protocol host pathname]} websocket?]
(str (if-not websocket? protocol (if (= protocol "https:") "wss:" 
"ws:"))
 "//" host (or path pathname


I've also amended the relevant docstrings to hopefully make all this 
clearer for folks in future. Feel free to ping me here or on GitHub if I 
was unclear somewhere or if you've got any follow-up questions.

Cheers! :-)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: what is the best way of seeding your database with leiningen

2014-07-27 Thread Rui Yang
Awesome, Nelson. That's exactly what I want.

One minor thing to improve is to isolate these fixture loading codes with 
app source. I tried to use Leiningen Dev Profile :source-paths. It didn't 
work. I'll investigate more time into it later. At least for now, I can 
just put codes in the repl.clj created by Luminus template.

Thanks!

On Sunday, July 27, 2014 12:04:53 AM UTC+10, Nelson Morris wrote:
>
> You can use `lein run` to execute a function from your project while 
> avoiding the complexity/distribution of a plugin.
>
> In order to seed from a command line I would::
> 1. Write a function that can seed the data (like the blog post).
> 2. Use `lein run -m my.seed.ns/load-fixtures`.  This will start a jvm with 
> all your project deps and then run the specified function.
> 3. Add an alias to the project.clj by adding `:aliases {"seed" ["run" "-m" 
> "my.seed.ns/load-fixtures"]}`.  This allows the above command to be run 
> using `lein seed`, which is easier to remember.
>
>
> On Sat, Jul 26, 2014 at 8:50 AM, Rui Yang 
> > wrote:
>
>> Hi all,
>>
>> Using Leiningen, wonder what is the best way of seeding my database.
>>
>> I used ragtime to do the migration. I could drop the database and 
>> recreate it. After creating database, I would like to invoke some task to 
>> seed my database.
>>
>> One approach could be 
>> http://dustingetz.tumblr.com/post/24982262733/clojure-webapp-fixtures-seed-data.
>>  
>> It needs to manually specify the relation of entity, eg set the ID of the 
>> entity, and foreign key of the entity. When the ID is auto-generated in 
>> database, you may not be able to set the id manually.
>>
>> Ideally, I could just write a function to read the yaml fixture, and call 
>> my functions based on korma to seed data. But I don't know how to do it. 
>> Could a Leiningen plugin to call the functions in the project?
>>
>> Wonder if anyone has a better idea?
>>
>> Thanks.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ANN: Namespace browser for Emacs users

2014-07-27 Thread John Andrews
Emacs users: I have put together a namespace browser which builds upon the
existing functionality of Cider. It is in early stages of development but I
find it quite useful.

Check it out! https://github.com/jxa/cider-browse-ns

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] ring-transit 0.1.1 released

2014-07-27 Thread Josh Lehman
I've just thrown together a ring middleware for transit 
 with an api like that of 
ring-json . 

You can check it out here: ring-transit 
.

-Josh

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ANN: Clojure/conj 2014 CFP open till August 1st

2014-07-27 Thread Alex Miller
Yes, I believe there will be intro to clojure and Datomic workshops. More info 
should be available when tickets go on sale, I think this week.

Alex

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ANN clj-time 0.8.0 is released

2014-07-27 Thread Michael Klishin
clj-time [1] is a popular Clojure date/time library built on top of Joda Time.

Unfortunately, the project currently doesn't have a human-friendly change log,
so here's a git one (sorry):

https://github.com/clj-time/clj-time/compare/v0.7.0...v0.8.0

1. https://github.com/clj-time/clj-time/ 
--  
@michaelklishin, github.com/michaelklishin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help Getting Sente to Work

2014-07-27 Thread Timothy Washington
Ok, got it.

It was indeed the CSRF issue. I included that middleware to fix the issue.
For anyone else struggling with this, There's a *sente/example-project* with
some code

that uses the csrf middleware.

But also in my case, I'm using austin's browser-repl. Now, sente's default
behaviour is to use the URL of your connected client. However, my connected
repl client is "172.28.128.5:*58269*", which is not the actual port of the
webserver. Http-kit defaults to port 8090, so I needed a URL of "ws://
172.28.128.5:*8090*/chsk". And sente let's you pass in a :chsk-url-fn,
letting you specify your own URL. And that's how I got around that problem.
Hope that's clear, and that it helps someone.


  (ns bkell.core
(:require-macros
 [cljs.core.match.macros :refer (match)] ; Optional, useful
 [cljs.core.async.macros :as asyncm :refer (go go-loop)])
(:require
 [clojure.browser.repl :as repl]
 [cljs.core.match]
 [cljs.core.async :as async :refer (! put! chan)]
 [taoensso.sente :as sente :refer (cb-success?)]))

  *(defn chsk-url-fn [path {:as window-location :keys [protocol host
pathname]} websocket?]*
*"ws://172.28.128.5:8090/chsk ")*

  (let [{:keys [chsk ch-recv send-fn state]}
(sente/make-channel-socket! "/chsk" {:type :auto
 :chsk-url-fn
*chsk-url-fn*})]

(def chsk   chsk)
(def ch-chskch-recv) ; ChannelSocket's receive channel
(def chsk-send! send-fn) ; ChannelSocket's send API fn
(def chsk-state state))

  (defn one []
(chsk-send! [:some/request-id {:name "Rich Hickey" :type "Awesome"}]))

  (defn hello []
(js/alert "Hello World"))




Thanks guys

Tim Washington
Interruptsoftware.com 


On Sat, Jul 26, 2014 at 8:27 AM, Daniel Kersten  wrote:

> Speaking of CSRF, I have a slightly different setup from the Sente
> examples where I use sente for all my communication after the initial load,
> whereas the Sente examples use normal HTTP to perform logins and only use
> Sente after login. This way the login request can set the client-id and
> CSRF token. In my setup I can't do this because I do all requests over
> Sente (and my html/js files are served by a static web server, so I can't
> set it from those requests either).
>
> What I do to get around this is have a 

ANN metrics-clojure 2.1.1 is released

2014-07-27 Thread Michael Klishin
metrics-clojure [1] is a Clojure interface to the Metrics library [2],
originally by Steve Losh [3].

Release notes:
http://blog.clojurewerkz.org/blog/2014/07/26/metrics-clojure-2-dot-1-1-is-released/

If you're new to metrics and not sure why collecting them is a good idea,
take a moment to watch [4].

1. https://github.com/sjl/metrics-clojure
2. http://metrics.codahale.com/
3. http://stevelosh.com/
4. http://www.youtube.com/watch?v=czes-oa0yik
--  
@michaelklishin, github.com/michaelklishin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Clara 0.6.0

2014-07-27 Thread Ryan Brush
Clara, a rule engine in pure Clojure and ClojureScript,  has released 
version 0.6.0. The headliners are:

   - Durability. There are no facilities to store and reload session state. 
   I consider this experimental since the format may change non-passively 
   between releases, but it can be used under those constraints. See  
   *https://github.com/rbrush/clara-rules/wiki/Durability* for details.
   - Performance. Several significant performance optimizations were made. 
   This was the basis for this post: 
   *http://www.toomuchcode.org/blog/2014/06/16/micro-bench-macro-optimize/*
   - Better explainability of why rules fired. See 
   *https://github.com/rbrush/clara-rules/wiki/Inspection*
   - Upgraded to Clojure 1.6.0 (no changes required for the upgrade)
   - Details and other references can be found in the change log: 
   *https://github.com/rbrush/clara-rules/blob/master/CHANGELOG.md*

I’m not quite ready to promise there will never be another breaking change, 
but at this point Clara’s core and APIs are stable and I think it’s a 
viable alternative to other rule engines on the JVM. There are a couple 
other features I want to add to the core, but I plan on spending more time 
on some simple tooling to make rules in Clojure easier to create, explore, 
and understand.

Also, please feel free to post any questions or suggestions for Clara here. 
Thanks!

-Ryan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Gorilla REPL 0.3.1

2014-07-27 Thread Jony Hudson
The save interface should still work as before, as in it will save to any 
path (that exists) relative to the project directory. So typing 
"ws/test.clj" will save the worksheet in the ws directory, assuming it 
exists. I'll have a bit think on how I can make the UI for the new 
load/save behaviours more self-evident. Any suggestions welcome :-)

Stack-traces on exceptions is a good idea. A nice way to do it could be to 
display the message as now, and have the full stack trace folded under a 
'disclosure' triangle type UI 
element. https://github.com/JonyEpsilon/gorilla-repl/issues/128


Jony


On Friday, 25 July 2014 19:07:33 UTC+1, Paul Mooser wrote:
>
> Ah, this makes sense. I renamed my worksheets, and it finds them fine. I 
> didn't understand that it was supposed to be showing me a filtered list, 
> since what I was doing worked in a previous version. 
>
> So, is there now no way to create a worksheet in a subdirectory of the 
> project? I normally keep all of mine in a subdirectory. 
>
> I have another question regarding how exceptions are rendered. If you 
> happen to evaluate code which generates an exception, the displayed 
> representation contains only a single line. If you try to use clojure.repl 
> and do something like (pst *e), that has the same effect. I have a dumb 
> workaround, but is there a way to get gorilla-repl to show me the full 
> stack trace, so that I can easily debug it in-place ? 
>
> Thanks again for all of your work on this! 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Change default alignment for clojure docstrings

2014-07-27 Thread Bastien
Hi Lars,

Lars Andersen  writes:

> I tried writing up some examples here, in plain text, but I think
> it's more productive to just link to the github issue where there's
> syntax highlighting and I can get a preview of how the content lines
> up: https://github.com/clojure-emacs/clojure-mode/issues/241

I just sent a pull request which adds an option in clojure-mode for
this, defaulting to the de facto aligning style, while allowing to
use the one you suggest.

Together with the Vim plugin, it paves the way for a slow change,
if people think the default should change.

-- 
 Bastien

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.