Skip to content

Instantly share code, notes, and snippets.

@pandeiro
pandeiro / gist:1006541
Created June 3, 2011 15:34
Scheme exercise from SICP ch 1
; Exercise 1.3: Define a procedure that takes threee numbers as arguments
; and returns the sum of the squares of the two larger numbers
(define (toptwosq x y z)
(if (and (< x y) (< x z))
(+ (* y y) (* z z))
(if (and (< y x) (< y z))
(+ (* x x) (* z z))
(+ (* x x) (* z z))
)
)
(defn take-randnth [num coll]
(take num
(rest
(map first
(iterate (fn [[ret items]]
(let [idx (rand-int (count items))]
[(items idx)
(subvec (assoc items idx (items 0))
1)]))
[nil
@pandeiro
pandeiro / 0main.md
Created January 2, 2012 22:49 — forked from SethRobertson/index.md
Git Best Practices

Git Best Practices

This is a fairly common question, and there isn't a One True Answer, but still, this represents a consensus from #git

Read about git

Knowing where to look is half the battle. I strongly urge everyone to read (and support) the Pro Git book. The other resources are highly

@pandeiro
pandeiro / alephNoir.clj
Created January 3, 2012 21:53 — forked from ibdknox/alephNoir.clj
aleph and noir
(require '[noir.server :as server])
(use 'noir.core 'aleph.http 'lamina.core)
(defn async-response [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
:body "async response"}))
(defpage "/" [] "hey from Noir!")
@pandeiro
pandeiro / gist:1565647
Created January 5, 2012 15:10
Clutch/Noir examples
;;
;; Using this to store the CouchDB connection and put auth credentials on requests that need them
;;
(ns couch-client.client
(:require [com.ashafa.clutch.utils :as clutch]))
(defonce ^:dynamic *dbs* (atom {}))
(defn put-auth [db]
(let [credentials (select-keys (meta @*dbs*) [:username :password])]
@pandeiro
pandeiro / gist:1590298
Created January 10, 2012 18:08
CouchDB type in Clojure
(ns noir-couchdb.core
(:use [com.ashafa.clutch :only [get-database put-document delete-document
get-document database-info all-documents
get-view]])
(:require [com.ashafa.clutch.utils :as clutch]
[clojure.string :as string])
(:refer-clojure :exclude (conj! assoc! dissoc!)))
(defprotocol CouchOps
"Defines side-effecting operations on a CouchDB database.
@pandeiro
pandeiro / xhr.cljs
Created September 6, 2012 03:22
Experimental ClojureScript XHR API
(ns please.core
(:require [please.help :as help]
[cljs.reader :as reader])
(:refer-clojure :exclude [get])) ; please?
;;
;; Event handler delegation
;;
(def ^{:doc "If this is nil, no events will be sent. Use please.core/set-request-event-fn! to
change this value"}
@pandeiro
pandeiro / index.html
Created October 19, 2012 20:56
A sample gist... again
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sample gist</title>
<style>
* { background: #434321; color: #d3d3e4; }
</style>
</head>
<body>
@pandeiro
pandeiro / gist:5477025
Created April 28, 2013 14:26
elnode error output
You can run the command `elnode-make-webserver' with C-c h
elnode-error: elnode--sentinel 'open from 127.0.0.1.' for process *elnode-webserver-proc*<1> <127.0.0.1:51600> with buffer nil
elnode-error: Elnode status: *elnode-webserver-proc*<1> <127.0.0.1:51600> open from 127.0.0.1
error in process filter: elnode--http-parse: Wrong number of arguments: #[(alist) "ÁÂ\"‡" [alist kvalist-keys->* #[(key) "ÁÂÃ\"!‡" [key intern format "%s"] 4]] 3 ("/home/mu/.emacs.d/elpa/kv-20130217.1638/kv.elc" . 8640)], 3
error in process filter: Wrong number of arguments: #[(alist) "ÁÂ\"‡" [alist kvalist-keys->* #[(key) "ÁÂÃ\"!‡" [key intern format "%s"] 4]] 3 ("/home/mu/.emacs.d/elpa/kv-20130217.1638/kv.elc" . 8640)], 3
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Create partition(s) and file system</a>
<ul>