Skip to content

Instantly share code, notes, and snippets.

View GurdeepSS's full-sized avatar

Gurdeep Singh Sabarwal GurdeepSS

  • san jose ,CA,USA
View GitHub Profile
@GurdeepSS
GurdeepSS / squash-commits.sh
Created August 17, 2022 17:06 — forked from mohamedhafezqo/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@GurdeepSS
GurdeepSS / cron_aws_check_ses_health.py
Created May 21, 2022 04:28 — forked from atsavalas/cron_aws_check_ses_health.py
Checks SES account health stats (either daily or every 15 mins), pauses SES sending service according to thresholds set and notifies administrators
# python3 cron_aws_check_ses_health.py --c=daily
# or for every 15 mins
# python3 cron_aws_check_ses_health.py --c=quarterly
import argparse
import boto3
import pytz as pytz
from mailer import Mailer, Message
from botocore.exceptions import ClientError
from datetime import datetime, timedelta, time
@GurdeepSS
GurdeepSS / Schema2CaseClass.scala
Created May 6, 2022 20:23 — forked from frne/Schema2CaseClass.scala
Spark DataFrame Schema to Scala Case Class Generator
object Schema2CaseClass {
import org.apache.spark.sql.types._
case class RecFieldRes(fieldStr: String, additionalCc: Option[String] = None)
case class CcRes(cc: String, additional: List[String])
def schema2Cc(schema: StructType, className: String): String = {
val res = CcRes(s"case class $className (\n", Nil)
@GurdeepSS
GurdeepSS / alternative-scheduler-for-celery.py
Created September 4, 2021 00:29 — forked from amitripshtos/alternative-scheduler-for-celery.py
Alternative to celery beat for people who got burned hard
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.job import Job
import json
import logging
from apscheduler.triggers.cron import CronTrigger
import time
from celery import Celery
from typing import List
@GurdeepSS
GurdeepSS / test_apscheduler_with_threadpool.py
Created September 2, 2021 16:35 — forked from newTypeGeek/test_apscheduler_with_threadpool.py
ThreadPoolExecutor issue in APScheduler
import logging
from concurrent.futures import ThreadPoolExecutor
from logging import config
from apscheduler.schedulers.blocking import BlockingScheduler
# Setup Logging Config for Console Output
logger_config = \
{
@GurdeepSS
GurdeepSS / create_task.py
Created August 24, 2021 19:57 — forked from inker610566/create_task.py
asyncio create_task example
#!/usr/local/bin/python3
from concurrent import futures
import asyncio
import time
loop = asyncio.get_event_loop()
async def task(t):
print('start task(%d)'%t)
await asyncio.sleep(t)
@GurdeepSS
GurdeepSS / pyppeteer.py
Created June 25, 2021 21:44 — forked from channprj/pyppeteer.py
Read html file and make pdf with pyppeteer
import asyncio
from pyppeteer import launch
async def main():
browser = await launch(
options={
'headless': True,
'args': [
'--no-sandbox',
@GurdeepSS
GurdeepSS / squash-commits.sh
Created November 21, 2019 09:07 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@GurdeepSS
GurdeepSS / LinkedList.java
Created July 1, 2019 20:20 — forked from lobster1234/LinkedList.java
A generic, singly LinkedList Implementation
public class LinkedList<T> {
private LinkedListNode<T> first = null;
/**
* Insert at the front of the list
* @param node
*/
public void insert(LinkedListNode<T> node) {
node.setNext(first);
@GurdeepSS
GurdeepSS / latency.markdown
Created April 18, 2019 16:23 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs