Skip to content

Instantly share code, notes, and snippets.

View gopigof's full-sized avatar
🎯
Focusing

Gopi Krishna Gorle gopigof

🎯
Focusing
View GitHub Profile
@gopigof
gopigof / record_upsert_procedure.sql
Created April 5, 2023 01:05
DAMG6210 - Assignment 4
CREATE OR REPLACE PROCEDURE MANAGE_DEPARTMENT (
p_dept_name IN VARCHAR2,
p_dept_location IN VARCHAR2
) IS
v_dept_id NUMBER;
v_dept_name VARCHAR2(50);
BEGIN
IF p_dept_name IS NULL OR LENGTH(p_dept_name) = 0 THEN
-- Validate Department Name (Question D)
RAISE_APPLICATION_ERROR(-20999, 'Department Name cannot be empty');
@gopigof
gopigof / set-alacritty-default.sh
Created June 17, 2022 23:12
Set Alacritty as Default Terminal Emulator - Ubunutu
# 50 - is the priority for chosing between `alternatives` available. 40 is default
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --config x-terminal-emulator

Class Abstractions

  • DataFeed Class : Tracking each datafeed
  • LogSummary Class : Tracking the log for each datafeed. (part of DataFeed object)

New Code Directory Style

  • Instead of having code spread across core/generic, core/stages and the python files inside them, move all the class related abstractions to a single file datafeed.py and the "transformations" & "actions" level code into a single folder (can be divided by stage if need be).
  • For the datafeeds, each one of them named after the feed (eg. "avent", "bos") has a package created in the {root_dir}/datafeeds directory. If custom logic is present for that feed, a file named based on the stage is created and the logic is written there.
  • All pure functions (functions that return the same output for the same input) should be put in utils package.
{root_dir}
class nQueens {
def isSafe(col: Int, queens: List[Int]): Boolean = {
val rows = queens.length
val rowsQueens = (rows-1 to 0 by -1).zip(queens)
rowsQueens.forall{
case(r, c) => col != c && math.abs(col - c) != rows - r
}
}
def placeQueens(k: Int): Set[List[Int]] =
@gopigof
gopigof / patch304.c
Created May 5, 2020 19:20
Patch to add memory address profiling features to Python 2.7.15 interpreter
diff - Naru
a / Include / objimpl.h
b / Include / objimpl.h
--- a / Include / objimpl.h
2018 - 04 - 30
06:47:33.000000000 + 0
800
+++ b / Include / objimpl.h
2018 - 10 - 31
11:59:39.000000000 + 0
@gopigof
gopigof / package_extractor.py
Created May 5, 2020 18:41
Script to crawl a project and extract used packages
import logging
import os
import ast
import traceback
import sys
from contextlib import contextmanager
open_func = open
py2 =False
def join(f):
# return os.path.join(os.path.dirname(__file__), f)
@gopigof
gopigof / YIFY_Scraper.py
Created June 8, 2019 19:05
YIFY Movies has been one of the leading webistes to torrent movies. Their magnets and trackers have been reliable for very long. Here is a scraper that scrapes movies as intersested.
import requests
import bs4
base_url = 'http://www.yify-movies.com'
def parse_link(soup_object):
movies = {}
movie_links = []
@gopigof
gopigof / Zippy Scraper.py
Created May 14, 2019 14:33
A scraper for Zippyshare file hoster, as most of download sites host file on these servers while chunking files.
import re
import json
import requests
import urllib.parse
from bs4 import BeautifulSoup
class ZippyLink():
def __init__(self):
self.REGEX_1 = r'(\(\'dlbutton\'\)\.href = )(.*)(\;)'
@gopigof
gopigof / net-speed.py
Created May 14, 2019 14:30
This script allows one to check their speed. This is more useful for applications which need a continuous check on the speed and packet loss details, like web services or multiplayer games. Not primarily for simple users
import os
import re
import csv
import sys
import math
import errno
import signal
import socket
import timeit
import datetime
@gopigof
gopigof / Chi-squared Descision Tree.py
Created May 14, 2019 14:28
Decision Tree with chi-squared pruning for ID3 Decision Tree implementation
from pprint import pprint
from scipy.stats import chi2, chi2_contingency
from sys import argv
import numpy as np
import pandas as pd
from sklearn import metrics, model_selection
file_name = argv[1]
# alpha values for chi square pruning