clojure-cookbook / clojure-cookbook Goto Github PK
View Code? Open in Web Editor NEWThis is the home of O'Reilly's Clojure Cookbook - http://clojure-cookbook.com
This is the home of O'Reilly's Clojure Cookbook - http://clojure-cookbook.com
The main road for Clojure developers is to code in Clojure and to optionally depend on some external Java based libraries/ frameworks. Clojure with its built-in Java interoperability makes this very easy.
In an enterprise Java environment, where introduction of new technologies such as Clojure might face some resistance due to risk considerations, a possible solution is to pick one component, code it in Clojure, and keep the rest in well known Java land. A Java interface, implemented in Clojure, and used from Java, requires an elaborate build setup.
Filling out the form at http://www.clahub.com/agreements/clojure-cookbook/clojure-cookbook leads to the error page consisting of the text, "We're sorry, but something went wrong."
Possibly alternate arrangements should be made for CAs until that signing form can be fixed.
There should be an example of using Clojure to consume the Twitter API.
Here is a list of updates I'd like to make to the Get files from a directory recipe
+
sHow to read a stack trace to figure out which form (which may be deeply nested) is failing.
Editing the raw asciidoc source is a frustrating way to preview one's own recipes. I managed to get asciidoc running and generating HTML copies of this book locally for editing purposes, but the following hints, perhaps added to the README, would be helpful:
I'm willing to help out on this one but could use help with (2).
[1] footnotes
Presently the ASCIIDoc callouts in the simple-statistics recipe are messed up in draft book renderings.
Make them not messed up.
(This one is probably most do-able for @levand or myself–that is unless you are able to compile the book.)
Problem: You want to parse command line arguments and use them in your command line application.
Starting with a fresh install of vim, what's a good setup to have? fireplace, nailgun etc
A lot of problems can be practically solved by referring to third party libraries. The twitter api is an example of this.
We can specify versions within each recipe, but I wonder if we shouldn't just mention the library versions in the description and where people can grab the latest release.
Thoughts?
I was thinking of creating a recipe for a pattern I use to validate input by applying a vector of validation functions and reducing to a set of booleans. Not sure where that would belong in the structure of the book, though. Any Ideas? Speaking of ideas, I can't seem to add a label to this issue. Looks like I have to be an existing contributor?
How about a chapter about practical use cases for core.logic?
Parsing CSV formatted files is incredibly common, we should show a good example of it.
There are currently a few recipes in the Local I/O chapter that utilize file-seq
with clojure.java.io/file
to get a list of files from a directory. Any such recipes should include an AsciiDoc Internal Cross Reference from those recipes See Also section to the Get files from a directory recipe.
The reference will look something like this:
===== See Also
* <<sec_primitives_strings_re_find>> for testing a string for the
presence of a pattern.
and the target recipe will look like this:
[[sec_primitives_strings_find_replace]]
==== Performing Find and Replace on Strings
LightTable (http://www.lighttable.com/) is alpha, but even in this early stage outperforms regular editors (be it emacs, vim, sublime, ...) in terms of developer productivity.
It is a tad bit tricky to correctly split file paths in Java. Write a recipe covering an adequate technique (See pedestal's app-tools for an example.)
Understanding destructuring in clojure is extremely important for writing concise code and understanding idiomatic clojure code. It would be useful to add a recipe for destructuring vectors, maps, and strings to the composite data section.
Most webapps need a login. OAuth is a common choice. We should have an example of this.
For instance, the "strings" section of primitive-data is not very vocal about existing.
Optimally this extra information might make it clear how complete a section is.
Interactive charts and graphics are all the rage; we should have an example of how to build them from Clojure data on a ClojureScript page
How do I do it properly?
Here is a list of updates I'd like to make to the Copy a file recipe
safe-copy
example. (This may be a bit difficult for others until we get better instructions for rendering.)Reader
/Writer
with clojure.java.io/copy
[[sec_....]]
and <<sec_...>>
pairs)I've documented what I'm asking for thoroughly on HackerNews here: https://news.ycombinator.com/item?id=5869422
For a more in depth example of what I struggle with, check out this SO question I asked: http://stackoverflow.com/questions/16901836/how-do-i-get-better-feedback-from-clojure-errors
I'd be happy to give this a shot. Do you think it's stable enough to get its own recipe?
My idea is to provide some trivial html and then scrape it the same way with at least Enlive and Laser.
The example would be as short and simple as possible, intended to show you how to load the html with each library and let you compare their syntax. I have to look up these semantics every time I switch between these libraries.
It'd be great to sum up REPL driven development a la my Clojure/west talk Editing Clojure Effectively with Emacs. I will do this in the near future, but if someone else wants to tackle this let me know.
This recipe should be cross linked with the Exploring Clojure section.
See this blog post by @malcolmsparks
Hi,
a little question, just to be sure and to don't mess around.
If I write recipe for you, then there are any problems if I publish my own recipes on my own blog ?
O'Reilly is fine with that ?
As covered in this SO post and others: http://stackoverflow.com/questions/13435541/reading-unbuffered-keyboard-input-in-clojure?lq=1
I might take this one if nobody else wants it ASAP.
If someone will +1, I can provide a recipe under local-io.
De/serializing Clojure data <=> edn and using it in a web context, as a data storage format, etc. would be useful.
I have started to put together read/write of XML for addition to the local io chapter. If that sounds like a good idea you can put this one to in-progress and I'll will keep working on it.
Extend Java native types. For example, we could add an isPalindrome?
method to java.lang.String
via extend-type
:
user=> (defprotocol Palindrome
#_=> (isPalindrome? [this]))
Palindrome
user=> (extend-type String
#_=> Palindrome
#_=> (isPalindrome? [this] (let [base-string (-> this
#_=> (clojure.string/replace #"[,.! ]" "")
#_=> .toLowerCase)]
#_=> (= base-string
#_=> (clojure.string/reverse base-string)))))
nil
user=> (def test-string "A man, a plan, a canal. Panama!")
#'user/test-string
user=> (class test-string)
java.lang.String
user=> (isPalindrome? test-string)
true
Should we include images if necessary ?
There are dimension that we need to stay in ?
The current proposed chapters look pretty comprehensive. However, one Chapter that I find missing is "Fun Problems". These are problems that are just fun to solve. Example recipes in this chapter could be various kind of algorithmic problems or puzzles or other misc. stuff which are fun to solve. Like:
I could contribute many of such recipes for this chapter. e.g. Look at some of the problems I have solved in python at https://github.com/nangia/funproblems and in clojure at https://github.com/nangia/funwithclojure. While there is no detailed documentation that I have put in on github yet, I can write up detailed recipes for the book to explain how these can be solved.
Thanks and regards,
As per the discussion in #54 CONTRIBUTING.md should include instructions on how to introduce a library dependency to a recipe both in its own project.clj (this may necessitate fleshing out the sub-project story) as well as how to tastefully mention this possibly versioned dependency to the recipe text itself.
Presently a recipes ASCIIDoc file must live under a sub-folder per recipe (i.e. my-recipe/my-recipe.asciidoc
). It should be possible to exclude the sub-folder for simple recipes (i.e. my-recipe.asciidoc
)
When to use agents/ refs etc
For example, compare lists of time-slots. A time-slot being an arbitrary length of time defined by a point in time and a duration. The recipe could show how to find overlaps of time slots (say for a scheduling system) via intersections of the times in multiple lists. Another manipulation could be to find open time slots (as in a booking system).
The point being would be to show the utility of the union/difference/intersection/etc functions, but not just on plain/simple lists. The above example is complex enough to not be trivial.
I believe is necessary to show how to publish a library using lein in clojar
credits need to go here too, thought.
https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#publishing-libraries
Java (and by proxy, Clojure) is capable of low-level graphics manipulation. Including an example of this would be interesting.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.