Skip to content

Instantly share code, notes, and snippets.

Baishampayan Ghose ghoseb

Block or report user

Report or block ghoseb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ghoseb
ghoseb / church_numerals.clj
Created Jun 12, 2009 — forked from jimweirich/church_numerals.clj
Church Numerals in Clojure
View church_numerals.clj
; Church Numerals in Clojure
;
; Church numerals use anonymous functions to represent numbers.
;
; ((zero f) x) -- returns x
; ((one f) x) -- return (f x)
; ((two f) x) -- return (f (f x))
; ...
(def zero (fn [f] (fn [x] x)))
View ghoseb.el
;;; ghoseb.el -- My customisations in addition to ESK
;;; Author: Baishampayan Ghose <b.ghose@gmail.com>
;;; Time-stamp: "2009-08-01 01:44:30 ghoseb"
(require 'cl)
;;; ----------------------
;;; General customisations
;;; ----------------------
(set-scroll-bar-mode 'nil)
@ghoseb
ghoseb / redis_memo.clj
Created Jan 1, 2010 — forked from purcell/redis_memo.clj
Clojure Memoize to Redis
View redis_memo.clj
(ns redis-memo
(:require redis)
(:import (java.net URLEncoder)))
;; --------------------------------------------------------------------------------
;; Default connection params
;; --------------------------------------------------------------------------------
(def memo-server {:host "localhost" :port 6379 :db 14})
View log4j.properties
# log4j.properties
log4j.rootLogger = DEBUG, standard
log4j.appender.standard = org.apache.log4j.RollingFileAppender
log4j.appender.standard.File = logs/project.log
log4j.appender.standard.MaxFileSize=1MB
log4j.appender.standard.MaxBackupIndex=1
log4j.appender.standard.layout = org.apache.log4j.PatternLayout
View delay.clj
(defn tests []
[{:name 'suiteA
:total 3
:tests [{:name 'testA}
{:name 'testB}
{:name 'testC}]}
{:name 'suiteB
:total 3
:tests [{:name 'testD}
{:name 'testE}
View promise.clj
(defn tests []
[{:name 'suiteA
:total 3
:passed (promise)
:failed (promise)
:success (promise)
:tests [{:name 'testA :success (promise)}
{:name 'testB :success (promise)}
{:name 'testC :success (promise)}]}
{:name 'suiteB
@ghoseb
ghoseb / accounts.clj
Created May 4, 2010
Simple bank account code
View accounts.clj
;;; accounts.clj -- Accounts -*- Clojure -*-
;;; Time-stamp: "2010-05-04 11:17:53 ghoseb"
;;; Author: Baishampayan Ghose <bg@infinitelybeta.com>
(ns accounts)
(def *min-bal* 500)
(defstruct account
:name
@ghoseb
ghoseb / with-retries.clj
Created Mar 18, 2011
Macro to retry executing some code in case of an exception
View with-retries.clj
(ns test)
(defn try-times
"Try executing a thunk `retries` times."
[retries thunk]
(if-let [res (try
[(thunk)]
(catch Exception e ; can be any exception
(when (zero? retries)
(throw e))))]
@ghoseb
ghoseb / pascal.clj
Created Jul 11, 2011
Psacal's Functional Triangle
View pascal.clj
(ns pascal)
(defn next-row
"Given one row, generate the next one."
[row]
(vec (map + (concat [0] row) (concat row [0]))))
(defn pascal
"Generate an infinite lazy sequence of Pascal rows."
[]
@ghoseb
ghoseb / tetris.clj
Created Sep 12, 2011 — forked from alexander-yakushev/tetris.clj
Tetris implementation in Clojure
View tetris.clj
(ns tetris.core
(:import (java.awt Color Dimension BorderLayout)
(javax.swing JPanel JFrame JOptionPane JButton JLabel)
(java.awt.event KeyListener))
(:use clojure.contrib.import-static deflayout.core
clojure.contrib.swing-utils)
(:gen-class))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE)
You can’t perform that action at this time.