Skip to content

Instantly share code, notes, and snippets.

View usernaamee's full-sized avatar
☄️
Optimistic Transpiler

usernaamee

☄️
Optimistic Transpiler
View GitHub Profile
@usernaamee
usernaamee / doc_agent.py
Created May 4, 2025 04:57
RAG on Read the Docs
# -*- coding: utf-8 -*-
"""
doc_agent.py: A Python script implementing a Retrieval-Augmented Generation (RAG)
agent specifically designed for querying technical documentation (e.g., from
Read the Docs source files like .rst or .txt).
Purpose: To provide more accurate and context-aware answers to questions
about a specific software package or project than traditional keyword search,
by leveraging an LLM grounded with retrieved documentation snippets.
@usernaamee
usernaamee / readthedocs-better-search.html
Created May 3, 2025 18:31
A better contextual search on readthedocs rst/txt file folder
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RTD Search Agent (Standalone)</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
@usernaamee
usernaamee / Backprop-derivation.md
Last active August 26, 2023 09:38
Derivation of Backpropagation algorithm in matrix form

Backpropagation : Derivation (Matrix form)

Notations

  1. Input matrix is $x_0$
  2. Layer 1 weight matrix is $W_1$
  3. Layer 1 output is $x_1 = f_1(W_1x_0)$, where $f$ is the activation function for layer 1
  4. There are 4 layers (including input layer)
  5. Hence, network output is $x_3 = f_3(W_3x_2)$
  6. Assuming MSE loss function, with $t$ as target variable, $E = \frac{1}{2}|x_3 - t|_2^2$
@usernaamee
usernaamee / otp.py
Created November 14, 2018 07:48
One time pad - pure python implementation
import os
import sys
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('infile')
parser.add_argument('padfile')
parser.add_argument('outfile')
chunksize = 8192
@usernaamee
usernaamee / change_ps1
Created March 23, 2018 08:49
some awesome ps1 prompts
function snip() {
PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\[\033[1;31m\]\u@\h: \[\033[1;34m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::'): \[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\] -> \[\033[0m\] "
}
function swog() {
PS1="\[\e[36;45m\]▓\[\e[m\]\[\e[36;45m\]▒\[\e[m\]\[\e[36;45m\]░\[\e[m\]\[\e[36;45m\]\u\[\e[m\]\[\e[36;45m\]@\[\e[m\]\[\e[36;45m\]\h\[\e[m\]\[\e[36;45m\]:\[\e[m\]\[\e[35;46m\]\w\[\e[m\]\[\e[35;46m\]░\[\e[m\]\[\e[35;46m\]▒\[\e[m\]\[\e[35;46m\]▓\[\e[m\]>>> "
}
@usernaamee
usernaamee / create-qgis-dock-plugin.py
Last active March 1, 2018 13:00
Dock widget based plugin builder for QGIS
"""
Replace following four appropriately first:
yourname yourcompany http://yourcompany.com http://yourcompany.com/logo.png
"""
import os
import sys
import urllib
import argparse
parser = argparse.ArgumentParser()
@usernaamee
usernaamee / compare-two-ml-models.ipynb
Created January 30, 2018 07:38
Compare the performance of two machine learning models
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@usernaamee
usernaamee / spectre.c
Created January 10, 2018 16:53 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@usernaamee
usernaamee / Bi-LSTM-kws.py
Created October 19, 2017 18:41
Bi-LSTM-kws.py
import os
import sys
import torch
import librosa
import numpy as np
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
from sklearn.model_selection import train_test_split
@usernaamee
usernaamee / wld-feature-extractor.py
Created June 9, 2017 13:31
wld-feature-extractor
import cv2
import sys
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
def get_wld_feats(gray_img):
f00 =np.array([[1, 1, 1], [1, -8, 1], [1, 1, 1]])
f10 = np.array([[0, -1, 0], [0, 0, 0], [0, 1, 0]])
f11 = np.array([[0, 0, 0], [1, 0, -1], [0, 0, 0]])