Skip to content

Instantly share code, notes, and snippets.

Divyansh Prakash divs1210

Block or report user

Report or block divs1210

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
divs1210 /
Last active Oct 27, 2019
helps escape the Python's clutch
import types
# Helpers
# =======
def _obj():
'''Dummy object'''
return lambda: None
_FILLER = _obj()
divs1210 / calculus.clj
Last active Sep 20, 2019
Calculus in Clojure
View calculus.clj
(ns calculus)
(defonce ^:const dx 0.00001M)
(defn df
"Returns the derivative of f."
(fn [x]
(/ (- (f (+ x dx)) (f x))
divs1210 /
Last active May 8, 2019
Download a specific folder from a github repo
Download a specific folder from a github repo:
__author__ = 'Divyansh Prakash'
import sys
import subprocess
View pascal.clj
(ns pascal)
(defn step [row]
(let [parents (partition 2 1 row)
new-row-middle (map (fn [[x y]]
(+ x y))
(concat [1] new-row-middle [1])))
(defonce pascals-triangle
View ordered_infix.rb
def ordered_infix(*nums_and_ops)
initial_val = nums_and_ops[0]
op_num_pairs = nums_and_ops.drop(1).each_slice(2).to_a
op_num_pairs.reduce(initial_val) do |accumulator, op_num_pair|
op, num = op_num_pair
accumulator.send(op, num)
ordered_infix 10, '/', 2, '-', 1, '*', 2
divs1210 / watch_db.cljs
Created Dec 14, 2018
Lightweight logging of db state changes for reagent/re-frame
View watch_db.cljs
(defn watch-db []
(add-watch re-frame.db/app-db :watcher
(fn [_ _ old-state new-state]
(let [[removed added] ( old-state new-state)]
(when (or removed added)
(println "=====\nRemoved:")
(cljs.pprint/pprint removed)
(println "Added:")
(cljs.pprint/pprint added))))))
divs1210 / data.edn
Created Nov 24, 2018
sample edn data
View data.edn
{:result 1}
divs1210 / lazy.rb
Last active Nov 13, 2018
Lazy Seqs in Ruby
View lazy.rb
# Abstract Class
# ==============
class ISeq
def first
def rest
def [](idx)
You can’t perform that action at this time.