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 / vi-lineage.txt
Last active Nov 28, 2016
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
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
ghoseb / uniquify.clj
Created Jan 15, 2014
Uniquify buffer names
View uniquify.clj
(ns ^{:doc "Uniquify"
:author "Baishampayan Ghose <b.ghose@helpshift.com>"}
uniquify
(:require [clojure.string :refer [join]]))
(defn explode
"Explode a directory name to its subcomponents."
[^String dir]
(seq (.split dir "/")))
@ghoseb
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
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
;; http://golang.org/doc/play/sieve.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)]
(future
(dosync
(swap! slow-tries inc)
(Thread/sleep 200)
@r)
@ghoseb
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]]
[clojure.java.io :refer [reader]])
(:import java.util.Properties))
(defn- split-key
"Split a string key to its subparts.
foo -> [foo]
foo.bar.baz -> [foo bar baz]"
@ghoseb
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 <b.ghose@gmail.com>"}
in.freegeek.props
(:import java.util.Properties)
(:require [clojure.java.io :refer [resource reader]]
[clojure.string :refer [split]]))
(defn- load-props
"Load a Java properties file. File should be in classpath."
[props-file]
@ghoseb
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 <b.ghose@helpshift.com>"}
meetup.freq
(:require [clojure.java.io :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))
You can’t perform that action at this time.