Skip to content

Instantly share code, notes, and snippets.

View deepanjanroy's full-sized avatar

Deepanjan Roy deepanjanroy

  • Google
  • Kitchener, ON, Canada
View GitHub Profile
@deepanjanroy
deepanjanroy / FastFacebookLogout
Created December 13, 2013 02:38
Tampermonkey script to log out of facebook by pressing only backtick (`). One-keypress exit during impulsive facebook visits.
// ==UserScript==
// @name FastFacebookLogout
// @namespace http://deepanjanroy.me/
// @version 0.1
// @description Log out of facebook by pressing only backtick (`). One-keypress exit during impulsive facebook visits.
// @match https://www.facebook.com/
// @copyright 2012+, Deepanjan Roy
// ==/UserScript==
window.onkeypress = function (evt) { // document.onkeypress doesn't seem to work on Facebook and Tampermonkey
@deepanjanroy
deepanjanroy / pymalion.zsh-theme
Created December 28, 2013 18:19
Fixes virtual_env prompt for the pymalion omz theme. Previously the prompt was not showing the currently active virtual_env.
# Yay! High voltage and arrows!
prompt_setup_pygmalion(){
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
@deepanjanroy
deepanjanroy / maxlikehood.py
Last active August 29, 2015 14:07
Maximum Likelihood Estimator for number of generations. Comp 561 Assignment 1 problem 8.
import numpy as np
from scipy.misc import comb
import matplotlib.pyplot as plt
S = np.array([[ 0.97, 0.01, 0.01, 0.01],
[ 0.01, 0.97, 0.01, 0.01],
[ 0.01, 0.01, 0.97, 0.01],
[ 0.01, 0.01, 0.01, 0.97]])
pchange = lambda M: M[0,0]

Today I spent about half an hour trying to figure out a mysterious bug in my Python code. The reason turned out to be quite unexpected, so I decided to write up a small post about it both as a reminder to my future self and as an cautionary tale to other unsuspecting victims.

This is a minimal reproduction of the bug:

class Node(object):
    def __init__(self, children={}):
    	"""
        By default children is an empty dict, but you can set
 children directly by supplying them as a value to the keyword argument.
@deepanjanroy
deepanjanroy / keybase.md
Created February 7, 2015 18:47
keybase.md

Keybase proof

I hereby claim:

  • I am deepanjanroy on github.
  • I am deepanjan (https://keybase.io/deepanjan) on keybase.
  • I have a public key whose fingerprint is 4EF0 99A8 6EB2 577D 0F73 0F8A A4A4 089D 9925 F1BB

To claim this, I am signing this object:

@deepanjanroy
deepanjanroy / UMAhistogram-techcrunch.txt
Last active August 20, 2016 22:54
tbmv2 vs UMA comparison on techcrunch: start and end times of latency slices used in computation
startTime endTime
1462522325143 1462522573681
1462522350094 1462522606162
1462522479957 1462522658064
1462522553779 1462522693764
1462522590651 1462522743941
1462522627242 1462522743941
1462522672757 1462522790259
1462522692097 1462522790259
1462522711007 1462522829463
This file has been truncated, but you can view the full file.
{
"traceEvents": [
{
"pid": 54113,
"tid": 775,
"ts": 0,
"ph": "M",
"cat": "__metadata",
"name": "thread_name",
"args": {
{Slice Title} : {Total cumulative self time ms spent across 10k pages in test run}
LocalFrameView::performLayout : 77859682.3385
TaskQueueManager::RunTask : 45631790.6605
Document::recalcStyle : 42088368.0356
Document::rebuildLayoutTree : 23380524.8535
LocalFrameView::prePaint : 22698465.596
WebURLLoaderImpl::loadSynchronously : 19509370.842
ProxyMain::BeginMainFrame::commit : 16127438.698
TaskQueueManager::ProcessTaskFromWorkQueue : 15972163.7861
V8.NewContext : 15733717.8783
@deepanjanroy
deepanjanroy / other-category-slices.txt
Created September 19, 2017 07:40
Slices in other category, after slight modifications of user friendly category driver. New updates to USC landing soon.
{Slice Title} : {Total cumulative self time ms spent across 10k pages in test run}
TaskQueueManager::RunTask : 45799357.7984
LocalFrameView::prePaint : 22831219.588
ProxyMain::BeginMainFrame::commit : 16157595.614
TaskQueueManager::ProcessTaskFromWorkQueue : 16034099.1022
V8.NewContext : 15784434.0443
TaskQueueManager::DoWork : 9825634.4282
V8.RunMicrotasks : 7687400.93465
content::mojom::URLLoaderClient : 7076002.57597
ImageResourceContent::updateImage : 6806556.24597
// ==UserScript==
// @name Time to Interactive Polyfill
// @namespace http://developers.google.com/
// @version 0.1
// @description Polyfill to detect Time to Interactive
// @author Deepanjan Roy
// @include http://*
// @include https://*
// @run-at document-start
// @noframes