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
divs1210 / SLIP.py
Last active Oct 27, 2019
helps escape the Python's clutch
View SLIP.py
import types
# Helpers
# =======
def _obj():
'''Dummy object'''
return lambda: None
_FILLER = _obj()
@divs1210
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."
[f]
(fn [x]
(/ (- (f (+ x dx)) (f x))
dx)))
@divs1210
divs1210 / gitget.py
Last active May 8, 2019
Download a specific folder from a github repo
View gitget.py
#!/usr/bin/python
"""
Download a specific folder from a github repo:
gitget.py https://github.com/divs1210/kilvish/tree/master/examples/bricksnball
"""
__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))
parents)]
(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)
end
end
ordered_infix 10, '/', 2, '-', 1, '*', 2
@divs1210
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] (clojure.data/diff old-state new-state)]
(when (or removed added)
(println "=====\nRemoved:")
(cljs.pprint/pprint removed)
(println "Added:")
(cljs.pprint/pprint added))))))
@divs1210
divs1210 / data.edn
Created Nov 24, 2018
sample edn data
View data.edn
{:result 1}
@divs1210
divs1210 / lazy.rb
Last active Nov 13, 2018
Lazy Seqs in Ruby
View lazy.rb
# Abstract Class
# ==============
class ISeq
def first
end
def rest
end
def [](idx)
You can’t perform that action at this time.