Skip to content

Instantly share code, notes, and snippets.

View rajmayank's full-sized avatar
🚀

Mayank Raj rajmayank

🚀
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>RxJS Tutorial</title>
<!-- Load CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" />
<!-- Load Rubik font -->
@rajmayank
rajmayank / app.py
Created June 14, 2019 18:14
AWS SQS - Move from the Deadletter Queue (DLQ) to Source Queues
import boto3
import json
import uuid
sqsClient = boto3.client('sqs', region_name='us-east-1')
# Source Queue (eg. DLQ)
srcQueueUrl = ''
# Destination Queues
@rajmayank
rajmayank / closure-example.js
Last active November 29, 2019 16:55
JavaScript Closures - 2
function customGreet(greetingPrefix) {
var customGreetingPrefix = greetingPrefix; // For simplicity we store it explicitly in a local variable
function printGreet(name) {
console.log(customGreetingPrefix + ' ' + name + '.');
}
return printGreet;
}
greetWithHey = customGreet('Hey');
greetWithHello = customGreet('Hello');
greetWithHey('Tom');
@rajmayank
rajmayank / README.md
Last active July 29, 2020 21:09
Adding the missing details on the Teachable course page

Teachables course page has a few key things missing and this small snippet is my attempt to fix that 🤞


MOVED: This has been published as a chrome extension. Please head to the official repo to use it and contribute.


  1. The total amount of time a particular section would take. It only exposes the time a chapter would take. As a student I would want this to better plan ahead.
    adding-missing-timestamps

  2. [coming soon] When I'm playing things at 2x speed, why not show me the times a lecture would take at this speed 🤯

@rajmayank
rajmayank / jupyterlab_service.sh
Created February 3, 2021 06:37
Create a Jupyerlab service on a Linux Server
# Get Base Dependencies
apt install -y python3-pip
apt-get install python3-venv
mkdir -p /var/jupyter_lab_home/
python3 -m venv /var/jupyter_lab_home/venv
source /var/jupyter_lab_home/venv/bin/activate
# (optional) Get a password hash
# python3 -c "from notebook.auth import passwd; print(passwd('cactusLABs20'))"
@rajmayank
rajmayank / snippets.py
Last active October 23, 2021 05:24
Python Snippets
# ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
# For a given list, find count of consecutive duplicates
from itertools import groupby
dupCount = [len(list(ListOfOccurrences)) for (element, ListOfOccurrences) in groupby(sortedList)]
# ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
# Find permutations and combinations
from itertool import permutations, combinations
@rajmayank
rajmayank / Python-Generators-Memory-Footprint.py
Last active June 10, 2021 01:48
Python-Generators-Memory-Footprint
items1 = ["Item #1", "item #2",]
items2 = ["Item #1", "item #2","Item #4", "item #5",]
items3 = ["Item #1", "item #2","Item #4", "item #5", "item#6", "item#7",]
sys.getsizeof(items1) # 72 bytes
sys.getsizeof(items2) # 120 bytes
sys.getsizeof(items3) # 152 bytes
@rajmayank
rajmayank / Python-Generators-API-Introduction.py
Last active October 9, 2021 10:53
Python-Generators-API-Introduction
def doSecretStuffVersion1(rawItem):
theSecretCode = rawItem ** 30000
return theSecretCode # Notice the return statement
def doSecretStuffVersion2(rawItem):
theSecretCode = rawItem ** 30000
yield theSecretCode # Notice the yield statement
@rajmayank
rajmayank / Python-Generators-API-Introduction-II.py
Created June 10, 2021 01:53
Python-Generators-API-Introduction-II
import sys
secretV1 = doSecretStuffVersion1(5)
secretV2 = doSecretStuffVersion2(5)
print(secretV1). # 12593025435840...
print(type(secretV1)) # <class 'int'>
print(secretV2) # <generator object doSecretStuffVersion2 at 0x10ca5ab30>
print(type(secretV2)) # <class 'generator'>
@rajmayank
rajmayank / Python-Generators-API-Introduction-III.py
Created June 10, 2021 01:54
Python-Generators-API-Introduction-III
secretV2 = doSecretStuffVersion2(5)
secretV2Value = next(secretV2)
print(secretV2Value) # 12593025435840...
print(type(secretV2Value)) # <class 'int'>
print(sys.getsizeof(secretV2Value)) # 9312