diff --git a/plugins/signature.rb b/plugins/signature.rb new file mode 100644 index 00000000..bf5e6eec --- /dev/null +++ b/plugins/signature.rb @@ -0,0 +1,22 @@ +# A Liquid tag for signatures +# by: Paulo Suzart +# Source https://gist.github.com/2372727 +# +# Example usage: {% signature paulosuzart %} +module Jekyll + + class SignatureTag < Liquid::Tag + def initialize(tag_name, text, token) + super + @text = text.strip! + end + + def render(context) + <<-HTML +

Don't forget to visit the about page. And follow me on Twitter: @#{@text}.

+ HTML + end + end +end + +Liquid::Template.register_tag('signature', Jekyll::SignatureTag) diff --git a/source/_posts/2011-10-30-dateparammatcher-for-finagle.markdown b/source/_posts/2011-10-30-dateparammatcher-for-finagle.markdown index f7592e12..0bdfaf5c 100644 --- a/source/_posts/2011-10-30-dateparammatcher-for-finagle.markdown +++ b/source/_posts/2011-10-30-dateparammatcher-for-finagle.markdown @@ -52,4 +52,6 @@ Note that if the param named `requestTimeParam` is not present or carries a inva Although easy to build and extract params from query string and requested path, it is not a Finagle strength. It is kinda limited. A better abstraction is offered by [Unfiltered](https://github.com/unfiltered/unfiltered)(another [@n8han's](http://twitter.com/n8han) great job). -Hope you enjoy it. \ No newline at end of file +Hope you enjoy it. + +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2011-10-30-what-you-are-supposed-to-find-here.markdown b/source/_posts/2011-10-30-what-you-are-supposed-to-find-here.markdown index 2e6439bf..aaf2dba8 100644 --- a/source/_posts/2011-10-30-what-you-are-supposed-to-find-here.markdown +++ b/source/_posts/2011-10-30-what-you-are-supposed-to-find-here.markdown @@ -10,4 +10,4 @@ Hi, this is another blog of mine. Yap, I have a - mostly in portuguese - wordpre The main reason to starting blogging directly on my Github is to keep the subjects even more focused on projects committed here, and share some experiences with some libs also committed here. -Hope you enjoy the content. Please don't forget to visit the [about](/about) page. And follow me at Twitter: [@paulosuzart](http://twitter.com/paulosuzart) \ No newline at end of file +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2011-12-04-korma-and-clojure-records.markdown b/source/_posts/2011-12-04-korma-and-clojure-records.markdown index 6c7459c7..5270bd2c 100644 --- a/source/_posts/2011-12-04-korma-and-clojure-records.markdown +++ b/source/_posts/2011-12-04-korma-and-clojure-records.markdown @@ -70,4 +70,4 @@ Now your code is a bit more resilient to database changes with this thing layer Korma can do a lot of things to make your life easier, as the abililty to compose queries, and performs really nice. Think I finally found THE framework for relational data access in clojure. -Don't forget to visit the [about](/about) page. And follow me on Twitter: [@paulosuzart](http://twitter.com/paulosuzart) \ No newline at end of file +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2011-12-11-my-own-redis-types-notation.markdown b/source/_posts/2011-12-11-my-own-redis-types-notation.markdown index ced871f0..e26e1fac 100644 --- a/source/_posts/2011-12-11-my-own-redis-types-notation.markdown +++ b/source/_posts/2011-12-11-my-own-redis-types-notation.markdown @@ -44,4 +44,4 @@ It is simple and is helping a lot. Another good thing I started to do is to writ I'm using [clj-redis](https://github.com/mmcgrana/clj-redis/) interact with redis. -Hope it may be useful for you. Don't forget to visit the [about](/about) page. And follow me on Twitter: [@paulosuzart](http://twitter.com/paulosuzart) \ No newline at end of file +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2011-12-11-my-own-redis-types-text-notation.markdown b/source/_posts/2011-12-11-my-own-redis-types-text-notation.markdown index 5b926943..b2e825de 100644 --- a/source/_posts/2011-12-11-my-own-redis-types-text-notation.markdown +++ b/source/_posts/2011-12-11-my-own-redis-types-text-notation.markdown @@ -35,4 +35,4 @@ An instance of this process would be: It is the form I'm using as doc strings in a namespace. It looks great with [Marginalia](http://www.fogus.me/fun/marginalia/). -Hope it may be useful for you. Don't forget to visit the [about](/about) page. And follow me on Twitter: [@paulosuzart](http://twitter.com/paulosuzart) \ No newline at end of file +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2012-02-03-clojure-macros-automating-aws-simpledb-admin-tasks.markdown b/source/_posts/2012-02-03-clojure-macros-automating-aws-simpledb-admin-tasks.markdown index 4ea1e9b5..ebf8af5b 100644 --- a/source/_posts/2012-02-03-clojure-macros-automating-aws-simpledb-admin-tasks.markdown +++ b/source/_posts/2012-02-03-clojure-macros-automating-aws-simpledb-admin-tasks.markdown @@ -76,4 +76,6 @@ If take a closer look you may notice a function call to `(env "AWS_KEYID")`. It You can extend the macro to have any admin task you may need. Note that the `*sdbconf*` will become available, so you can call rummage directly without having to configure all again. -That is it. Clojure is smart! \ No newline at end of file +That is it. Clojure is smart! + +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2012-03-25-web-noir-plus-enlive-template.markdown b/source/_posts/2012-03-25-web-noir-plus-enlive-template.markdown index 39535f1d..25766f28 100644 --- a/source/_posts/2012-03-25-web-noir-plus-enlive-template.markdown +++ b/source/_posts/2012-03-25-web-noir-plus-enlive-template.markdown @@ -101,4 +101,4 @@ lein run And start having fun with enlive and noir. This project template may be evolved to have [korma](http://sqlkorma.com/) or any persistence framework. -Hope it may be useful for you. Don't forget to visit the [about](/about) page. And follow me on Twitter: [@paulosuzart](http://twitter.com/paulosuzart) \ No newline at end of file +{% signature paulosuzart %} \ No newline at end of file diff --git a/source/_posts/2012-03-27-lazy-seqs-from-database-with-clojure-korma.markdown b/source/_posts/2012-03-27-lazy-seqs-from-database-with-clojure-korma.markdown index 68679a54..8ca58040 100644 --- a/source/_posts/2012-03-27-lazy-seqs-from-database-with-clojure-korma.markdown +++ b/source/_posts/2012-03-27-lazy-seqs-from-database-with-clojure-korma.markdown @@ -43,7 +43,9 @@ Just to play around, try: It returns from 0 to 10, being a finite lazy sequence just like the source data set. One can use `take-while` to limit the results of a lazy-seq. You can compute really big sets using the laziness approach. -Hope it may be useful. Don't forget to visit the [about](/about) page. And follow me on Twitter: [@paulosuzart](http://twitter.com/paulosuzart). +Hope it may be useful. + +{% signature paulosuzart %} **Update - Apr 7 2012**: *Although an interesting and working solution, this code is not that functional. First of all, because it does I/O, but there is something that could be fixed to have a better "purity". `map` or `pmap` produce new sequences. Sequences full of `nils` in this case, because `persist` returns `nil`. The only advantage is the use of `pmap`, to run it in parallel, but it is still weird to have resulting seqs of `nils`.* diff --git a/source/_posts/2012-04-11-sorting-with-clojure-comparator.markdown b/source/_posts/2012-04-11-sorting-with-clojure-comparator.markdown new file mode 100644 index 00000000..2b33b8c3 --- /dev/null +++ b/source/_posts/2012-04-11-sorting-with-clojure-comparator.markdown @@ -0,0 +1,35 @@ +--- +layout: post +title: "sorting with clojure comparator" +date: 2012-04-11 22:51 +comments: true +categories: clojure elementary +--- + +This is a quick post to show an example of [clojure](http://clojure.org) `comparator` for sorting a list with `sort`. + +At work a friend wrote dozen lines of java to sort a list of characters that represents t-shirt sizes. The sizes are: pp, p, m, mm, g, gg, a, aa. Whre pp is super small, p small, m medium, etc. + +Some shees have all the sizes available, some not. So imagine a shirt with just g, a, gg, p sizes availabe. The screen should show: p, g, gg, a. + +He requested me to do a clojure version of it. Here it goes. + +{% gist 2351780 %} + +The first useful function is [`map-indexed`](http://clojuredocs.org/clojure_core/clojure.core/map-indexed). Since the order of sizes is not natural, we associate numbers to them given we know the size order. So `sizes` becomes `{:a 6, :gg 5, :g 4, :pp 0, :m 2, :mm 3, :aa 7, :p 1}`. + +Then I used a [`comparator`](http://clojuredocs.org/clojure_core/clojure.core/comparator). It produces a `java.util.Comparator` for the given function. In this case the comparison of the map values for each key. + +To finish that, the [`sort`](http://clojuredocs.org/clojure_core/clojure.core/sort) function. It takes a given product sizes list and sorts then. So `'(p, g, gg, aa)` becomes `(p g gg a)`. + +It is even silly for a blog post but what if I can convince him to replace the java methods/utils/whatever methods for a [`gen-class`](http://clojuredocs.org/clojure_core/clojure.core/gen-class) of it? Packing compiled clojure code and using them for utility functions and small piece of your application can be a good way to get used to the language and confidence to start a full application in it. + +Actually to let this code resuable, one can take the list of sizes instead of hard coding it. But this is an exercise for you. + +{% signature paulosuzart %} + +*Thanks to USA guys, you are the top visitors here. Thank you very much.* + + + +