Re: Can I use reduce here?

2014-12-12 Thread Jarrod Swart
Mathias, I wrote a short article about building more complex reduce functions here[1]. I wrote it mostly to reinforce my own knowledge. The bottom section will be most relevant to you. Hope it helps, Jarrod [1]: http://jarrodswart.com/articles/clojure-tutorial-reduce-functions On Friday, De

Re: System/getenv can't read env vars?

2014-07-08 Thread Jarrod Swart
Awesome thank you! -- 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,

Re: System/getenv can't read env vars?

2014-07-08 Thread Jarrod Swart
James, It appears Sean and yourself have identified the issue. The tmux scripts that launch my dev environment don't pull in the necessary environment. I have seen your environ library and I was to thank you for all your contributions. Sean too! While I have you James do you have a good ex

Re: System/getenv can't read env vars?

2014-07-07 Thread Jarrod Swart
Sean, Thanks for the input. There is a good chance you are right. The process is launched from tmuxinator a tool that opens multiple processes and joins them all to a tmux session. I suppose I'll have to investigate that but it seems odd that if I type "echo $MY_VAR" I get the expected value

Re: System/getenv can't read env vars?

2014-07-07 Thread Jarrod Swart
Yep I ran export MY_VAR=foo and all subsequent "calls" to get or print the env var on the CLI work fine. I set the var and restarted all repl processes. I'll try setting it in .bashrc as well. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

System/getenv can't read env vars?

2014-07-07 Thread Jarrod Swart
If I call: (System/getenv "MY_VAR") ;=> nil >From bash set | grep MY_VAR ;=> foo echo $MY_VAR' ;=> foo I can do this from bash, as well as my tmux session. I use tmuxinator to launch a repl and vim, thus my repl process is running inside TMUX. That said, I can see the env var in other tmu

Re: Hosting Providers

2014-05-01 Thread Jarrod Swart
As Richard said most places that run Java, will run your Clojure. Google App Engine and Engine Yard appear to take a WAR file. lein ring uberwar (in your project dir) While heroku pushes your code to the "server" and then does its magic. git push If you run on your own servers most people do

Re: Ring + Compojure new route recognition

2014-04-28 Thread Jarrod Swart
Thank you. The compojure-app template does something similar, and I was using that from LightTable, evaling a (start-server) var. This was good info and reminded me what I was doing and how to apply it to the new environment. -- You received this message because you are subscribed to the Go

Ring + Compojure new route recognition

2014-04-27 Thread Jarrod Swart
I've noticed that when using Ring + Compojure w/ LightTable the following process will get me access to any newly added routes. 1. Add a route 2. Eval the route NS 3. Eval the handler NS 4. Check route in browser 5. Success Recently I've begun using Vim + Fireplace. I cd to my project dir and s

One app, multiple mains \ processes -- heroku style architecture

2014-04-15 Thread Jarrod Swart
I've been reading about Heroku's process model and their approach to web app architecture. I'm curious how you could recreate something like this: https://devcenter.heroku.com/articles/getting-started-with-clojure#one-off-scripts Using an uberjar in environments other than heroku. Would it mak

Re: How to update an atom & return the change?

2014-03-21 Thread Jarrod Swart
Just to add to this because I ran across this reading some code a few days ago: https://github.com/overtone/at-at/blob/master/src/overtone/at_at.clj#L43-51 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: How did you learn Clojure?

2014-03-21 Thread Jarrod Swart
A tip if you are completely stuck on 4clojure: Often the 4clojure problem will say you can't use a particular function. The first thing I would do is go look at the source code for that function, then I would try to find other functions with similar functionality. Much like learning to paint

Re: Help a Startup use Clojure!

2014-03-13 Thread Jarrod Swart
Oh wow, thanks for all the responses! I'm certainly not making it a PHP vs. Clojure all or nothing debate. Anything other than PHP would be helpful, not simply because I want to bad mouth PHP. After 2 years working with it I know firsthand its shortcomings for building actual applications. Wh

Re: Help a Startup use Clojure!

2014-03-12 Thread Jarrod Swart
Alan, Thanks for your input! ClojureScript is something I have wanted to try more but it seems even more cutting edge than Clojure. It might be too much effort to try and tackle that now. I do agree though that Clojure+Ring is a great back-end setup for connecting to with JavaScript. Best,

Re: Help a Startup use Clojure!

2014-03-12 Thread Jarrod Swart
David, Awesome thanks for sharing! I hope it works out for you! -- 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 you

Re: Help a Startup use Clojure!

2014-03-11 Thread Jarrod Swart
Sean, Thanks for the reply and insight. I completely agree on your points. We will be in a 12 week accelerator program so it is quite possible that this code & business could fail. Our work is likely going to be more back-end API centric as a point of integration for other businesses rather

