Skip to content

Instantly share code, notes, and snippets.

View PCJohn's full-sized avatar

Prithvijit Chakrabarty PCJohn

View GitHub Profile
@PCJohn
PCJohn / ServoScan.ino
Last active February 19, 2024 07:34
A processing and arduino sketch for 3D mapping with an ultrasonic sensor
/*
Arduino program to control a ultrasonic 3-D mapping sensor.
The programs controls an HC-SR04 ultrasonic sensor connected to the Arduino board.
A collaborating Processing sketch interacts with this program with serial communication to control the angle
Authors:Prithvijit Chakrabarty (prithvichakra@gmail.com)
Kartik S. Lovekar (kslovekar@gmail.com)
*/
#include <Servo.h>
#include <NewPing.h>
@PCJohn
PCJohn / setup.sh
Last active January 13, 2023 22:37
wget https://gist.githubusercontent.com/PCJohn/ccbac70608f44f8c8d18cc4c89f3ab90/raw/8853e386321c61d4b0b6ac58db1bc4ac457574e0/vimrc
mv vimrc ~/.vimrc
bash
# Following: https://askubuntu.com/questions/284957/vi-getting-multiple-sorry-the-command-is-not-available-in-this-version-af
sudo apt-get install vim-gui-common
sudo apt-get install vim-runtime
# Use the Vundle vim plugin manager
# See: https://pseudoscripter.wordpress.com/2020/04/26/install-black-on-vim/
@PCJohn
PCJohn / ConnectFour.java
Last active November 30, 2020 14:37
A Java text based game for Connect Four
/*Java source for a simple, text based game of Connect Four. Change the package name as required.
Players must enter a number between 0 and 7 (both inclusive) to specify the column in which he/she wants to drop his/her chip.
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)*/
package projectjava;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@PCJohn
PCJohn / memory_list.txt
Last active June 14, 2020 15:56
List of pages for memory
The rational analysis of memory: http://gershmanlab.webfactional.com/pubs/RationalAnalysisOfMemory.pdf
Rate distortion trade-off in human memory: https://ccneuro.org/2019/proceedings/0000369.pdf
Convolutional Neural Associative Memories: https://arxiv.org/pdf/1407.6513.pdf
Holographic Reduced Representation: https://www.amazon.com/dp/B0188Y14VS/ref=dp-kindle-redirect?_encoding=UTF8&btkr=1
@PCJohn
PCJohn / kalman.py
Created June 6, 2020 21:03
Simple Kalman Filter
import os
import cv2
import time
import numpy as np
from matplotlib import pyplot as plt
size = 1000
im = np.ones((size,size,3))
def plot(p,sz=3,col=(0,255,0)):
"""
Usage:
srun -p 1080ti-short --mem 100000 --gres=gpu:1 \
python tools/viz_net.py --dataset coco2017 --output_dir tmp \
--cfg configs/context/self-attn/e2e_faster_rcnn_R-50-C4_1x_attn_head-8_lr-long-v3.yaml \
--ckpt data/models/coco-visual-8-head/model_step69999.pth
Example (8 heads v3 on COCO):
srun -p 1080ti-short --gres=gpu:1 --mem 20000 python tools/viz_net.py \
@PCJohn
PCJohn / graph.py
Created January 14, 2019 07:28
Display graphs with networkx
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
import networkx as nx
import copy
class Graph:
def __init__(self,adj,labels):
self.adj = adj
self.char_list = labels
@PCJohn
PCJohn / convdiv.py
Created July 20, 2017 05:06
This script tries to overfit a small convolutional network, to perform integer division
"""
Attempt to perform integer division by overfitting convolution layers
Input: 2 numbers A and C
Output: Integer B such that A.B = C
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
"""
import random
@PCJohn
PCJohn / matfact.py
Created June 26, 2017 16:30
NNMF by overfitting neural networks
"""
Attempt to run NNMF (Non-negative matrix factorization) for integer matrices by overfitting with a high learning rate on backpropagation.
Try to factorize matrices: Find a matrix A such that xA = y for given matrices (x,y)
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
"""
import random
import numpy as np
import tensorflow as tf
@PCJohn
PCJohn / AudioPlayer.java
Last active September 17, 2015 08:07
Processing sketch for a music player
/*
A Processing sketch for an audio player with frequency visualization.
Authors: Prithvijit Chakrabarty (prithvichakra@gmail.com)
Kartik Lovekar (kslovekar@gmail.com)
*/
import ddf.minim.*;
import java.io.*;
import java.util.*;