This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import math | |
# Define the Transformer model architecture | |
class Transformer: | |
def __init__(self, input_vocab_size, output_vocab_size, max_seq_length, d_model, num_heads, num_layers): | |
self.input_vocab_size = input_vocab_size | |
self.output_vocab_size = output_vocab_size | |
self.max_seq_length = max_seq_length | |
self.d_model = d_model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# The cheapest CUDA instance on AWS is Graviton2 based g5g instances | |
# 1) Install right CUDA Drivers on the system. Whilst this script has been tested on Ubuntu 22.04. It should work on others | |
# 2) Install torch with GPU support. Compiling from source works the best | |
# 3) Preferably Quantize the models - https://huggingface.co/docs/transformers/main/en/main_classes/quantization | |
# | |
# Author: Supreet Sethi <[email protected]> | |
# Web: https://www.linkedin.com/in/djinn | |
# | |
# Step 1) is here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from json import dumps | |
test_load = """SQL statistics: | |
queries performed: | |
read: 845684 | |
write: 241589 | |
other: 120831 | |
total: 1208104 | |
transactions: 60398 (1506.89 per sec.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author Supreet Sethi <[email protected]> | |
# Dated Thu Jul 21 13:26:06 +08 2022 | |
# Instructions - wget <script>; chmod +x yubikey.sh; ./yubikey.sh | |
sudo pmset -a hibernatemode 25 && sudo pmset -a standbydelay 15 | |
echo "Yubikey hibernation changes installed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cinttypes> // for uint32_t | |
#include <cfenv> | |
#include <cmath> | |
std::string float_to_binary(float f) { | |
union {float f; uint32_t i;} u; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Copyright(C) 2020 Supreet Sethi <[email protected]> | |
# I do Hindi, Punjabi and Urdu in Python dude! | |
बोल = print | |
बोल("ਬੋਲ ਕੇ ਲਾਬ ਆਜ਼ਾਦ ਹੈਂ ਤੇਰੇ - فیض احمد فیض") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Author: Supreet Sethi <[email protected]> | |
# Dated: 16/10/2020 | |
# Please use it has working prototype | |
# Lot can be done from process management and general housekeeping perspective | |
from multiprocessing import Pool, cpu_count, Manager | |
from collections import namedtuple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas, boto3 | |
from sklearn.utils import shuffle | |
ratings = pandas.read_csv('ratings.csv') | |
ratings = shuffle(ratings) | |
ratings = ratings[ratings['rating']>3.6] | |
ratings = ratings.drop(columns='rating') | |
ratings.columns = ['USER_ID','ITEM_ID','TIMESTAMP'] | |
ratings = ratings[:100000] | |
ratings.to_csv('ratings.processed.csv',index=False) | |
s3 = boto3.client('s3') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from requests import get | |
from shutil import copyfileobj | |
from tempfile import NamedTemporaryFile as TemporaryFile | |
import time | |
from os import sendfile | |
import hashlib | |
import os.path | |
WIKIDUMPURL = 'https://dumps.wikimedia.org/enwikinews/20200701/enwikinews-20200701-pages-articles-multistream.xml.bz2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ program to print all primes smaller than or equal to | |
// n using Miller-Rabin Primality Test | |
// Reference: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test | |
// It is not particularly to optimized | |
// since focus is readability | |
// Compile: g++ -std=c++17 -o prime prime.c++ -ltbb | |
#include <execution> | |
#include <iostream> | |
#include <math.h> |