Skip to content

Instantly share code, notes, and snippets.

View alirezastack's full-sized avatar
🏠
Working from home

Alireza alirezastack

🏠
Working from home
View GitHub Profile
@alirezastack
alirezastack / cli_waether_app.py
Last active December 30, 2017 11:42
click python module for argument parsing using decorators
import click
import requests
# TODO change api key to your own api key, this is a sample key
SAMPLE_API_KEY = 'b1b15e88fa797225412429c1c50c122a1'
def current_weather(location, api_key=SAMPLE_API_KEY):
url = 'https://api.openweathermap.org/data/2.5/weather'
@alirezastack
alirezastack / redis_pubsub.py
Created December 24, 2017 11:45
Redis pubsub (Publish, Subscribe) in Python using threading and `redis` module
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@alirezastack
alirezastack / Dockerfile
Created October 31, 2017 14:38
Dockerfile for node, npm installation of specific version (DEBIAN)
FROM debian:jessie-slim
RUN mkdir /node_source
WORKDIR /node_source
RUN apt-get update && apt-get --yes install wget
RUN wget https://nodejs.org/dist/v5.7.0/node-v5.7.0-linux-x64.tar.gz
RUN mkdir -p /opt/nodejs
RUN tar -xvzf node-v5.7.0-linux-x64.tar.gz -C /opt/nodejs/