Skip to content

Instantly share code, notes, and snippets.

View SahilAgarwal321's full-sized avatar

Sahil Agarwal SahilAgarwal321

View GitHub Profile
@SahilAgarwal321
SahilAgarwal321 / rewriter.py
Created September 16, 2019 06:50
Self modifying code / Self changing code. This will keep the create a class object and raise errors instead of running the file.
import inspect
class TestModelClass(object):
def __init__(self, x):
"""Class initializations are done in this method"""
self.x = x
print self.x
@SahilAgarwal321
SahilAgarwal321 / python-selenium-open-tab.md
Created October 18, 2017 15:26 — forked from lrhache/python-selenium-open-tab.md
Python Selenium - Open new tab / focus tab / close tab

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

@SahilAgarwal321
SahilAgarwal321 / msc_codes.csv
Created August 16, 2017 16:53
India MSC, MNC Codes
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 4 columns, instead of 3 in line 8.
City,Operator,MSC codes,MNC code
Madhya Pradesh,Loop,91110-91119,NA
Madhya Pradesh,Reliance Jio Infocomm,"009, 008, 007, 006, 004, 003, 002, 001, 000",70
Madhya Pradesh,Reliance Telecom,98270-98279 97700-97709 99070-99078 96910-96919 90980-90989 78790-78799 78280-78289 88170-88179 83050-83059 82530 82518-82519 82510 82368-82369 82360 82348-82349 82340,67
Madhya Pradesh,Shyam Telelink,91440-91449,NA
Madhya Pradesh,Unitech Wireless,91740-91749,NA
Madhya Pradesh,Vodafone Essar,"97130-97139 95840-95849 88780-88789 75660-75669 88238 88230 88219 88218 88210 88199 88198 88190 88189 88188 85160 85168-85170 85178-85180 85188-85190 83700 83599 83598, 83588-83590 83578-83580 83570 75808, 75809, 75810, 75818, 75819, 75820, 75828, 75829, 75830, 75838, 75838, 75830, 75829, 75828, 75820, 75819, 75818, 75810, 75809, 75808",NA
Madhya Pradesh,Aircel,98060-98064 98560-98561 98065-98069 86599 86598 86568 86569 86590 86548 86549 86560 86499 86540,NA
Madhya Pradesh,Bharti Airtel,98930-98939 98340-98349 99810-99819 97520-97529 9179
@SahilAgarwal321
SahilAgarwal321 / python tutorial links
Last active July 15, 2017 05:48
links for python tutorial
@SahilAgarwal321
SahilAgarwal321 / The Technical Interview Cheat Sheet.md
Created April 9, 2017 20:20 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@SahilAgarwal321
SahilAgarwal321 / solr-eclipse
Created March 14, 2017 08:01
Running solr using eclipse remote debugging
#!/bin/bash
echo -e "\n"
echo "./solr start -m 1g -a \"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044\""
echo -e "Running Apache Solr with remote debugging using Eclipse. \n"
echo "Configuring Eclipse -"
echo "Open Eclipse --> Switch to solr workspace."
echo -e "Right click on your Solr/Lucene Java project and select 'Debug As' and then 'Debug Configurations'.\nUnder the 'Remote Java Application' category, click 'New' to create a new debug configuration.\nEnter in the port used for this command — 1044.\nHit Apply and Debug. \n\nNote: In the future, you can simply recall this debug configuration in the “Debug As” menu and Eclipse will attempt to attach to any Solr instance launched with Java’s debug commands. \n\n"
./solr start -m 1g -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"
#Program for calc
x=int(input("Enter first number : "))
y=int(input("Enter second number : "))
print("\nx =" + str(x) +"\ny = "+ str(y) )
func=input("Enter calc function : \n Enter 1 for addition \n Enter 2 for subtraction \n Enter 3 for multiplication \n Enter 4 for division \n")
switcher={
'1': "x + y = " +str(x+y),
'2': "x - y = " +str(x-y),
'3': "x * y = " +str(x*y),
#Program for calc
x=int(input("Enter first number : "))
y=int(input("Enter second number : "))
print("\nx =" + str(x) +"\ny = "+ str(y) )
func=int(input("Enter calc function : \n Enter 1 for addition \n Enter 2 for subtraction \n Enter 3 for multiplication \n Enter 4 for division \n"))
if func==1:
print("x + y = " +str(x+y))
elif func==2:
print("x - y = " +str(x-y))