Simplest Slack bot of yours

robot-character In our team at legelisten.no we had HipChat as a main way of communication before. But recently we’ve migrated to Slack and do not feel regret.

One thing I feel missing there was Standup Bot which we used to write and read each other standup messages during the day.

Functions of this standup bot were deadly simple: it can save your message and it can show you all messages from all team members for today.

So long story short, I decided to make the same bot for slack. I’ve seen some alternatives, but they seemed too complicated for such simple issue.

I made my own Ruby (Sinatra) + MongoDB – based bot.

How to make the simplest Slack bot?

  1. Choose outgoing webhooks instead of slask app. You can read about this hooks here: https://api.slack.com/outgoing-webhooks
  2. Create simple sinatra app with one route for POST.
  3. Point your webhook to that route you just created.
  4. Do whatever you want with data you have from Slack.
  5. Respond with simple JSON like {text: “your bot’s answer here”}
  6. PROFIT!

You can have a look to my slask bot here: https://github.com/kiote/standup-bot

Advertisements

Rack::Attack testing with Rspec

dsc_4241

Let’s say you are using Rack::Attack. And if you not, you’d probably want to see it. Long story short, it’s a simple middelware for Rails to prevent some (most stupid) attacks to your site.

So if you are using it, you’d possibly want to test it. Just a small example of throttling (don’t mess up with trolling) tests: Continue reading

Does Naive Bayes Belive in a Big Foot?

There is a quite interesting, widely-using and powerful theorem in a probability theory: Bayes’ theorem. In AI this theorem are used for “Naive Bayes classifier” algorithm.

Why this theorem is interesting? Because in many cases of machine-learning it could give you good result and it’s really simple to implement this algorithm. For example, with Naive Bayes help many spam-filtering systems are working.

Why the hell it’s “naive”? Continue reading

Google Trends API + Golang

Google trends is a really nice stuff, when you try to compare what is more popular: cola or pepsi, whiskey or soda?

So I wondered, is it have any API. With a bit of googling I found they have some kind of.. unofficial though. With special formed query anybody can obtain javascript-ready string with whole data: example.

Not so friendly as before, huh? But it’s still something.

With zero knowledge of golang, and with only help of online documentation to this great language (so I pretty sure you can do better!), I’ve created this command-line tool.

You can run it with two paramethers and have the “rating” of first and second as an answer.

That was pretty much just go-practice.

Month With No Social Networks

What is Itching

Recently I’ve noticed I spend too much time in social networks, doing nothing, just browsing. Reading “news” and reposts of funny videos from the people I used to know.

I can’t feel I can retreive any useful info there. Just wasting time. But it turns to be my main excercise any time I have some “free time”.

I’ve started my day with browsing friend’s posts in facebook. I’ve finished my day with browsing instagram posts. During dinner, while waiting anything… Really destructive. Continue reading