Skip to content

Instantly share code, notes, and snippets.

View alokito's full-sized avatar

Alok Saldanha alokito

  • Novartis Institutes of Biomedical Research
  • Cambridge, MA
View GitHub Profile
@alokito
alokito / ufunc_a_python_func.ipynb
Last active September 29, 2021 01:03 — forked from wusixer/ufunc_a_python_func.ipynb
Vectorize a python function to speed up computation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alokito
alokito / README.md
Last active May 26, 2019 16:22 — forked from sxywu/README.md
The Force with React + D3, Approach #2 (smooth drag)

This is a fork of The Force with React + D3, Approach #2 with force.drag applied to the entire selection nodes rather than the just the appended circles. This results in smoother dragging behavior as you can tell by dragging a circle in this gist vs the original (click on link to compare). See the "Revisions" for details on the change.

React + D3 exploration with the force layout:

  • React for structure
  • D3 for data calculation
  • D3 AND React for rendering
    • React for enter/exit
    • D3 for update
import org.apache.spark.api.java.*;
import org.apache.spark.api.java.function.Function;
import scala.Tuple2;
public class SimpleApp {
private static Function<Tuple2<String,Long>, Long> indexMod4 = new Function<Tuple2<String,Long>, Long>() {
@Override
public Long call(Tuple2<String, Long> arg0) throws Exception {
return (long)(arg0._2 / 4);
}
class wrapper {
val fib: Stream[Int] = 1 #:: 1 #:: (fib zip fib.tail map Function.tupled(_+_))
}
@alokito
alokito / README.txt
Created September 16, 2011 14:51
patch to jquery.contextMenu.js from jQuery Context Menu Plugin v1.01
The attached "jquery.contextMenu.js.diff" is a patch for two improvements to the jQuery Context Menu Plugin
1) instead of requiring an id for the menu div, allow the plugin to accept either the
id string or a jquery object. I have been dynamically adding menus, and it is annoying
to have to make up ids. The code change is as simple as adding the followin to the contextMenu function:
if (o.menu.substr)
o.menu = $('#' + o.menu);
and then going through the rest of the code and making sure that o.menu is used as a