Skip to content

Instantly share code, notes, and snippets.

(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
(defn make-counter [initial-value]
(let [current-value (atom initial-value)]
(fn []
(swap! current-value inc))))
(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
(defn numbered-lines [lines]
(map vector (iterate inc 0) lines))
(defn grep-in-file [pattern file]
{file (filter #(re-find pattern (second %)) (numbered-lines (read-lines file)))})
(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
;; same as clojure.contrib.seq/indexed, just to show how to do it
(defn numbered-lines [lines]
(map vector (iterate inc 0) lines))
(defn grep-in-file [pattern file]
(defn compress [l]
(let [sum-up (fn [l e]
(if (= (last (drop-last l)) e)
(conj (vec (drop-last l)) (inc (last l)))
(conj l e 1)))]
(reduce sum-up [] l)))
(defproject clj-blog "0.0.1"
:description "Clojure Blog App"
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
[org.clojure/clojure-http-client "1.0.0-SNAPSHOT"]
[compojure "0.4.0-RC3"]
[enlive "1.0.0-SNAPSHOT"]
[org.markdownj/markdownj-core "0.4-SNAPSHOT"]
[org.clojars.the-kenny/clojure-couchdb "0.1.3"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3-ruby', :require=> 'sqlite3'
end

From us ("the wishors") to you ("hereinafter called the wishee"):

Please accept without obligation, explicit or implicit, our best wishes for an environmentally conscious, socially responsible, politically correct, low stress, non-addictive, gender neutral, celebration of the winter solstice holiday, practiced within the most enjoyable traditions of the religious persuasion or secular practice of your choice, with respect for the religious/secular persuasions and/or traditions of others, or their choice not to practice religious or secular traditions.

Please also accept, under aforesaid waiver of obligation on your part, our best wishes for a financially successful, personally fulfilling and medically uncomplicated recognition of the onset of this calendar year of the Common Era, but with due respect for the calendars of all cultures or sects, and for the race, creed, colour, age, physical ability, religious faith, choice of computer platform or dietary preference of the wishee.

By accepting this greeting

var sys = require("sys"),
http = require("http"),
url = require("url"),
util = require("util"),
path = require("path"),
fs = require("fs");
var port = parseFloat(process.argv[2]) || 8081;
var options = function(request) {
@stilkov
stilkov / gist:860474
Created March 8, 2011 16:17
Simplistic Node.js proxy
var sys = require("sys"),
http = require("http"),
url = require("url");
var port = parseFloat(process.argv[2]) || 8081;
var options = function(request) {
var uri = url.parse(request.url);
var opt = {
host: uri.hostname,
@stilkov
stilkov / gist:2912079
Created June 11, 2012 19:14
Max Goldt zur BILD

“Diese Zeitung ist ein Organ der Niedertracht. Es ist falsch, sie zu lesen. Jemand, der zu dieser Zeitung beiträgt, ist gesellschaftlich absolut inakzeptabel. Es wäre verfehlt, zu einem ihrer Redakteure freundlich oder auch nur höflich zu sein. Man muß so unfreundlich zu ihnen sein, wie es das Gesetz gerade noch zuläßt. Es sind schlechte Menschen, die Falsches tun.” – Max Goldt, Mein Nachbar und der Zynismus, in: Der Krapfen auf dem Sims, Alexander Fest Verlag, Berlin 2001, ISBN 3-8286-0156-1, Seite 14