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 / ns-cheatsheet.clj
Last active Sep 14, 2019 — forked from alandipert/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
View ns-cheatsheet.clj
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@ghoseb
ghoseb / factorial.py
Created Nov 14, 2008
The evolution of a Python Programmer
View factorial.py
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@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 / heady-thrill.md
Created Sep 2, 2012
The Heady Thrill of Having Nothing to Do
View heady-thrill.md

Is constant stimulation hurting our creativity—and the economy? Scott Adams pays tribute to tedium

By Scott Adams

We’ve won the war on boredom! If you have a smartphone in your pocket, a game console in the living room, a Kindle in your backpack and an iPad in the kitchen, you never need to suffer a minute without stimulation. Yay!

@ghoseb
ghoseb / cut.clj
Created Apr 16, 2012
Cut macro from SRFI-26 in Clojure
View cut.clj
;;; http://srfi.schemers.org/srfi-26/srfi-26.html
(defn ^:private cut*
[[a f] form]
(cond
(nil? form) [a f]
(seq? (first form))
(let [[arg-list xform] (cut* [[] '()] (first form))]
(recur [(reduce conj a arg-list) (concat f (list xform))] (next form)))
@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 / gevent_example.py
Created Jul 27, 2011
Gevent spawn / link example
View gevent_example.py
from gevent import monkey; monkey.patch_all()
import gevent
import gevent.greenlet
from functools import partial
from random import random
import urllib
import urllib2
def on_exception(fun, greenlet):
@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
@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."
@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 "/")))
You can’t perform that action at this time.