Skip to content

Instantly share code, notes, and snippets.

View sunjay's full-sized avatar
🔍
Looking for answers so I can share them with the world

Sunjay Varma sunjay

🔍
Looking for answers so I can share them with the world
View GitHub Profile
@sunjay
sunjay / curry.js
Last active December 9, 2015 03:06
An example of currying in JavaScript using the .length property of function to dictate when to evaluate
/**
* Returns a curry-able version of a function
* The parameters for this function are exactly the same as .bind()
* context is optional - if null, the default context will be used
* Any arguments passed in after context will automatically be passed
* in before any other arguments that are applied
*/
Function.prototype.curry = function(context) {
var f = this;
var baseArgs = Array.prototype.slice.call(arguments);
@sunjay
sunjay / hangman.py
Created November 17, 2015 08:06
Simple Hangman AI
BLANK = "_"
WORDS = "/usr/share/dict/words"
def letter_indexes(word):
indexes = {}
for i, L in enumerate(word):
indexes.setdefault(L, []).append(i)
return indexes
class Hangman(object):
@sunjay
sunjay / units.py
Created November 5, 2015 00:32
Simple Operations with Values that have Units
"""
Does many simple operations with values that have units.
Takes advantage of Python's operator overloading to allow
you to write expressions with units in Python's regular
interpreter.
>>> # Write units in several different ways
>>> 2*cm
>>> 2|cm
>>> cm(2) # for when operator precedence is hurting you
#lang racket
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Program for Drawing Genius Tic-Tac-Toe Boards
;
; Author: Sunjay Varma
; Copyright 2014 by Sunjay Varma. All rights reserved.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@sunjay
sunjay / README.md
Created May 23, 2014 00:51
Generating Parallel Trails using HTML5 Canvas

Generating Parallel Trails using HTML5 Canvas

Author: Sunjay Varma Date: May 22, 2014

This is a demonstration of a method of generating parallel trails of points in JavaScript. They are called "trails" since this implementaion uses mouse movements to generate curves that "trail" behind the mouse.

  • Supports minimum sampling distance between points
  • Generate any number of parallel points