Re: Help a Startup use Clojure!

2014-03-11 Thread Jarrod Swart
Sean, Oops I didn't realize you were asking these questions: - What are you building? - An application for businesses to help leverage the power of crowds in non-traditional "crowdsource" environments. - The main use-case for many will be that of integration with-in

Re: Question about importing java classes to Clojure

2014-03-11 Thread Jarrod Swart
No problem, happy to help. Here is one way you might write the above with fs. I didn't check this I just typed it out so there may be a few tiny bugs. (defn jar? [filename] (if (= (fs/extension filename) "jar") true false)) (defn list-paths [path-str] (println "Files in " path-str

Re: Question about importing java classes to Clojure

2014-03-11 Thread Jarrod Swart
Hey Brandon, I had a really simple blog post about reading a directory of files that I never published, I updated it and hopefully it can help: http://jarrodswart.com/clojure-like-im-five-working-with-files/ Best, Jarrod -- You received this message because you are subscribed to the Google Gr

Re: Help a Startup use Clojure!

2014-03-11 Thread Jarrod Swart
Christopher, Absolutely I agree. I enjoyed that book very much. I think I misstated my question a bit in that I don't need to be convinced of the value, but rather how best to relay Clojure's benefits to non-technical business types. Thanks for your input. -- You received this message becau

Re: Help a Startup use Clojure!

2014-03-11 Thread Jarrod Swart
Gary, Thanks for your observations. I agree it doesn't necessarily have to be all or nothing. I'm hoping to get as much as possible insight before I present to the founders. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Help a Startup use Clojure!

2014-03-11 Thread Jarrod Swart
I'm about to be an early employee at a small startup. I will be the first technical hire and am a competent but not extraordinarily experienced developer. The founders know this and hired me based on soft as well as technical skills. I don't want to be the first technical employee and make

Re: I'm trying to make proper urls, but I seem to be failing at it.

2014-03-10 Thread Jarrod Swart
No edit button so I have to post again, that first example should end with ";; (make-profile-url "John Smith") => "/John-Smith" And to reiterate you decide what your url will look like in your template: http://myapp.com/JohnSmith";>View John Smith's Profile or http://myapp.com/John-Smith";>View

Re: I'm trying to make proper urls, but I seem to be failing at it.

2014-03-10 Thread Jarrod Swart
Right, either way the compojure route would be the same. (GET "/:profile-name" [profile-name] ...). You don't need an extra column in your DB unless you want to do so. The route/compojure is simply responding to the URL you write out in your template, or that is requested by some other mecha

Re: I'm trying to make proper urls, but I seem to be failing at it.

2014-03-10 Thread Jarrod Swart
in the URL. I recommend not having a space, take a look at google+ where my username is "Jarrod Swart" but my profile url is: plus.google.com/+JarrodSwart Hopefully this helps, or perhaps I misread the thread. -- You received this message because you are subscribed to the Googl

Re: [ANN] Stasis - not another static site framework

2014-03-09 Thread Jarrod Swart
Awesome, thanks for bringing these great libraries to my attention! -- 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 y

Re: Clojure performance question

2014-03-05 Thread Jarrod Swart
Thanks for the elaboration, I just wanted to make sure I understood. -- 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

Re: Clojure performance question

2014-03-04 Thread Jarrod Swart
On Monday, March 3, 2014 11:35:58 AM UTC-5, Mikera wrote: > > > Obviously, there are cases where allocating a sequence will be slower than > iterative techniques. But that's *easy enough to fix by just using > iterations in those cases* use the right tool for the job and all > that. > > I

Re: [ANN] Stasis - not another static site framework

2014-03-04 Thread Jarrod Swart
This is a cool project. I primarily use static site generators to build the front-end for sites that I will use enlive to template inside my app. I currently use: http://harpjs.com for this purpose because it allows easy integration of LESS and Jade which are auto recompiled & watched by the de

Re: Accumulate results without state?

2014-03-04 Thread Jarrod Swart
I do something very similar to this where I parse large CSVs and keep/discard rows of the CSV based on the values of columns. Like you I had a hard time "getting" how to use reduce beyond trivial implementations. I spent some time messing with reduce and learning how to construct more advanced

Re: Question about best pattern for side-effecting function with a return value

2014-02-10 Thread Jarrod Swart
> if not, I'd use doseq. This is a guess, but it seems like you don't have > any need for the results, you just want the side effects of updating the DB > and storing the file, so I'd just use doseq. I hope that helps! > > Shaun > > On Monday, February 10, 2014 7:

Re: Question about best pattern for side-effecting function with a return value

2014-02-10 Thread Jarrod Swart
> (process-api-result!) > ;; do whatever you want with the state, for now return the entity > and the result file > (select-keys [:db-entity :api-result-file]))) > > > In this example you'd just call api-call-pipeline! with the database > entity. This let

