Skip to content

Instantly share code, notes, and snippets.

View sathishbabu96's full-sized avatar

S Sathish Babu sathishbabu96

View GitHub Profile
@sathishbabu96
sathishbabu96 / run_pylint.py
Created December 20, 2019 05:59 — forked from nivbend/run_pylint.py
A simple git pre-commit hook to run pylint on all python scripts changed.
#! /usr/bin/env python
"""Git pre-commit hook to run pylint on python files.
To install:
wget https://gist.github.com/nivbend/7e0e306a98138916b3c9#file-run_pylint-py -O .git/hooks/pre-commit
"""
from __future__ import print_function
from subprocess import check_output, CalledProcessError
from sys import stderr
"""Module to consume events generated from RabbitMQ."""
from rabbitmq.connection_handler import ConnectionHandler
from event_consumer_utils import *
connection = ConnectionHandler.get_connection()
channel = connection.channel()
@sathishbabu96
sathishbabu96 / PrivateMethodCaller.scala
Created January 31, 2019 11:45 — forked from jorgeortiz85/PrivateMethodCaller.scala
Calling private methods in Scala
// Usage:
// p(instance)('privateMethod)(arg1, arg2, arg3)
class PrivateMethodCaller(x: AnyRef, methodName: String) {
def apply(_args: Any*): Any = {
val args = _args.map(_.asInstanceOf[AnyRef])
def _parents: Stream[Class[_]] = Stream(x.getClass) #::: _parents.map(_.getSuperclass)
val parents = _parents.takeWhile(_ != null).toList
val methods = parents.flatMap(_.getDeclaredMethods)
val method = methods.find(_.getName == methodName).getOrElse(throw new IllegalArgumentException("Method " + methodName + " not found"))
import random
a=str(random.randint(1000,9999))
while a!=b:
b=input('Guess the 4 digit number : ')
cow=0
bull=0
for i in a:
if i in b and a.index(i)==b.index(i):
cow+=1
elif i in b and a.index(i)!=b.index(i):
a=input("Enter a long string ").split(" ")
a=a[::-1]
a=" ".join(a)
print(a)
# Without using sets
for i in list1:
if i not in list2:
list2=list2+[i]
# Using sets
print(set(list1))
def fibonacci():
a=1
b=0
c=0
n=int(input())
for i in range(0,n):
c=a+b
a=b
b=c
print(c)
def prime():
a=int(input("Enter a number "))
for i in range(2,a):
if a%i==0:
break
else:
continue
if i==(a-1):
print("prime")
else:
def guess():
a=random.randint(1,9)
b=int(input("Guess the number "))
if b==a:
print("You guessed it right!")
return 1
else:
if b<a:
print("Your guess is low")
return 0
def game():
p1=input("Player 1 input rock,paper or scissors ")
p2=input("Player 2 input rock,paper or scissors ")
if p1==p2:
print("It is a tie!")
else:
if p1=="rock":
if p2=="paper":
print("Player 2 wins!")
elif p2=="scissors":