Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sids on github.
  • I am sids (https://keybase.io/sids) on keybase.
  • I have a public key whose fingerprint is 940D 5E1F 153F 8DAB 36CA 0727 DFF8 A272 1E00 FA78

To claim this, I am signing this object:

@sids
sids / destructuring_examples.clj
Created October 18, 2012 19:48
Clojure Destructuring examples
;;; This is taken from http://paste.lisp.org/display/97057
;;; (which is no more; thanks to Wayback Machine which let me retrieve this).
;;; http://clojure.googlegroups.com/web/tutorial.pdf
;;; Vector binding forms destructure sequential things (vectors,
;;; lists, seqs, strings, arrays, and anything that supports nth)
;;; Map binding forms destructure associative things (maps, vectors, strings and arrays;
;;; the latter three have integer keys)
@sids
sids / prime_summands.clj
Created November 29, 2011 03:46
Prime Summands
(ns prime-summands.core
(:use [clojure.contrib.lazy-seqs :only #{primes}]))
(defn prime-summands [n]
(let [primes (take-while #(<= % n) primes)]
(reduce +
(for [start (range (count primes))]
(let [primes-sums (->> primes
(drop start)
(reductions +)
@sids
sids / prime_summands.clj
Created November 29, 2011 03:37
Prime Summands
(ns prime-summands.core
(:use [clojure.contrib.lazy-seqs :only #{primes}]))
(defn prime-summands [n]
(let [primes (take-while #(<= % n) primes)]
(reduce +
(for [start (range (count primes))
end (range 1 (inc (count primes)))]
(let [primes (drop start (take end primes))]
(if (= n (reduce + primes))
@sids
sids / gist:1013710
Created June 8, 2011 03:22 — forked from gf3/gist:457702
Regenerate ctags on checkout
#!/bin/sh
# Regenerate ctags on checkout
# project/.git/hooks/post-checkout
DIR=$GIT_DIR
if [ 0 -eq $3 ]; then
# file checkout
else
# tree checkout
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
http://search1.flipkart.com/solr/select?spellcheck=true&q=resumen+los+anticonceptivos+explicados+a+los+jovenes&spellcheck.q=resumen+los+anticonceptivos+explicados+a+los+jovenes&spellcheck.count=6&qt=spell_not&spellcheck.collate=true&debugQuery=true&indent=on&echoParams=true
;; First fetch CVS version of slime, git version of clojure, swank-clojure, clojure-contrib and clojure-mode
;; Create ~/bin/clojure script which starts clojure repl and adds clojure-contrib src dir and swank-clojure src dir to classpath. I used clj-env helper from clojure-contrib
(pushnew '("\.clj$" . clojure-mode) auto-mode-alist)
(require 'clojure-mode)
;;;; Slime configuration stuff
(setf slime-lisp-implementations
'((ecl("~/bin/ecl" "--heap-size" "1024000000") :coding-system utf-8-unix)
;;; all code in this function lifted from the clojure-mode function
;;; from clojure-mode.el
(defcustom sids/clojure-mode-font-lock-comment-sexp nil
"Set to non-nil in order to enable font-lock of (comment...)
forms. This option is experimental. Changing this will require a
restart (ie. M-x clojure-mode) of existing clojure mode buffers."
:type 'boolean)
(defconst sids/clojure-font-lock-keywords
@sids
sids / html_parser.clj
Created May 6, 2010 05:44
HTML Parsing in Clojure using HtmlCleaner.
(ns in.grok.history.html-parser
(:require [clojure.contrib.logging :as log])
(:import [org.htmlcleaner HtmlCleaner]
[org.apache.commons.lang StringEscapeUtils]))
(defn parse-page
"Given the HTML source of a web page, parses it and returns the :title
and the tag-stripped :content of the page. Does not do any encoding
detection, it is expected that this has already been done."
[page-src]