Question about best pattern for side-effecting function with a return value

2014-02-10 Thread Jarrod Swart
I'm having a hard time coming up with a satisfactory way to implement the following: 1. Call an API with a map from the DB containing various endpoint data like URL, etc. 2. If the response has an HTTP 200, update the map-from-db and then write response body to a file. 3. If ste

Re: Java interoperability

2014-01-27 Thread Jarrod Swart
eshire for JSON? > > Yes, I am probably taking the wrong approach. Is the Clojure way to put > the JSON in Clojure data structures and manipulate it with filters etc? > > Many Thanks > > Paul > > > On Mon, Jan 27, 2014 at 3:35 PM, Jarrod Swart > > wrote: > &g

Re: Java interoperability

2014-01-27 Thread Jarrod Swart
It looks like the method exists to me: https://github.com/jayway/JsonPath/blob/master/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java#L-445-505 It looks like the problem is that you are passing in empty strings: https://github.com/jayway/JsonPath/blob/master/json-path/src/main/java/com

Re: Clojure development & laptop battery usage

2014-01-25 Thread Jarrod Swart
MBP --> Mac Book Pro MBA --> Mac Book Air Best, Jarrod On Saturday, January 25, 2014 11:12:37 PM UTC-5, greybird wrote: > > In case it helps, I've also seen this CPU eating problem. I'm using: > REPL-y 0.1.9 Clojure 1.5.1. I don't know what you guys mean by MBP and MBA. > --mark > > -- -- Y

Re: Rename file uploaded

2014-01-25 Thread Jarrod Swart
Awesome, glad you got it working. I highly recommend: http://pragprog.com/book/dswdcloj/web-development-with-clojure, for step by step Web Dev in Clojure. Reading through it got me up to speed really quickly as far as project structure, common libs and practices, etc. On Saturday, January 25

Re: Helping newcomers get involved in Clojure projects

2014-01-25 Thread Jarrod Swart
> > I have been spending a lot of time thinking about the Clojure newcomer > perspective lately, and I'd like to work on some things that help smooth > that path. I've been thinking about this as well, and I would love to hear your thoughts. Please elaborate! On Saturday, January 25, 2014

Re: Rename file uploaded

2014-01-25 Thread Jarrod Swart
Nothing sticks out, but a NullPointerException is something I most commonly get as a result of an incorrect file path. Things I would do: 1. Make sure that (gallery-path) actually exists or is writable. 2. I would do (POST "/upload" [file] (println file) (handle-upload file))), to inspect what

Re: Clojure memory usage

2014-01-25 Thread Jarrod Swart
This was talked about here: https://groups.google.com/forum/#!searchin/clojure/user$3A$20g$20vim/clojure/XqPGnX5aSAI/PoLYaydgX3cJ TLDR: The JVM carves out its own chunk of memory from the OS. It then uses very advanced and finely tuned means to manage said memory. So even though the app isn't

Re: Web App structure on server?

2014-01-25 Thread Jarrod Swart
task. > > Cheers, > > Josh > > > On Saturday, January 25, 2014 at 7:40, Jarrod Swart wrote: > > > I appreciate your outlook, and yes I have definitely discussed the pros > of Clojure. They are apprehensive in the event they have to outsource > development

Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
-timestamp function? Checking that link right now. > > On Friday, January 24, 2014 9:05:35 PM UTC-8, Jarrod Swart wrote: >> >> Well that isn't quite what I meant. In that case you are just casting >> what is likely the map of upload data to a string. >> >> Try

Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
ntire map as: > > {:size 17401, :tempfile #, :content-type "image/jpeg", :filename > "AngryBaby4.jpg"} > > How can feed it just the :filename portion of the map as string to the > add-timestamp function? Checking that link right now. > > On Friday, January 24, 201

Re: Web App structure on server?

2014-01-24 Thread Jarrod Swart
s => process coordination within the server (perhaps core.async, > or other scheduling tools) > - python scripts / micro-apps => separate Compojure routes / APIs within > the server > - hacking at the command line => hacking with the REPL > > > On Saturday, 25 January 2014 1

Re: clojure debugging repl

2014-01-24 Thread Jarrod Swart
pter alone. > > However, looking at http://www.manning.com/fogus2/ I can't seem to find > it. Which chapter is it? > > > > On Fri, Jan 24, 2014 at 3:46 PM, Jarrod Swart > > wrote: > >> The second version of The Joy of Clojure talks about building a debugging >

Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
Well that isn't quite what I meant. In that case you are just casting what is likely the map of upload data to a string. Try this: (defn handle-upload [filename] (str filename)) Why? This will show you what type of data you receiving on upload. My guess is that it is a map containing all

Web App structure on server?

2014-01-24 Thread Jarrod Swart
I have a general question about application architecture as it relates to deploying to the server. Most of my previous development work involved python/php/ruby so we typically had: 1. One massive framework / application complection nightmare 2. Background scripts run by crons At prese

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
ng, as > (intersection A Everything) = A no matter what A is. > > > On Fri, Jan 24, 2014 at 7:38 PM, Jarrod Swart > > wrote: > >> Good points. But the "identity" thing is still what gets me. What is >> the identity of an intersection? >> >> Lik

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
> then (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The >>> latter is true under the hypothesis for every "real" set but would be false >>> for (intersection). >>> >>> Perhaps this is why (intersection) is not supported at thi

Re: clojure debugging repl

2014-01-24 Thread Jarrod Swart
The second version of The Joy of Clojure talks about building a debugging repl that allows insertion of breakpoints into code. Perhaps something similar could be done here. On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote: > > Found it, apparently it's > > debug-repl => swank-clojure =>

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
The > latter is true under the hypothesis for every "real" set but would be false > for (intersection). > > Perhaps this is why (intersection) is not supported at this time, even > though (union) returns an empty set object, the identity element for the > union operation.

Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
It works for me. I am guessing you are not passing in a string when you are calling (add-timstamp filename). Which is to say that your param 'filename' is a map not a string. If you are passing in a map of the upload information you need to grab the filename for your let: (let [ext-postion (

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Ah cool, thanks for posting your solution! On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote: > > Jarrod Swart > writes: > > > The reason you can't get this to work is that r/map returns a > > > not a for reduce to operate on. > > Ah,

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
The reason you can't get this to work is that r/map returns a not a for reduce to operate on. I'm not sure of a solution because I'm not familiar with core.reducers. But reading this: http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html informed me

Re: core.async count in a channel

2014-01-21 Thread Jarrod Swart
I have not used core.async much but I did use Go a fair bit and I concur with what Aaron said. The missing piece for you Paul is that goblocks\channels are not just a way to do concurrent work, but also a control flow mechanism. What Aaron is saying is that by using channels to control various

Re: [Large File Processing] What am I doing wrong?

2014-01-21 Thread Jarrod Swart
Jim, Thanks for the idioms, I appreciate it! And thanks everyone for the help! On Tuesday, January 21, 2014 8:43:40 AM UTC-5, Jim foo.bar wrote: > > On 21/01/14 13:11, Chris Perkins wrote: > > This part: (some #{hashed} already-seen) is doing a linear lookup in > > `already-seen`. Try (contain

Re: [Large File Processing] What am I doing wrong?

2014-01-21 Thread Jarrod Swart
Monday, January 20, 2014 11:55:00 PM UTC-7, Jarrod Swart wrote: >> >> I'm processing a large csv with Clojure, honestly not even that big (~18k >> rows, 11mb). I have a list of exported data from a client and I am >> de-duplicating URLs within the list. My final output i

[Large File Processing] What am I doing wrong?

2014-01-20 Thread Jarrod Swart
I'm processing a large csv with Clojure, honestly not even that big (~18k rows, 11mb). I have a list of exported data from a client and I am de-duplicating URLs within the list. My final output is a series of vectors: [url url-hash]. The odd thing is how slow it seems to be going. I have tri

Re: HttpKit, Enlive (html retrieval and parsing)

2014-01-13 Thread Jarrod Swart
This is exactly what I do and it works great! On Saturday, January 11, 2014 7:00:22 PM UTC-5, Jan Herich wrote: > > I don't recommend using java's built in HTTP retrieval (by passing > java.net.URL object to enlive html-resource function). > Not only is it significantly slower then using clj-http

Re: 2013 State of Clojure & ClojureScript survey results

2013-11-18 Thread Jarrod Swart
I will second http://clojure-toolbox.com and I also recently found: http://www.clojuresphere.com/ On Monday, November 18, 2013 4:01:27 PM UTC-5, Brian Craft wrote: > > Wow, this result is shocking to me: > > In short, Clojure libraries are easy to find, their maintainers are >> receptive to fee

Re: Do web apps need Clojure?

2013-11-18 Thread Jarrod Swart
16, 2013, at 4:34 PM, Jarrod Swart > > wrote: > > I think the more interesting question is: *do web developers need > Clojure? *If performance were the sole concern then everyone would still > code web apps in C or assembler. There is great power in abstraction. I >

Re: Do web apps need Clojure?

2013-11-16 Thread Jarrod Swart
I think the more interesting question is: *do web developers need Clojure? *If performance were the sole concern then everyone would still code web apps in C or assembler. There is great power in abstraction. I like this talk by Uncle Bob: http://skillsmatter.com/podcast/agile-testing/bobs-l