Going to shit
2015 is when web development went to shit. Web development used to be nice. You could fire up a text editor and start creating JS and CSS files. You can absolutely still do this. That has not changed. So yes, everything I’m about to say can be invalidated by saying that.
Read “The Sad State of Web Development” >
Here is a simple Python program that can be used to:
- Test the API
- Get a list of Slack Users
- Get a list of Slack Channels
- Get information about a Slack Channel
- Post a message to Slack Channel
Students in my Intro to Programming and Problems Solving class at Clark College learn how to build this and other things using Python.
Have fun with it!
# CTEC 121 / Intro to Programming and Problem Solving # Lab - Using the Slack API # by Bruce Elgort, 2016 # pip install slackclient to install SlackClient library from slackclient import SlackClient import json def test_slack(sc): # use for debugging print("Testing API") print(80 * "=") print (sc.api_call("api.test")) def get_channel_info(sc,channel): # get info about the channel print("Getting Channel Info") print(80 * "=") print (sc.api_call("channels.info", channel=channel)) def get_list_of_channels(sc): print("Getting List of Channels") print(80 * "=") # get list of channels channels = sc.api_call("channels.list") channels = json.dumps(channels) channels = json.loads(str(channels)) return channels def display_channels(channels): print("Display Channels") print(80 * "=") for i in channels['channels']: print("Channel:",i['name']) def post_message(sc,text,channel,icon_url,username): print("Posting Message to Slack") print(80 * "=") # post a message into the #general channel print (sc.api_call("chat.postMessage",channel=channel,text=text,username=username,icon_url=icon_url,unfurl_links="true")) def get_users(sc): print("Get Users") print(80 * "=") #call the users.list api call and get list of users users = (sc.api_call("users.list")) users = json.dumps(users) users = json.loads(str(users)) return users def display_users(sc,users): print("User List") print(80 * "=") # display active users for i in users['members']: # don't display slackbot if i['profile']['real_name'] != "slackbot": # don't display deleted users if not i['deleted']: # display real name print (i['profile']['real_name']) def main(): # define variables token = "your token" channel = "a channel id" username = "Username to use display for message function" icon_url = "icon url for message function" # connect to Slack sc = SlackClient(token) # test slack test_slack(sc) # get channel info get_channel_info(sc,channel) # get list of channels channels = get_list_of_channels(sc) # display channels display_channels(channels) # post message post_message(sc,"Visit http://slack.com",channel,icon_url,username) # get users users = get_users(sc) # display users display_users(sc,users) main()
Front-End Architecture: A Modern Blueprint for Scalable and Sustainable Design Systems by Micah Godbolt
You’ll learn about the rewards gained from early, informed decisions, and the risks incurred if choices are made too hastily, or too late. Whether you are a front-end developer or a project owner, this book will inspire you.
Micah is a friend of mine who is the author of this fabulous book on front-end architecture. You can pre-order the book on Amazon or you can purchase the early release draft from O’Rielly. I highly recommend this book. I personally have learned a tremendous amount from it.
You can also find Micah on the Sass Bites podcast.
Earlier today I blogged about integrating the IdeaJam API with Slack and now I built another integration using the New York Times Top Stories API (JSON):
By default the /nyt slash command returns the top stories from the home page however, users can get a list of the sections available by typing /nyt list:
With only 17 lines of PHP code I was able to add a Slack “slash” command (/whatshot) to bring up the list of “What’s Hot” ideas from http://ideajam.net. To do this I used the IdeaJam JSON API and some PHP code to produce the list you see in the picture above. Slack makes it very easy to add integrations. In fact, I also coded another Slack integration for an IBM Notes customer that allows them to pull up data from their CRM database with a simple “/customer” command. That code was also less than 20 lines.
Want to learn more about the Slack API and how you can integrate it with it your apps? You can contact me or you can learn yourself Slack API.
PS – no server reboot was required to add the integration 🙂
Have you ever needed to insert an image placeholder into a web page? Well look no further. placehold.it is an easy to use service that can provide you with placeholder images. You can specify the image dimensions, background color, image format, text and text color:
UPDATE: Here’s a list from tuts+ of the top 8 image placeholder services for web designers
Flexbox Layout(Flexible Box) module (currently a W3C Last Call Working Draft) aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word “flex”).
The main idea behind the flex layout is to give the container the ability to alter its items’ width/height (and order) to best fill the available space (mostly to accommodate to all kind of display devices and screen sizes). A flex container expands items to fill available free space, or shrinks them to prevent overflow.
Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based). While those work well for pages, they lack flexibility (no pun intended) to support large or complex applications (especially when it comes to orientation changing, resizing, stretching, shrinking, etc.).