Skip to content

Instantly share code, notes, and snippets.


Baishampayan Ghose ghoseb

  • India
View GitHub Profile
ghoseb / vi-lineage.txt
Last active Mar 11, 2021
The lineage of Vi
View vi-lineage.txt
Colossal Typewriter
by John McCarthy and Roland
Silver for the PDP-1 | Photon typesetter
? | editors by Michael
? \ Barnett & Kalon
Expensive Typewriter CREATE/EDIT \ Kelley for TECO
for PDP-1 by Steve Piner for CTSS \ IBM 704 for PDP-1
/ | / | \ \__ \ by Dan Murphy
/ | / | \ \ \ |
* Expensive Typewriter editors EDITS | MEMO/MODIFY | | VEDIT |
ghoseb / clj_spec_playground.clj
Last active Mar 30, 2019
Examples of Clojure's new clojure.spec library
View clj_spec_playground.clj
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
ghoseb / uniquify.clj
Created Jan 15, 2014
Uniquify buffer names
View uniquify.clj
(ns ^{:doc "Uniquify"
:author "Baishampayan Ghose <>"}
(:require [clojure.string :refer [join]]))
(defn explode
"Explode a directory name to its subcomponents."
[^String dir]
(seq (.split dir "/")))
ghoseb / rover.clj
Last active Jun 9, 2016
Mars rover problem solved in Clojure.
View rover.clj
(ns mars.rover)
;; A squad of robotic rovers are to be landed by NASA on a plateau on
;; Mars.
;; This plateau, which is curiously rectangular, must be navigated by the
;; rovers so that their on-board cameras can get a complete view of the
;; surrounding terrain to send back to Earth.
;; A rover's position and location is represented by a combination of x and
View bottles.clj
;;; 99 bottles of beer in Clojure
(def bottles "
# 99 Bottles of Beer
# Brainfuck version
# by Michal Wojciech Tarnowski
ghoseb / prime_sieve.clj
Last active Apr 22, 2016
A concurrent prime sieve in Clojure using core.async
View prime_sieve.clj
(ns prime-sieve
(:require [clojure.core.async :as async :refer [chan go <! >!]]))
;;; concurrent prime sieve in Clojure using core.async
;; inspired by a similar implementation in Go
(defmacro go-forever
"An infinite loop that runs in a go block."
View ref-history-stress.clj
; STM history stress-test
(defn stress [hmin hmax]
(let [r (ref 0 :min-history hmin :max-history hmax)
slow-tries (atom 0)]
(swap! slow-tries inc)
(Thread/sleep 200)
ghoseb / props.clj
Last active Dec 16, 2015
A simple problem that I solved at the April '13 meetup of Pune Clojure Users' Group. The problem is about parsing a Java properties file into Clojure & back.
View props.clj
(ns props.core
(:require [clojure.string :refer [split]]
[ :refer [reader]])
(:import java.util.Properties))
(defn- split-key
"Split a string key to its subparts.
foo -> [foo] -> [foo bar baz]"
ghoseb / props.clj
Last active Dec 12, 2015
Read a Java Properties file into a map (with potentially nested keys).
View props.clj
(ns ^{:doc "Read Java properties file."
:author "Baishampayan Ghose <>"}
(:import java.util.Properties)
(:require [ :refer [resource reader]]
[clojure.string :refer [split]]))
(defn- load-props
"Load a Java properties file. File should be in classpath."
ghoseb / freq.clj
Last active Dec 12, 2015
Sample code from Pune Clojure Dojo Meetup session held at 8 feb 2013.
View freq.clj
(ns ^{:doc "Word frequencies in a text file."
:author "Baishampayan Ghose <>"}
(:require [ :as io]
[clojure.string :as s]))
(def stop-word? #{"is" "the" "am" "i" "that" "if"}) ;; fill it up!
;;; all these functions are written in a "point free" style
(def get-lines (comp line-seq io/reader))