Skip to content

Instantly share code, notes, and snippets.

@devStepsize
devStepsize / slack_webhook_post.py
Last active August 12, 2024 11:14
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests
@devStepsize
devStepsize / slack_slash_cmd.py
Created April 21, 2016 23:12
Server-side logic to handle a Slack slash command using Python and Flask
'''
This is an example of the server-side logic to handle slash commands in
Python with Flask.
Detailed documentation of Slack slash commands:
https://api.slack.com/slash-commands
Slash commands style guide:
https://medium.com/slack-developer-blog/slash-commands-style-guide-4e91272aa43a#.6zmti394c
'''
@devStepsize
devStepsize / radar_plot.py
Last active August 3, 2021 22:00
Chart a radar plot with matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.spines import Spine
from matplotlib.projections.polar import PolarAxes
from matplotlib.projections import register_projection
def radar_factory(num_vars, frame='circle'):
@devStepsize
devStepsize / pg_dump_table.sql
Last active March 28, 2019 09:13
PostgreSQL pg_dump syntax for a single table
pg_dump -Fc -v -U user_name -d db_name -t table_name > /path/to/file.bak
@devStepsize
devStepsize / slack_rtm_client.py
Last active July 9, 2018 15:14
Use Slack's Real Time Messaging API with Python and python-slackclient
'''
This is an example of how to use the Slack Real Time Messaging API using
Python and the python-slackclient.
The example below originates from the python-slackclient documentation.
See https://github.com/slackhq/python-slackclient#real-time-messaging
This is everything you can do with the client:
Connect to a Slack RTM websocket. This is a persistent connection from which you can read events.
@devStepsize
devStepsize / botkit_slack_example2.js
Created April 22, 2016 19:00
An example Botkit Slack bot showing how to perform slightly different actions (from https://github.com/howdyai/botkit/blob/master/examples/demo_bot.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
This bot demonstrates many of the core features of Botkit:
* Connect to Slack using the real time API
* Receive messages based on "spoken" patterns
@devStepsize
devStepsize / botkit_slack_example1.js
Last active April 27, 2018 03:26
An example Botkit Slack bot that can be connected your team (from https://github.com/howdyai/botkit/blob/master/slack_bot.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
This bot demonstrates many of the core features of Botkit:
* Connect to Slack using the real time API
* Receive messages based on "spoken" patterns
@devStepsize
devStepsize / azure_face_local_image.py
Created May 5, 2016 19:07
Detect faces in a local image using the Azure Face API in Python
import json
import urllib
import requests
from pprint import pprint
from os.path import expanduser
headers = {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': 'your-api-key',
@devStepsize
devStepsize / botkit_slackbutton_incomingwebhooks.js
Created April 22, 2016 19:24
Botkit example of using the Slack Button to offer an incoming webhook integration (from https://github.com/howdyai/botkit/blob/master/examples/slackbutton_incomingwebhooks.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack Button application that allows the application
to post messages into Slack.
This bot demonstrates many of the core features of Botkit:
@devStepsize
devStepsize / botkit_slack_buttonbot.js
Created April 22, 2016 19:03
An example of Botkit using the Slack Button to offer a bot integration (from https://github.com/howdyai/botkit/blob/master/examples/slackbutton_bot.js)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack Button application that adds a bot to one or many slack teams.
# RUN THE APP:
Create a Slack app. Make sure to configure the bot user!
-> https://api.slack.com/applications/new