Skip to content

Instantly share code, notes, and snippets.

View jattoabdul's full-sized avatar
👑
ruling the world

Jatto Abdulqahhar jattoabdul

👑
ruling the world
View GitHub Profile
@jattoabdul
jattoabdul / GoalChallenge_MainActivitity.java
Last active March 21, 2018 18:59
Android app that randomly awards score to paired opponents based on score point and comments out the winner after 20 plays
package com.example.android.goalchallenge;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
// This is an example of an implementation of inheritance
public class MainActivity extends AppCompatActivity {
@jattoabdul
jattoabdul / Main.java
Last active March 21, 2018 22:54
A simple implementation of OOP concepts in JAVA
class Calculation {
private int batteryLife = 10;
int z;
int w;
public void addition(int x, int y) {
z = x + y;
System.out.println("The sum of the given numbers:"+z);
}
@jattoabdul
jattoabdul / requirements.txt
Last active July 10, 2018 17:17
A package requirements file for a python slack notification bot tutorial
asn1crypto==0.24.0
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
click==6.7
cryptography==2.2.2
Flask==1.0.2
Flask-API==1.0
gspread==3.0.0
gunicorn==19.8.1
@jattoabdul
jattoabdul / part1_ranti.py
Created July 10, 2018 17:36
Code Snippets for Part one of my article on "How to Build A Task Notification Bot for Slack with Python"
import os
from flask import Flask, request, make_response, render_template
app = Flask(__name__)
@app.route("/", methods=["GET"])
def home():
"""This route renders a hello world text."""
#rendering text
return 'Hello World'
if __name__ == '__main__':
app.run()
@jattoabdul
jattoabdul / __init__.py
Created July 10, 2018 17:43
Configuration __init__.py file.
from os import path, environ
from dotenv import load_dotenv
env_path = path.join(path.dirname(__file__), path.pardir, '.env')
load_dotenv(env_path, override=True)
def get_env(key):
return environ.get(key)
@jattoabdul
jattoabdul / env.py
Created July 10, 2018 17:44
Config env.py file.
from config import get_env
class EnvConfig(object):
"""Parent configuration class."""
DEBUG = False
CSRF_ENABLED = True
SECRET = get_env('SECRET')
@jattoabdul
jattoabdul / gappshelper.py
Created July 10, 2018 17:54
Google Sheet API helper for our application using gspread as a python wrapper.
import gspread
from os import path
from config import get_env
from oauth2client.service_account import ServiceAccountCredentials
class GappsHelper:
def __init__(self):
# setup for google sheet - Google Drive API Instance
@jattoabdul
jattoabdul / slackhelper.py
Created July 10, 2018 17:56
Slack API helpers for our application using SlackClient as a python wrapper.
from slackclient import SlackClient
from config import get_env
class SlackHelper:
def __init__(self):
self.slack_token = get_env('SLACK_TOKEN')
self.slack_client = SlackClient(self.slack_token)
self.slack_channel = get_env('SLACK_CHANNEL')
from config import get_env
from app import create_app
app = create_app(get_env('APP_ENV'))
if __name__ == '__main__':
app.run()
@jattoabdul
jattoabdul / part1_app__init__.py
Last active July 10, 2018 18:02
Application entry point and main route
from flask_api import FlaskAPI
from config.env import app_env
from app.utils.slackhelper import SlackHelper
# from flask import request, jsonify
# from re import match
# from app.actions import Actions
def create_app(config_name):
app = FlaskAPI(__name__, instance_relative_config=False)