Skip to content

Instantly share code, notes, and snippets.

📢
Working from home

Adnan Siddiqi kadnan

📢
Working from home
Block or report user

Report or block kadnan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kadnan
kadnan / docker-compose.yaml
Last active May 15, 2019
Docker compose file for running Cassandra Cluster
View docker-compose.yaml
version: '2'
services:
cas1:
container_name: cas1
image: cassandra:latest
volumes:
- /Development/PetProjects/CassandraTut/data/node1:/var/lib/cassandra/data
ports:
- 9042:9042
View keybase.md

Keybase proof

I hereby claim:

  • I am kadnan on github.
  • I am kadnan (https://keybase.io/kadnan) on keybase.
  • I have a public key ASAHNs8LV2Ck6XIFQPi-XKiD1amTKsrvPY8RTrvsBr13lwo

To claim this, I am signing this object:

@kadnan
kadnan / cl2.py
Created Oct 13, 2018
Anti Captcha test
View cl2.py
import requests
from bs4 import BeautifulSoup
from python_anticaptcha import NoCaptchaTaskProxylessTask, AnticaptchaClient
def get_token(s_key):
client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(website_url=url,
website_key=s_key.strip())
job = client.createTask(task)
@kadnan
kadnan / consumer-notification.py
Created Jun 10, 2018
Consumer that notifies if calories count cross the threshold
View consumer-notification.py
import json
from time import sleep
from kafka import KafkaConsumer
if __name__ == '__main__':
parsed_topic_name = 'parsed_recipes'
# Notify if a recipe has more than 200 calories
calories_threshold = 200
View producer_consumer_parse_recipes.py
import json
from time import sleep
from bs4 import BeautifulSoup
from kafka import KafkaConsumer, KafkaProducer
def publish_message(producer_instance, topic_name, key, value):
try:
key_bytes = bytes(key, encoding='utf-8')
@kadnan
kadnan / producer-raw-recipies.py
Created Jun 10, 2018
methods to access recipes listing and extract markup
View producer-raw-recipies.py
def fetch_raw(recipe_url):
html = None
print('Processing..{}'.format(recipe_url))
try:
r = requests.get(recipe_url, headers=headers)
if r.status_code == 200:
html = r.text
except Exception as ex:
print('Exception while accessing raw html')
print(str(ex))
@kadnan
kadnan / producer-raw-recipies.py
Created Jun 10, 2018
methods to connect Kafa Producer and publishing data.
View producer-raw-recipies.py
def publish_message(producer_instance, topic_name, key, value):
try:
key_bytes = bytes(key, encoding='utf-8')
value_bytes = bytes(value, encoding='utf-8')
producer_instance.send(topic_name, key=key_bytes, value=value_bytes)
producer_instance.flush()
print('Message published successfully.')
except Exception as ex:
print('Exception in publishing message')
print(str(ex))
@kadnan
kadnan / fabfile
Created May 15, 2017
Gist for Automating remote and local git commands
View fabfile
from fabric.api import *
from fabric.colors import red, green
from time import sleep
from pprint import pprint
from fabric.contrib.files import exists
def local_git():
is_done = True
@kadnan
kadnan / beautiful_idiomatic_python.md
Created Mar 15, 2017 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!
View beautiful_idiomatic_python.md

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@kadnan
kadnan / listing_seq.py
Created Dec 11, 2016
Scraping OLX Listing
View listing_seq.py
import requests
from bs4 import BeautifulSoup
from time import sleep
def get_listing(url):
headers = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}
html = None
links = None
You can’t perform that action at this time.