Skip to content

Instantly share code, notes, and snippets.

View rijulg's full-sized avatar

Rijul Gupta rijulg

View GitHub Profile
@rijulg
rijulg / pytorch_hot_embedding.ipynb
Last active July 18, 2020 08:06
Pytorch Embedding that supports gradient propagation to inputs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rijulg
rijulg / packagify.py
Created June 17, 2020 14:51
Packagify - for loading python projects not maintained as packages like packages
import builtins
import sys
class Packagify:
"""
Used to load python projects that aren't suitable to be used as packages
You can use this class as following:
```
from packagify import Packagify
@rijulg
rijulg / prune.py
Created June 7, 2020 06:31
Pruning and converting sparse network to dense in pytorch
#!/usr/bin/python
import copy
import torch
import numpy as np
torch.manual_seed(0)
class Original(torch.nn.Module):
@rijulg
rijulg / apollo.js
Created August 26, 2019 02:31
Monitor apollo client network requests globally
import { isNetworkRequestInFlight } from 'apollo-client/core/networkStatus';
/**
* Hooking into the onBroadcast function to save the inFlight data point in the client state
*/
apolloClient.queryManager.onBroadcast = () => {
const { queryManager: { queryStore: { store } } } = apolloClient;
const queries = Object.values(store);
// if we can find a way to escape early that will be better, but regular for loops don't sit well with eslint
const inFlight = queries.reduce(
@rijulg
rijulg / gamma.html
Created January 4, 2019 11:13
An implementation of Gamma filter in HTML5 Canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Canvas Gamma Adjust</title>
<meta name="og:title" content="HTML5 Canvas Gamma Adjust"/>
<meta name="author" content="Rijul Gupta">
<meta name="description" content="An implementation of Gamma filter in HTML5 Canvas"/>
</head>
@rijulg
rijulg / example.vhd
Created August 30, 2018 15:49
Sample VHDL Code
-- --------------------------------------------------------------------.
--
-- Example VHDL Component Organization
--
-- Title : example
-- :
-- Library : work
-- :
-- Developers : Rijul Gupta (rijulg@gmail.com)
-- :