Skip to content

Instantly share code, notes, and snippets.

View leesharma's full-sized avatar

Lee Sharma leesharma

View GitHub Profile
@leesharma
leesharma / vector_gradients.jl
Last active October 26, 2020 05:36
Mockup of how to use Flux to take gradients in Julia
import Pkg; Pkg.add("Flux")
using Flux: gradient, Chain, Dense, σ, softmax
# Partial derivatives of a basic function
#
# docs: https://fluxml.ai/Zygote.jl/dev/#Taking-Gradients-1
#
f(x,y) = 3x^2 + x*y + 5y
f_x(x,y) = gradient(f, x, y)[1] # f_x = 6x + y
@leesharma
leesharma / Bit.hdl
Created January 26, 2019 23:13
Nand2Tetris Project 3: Memory
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/03/a/Bit.hdl
/**
* 1-bit register:
* If load[t] == 1 then out[t+1] = in[t]
* else out does not change (out[t+1] = out[t])
*/
@leesharma
leesharma / ALU.hdl
Created January 20, 2019 02:24
Nand2Tetris Project 2: ALU
/**
* The ALU (Arithmetic Logic Unit).
* Computes one of the following functions:
* x+y, x-y, y-x, 0, 1, -1, x, y, -x, -y, !x, !y,
* x+1, y+1, x-1, y-1, x&y, x|y on two 16-bit inputs,
* according to 6 input bits denoted zx,nx,zy,ny,f,no.
* In addition, the ALU computes two 1-bit outputs:
* if the ALU output == 0, zr is set to 1; otherwise zr is set to 0;
* if the ALU output < 0, ng is set to 1; otherwise ng is set to 0.
*/
@leesharma
leesharma / And.hdl
Created January 19, 2019 19:29
Nand2Tetris Project 1: Logic Gates
/**
* And gate:
* out = 1 if (a == 1 and b == 1)
* 0 otherwise
*/
CHIP And {
IN a, b;
OUT out;
@leesharma
leesharma / symbolic-differentiation.scm
Created October 24, 2017 15:15
A working example of symbolic differentiation (SICP section 2.4).
;Symbolic Differentiation
;
; note: all arithmetic terms must have two operands!
; e.g. `(+ a b c) becomes `(+ a (+ b c)))
;
(define (deriv exp var)
(cond ((constant? exp var) 0)
((same-var? exp var) 1)
((sum? exp)
(make-sum (deriv (a1 exp) var)

Keybase proof

I hereby claim:

  • I am leesharma on github.
  • I am leesharma (https://keybase.io/leesharma) on keybase.
  • I have a public key ASD0mqONaqZvg_k6vXe6qJ1U332z-LwpBaU9-UBJhF8ngAo

To claim this, I am signing this object:

April 2017

Here is a calendar, written in HTML + GitHub-Flavored Markdown. The code is pretty messy, but it's functional.

Monday Tuesday Wednesday Thursday Friday Saturday Sunday










1
[C][20170401]
2
[C][20170402]
3
[tmux][20170403]
4
[vim][20170404]
5
[elixir][20170405]
6
[elixir][20170406]
7
[elixir][20170407]
8
[git][20170408]
9
[erlang][20170409]
10 11 12 13 14 15 16
@leesharma
leesharma / matching_bound_variables.exs
Last active August 13, 2016 06:21
What is the best practice for matching against bound variables?
ExUnit.start
defmodule DateParser do
defmodule Timezone, do: defstruct [:full_name, :source]
@doc """
`timezone/2` takes a date/datetime string and a global time zone and returns
a time zone for the specific string. Timezones specified inline should take
priority over the passed-in global timezone.
"""
@leesharma
leesharma / pwldc-meetup.md
Last active July 2, 2016 18:22
A draft description for the Papers We Love DC/NoVA meetup group

What is this group?

What was the last paper within the realm of computing you read and loved? What did it inspire you to build or tinker with? Come share the ideas in an awesome academic/research paper with fellow engineers, programmers, and paper-readers. Lead a session and show off code that you wrote that implements these ideas or just give us the lowdown about the paper. Otherwise, just come, listen, and discuss.

Find us:

@leesharma
leesharma / triangle_peg.rb
Created June 14, 2016 18:57 — forked from bokmann/triangle_peg.rb
An example from "What Computer Scientists Know: Thinking Recursively, Part 2. In this example we are going to explore how we use our newfound knowledge of recursion to search through all the solutions of a simple puzzle using recursive backtracking.
# This is a programming chellenge from David Bock's series
# "What Computer Scientists Know". This is a problem that can
# be used to discuss a bunch of computer science topics, but
# as I'm providing most of the skeleton of the solution, the
# point of this exercise is to demonstrate 'recursive backtracking'.
# http://en.wikipedia.org/wiki/Backtracking
# this problem is based on the classic 'triange peg game', a common
# sight in roadside diners in America, in particular, Cracker